createLink(to:named:in:context:replyHandler:)
Creates a new hard link.
Declaration
func createLink(to item: FSItem, named name: FSFileName, in directory: FSItem, context: FSContext, replyHandler reply: @escaping @Sendable (FSCreateLinkResult?, (any Error)?) -> Void)func createLink(to item: FSItem, named name: FSFileName, in directory: FSItem, context: FSContext) async throws -> FSCreateLinkResultParameters
- item:
The existing item to which to link.
- name:
The name for the new link.
- directory:
The directory in which to create the link.
- context:
An object that enables context-aware file system decisions throughout the operation.
- reply:
A block or closure to indicate success or failure. If creation succeeds, pass an instance of Fscreatelinkresult containing the Fsfilename of the newly-created link, the Attributes of the linked item, the updated Attributes of the parent directory, and the volume’s updated free space, along with a
nilerror. If creation fails, pass the relevant error as the second parameter; FSKit ignores the Fscreatelinkresult instance in this case. For anasyncSwift implementation, there’s no reply handler; simply return the result instance or throw an error.
Discussion
If creating the link fails, complete the request with an error with a domain of NSPOSIXErrorDomain and the following error codes:
EEXISTif there’s already an item namednamein the directory.EMLINKif creating the link would exceed the maximum number of hard links supported onitem.ENOTSUPif the file system doesn’t support creating hard links to the type of file system object thatitemrepresents.