Contents

createItem(named:type:inDirectory:attributes:replyHandler:)

Creates a new file or directory item.

Declaration

func createItem(named name: FSFileName, type: FSItem.ItemType, inDirectory directory: FSItem, attributes newAttributes: FSItem.SetAttributesRequest, replyHandler reply: @escaping  @Sendable (FSItem?, FSFileName?, (any Error)?) -> Void)
func createItem(named name: FSFileName, type: FSItem.ItemType, inDirectory directory: FSItem, attributes newAttributes: FSItem.SetAttributesRequest) async throws -> (FSItem, FSFileName)

Parameters

  • name:

    The new item’s name.

  • type:

    The new item’s type. Valid values are File or Directory.

  • directory:

    The directory in which to create the item.

  • newAttributes:

    Attributes to apply to the new item.

  • reply:

    A block or closure to indicate success or failure. If creation succeeds, pass the newly-created Fsitem and its Fsfilename, along with a nil error. If creation fails, pass the relevant error as the third parameter; FSKit ignores any Fsitem or Fsfilename in this case. For an async Swift implementation, there’s no reply handler; simply return a tuple of the Fsitem and its Fsfilename 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