Contents

removeItem(_:named:fromDirectory:replyHandler:)

Removes an existing item from a given directory.

Declaration

func removeItem(_ item: FSItem, named name: FSFileName, fromDirectory directory: FSItem, replyHandler reply: @escaping  @Sendable ((any Error)?) -> Void)
func removeItem(_ item: FSItem, named name: FSFileName, fromDirectory directory: FSItem) async throws

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 an async Swift implementation, there’s no reply handler; simply throw an error or return normally.

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