3S6LU2U5TIU43WRE5RQS3IOLVJLVNCDL4W44FVK2HR3NAXZ7IDUAC
IIV3EL2XYI2X7HZWKXEXQFAE3R3KC2Q7SGOT3Q332HSENMYVF32QC
ADPAFSMYUBTKSK63EPCY5WQGROJQWFCWO4UFPWY3ZXD5ZNH26P2QC
X243Z3Y54ULINQMMRIKLHRV5T237B7VUOAHVJ7DMPOQ6A6GQXY2AC
Q3GU26WDEYE2HXMM4WWNEGVMSXLQAKRJBSB2EJZA6JTHPKQHXCXQC
SXEYMYF7P4RZMZ46WPL4IZUTSQ2ATBWYZX7QNVMS3SGOYXYOHAGQC
VO5OQW4W2656DIYYRNZ3PO7TQ4JOKQ3GVWE5ALUTYVMX3WMXJOYQC
YN63NUZO4LVJ7XPMURDULTXBVJKW5MVCTZ24R7Z52QMHO3HPDUVQC
LLT3GY6ULCVHMO3VUSVI5H4O244Z3ULOWLTW2IGJXIA2TWIHJDSQC
CCLLB7OIFNFYJZTG3UCI7536TOCWSCSXR67VELSB466R24WLJSDAC
GHO6DWPILBBTL6CVZKERJBTFL3EY6ZT4YM4E5R4S6YPGVFKFHCVAC
I52XSRUH5RVHQBFWVMAQPTUSPAJ4KNVID2RMI3UGCVKFLYUO6WZAC
meta.write(&mut self.rec.contents).unwrap();
self.rec.contents.extend(item.basename.as_bytes());
let file_meta = FileMetadata {
metadata: meta,
basename: item.basename.as_str(),
};
file_meta.write(&mut self.rec.contents);
let name_start = ChangePosition(self.rec.contents.len().into());
item.metadata.write(&mut self.rec.contents).unwrap();
self.rec.contents.extend(item.basename.as_bytes());
let name_end = ChangePosition(self.rec.contents.len().into());
let basename = item.basename.as_str();
let meta_start = ChangePosition(self.rec.contents.len().into());
FileMetadata {
metadata: item.metadata,
basename,
}
.write(&mut self.rec.contents);
let meta_end = ChangePosition(self.rec.contents.len().into());
let name_changed =
(parent_name != &name[2..]) || (new_meta != parent_meta && cfg!(not(windows)));
let name_changed = (parent_name != name) || (new_meta != parent_meta && cfg!(not(windows)));
assert!(buf.len() >= 2);
let (a, b) = buf.as_slice().split_at(2);
Ok((InodeMetadata::from_basename(a), std::str::from_utf8(b)?))
Ok(FileMetadata::read(buf))
}
}
#[derive(Serialize, Deserialize)]
pub struct FileMetadata<'a> {
pub metadata: InodeMetadata,
pub basename: &'a str,
// pub encoding: Encoding,
}
impl<'a> FileMetadata<'a> {
pub fn read(buf: &'a [u8]) -> FileMetadata<'a> {
// FIXME use ? by adding the From trait somehow
bincode::deserialize(buf).unwrap()
}
pub fn write(&self, w: &mut Vec<u8>) {
// FIXME use ? by adding the From trait somehow
bincode::serialize_into(w, self).unwrap()
let name =
std::str::from_utf8(&change_contents[add.start.us() + 2..add.end.us()])
.unwrap();
let perms = crate::pristine::InodeMetadata::from_basename(
&change_contents[add.start.us()..add.start.us() + 2],
);
let FileMetadata {
basename: name,
metadata: perms,
} = FileMetadata::read(&change_contents);
let name = std::str::from_utf8(&change_contents[n.start.us() + 2..n.end.us()])
.unwrap();
let perms = crate::pristine::InodeMetadata::from_basename(
&change_contents[n.start.us()..n.start.us() + 2],
);
let FileMetadata {
basename: name,
metadata: perms,
} = FileMetadata::read(&change_contents);