Contents

lookupItem(named:inDirectory:replyHandler:)

Looks up an item within a directory.

Declaration

func lookupItem(named name: FSFileName, inDirectory directory: FSItem, replyHandler reply: @escaping  @Sendable (FSItem?, FSFileName?, (any Error)?) -> Void)
func lookupItem(named name: FSFileName, inDirectory directory: FSItem) async throws -> (FSItem, FSFileName)

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 its Fsfilename (as saved within the file system), along with a nil error. If lookup fails, pass the relevant error as the third parameter; any Fsitem or Fsfilename are ignored in this case. For an async Swift implementation, there’s no reply handler; simply return the Fsitem and Fsfilename as a tuple or throw an error.

Discussion

If no item matching name exists in the directory indicated by directory, complete the request with an error with a domain of NSPOSIXErrorDomain and a code of ENOENT.

See Also

Working with items