class FDB::DirectoryLayer

def create_directory(tr, path, options)

def create_directory(tr, path, options)
  check_version(tr, true)
  prefix = options[:prefix]
  if prefix.nil?
    prefix = @content_subspace.key + @allocator.allocate(tr)
    if !tr.get_range_start_with(prefix, { :limit => 1 }).to_a.empty?
      raise "The database has keys stored at the prefix chosen by the automatic prefix allocator: #{prefix.dump}."
    end
    if !is_prefix_free?(tr.snapshot, prefix)
      raise 'The directory layer has manually allocated prefixes that conflict with the automatic prefix allocator.'
    end
  elsif !is_prefix_free?(tr, prefix)
    raise ArgumentError, 'The given prefix is already in use.'
  end
  parent_node = if path[0...-1].length > 0
                  node_with_prefix(create_or_open(tr, path[0...-1]).key)
                else
                  @root_node
                end
  raise 'The parent directory does not exist.' unless parent_node
  node = node_with_prefix(prefix)
  tr[parent_node[@@SUBDIRS][path[-1]]] = prefix
  tr[node['layer']] = options[:layer]
  contents_of_node(node, path, options[:layer])
end