diff --git a/src/lib.rs b/src/lib.rs index e32435d..7326e73 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -232,7 +232,7 @@ impl File { #[repr(u8)] #[derive(Debug)] pub enum FileType { - Normal = 0, + Normal(File), HardLink(String), SoftLink(String), Directory, @@ -246,7 +246,10 @@ impl FileType { let mut buf = [0; 1]; reader.read_exact(&mut buf)?; match buf[0] { - 0 => Ok(Self::Normal), + 0 => { + let file = File::read(reader)?; + Ok(Self::Normal(file)) + }, 1 => { let mut len = [0; 8]; reader.read_exact(&mut len)?; @@ -283,7 +286,12 @@ impl FileType { pub fn write(&self, writer: &mut T) -> Result<(), Error> { match self { - Self::Normal => writer.write_all(&[0])?, + Self::Normal(f) => { + writer.write_all(&[0])?; + writer.write_all(&f.len.to_le_bytes())?; + f.checksum.write(writer)?; + writer.write_all(&f.data)?; + }, Self::HardLink(s) => { writer.write_all(&[1])?; let len = s.len() as u64;