write(contents:to:at:replyHandler:)
Writes contents to the given file item.
Declaration
func write(contents: Data, to item: FSItem, at offset: off_t, replyHandler reply: @escaping @Sendable (Int, (any Error)?) -> Void)func write(contents: Data, to item: FSItem, at offset: off_t) async throws -> IntParameters
- contents:
A buffer containing the data to write to the file.
- item:
The item to which to write. FSKit guarantees this item will be of type File.
- offset:
The offset in the file from which to start writing.
- reply:
A block or closure to indicate success or failure. If writing succeeds, pass the number of bytes written and a
nilerror. If writing fails, pass the number of bytes written prior to the error along with the relevant error. For anasyncSwift implementation, there’s no reply handler; simply return the byte count or throw an error.
Discussion
FSKit expects this routine to allocate space in the file system to extend the file as necessary.
If the volume experiences an out-of-space condition, reply with an error of domain NSPOSIXErrorDomain and code ENOSPC.