preallocateSpace(for:at:length:flags:packer:replyHandler:)
Preallocates and maps disk space for the given file.
Declaration
optional func preallocateSpace(for file: FSItem, at offset: off_t, length: Int, flags: FSVolume.PreallocateFlags, packer: FSExtentPacker, replyHandler reply: @escaping @Sendable (Int, (any Error)?) -> Void)optional func preallocateSpace(for file: FSItem, at offset: off_t, length: Int, flags: FSVolume.PreallocateFlags, packer: FSExtentPacker) async throws -> IntParameters
- file:
The item for which to preallocate space.
- offset:
The offset from which to allocate.
- length:
The length of the space in bytes.
- flags:
Flags that affect the preallocation behavior.
- packer:
An extent packer you use to pack the file’s preallocated disk space.
- reply:
A block or closure to indicate success or failure. If preallocation succeeds, pass the amount of bytes allocated and a nil error. If preallocation fails, pass the relevant error as the second parameter; FSKit ignores any byte count in this case. For an
asyncSwift implementation, there’s no reply handler; simply return the allocated byte count or throw an error.
Discussion
This method allows the module to opportunistically supply extents, avoiding future calls to blockmapFile(_:offset:length:flags:operationID:packer:replyHandler:).