pub unsafe trait FSVolumePreallocateOperations: NSObjectProtocol {
// Provided methods
unsafe fn isPreallocateInhibited(&self) -> bool
where Self: Sized + Message { ... }
unsafe fn setPreallocateInhibited(&self, preallocate_inhibited: bool)
where Self: Sized + Message { ... }
unsafe fn preallocateSpaceForItem_atOffset_length_flags_replyHandler(
&self,
item: &FSItem,
offset: off_t,
length: usize,
flags: FSPreallocateFlags,
reply: &DynBlock<dyn Fn(usize, *mut NSError)>,
)
where Self: Sized + Message { ... }
}FSVolume only.Expand description
Methods and properties implemented by volumes that want to offer preallocation functions.
A preallocation operation allocates space for a file without writing to it yet. A file system may use reallocation to avoid performing space allocation while in the midst of I/O; this strategy improves performance. Also, if the expected I/O pattern is many small writes, preallocating contiguous chunks may prevent fragmenting the file system. This process can improve performance later.
In a kernel-based file system, you typically preallocate space with the VNOP_ALLOCATE operation, called from fcntl(F_PREALLOCATE).
See also Apple’s documentation
Provided Methods§
Sourceunsafe fn isPreallocateInhibited(&self) -> bool
unsafe fn isPreallocateInhibited(&self) -> bool
A Boolean value that instructs FSKit not to call this protocol’s methods, even if the volume conforms to it.
FSKit reads this value after the file system replies to the loadResource message.
Changing the returned value during the runtime of the volume has no effect.
Sourceunsafe fn setPreallocateInhibited(&self, preallocate_inhibited: bool)
unsafe fn setPreallocateInhibited(&self, preallocate_inhibited: bool)
Setter for isPreallocateInhibited.
Sourceunsafe fn preallocateSpaceForItem_atOffset_length_flags_replyHandler(
&self,
item: &FSItem,
offset: off_t,
length: usize,
flags: FSPreallocateFlags,
reply: &DynBlock<dyn Fn(usize, *mut NSError)>,
)
Available on crate features FSItem and block2 and libc only.
unsafe fn preallocateSpaceForItem_atOffset_length_flags_replyHandler( &self, item: &FSItem, offset: off_t, length: usize, flags: FSPreallocateFlags, reply: &DynBlock<dyn Fn(usize, *mut NSError)>, )
FSItem and block2 and libc only.Prealocates disk space for the given item.
- Parameters:
- item: 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.
- reply: A block or closure to indicate success or failure. If preallocation succeeds, pass the amount of bytes allocated and a
nilerror. If preallocation fails, pass the relevant error as the second parameter; FSKit ignores any byte count in this case. For anasyncSwift implementation, there’s no reply handler; simply return the allocated byte count or throw an error.