From 2e7415e1e61302809556bdd5b52a18be927da22c Mon Sep 17 00:00:00 2001 From: Julien CLEMENT Date: Sun, 25 Dec 2022 13:02:25 +0100 Subject: [PATCH] more refactoring Signed-off-by: Julien CLEMENT --- src/fs/iso/iso9660.rs | 8 ++++++++ src/fs/iso/mod.rs | 7 ++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/fs/iso/iso9660.rs b/src/fs/iso/iso9660.rs index 82e7354..726f6d7 100644 --- a/src/fs/iso/iso9660.rs +++ b/src/fs/iso/iso9660.rs @@ -75,6 +75,14 @@ impl IsoDir { pub fn get_idf(&self) -> &[u8] { 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 diff --git a/src/fs/iso/mod.rs b/src/fs/iso/mod.rs index 8ef8d39..6587016 100644 --- a/src/fs/iso/mod.rs +++ b/src/fs/iso/mod.rs @@ -46,7 +46,7 @@ impl FileSystem for IsoFS { serial_println!("{:?}", curr_entry.idf_len); 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); curr_entry_block = read_block(curr_entry.data_blk.le).await; curr_entry = unserialize(curr_entry_block.as_ptr()); @@ -54,7 +54,7 @@ impl FileSystem for IsoFS { } // 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 { let desc_block = read_block(iso9660::ISO_PRIM_VOLDESC_BLOCK).await;