Fix bug in direntry.

This commit is contained in:
Bas Wiel, van de 2024-05-02 18:43:01 +02:00
parent d9c2bf7539
commit f0d98d0d0e
1 changed files with 3 additions and 2 deletions

View File

@ -206,12 +206,13 @@ impl DirEntry {
/// or an `std::io::Error` if an error occurs during the conversion process.
///
pub fn as_bytes(&self) -> Result<[u8; 32], std::io::Error> {
let start_cluster = self.allocated_clusters[0] as u16;
let mut result = [0u8; 32];
result[0..11].copy_from_slice(&self.filename.as_bytes());
result[11] = self.attributes.as_byte();
result[22..24].copy_from_slice(&self.create_timedate.creation_time_bytes()?);
result[24..26].copy_from_slice(&self.create_timedate.creation_date_bytes()?);
result[26..28].copy_from_slice(&(self.allocated_clusters[0]).to_le_bytes());
result[26..28].copy_from_slice(&start_cluster.to_le_bytes());
result[28..32].copy_from_slice(&self.file_size.to_le_bytes());
Ok(result)
}
@ -382,7 +383,7 @@ mod tests {
file_size: 4608,
entry_type: DirEntryType::File, // Dummy placeholder
children: Vec::new(),
allocated_clusters: Vec::new(),
allocated_clusters: vec![2,3,4],
data: Vec::new(),
};
// Semi-representative entry that reflects IBMBIO.COM on April 4 1983.