Skip to main content

CreateFileOptions

Struct CreateFileOptions 

Source
pub struct CreateFileOptions {
Show 20 fields pub mode: Option<u32>, pub uid: Option<u32>, pub gid: Option<u32>, pub type_code: Option<String>, pub creator_code: Option<String>, pub os_type: Option<[u8; 4]>, pub os_creator: Option<[u8; 4]>, pub finder_flags: Option<u16>, pub aux_type: Option<u16>, pub resource_fork: Option<ResourceForkSource>, pub xattrs: Vec<Xattr>, pub amiga_protection: Option<u32>, pub amiga_comment: Option<String>, pub amiga_dates: Option<(i32, i32, i32)>, pub skip_data_write: bool, pub skip_name_checks: bool, pub skip_fsinfo_update: bool, pub dos_attributes: Option<u16>, pub unix_times: Option<UnixTimes>, pub qnx2_attrs: Option<Qnx2Attrs>,
}
Expand description

Options for creating a file on an editable filesystem.

Fields§

§mode: Option<u32>

Unix mode bits (default 0o100666). Ignored on FAT/exFAT.

§uid: Option<u32>

Unix user ID (default 0). Ignored on FAT/exFAT/NTFS.

§gid: Option<u32>

Unix group ID (default 0). Ignored on FAT/exFAT/NTFS.

§type_code: Option<String>

HFS/HFS+ type code (e.g. “TEXT”) or ProDOS type as “$XX” (e.g. “$04”). Auto-detected from extension if not set. This is the caller-typed text form; for byte-exact Mac type/creator preservation (high-bit OSTypes) use os_type instead.

§creator_code: Option<String>

HFS/HFS+ creator code (e.g. “MSWD”). Auto-detected from extension if not set.

§os_type: Option<[u8; 4]>

Raw 4-byte Mac OSType file type. When set, HFS/HFS+/MFS create_file writes these bytes into the Finder info verbatim, taking precedence over the lossy type_code text. Used by fidelity-preserving copies (cp, get-binhex, archive replay) so a high-bit creator like Prince of Persia’s PoƒP (0xC4) survives. None outside the Mac family.

§os_creator: Option<[u8; 4]>

Raw 4-byte Mac OSType creator. See os_type.

§finder_flags: Option<u16>

Finder flags (fdFlags) for HFS/HFS+: bundle bit, custom icon, invisible. None leaves them zero, as a freshly created file has them.

§aux_type: Option<u16>

ProDOS auxiliary type (16-bit). Semantics depend on the file type: $0801 for Applesoft BASIC load address, $2000 for typical BIN, record length for random-access TXT, etc. Auto-detected from extension if not set. Ignored on non-ProDOS filesystems.

§resource_fork: Option<ResourceForkSource>

Optional resource fork data source (HFS/HFS+ only).

§xattrs: Vec<Xattr>

Extended attributes to stamp on the new file, on filesystems that store them. Ignored elsewhere.

Exists mainly so an overwrite can keep them. Replacing a file is delete-then-create, and the create otherwise knows nothing about what it displaced — so a binary carrying security.capability came back without it and silently stopped working. Mode and ownership already survive a replace via [crate::fs::attrs::resolve_attrs]; this is the same rule for the attributes that don’t live in the inode. See [crate::fs::attrs::inherited_xattrs].

§amiga_protection: Option<u32>

AmigaDOS protection bits (access word) for AFFS/FFS. The on-disk default of 0 displays as ----rwed. Ignored on non-Amiga filesystems.

§amiga_comment: Option<String>

AmigaDOS filenote (comment, up to 79 bytes). Ignored on non-Amiga filesystems.

§amiga_dates: Option<(i32, i32, i32)>

AmigaDOS raw datestamp triple (days, minutes, ticks) since 1978-01-01. When set, written verbatim into the on-disk entry so dates round-trip through clone/restore. Ignored on non-Amiga filesystems. Default None leaves the date zero (which display tools render as the epoch).

§skip_data_write: bool

When true, allocate clusters and create the directory entry but skip writing file content. The allocated clusters are left uninitialized (zero on fresh images). Used by the GHO file-aware virtual-FAT builder to avoid writing 1 GB+ of zeros that are immediately evicted.

§skip_name_checks: bool

When true, skip the duplicate-name check and SFN collision scan before creating the file. The caller guarantees uniqueness (e.g. entries come from a pre-deduplicated tree on a fresh FS). Eliminates the O(n) parent-directory read per file.

§skip_fsinfo_update: bool

When true, skip the per-operation FSInfo update (FAT32). Caller must call sync_metadata when done to write a correct FSInfo sector. Eliminates two full FAT-table reads per file.

§dos_attributes: Option<u16>

Standard DOS attribute bits to stamp on the new file (read-only 0x01, hidden 0x02, system 0x04, archive 0x20). Honored by FAT and exFAT; ignored elsewhere. None lets the filesystem pick its conventional default (FAT/exFAT use archive). See [crate::fs::entry::FileEntry::dos_attributes].

§unix_times: Option<UnixTimes>

Preserve these Unix timestamps (seconds since 1970) on the new inode instead of stamping the current time. Set by dir_import / tar_import / Commander stage_copy so a copy carries the source’s mtime through end-to-end; left None for a genuinely new file (rb-cli put from a - stdin stream, GUI “new blank file”), where the driver stamps now. Ignored on filesystems that don’t carry per-file Unix times (FAT/exFAT/NTFS have their own scheme, AmigaDOS uses amiga_dates, HFS uses mac_dates). See [crate::fs::times::UnixTimes].

§qnx2_attrs: Option<Qnx2Attrs>

QNX 2 permissions, owner and date copied exactly (from FileEntry::qnx2_attrs); overrides mode / uid / gid / unix_times.

Trait Implementations§

Source§

impl Clone for CreateFileOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CreateFileOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CreateFileOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.