diff --git a/src/lib.rs b/src/lib.rs index 7326e73..03f9a19 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -288,9 +288,7 @@ impl FileType { match self { Self::Normal(f) => { writer.write_all(&[0])?; - writer.write_all(&f.len.to_le_bytes())?; - f.checksum.write(writer)?; - writer.write_all(&f.data)?; + f.write(writer)?; }, Self::HardLink(s) => { writer.write_all(&[1])?; @@ -319,6 +317,33 @@ impl FileType { } } +#[derive(Debug)] +enum Kind { + Normal, + Dir, + Char, + Block, + Pipe, +} + +impl From for Kind { + fn from(value: u32) -> Self { + if value & 0o60000 != 0 { + Self::Block + } else if value & 0o20000 != 0 { + Self::Char + } else if value & 0o10000 != 0 { + Self::Pipe + } else if value & 0o40000 != 0 { + Self::Dir + } else if value & 0o100000 != 0 { + Self::Normal + } else { + panic!(); + } + } +} + #[derive(Debug)] pub struct Node { pub name: String,