removeItem(_:named:from:context:replyHandler:)
Removes an existing item from a given directory.
Declaration
func removeItem(_ item: FSItem, named name: FSFileName, from directory: FSItem, context: FSContext, replyHandler reply: @escaping @Sendable (FSRemoveItemResult?, (any Error)?) -> Void)func removeItem(_ item: FSItem, named name: FSFileName, from directory: FSItem, context: FSContext) async throws -> FSRemoveItemResultParameters
- item:
The item to remove.
- name:
The name of the item to remove.
- directory:
The directory from which to remove the item.
- context:
An object that enables context-aware file system decisions throughout the operation.
- reply:
A block or closure to indicate success or failure. If removal succeeds, pass an instance of Fsremoveitemresult containing the Attributes of the removed item, the updated Attributes of the parent directory, and the volume’s updated free space, along with a
nilerror. If removal fails, pass the relevant error as the second parameter; FSKit ignores the Fsremoveitemresult instance in this case. For anasyncSwift implementation, there’s no reply handler; simply return the result instance or throw an error.
Discussion
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:).
See Also
Working with items
createItem(named:type:in:attributes:context:replyHandler:)FSFileNameFSItem.ItemTypeFSItem.SetAttributesRequestFSCreateItemResultlookupItem(named:in:context:replyHandler:)FSLookupItemResultFSRemoveItemResultrenameItem(_:inDirectory:named:to:inDirectory:overItem:context:replyHandler:)FSRenameItemResultreclaimItem(_:replyHandler:)