pub unsafe trait FSVolumeOperations: NSObjectProtocol + FSVolumePathConfOperations {
Show 18 methods
// Provided methods
unsafe fn supportedVolumeCapabilities(
&self,
) -> Retained<FSVolumeSupportedCapabilities>
where Self: Sized + Message { ... }
unsafe fn volumeStatistics(&self) -> Retained<FSStatFSResult>
where Self: Sized + Message { ... }
unsafe fn mountWithOptions_replyHandler(
&self,
options: &FSTaskOptions,
reply: &DynBlock<dyn Fn(*mut NSError)>,
)
where Self: Sized + Message { ... }
unsafe fn unmountWithReplyHandler(&self, reply: &DynBlock<dyn Fn()>)
where Self: Sized + Message { ... }
unsafe fn synchronizeWithFlags_replyHandler(
&self,
flags: FSSyncFlags,
reply: &DynBlock<dyn Fn(*mut NSError)>,
)
where Self: Sized + Message { ... }
unsafe fn getAttributes_ofItem_replyHandler(
&self,
desired_attributes: &FSItemGetAttributesRequest,
item: &FSItem,
reply: &DynBlock<dyn Fn(*mut FSItemAttributes, *mut NSError)>,
)
where Self: Sized + Message { ... }
unsafe fn setAttributes_onItem_replyHandler(
&self,
new_attributes: &FSItemSetAttributesRequest,
item: &FSItem,
reply: &DynBlock<dyn Fn(*mut FSItemAttributes, *mut NSError)>,
)
where Self: Sized + Message { ... }
unsafe fn lookupItemNamed_inDirectory_replyHandler(
&self,
name: &FSFileName,
directory: &FSItem,
reply: &DynBlock<dyn Fn(*mut FSItem, *mut FSFileName, *mut NSError)>,
)
where Self: Sized + Message { ... }
unsafe fn reclaimItem_replyHandler(
&self,
item: &FSItem,
reply: &DynBlock<dyn Fn(*mut NSError)>,
)
where Self: Sized + Message { ... }
unsafe fn readSymbolicLink_replyHandler(
&self,
item: &FSItem,
reply: &DynBlock<dyn Fn(*mut FSFileName, *mut NSError)>,
)
where Self: Sized + Message { ... }
unsafe fn createItemNamed_type_inDirectory_attributes_replyHandler(
&self,
name: &FSFileName,
type: FSItemType,
directory: &FSItem,
new_attributes: &FSItemSetAttributesRequest,
reply: &DynBlock<dyn Fn(*mut FSItem, *mut FSFileName, *mut NSError)>,
)
where Self: Sized + Message { ... }
unsafe fn createSymbolicLinkNamed_inDirectory_attributes_linkContents_replyHandler(
&self,
name: &FSFileName,
directory: &FSItem,
new_attributes: &FSItemSetAttributesRequest,
contents: &FSFileName,
reply: &DynBlock<dyn Fn(*mut FSItem, *mut FSFileName, *mut NSError)>,
)
where Self: Sized + Message { ... }
unsafe fn createLinkToItem_named_inDirectory_replyHandler(
&self,
item: &FSItem,
name: &FSFileName,
directory: &FSItem,
reply: &DynBlock<dyn Fn(*mut FSFileName, *mut NSError)>,
)
where Self: Sized + Message { ... }
unsafe fn removeItem_named_fromDirectory_replyHandler(
&self,
item: &FSItem,
name: &FSFileName,
directory: &FSItem,
reply: &DynBlock<dyn Fn(*mut NSError)>,
)
where Self: Sized + Message { ... }
unsafe fn renameItem_inDirectory_named_toNewName_inDirectory_overItem_replyHandler(
&self,
item: &FSItem,
source_directory: &FSItem,
source_name: &FSFileName,
destination_name: &FSFileName,
destination_directory: &FSItem,
over_item: Option<&FSItem>,
reply: &DynBlock<dyn Fn(*mut FSFileName, *mut NSError)>,
)
where Self: Sized + Message { ... }
unsafe fn enumerateDirectory_startingAtCookie_verifier_providingAttributes_usingPacker_replyHandler(
&self,
directory: &FSItem,
cookie: FSDirectoryCookie,
verifier: FSDirectoryVerifier,
attributes: Option<&FSItemGetAttributesRequest>,
packer: &FSDirectoryEntryPacker,
reply: &DynBlock<dyn Fn(FSDirectoryVerifier, *mut NSError)>,
)
where Self: Sized + Message { ... }
unsafe fn activateWithOptions_replyHandler(
&self,
options: &FSTaskOptions,
reply: &DynBlock<dyn Fn(*mut FSItem, *mut NSError)>,
)
where Self: Sized + Message { ... }
unsafe fn deactivateWithOptions_replyHandler(
&self,
options: FSDeactivateOptions,
reply: &DynBlock<dyn Fn(*mut NSError)>,
)
where Self: Sized + Message { ... }
}
FSVolume
only.Expand description
Methods that all volumes implement to provide required capabilities.
Conform to this protocol in your subclass of FSVolume
.
To provide additional capabilities, conform to the other FSVolume
operations protocols, like FSVolumeOpenCloseOperations
and FSVolumeReadWriteOperations
.
Note: This protocol extends
FSVolumePathConfOperations
, so your volume implementation must also conform to that protocol.
See also Apple’s documentation
Provided Methods§
Sourceunsafe fn supportedVolumeCapabilities(
&self,
) -> Retained<FSVolumeSupportedCapabilities>
unsafe fn supportedVolumeCapabilities( &self, ) -> Retained<FSVolumeSupportedCapabilities>
A property that provides the supported capabilities of the volume.
Sourceunsafe fn volumeStatistics(&self) -> Retained<FSStatFSResult>
unsafe fn volumeStatistics(&self) -> Retained<FSStatFSResult>
A property that provides up-to-date statistics of the volume.
Sourceunsafe fn mountWithOptions_replyHandler(
&self,
options: &FSTaskOptions,
reply: &DynBlock<dyn Fn(*mut NSError)>,
)
Available on crate features FSTaskOptions
and block2
only.
unsafe fn mountWithOptions_replyHandler( &self, options: &FSTaskOptions, reply: &DynBlock<dyn Fn(*mut NSError)>, )
FSTaskOptions
and block2
only.Mounts this volume, using the specified options.
FSKit calls this method as a signal that some process is trying to mount this volume.
Your file system receives a call to activate(options:replyHandler:)
prior to receiving any mount calls.
- Parameters:
- options: Options to apply to the mount. These can include security-scoped file paths. There are no defined options currently.
- reply: A block or closure to indicate success or failure. If mounting fails, pass an error as the one parameter to the reply handler. If mounting succeeds, pass
nil
. For anasync
Swift implementation, there’s no reply handler; simply return normally.
Sourceunsafe fn unmountWithReplyHandler(&self, reply: &DynBlock<dyn Fn()>)
Available on crate feature block2
only.
unsafe fn unmountWithReplyHandler(&self, reply: &DynBlock<dyn Fn()>)
block2
only.Unmounts this volume.
Clear and flush all cached state in your implementation of this method.
- Parameters:
- reply: A block or closure to indicate success or failure. If unmounting fails, pass an error as the one parameter to the reply handler. If unmounting succeeds, pass
nil
. For anasync
Swift implementation, there’s no reply handler; simply return normally.
Sourceunsafe fn synchronizeWithFlags_replyHandler(
&self,
flags: FSSyncFlags,
reply: &DynBlock<dyn Fn(*mut NSError)>,
)
Available on crate feature block2
only.
unsafe fn synchronizeWithFlags_replyHandler( &self, flags: FSSyncFlags, reply: &DynBlock<dyn Fn(*mut NSError)>, )
block2
only.Synchronizes the volume with its underlying resource.
After calling this method, FSKit assumes that the volume has sent all pending I/O or metadata to its resource.
- Parameters:
- flags: Timing flags, as defined in
mount.h.
These flags let the file system know whether to run the operation in a blocking or nonblocking fashion. - reply: A block or closure to indicate success or failure. If synchronization fails, pass an error as the one parameter to the reply handler. If synchronization succeeds, pass
nil
. For anasync
Swift implementation, there’s no reply handler; simply throw an error or return normally.
Sourceunsafe fn getAttributes_ofItem_replyHandler(
&self,
desired_attributes: &FSItemGetAttributesRequest,
item: &FSItem,
reply: &DynBlock<dyn Fn(*mut FSItemAttributes, *mut NSError)>,
)
Available on crate features FSItem
and block2
only.
unsafe fn getAttributes_ofItem_replyHandler( &self, desired_attributes: &FSItemGetAttributesRequest, item: &FSItem, reply: &DynBlock<dyn Fn(*mut FSItemAttributes, *mut NSError)>, )
FSItem
and block2
only.Fetches attributes for the given item.
For file systems that don’t support hard links, set FSItemAttributes/linkCount
to 1
for regular files and symbolic links.
If the item’s bsdFlags
contain the UF_COMPRESSED
flag, your file system returns the uncompressed size of the file.
- Parameters:
- desiredAttributes: A requested set of attributes to get. The implementation inspects the request’s
FSItemGetAttributesRequest/wantedAttributes
to determine which attributes to populate. - item: The item to get attributes for.
- reply: A block or closure to indicate success or failure. If getting attributes succeeds, pass an
FSItemAttributes
with the requested attributes populated and anil
error. If getting attributes fails, pass the relevant error as the second parameter; FSKit ignores anyFSItemAttributes
in this case. For anasync
Swift implementation, there’s no reply handler; simply return theFSItemAttributes
or throw an error.
Sourceunsafe fn setAttributes_onItem_replyHandler(
&self,
new_attributes: &FSItemSetAttributesRequest,
item: &FSItem,
reply: &DynBlock<dyn Fn(*mut FSItemAttributes, *mut NSError)>,
)
Available on crate features FSItem
and block2
only.
unsafe fn setAttributes_onItem_replyHandler( &self, new_attributes: &FSItemSetAttributesRequest, item: &FSItem, reply: &DynBlock<dyn Fn(*mut FSItemAttributes, *mut NSError)>, )
FSItem
and block2
only.Sets the given attributes on an item.
Several attributes are considered “read-only”, and an attempt to set these attributes results in an error with the code EINVAL
.
A request may set FSItem/Attributes/size
beyond the end of the file.
If the underlying file system doesn’t support sparse files, allocate space to fill the new file size.
Either fill this space with zeroes, or configure it to read as zeroes.
If a request sets the file size below the current end-of-file, truncate the file and return any unused space to the file system as free space.
Ignore attempts to set the size of directories or symbolic links; don’t produce an error.
If the caller attepts to sest an attribute not supported by the on-disk file system format, don’t produce an error. The upper layers of the framework will detect this situation.
- Parameters:
- newAttributes: A request containing the attributes to set.
- item: The item on which to set the attributes.
- reply: A block or closure to indicate success or failure. If setting attributes succeeds, pass an
FSItemAttributes
with the item’s updated attributes and anil
error. If setting attributes fails, pass the relevant error as the second parameter; FSKit ignores anyFSItemAttributes
in this case. For anasync
Swift implementation, there’s no reply handler; simply return theFSItemAttributes
or throw an error.
Sourceunsafe fn lookupItemNamed_inDirectory_replyHandler(
&self,
name: &FSFileName,
directory: &FSItem,
reply: &DynBlock<dyn Fn(*mut FSItem, *mut FSFileName, *mut NSError)>,
)
Available on crate features FSFileName
and FSItem
and block2
only.
unsafe fn lookupItemNamed_inDirectory_replyHandler( &self, name: &FSFileName, directory: &FSItem, reply: &DynBlock<dyn Fn(*mut FSItem, *mut FSFileName, *mut NSError)>, )
FSFileName
and FSItem
and block2
only.Looks up an item within a directory.
If no item matching name
exists in the directory indicated by directory
, complete the request with an error with a domain of
<doc
://com.apple.documentation/documentation/Foundation/NSPOSIXErrorDomain> and a code of ENOENT
.
Tip: The
FSFileName
sent back to the caller may differ from thename
parameter. This flexibility allows your implementation to handle case-insensitive and case-sensitive file systems. It might also be the case thatname
uses a composed Unicode string, but the name maintained by the file system and provided to the caller is uncomposed Unicode.
- Parameters:
- name: The name of the item to look up.
- directory: The directory in which to look up the item.
- reply: A block or closure to indicate success or failure. If lookup succeeds, pass the found
FSItem
and itsFSFileName
(as saved within the file system), along with anil
error. If lookup fails, pass the relevant error as the third parameter; anyFSItem
orFSFileName
are ignored in this case. For anasync
Swift implementation, there’s no reply handler; simply return theFSItem
andFSFileName
as a tuple or throw an error.
Sourceunsafe fn reclaimItem_replyHandler(
&self,
item: &FSItem,
reply: &DynBlock<dyn Fn(*mut NSError)>,
)
Available on crate features FSItem
and block2
only.
unsafe fn reclaimItem_replyHandler( &self, item: &FSItem, reply: &DynBlock<dyn Fn(*mut NSError)>, )
FSItem
and block2
only.Reclaims an item, releasing any resources allocated for the item.
FSKit guarantees that for every FSItem
returned by the volume, a corresponding reclaim operation occurs after the upper layers no longer reference that item.
Note: Block device file systems may assess whether an underyling resource terminates before processing reclaim operations. On unary file systems, for example, the associated volumes unmount when such resources disconnect from the system. The unmount triggers a reclaiming of all items. Some implementations benefit greatly from short-circuiting in such cases. With a terminated resource, all I/O results in an error, making short-circuiting the most efficient response.
- Parameters:
- item: The item to reclaim.
- reply: A block or closure to indicate success or failure. If removal fails, pass an error as the one parameter to the reply handler. If removal succeeds, pass
nil
. For anasync
Swift implementation, there’s no reply handler; simply throw an error or return normally.
Sourceunsafe fn readSymbolicLink_replyHandler(
&self,
item: &FSItem,
reply: &DynBlock<dyn Fn(*mut FSFileName, *mut NSError)>,
)
Available on crate features FSFileName
and FSItem
and block2
only.
unsafe fn readSymbolicLink_replyHandler( &self, item: &FSItem, reply: &DynBlock<dyn Fn(*mut FSFileName, *mut NSError)>, )
FSFileName
and FSItem
and block2
only.Reads a symbolic link.
- Parameters:
- item: The symbolic link to read from. FSKit guarantees this item is of type
FSItem/ItemType/symlink
. - reply: A block or closure to indicate success or failure. If reading succeeds, pass the link’s contents as an
FSFileName
and anil
error. If reading fails, pass the relevant error as the second parameter; FSKit ignores anyFSFileName
in this case. For anasync
Swift implementation, there’s no reply handler; simply return theFSFileName
or throw an error.
Sourceunsafe fn createItemNamed_type_inDirectory_attributes_replyHandler(
&self,
name: &FSFileName,
type: FSItemType,
directory: &FSItem,
new_attributes: &FSItemSetAttributesRequest,
reply: &DynBlock<dyn Fn(*mut FSItem, *mut FSFileName, *mut NSError)>,
)
Available on crate features FSFileName
and FSItem
and block2
only.
unsafe fn createItemNamed_type_inDirectory_attributes_replyHandler( &self, name: &FSFileName, type: FSItemType, directory: &FSItem, new_attributes: &FSItemSetAttributesRequest, reply: &DynBlock<dyn Fn(*mut FSItem, *mut FSFileName, *mut NSError)>, )
FSFileName
and FSItem
and block2
only.Creates a new file or directory item.
If an item named name
already exists in the directory indicated by directory
, complete the request with an error with a domain of
<doc
://com.apple.documentation/documentation/Foundation/NSPOSIXErrorDomain> and a code of EEXIST
.
- Parameters:
- name: The new item’s name.
- type: The new item’s type. Valid values are
FSItem/ItemType/file
orFSItem/ItemType/directory
. - directory: The directory in which to create the item.
- newAttributes: Attributes to apply to the new item.
- reply: A block or closure to indicate success or failure. If creation succeeds, pass the newly-created
FSItem
and itsFSFileName
, along with anil
error. If creation fails, pass the relevant error as the third parameter; FSKit ignores anyFSItem
orFSFileName
in this case. For anasync
Swift implementation, there’s no reply handler; simply return a tuple of theFSItem
and itsFSFileName
or throw an error.
Sourceunsafe fn createSymbolicLinkNamed_inDirectory_attributes_linkContents_replyHandler(
&self,
name: &FSFileName,
directory: &FSItem,
new_attributes: &FSItemSetAttributesRequest,
contents: &FSFileName,
reply: &DynBlock<dyn Fn(*mut FSItem, *mut FSFileName, *mut NSError)>,
)
Available on crate features FSFileName
and FSItem
and block2
only.
unsafe fn createSymbolicLinkNamed_inDirectory_attributes_linkContents_replyHandler( &self, name: &FSFileName, directory: &FSItem, new_attributes: &FSItemSetAttributesRequest, contents: &FSFileName, reply: &DynBlock<dyn Fn(*mut FSItem, *mut FSFileName, *mut NSError)>, )
FSFileName
and FSItem
and block2
only.Creates a new symbolic link.
If an item named name
already exists in the directory indicated by directory
, complete the request with an error with a domain of
<doc
://com.apple.documentation/documentation/Foundation/NSPOSIXErrorDomain> and a code of EEXIST
.
- Parameters:
- name: The new item’s name.
- directory: The directory in which to create the item.
- newAttributes: Attributes to apply to the new item.
- contents: The contents of the new symbolic link.
- reply: A block or closure to indicate success or failure. If creation succeeds, pass the newly-created
FSItem
and anil
error. If creation fails, pass the relevant error as the second parameter; FSKit ignores anyFSItem
in this case. For anasync
Swift implementation, there’s no reply handler; simply return theFSItem
or throw an error.
Sourceunsafe fn createLinkToItem_named_inDirectory_replyHandler(
&self,
item: &FSItem,
name: &FSFileName,
directory: &FSItem,
reply: &DynBlock<dyn Fn(*mut FSFileName, *mut NSError)>,
)
Available on crate features FSFileName
and FSItem
and block2
only.
unsafe fn createLinkToItem_named_inDirectory_replyHandler( &self, item: &FSItem, name: &FSFileName, directory: &FSItem, reply: &DynBlock<dyn Fn(*mut FSFileName, *mut NSError)>, )
FSFileName
and FSItem
and block2
only.Creates a new hard link.
If creating the link fails, complete the request with an error with a domain of <doc ://com.apple.documentation/documentation/Foundation/NSPOSIXErrorDomain> and the following error codes:
EEXIST
if there’s already an item namedname
in the directory.EMLINK
if creating the link would exceed the maximum number of hard links supported onitem
.ENOTSUP
if the file system doesn’t support creating hard links to the type of file system object thatitem
represents.
- Parameters:
- item: The existing item to which to link.
- name: The name for the new link.
- directory: The directory in which to create the link.
- reply: A block or closure to indicate success or failure. If creation succeeds, pass an
FSFileName
of the newly-created link and anil
error. If creation fails, pass the relevant error as the second parameter; FSKit ignores anyFSFileName
in this case. For anasync
Swift implementation, there’s no reply handler; simply return theFSFileName
or throw an error.
Sourceunsafe fn removeItem_named_fromDirectory_replyHandler(
&self,
item: &FSItem,
name: &FSFileName,
directory: &FSItem,
reply: &DynBlock<dyn Fn(*mut NSError)>,
)
Available on crate features FSFileName
and FSItem
and block2
only.
unsafe fn removeItem_named_fromDirectory_replyHandler( &self, item: &FSItem, name: &FSFileName, directory: &FSItem, reply: &DynBlock<dyn Fn(*mut NSError)>, )
FSFileName
and FSItem
and block2
only.Removes an existing item from a given directory.
Don’t actually remove the item object itself in your implementation; instead, only remove the given item name from the given directory.
Remove and deallocate the item in reclaimItem(_:replyHandler:)
.
- Parameters:
- item: The item to remove.
- name: The name of the item to remove.
- directory: The directory from which to remove the item.
- reply: A block or closure to indicate success or failure. If removal fails, pass an error as the one parameter to the reply handler. If removal succeeds, pass
nil
. For anasync
Swift implementation, there’s no reply handler; simply throw an error or return normally.
Sourceunsafe fn renameItem_inDirectory_named_toNewName_inDirectory_overItem_replyHandler(
&self,
item: &FSItem,
source_directory: &FSItem,
source_name: &FSFileName,
destination_name: &FSFileName,
destination_directory: &FSItem,
over_item: Option<&FSItem>,
reply: &DynBlock<dyn Fn(*mut FSFileName, *mut NSError)>,
)
Available on crate features FSFileName
and FSItem
and block2
only.
unsafe fn renameItem_inDirectory_named_toNewName_inDirectory_overItem_replyHandler( &self, item: &FSItem, source_directory: &FSItem, source_name: &FSFileName, destination_name: &FSFileName, destination_directory: &FSItem, over_item: Option<&FSItem>, reply: &DynBlock<dyn Fn(*mut FSFileName, *mut NSError)>, )
FSFileName
and FSItem
and block2
only.Renames an item from one path in the file system to another.
Implement renaming along the lines of this algorithm:
-
If
item
is a file: -
If the destination file exists:
-
Remove the destination file.
-
If the source and destination directories are the same:
-
Rewrite the name in the existing directory.
-
Else:
-
Write the new entry in the destination directory.
-
Clear the old directory entry.
-
If
item
is a directory: -
If the destination directory exists:
-
If the destination directory isn’t empty:
-
Fail the operation with an error of <doc ://com.apple.documentation/documentation/Foundation/NSPOSIXErrorDomain> and a code of
ENOTEMPTY
. -
Else:
-
Remove the destination directory.
-
If the source and destination directories are the same:
-
Rewrite the name in the existing directory.
-
Else:
-
If the destination is a child of the source directory:
-
Fail the operation with an error.
-
Else:
-
Write the new entry in the destination directory.
-
Update
"."
and".."
in the moved directory. -
Clear the old directory entry.
-
Parameters:
-
item: The file system object being renamed.
-
sourceDirectory: The directory that currently contains the item to rename.
-
sourceName: The name of the item within the source directory.
-
destinationName: The new name of the item as it appears in
destinationDirectory
. -
destinationDirectory: The directory to contain the renamed object, which may be the same as
sourceDirectory
. -
overItem: The file system object if the destination exists, as discovered in a prior lookup. If this parameter is non-
nil
, markoverItem
as deleted, so the file system can free its allocated space on the next call toreclaimItem(_:replyHandler:)
. After doing so, ensure the operation finishes without errors. -
reply: A block or closure to indicate success or failure. If renaming succeeds, pass the
FSFileName
as it exists withindestinationDirectory
and anil
error. If renaming fails, pass the relevant error as the second parameter; FSKit ignores anyFSFileName
in this case. For anasync
Swift implementation, there’s no reply handler; simply return theFSFileName
or throw an error.
Sourceunsafe fn enumerateDirectory_startingAtCookie_verifier_providingAttributes_usingPacker_replyHandler(
&self,
directory: &FSItem,
cookie: FSDirectoryCookie,
verifier: FSDirectoryVerifier,
attributes: Option<&FSItemGetAttributesRequest>,
packer: &FSDirectoryEntryPacker,
reply: &DynBlock<dyn Fn(FSDirectoryVerifier, *mut NSError)>,
)
Available on crate features FSItem
and block2
only.
unsafe fn enumerateDirectory_startingAtCookie_verifier_providingAttributes_usingPacker_replyHandler( &self, directory: &FSItem, cookie: FSDirectoryCookie, verifier: FSDirectoryVerifier, attributes: Option<&FSItemGetAttributesRequest>, packer: &FSDirectoryEntryPacker, reply: &DynBlock<dyn Fn(FSDirectoryVerifier, *mut NSError)>, )
FSItem
and block2
only.Enumerates the contents of the given directory.
This method uses the FSDirectoryEntryPacker/packEntry(name:itemType:itemID:nextCookie:attributes:)
method of the packer
parameter to deliver the enumerated items to the caller.
The general flow of an enumeration implementation follows these steps:
- Enumeration starts with a call to
enumerateDirectory
using the initial next-cookie and verifier valuesFSDirectoryCookieInitial
andFSDirectoryVerifierInitial
, respectively. - The implementation uses
packer
to pack the initial set of directory entries. Packing also sets anextCookie
to use on the next call. - The implementation replies with a new verifier value, a nonzero value that reflects the directory’s current version.
- On the next call the implementation packs the next set of entries, starting with the item indicated by
cookie
. Ifcookie
doesn’t resolve to a valid directory entry, complete the request with an error of domain <doc ://com.apple.documentation/documentation/Foundation/NSPOSIXErrorDomain> and codeFSError/Code/invalidDirectoryCookie
.
When packing, make sure to use acceptable directory entry names and unambiguous input to all file operations that take names without additional normalization, such aslookupName
.
Tip: If the
attributes
parameter isnil
, include at least two entries in a directory:"."
and".."
, which represent the current and parent directories, respectively. Both of these items have typeFSItem/ItemType/directory
. For the root directory,"."
and".."
have identical contents. Don’t pack"."
and".."
ifattributes
isn’tnil
.
- Parameters:
- directory: The item to enumerate. FSKit guarantees this item is of type
FSItem/ItemType/directory
. - cookie: A value that indicates the location within the directory from which to enumerate. Your implementation defines the semantics of the cookie values; they’re opaque to FSKit. The first call to the enumerate method passes
FSDirectoryCookieInitial
for this parameter. Subsequent calls pass whatever cookie value you previously passed to the packer’snextCookie
parmeter. - verifier: A tool to detect whether the directory contents changed since the last call to
enumerateDirectory
. Your implementation defines the semantics of the verifier values; they’re opaque to FSKit. The first call to the enumerate method passesFSDirectoryVerifierInitial
for this parameter. Subsequent calls pass whatever cookie value you previously passed to the packer’scurrentVerifier
parmeter. - attributes: The desired attributes to provide, or
nil
if the caller doesn’t require attributes. - packer: An object that your implementation uses to enumerate directory items, packing one item per callback to
enumerateDirectory
. - reply: A block or closure to indicate success or failure. If enumeration succeeds, pass the current verifier and a
nil
error. If enumeration fails, pass the relevant error as the second parameter; FSKit ignores any verifier in this case. For anasync
Swift implementation, there’s no reply handler; simply return the current verifier or throw an error.
Sourceunsafe fn activateWithOptions_replyHandler(
&self,
options: &FSTaskOptions,
reply: &DynBlock<dyn Fn(*mut FSItem, *mut NSError)>,
)
Available on crate features FSItem
and FSTaskOptions
and block2
only.
unsafe fn activateWithOptions_replyHandler( &self, options: &FSTaskOptions, reply: &DynBlock<dyn Fn(*mut FSItem, *mut NSError)>, )
FSItem
and FSTaskOptions
and block2
only.Activates the volume using the specified options.
When FSKit calls this method, allocate any in-memory state required to represent the file system.
Also allocate an FSItem
for the root directory of the file system, and pass it to the reply block.
FSKit caches this root item for the lifetime of the volume, and uses it as a starting point for all file look-ups.
Volume activation occurs prior to any call to mount the volume.
- Parameters:
- options: Options to apply to the activation. These can include security-scoped file paths. There are no defined options currently.
- reply: A block or closure to indicate success or failure. If activation succeeds, pass the root
FSItem
and anil
error. If activation fails, pass the relevant error as the second parameter; FSKit ignores anyFSItem
in this case. In Swift,reply
takes only theFSItem
as the parameter; you signal any error with athrow
. For anasync
Swift implementation, there’s no reply handler; simply return theFSItem
or throw an error.
Sourceunsafe fn deactivateWithOptions_replyHandler(
&self,
options: FSDeactivateOptions,
reply: &DynBlock<dyn Fn(*mut NSError)>,
)
Available on crate feature block2
only.
unsafe fn deactivateWithOptions_replyHandler( &self, options: FSDeactivateOptions, reply: &DynBlock<dyn Fn(*mut NSError)>, )
block2
only.Tears down a previously initialized volume instance.
Set up your implementation to release any resources allocated for the volume instance. By the time you receive this callback, FSKit has already performed a reclaim call to release all other file nodes associated with this file system instance.
Avoid performing any I/O in this method. Prior to calling this method, FSKit has already issued a sync call to perform any cleanup-related I/O.
FSKit unmounts any mounted volume with a call to unmount(replyHandler:)
prior to the deactivate callback.
- Parameters:
- options: Options to apply to the deactivation.
- reply: A block or closure to indicate success or failure. If activation fails, pass an error as the one parameter to the reply handler. If activation succeeds, pass
nil
. For anasync
Swift implementation, there’s no reply handler; simply throw an error or return normally.