more refactoring
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
Julien CLEMENT 2022-12-25 13:02:25 +01:00
parent 0ad8ba9adb
commit 2e7415e1e6
2 changed files with 10 additions and 5 deletions

@ -75,6 +75,14 @@ impl IsoDir {
pub fn get_idf(&self) -> &[u8] { pub fn get_idf(&self) -> &[u8] {
unsafe { core::slice::from_raw_parts(self.idf.as_ptr(), self.idf_len as usize) } unsafe { core::slice::from_raw_parts(self.idf.as_ptr(), self.idf_len as usize) }
} }
pub fn next_entry(&self) -> &IsoDir {
crate::utils::ref_raw_offset(self, self.dir_size as isize)
}
pub fn matches(&self, path: &str) -> bool {
self.get_idf() == path.as_bytes()
}
} }
// Primary volume descriptor structure // Primary volume descriptor structure

@ -46,7 +46,7 @@ impl FileSystem for IsoFS {
serial_println!("{:?}", curr_entry.idf_len); serial_println!("{:?}", curr_entry.idf_len);
serial_println!("{:?}", alloc::str::from_utf8(curr_entry.get_idf()).unwrap()); serial_println!("{:?}", alloc::str::from_utf8(curr_entry.get_idf()).unwrap());
if curr_entry.get_idf() == path_component.as_bytes() { if curr_entry.matches(path_component) {
serial_println!("Found {}", path_component); serial_println!("Found {}", path_component);
curr_entry_block = read_block(curr_entry.data_blk.le).await; curr_entry_block = read_block(curr_entry.data_blk.le).await;
curr_entry = unserialize(curr_entry_block.as_ptr()); curr_entry = unserialize(curr_entry_block.as_ptr());
@ -54,7 +54,7 @@ impl FileSystem for IsoFS {
} }
// Next entry // Next entry
curr_entry = next_entry(curr_entry); curr_entry = curr_entry.next_entry();
} }
} }
@ -64,9 +64,6 @@ impl FileSystem for IsoFS {
} }
} }
pub fn next_entry(entry: &IsoDir) -> &IsoDir {
crate::utils::ref_raw_offset(entry, entry.dir_size as isize)
}
pub async fn get_prim_vol_desc() -> IsoPrimVolDesc { pub async fn get_prim_vol_desc() -> IsoPrimVolDesc {
let desc_block = read_block(iso9660::ISO_PRIM_VOLDESC_BLOCK).await; let desc_block = read_block(iso9660::ISO_PRIM_VOLDESC_BLOCK).await;