Contents

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 -> FSRemoveItemResult

Parameters

  • 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 nil error. If removal fails, pass the relevant error as the second parameter; FSKit ignores the Fsremoveitemresult instance in this case. For an async Swift 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