class FDB::DirectoryLayer
def create_or_open_internal(db_or_tr, path, allow_create, allow_open, options={})
def create_or_open_internal(db_or_tr, path, allow_create, allow_open, options={}) defaults = { :layer => '', :prefix => nil } options = defaults.merge(options) if !options[:prefix].nil? and allow_open and allow_create raise ArgumentError, 'Cannot specify a prefix when calling create_or_open.' end if !options[:prefix].nil? and !@allow_manual_prefixes if @path.length == 0 raise ArgumentError, 'Cannot specify a prefix unless manual prefixes are enabled.' else raise ArgumentError, 'Cannot specify a prefix in a partition.' end end db_or_tr.transact do |tr| check_version(tr, false) path = to_unicode_path(path) raise ArgumentError, 'The root directory cannot be opened.' if path.length == 0 existing_node = find(tr, path).prefetch_metadata(tr) if existing_node.exists? if existing_node.is_in_partition? subpath = existing_node.get_partition_subpath existing_node.get_contents(self).directory_layer.create_or_open_internal(tr, subpath, allow_create, allow_open, options) else raise ArgumentError, 'The directory already exists.' unless allow_open open_directory(path, options, existing_node) end else raise ArgumentError, 'The directory does not exist.' unless allow_create create_directory(tr, path, options) end end end