pub struct PreservedMeta {
pub mode: Option<u32>,
pub uid: Option<u32>,
pub gid: Option<u32>,
pub os_type: Option<[u8; 4]>,
pub os_creator: Option<[u8; 4]>,
pub aux_type: Option<u16>,
pub dos_attributes: Option<u16>,
pub amiga_protection: Option<u32>,
pub amiga_comment: Option<String>,
pub amiga_dates: Option<(i32, i32, i32)>,
pub mac_dates: Option<(u32, u32, u32)>,
pub xattrs: Vec<Xattr>,
}Expand description
Everything worth carrying from a file that is about to be replaced.
Replacing a file writes new contents; it is not a request to reset who may read it, when it was made, or what application owns it. But a replace is implemented as delete-then-create on every filesystem here, so unless these are captured first they are simply gone. Only xattrs used to be carried, which meant fixing one line of a config file silently reset its permissions, owner and timestamps.
Capture with preserved_meta before the delete, apply with
PreservedMeta::apply_to_options and PreservedMeta::reapply_dates.
Deliberately not preserved: the resource fork. That is content rather than metadata, and pairing a new data fork with the previous resource fork produces a file that is neither of the two things it came from.
Fields§
§mode: Option<u32>§uid: Option<u32>§gid: Option<u32>§os_type: Option<[u8; 4]>Classic-Mac OSType / creator, kept raw so a non-ASCII code survives.
os_creator: Option<[u8; 4]>§aux_type: Option<u16>ProDOS auxiliary type (a file’s load address, say).
dos_attributes: Option<u16>FAT attribute bits: read-only, hidden, system, archive.
amiga_protection: Option<u32>§amiga_comment: Option<String>§amiga_dates: Option<(i32, i32, i32)>§mac_dates: Option<(u32, u32, u32)>(created, modified, backup) in Mac epoch seconds.
xattrs: Vec<Xattr>Implementations§
Source§impl PreservedMeta
impl PreservedMeta
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether anything was actually captured, so callers can stay quiet when there is nothing to say.
Sourcepub fn summary(&self) -> String
pub fn summary(&self) -> String
A short, ASCII-only summary for the log line — the GUI font has no glyph coverage beyond ASCII.
Sourcepub fn apply_to_options(&self, opts: &mut CreateFileOptions)
pub fn apply_to_options(&self, opts: &mut CreateFileOptions)
Fill a [CreateFileOptions] with the preserved values, leaving anything
the caller already set alone.
An explicit --type/--mode is an instruction and must win; preserved
metadata is only the default for fields nobody spoke about.
Sourcepub fn reapply_dates(
&self,
fs: &mut dyn EditableFilesystem,
entry: &FileEntry,
) -> bool
pub fn reapply_dates( &self, fs: &mut dyn EditableFilesystem, entry: &FileEntry, ) -> bool
Restore timestamps, which no filesystem here accepts at creation time.
Best-effort by design: a filesystem with no date setter answers
Unsupported, and failing the whole write over a timestamp would be a
worse outcome than the file keeping today’s date. Returns whether the
dates were actually applied so the caller can report honestly.