createItem(named:type:in:attributes:context:replyHandler:)
Creates a new file or directory item.
Declaration
func createItem(named name: FSFileName, type: FSItem.ItemType, in directory: FSItem, attributes newAttributes: FSItem.SetAttributesRequest, context: FSContext, replyHandler reply: @escaping @Sendable (FSCreateItemResult?, (any Error)?) -> Void)func createItem(named name: FSFileName, type: FSItem.ItemType, in directory: FSItem, attributes newAttributes: FSItem.SetAttributesRequest, context: FSContext) async throws -> FSCreateItemResultParameters
- name:
The new item’s name.
- type:
- directory:
The directory in which to create the item.
- newAttributes:
Attributes to apply to the new 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 creation succeeds, pass an instance of Fscreateitemresult containing the newly-created Fsitem, its Fsfilename, its Attributes, 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 Fscreateitemresult instance in this case. For anasyncSwift implementation, there’s no reply handler; simply return the result instance or throw an error.
Discussion
If an item named name already exists in the directory indicated by directory, complete the request with an error with a domain of NSPOSIXErrorDomain and a code of EEXIST.
See Also
Working with items
FSFileNameFSItem.ItemTypeFSItem.SetAttributesRequestFSCreateItemResultlookupItem(named:in:context:replyHandler:)FSLookupItemResultremoveItem(_:named:from:context:replyHandler:)FSRemoveItemResultrenameItem(_:inDirectory:named:to:inDirectory:overItem:context:replyHandler:)FSRenameItemResultreclaimItem(_:replyHandler:)