struct size hacking shenanigans
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-17 20:31:14 +01:00
parent 96e7b1cd8e
commit c4531b5074
2 changed files with 5 additions and 5 deletions

2
.gitignore vendored
View File

@ -1,5 +1,5 @@
/target /target
iso /iso
*.iso *.iso
*.o *.o
julios julios

View File

@ -4,7 +4,7 @@ pub struct IsoPathTable {
ext_size: u8, // Extended attribute record length ext_size: u8, // Extended attribute record length
data_blk: u8, // File data block index data_blk: u8, // File data block index
parent_dir: u16, // Number of the parent dir parent_dir: u16, // Number of the parent dir
// idf: [char] // Directory name, of size Self::idf_len idf: [char; 0] // Directory name, of size Self::idf_len
} }
impl IsoPathTable { impl IsoPathTable {
@ -16,10 +16,10 @@ impl IsoPathTable {
} }
} }
pub fn get_idf(&self) -> *const char { #[allow(unaligned_references)]
let ptr: *const IsoPathTable = self; pub fn get_idf(&self) -> &[char] {
unsafe { unsafe {
ptr.offset(1) as *const char core::slice::from_raw_parts(self.idf.as_ptr(), self.idf_len as usize)
} }
} }
} }