diff --git a/src/Tools/psxcdgen_ex/src/encoder/psx.rs b/src/Tools/psxcdgen_ex/src/encoder/psx.rs index 683fc192..1b0c9b41 100644 --- a/src/Tools/psxcdgen_ex/src/encoder/psx.rs +++ b/src/Tools/psxcdgen_ex/src/encoder/psx.rs @@ -108,7 +108,6 @@ fn process_pvd(pvd: &PrimaryVolumeDescriptor, path_table: SharedPtr, return Err(Error::from_text(format!("PVD required to start at sector 16 of Track - found LBA: {}", pvd_lba))); } - let mut cd_pvd = cd_pvd::PrimaryVolumeDescriptor::new(); let now = Date::now(); @@ -126,11 +125,7 @@ fn process_pvd(pvd: &PrimaryVolumeDescriptor, path_table: SharedPtr, //Set Root Directory Record let root_dir_record = unsafe{std::mem::transmute::<&mut [u8; 34], &mut DirectoryRecord>(&mut cd_pvd.root_dir_record)}; - unsafe{root_dir_record.new("\x00", false)}; - root_dir_record.data_block_number.write(root_dir.properties.track_rel_lba as u32); - root_dir_record.data_size.write(root_dir.get_size() as u32); - root_dir_record.time_stamp = SmallDate::now(); - root_dir_record.set_directory(); + update_dir_record(root_dir_record, &root_dir)?; //Set other stuff cd_pvd.publisher_id = AString::from_str(pvd.publisher.as_str())?; @@ -156,4 +151,15 @@ fn validate_path_table(path_table: &SharedPtr) -> Result Result<(), Error> { + unsafe{dir_record.new(dir.name.as_str().unwrap_or("\x00"), false)}; + + dir_record.data_block_number.write(dir.properties.track_rel_lba as u32); + dir_record.data_size.write(dir.get_size() as u32); + dir_record.time_stamp = SmallDate::now(); + dir_record.set_directory(); + + Ok(()) } \ No newline at end of file diff --git a/src/Tools/psxcdgen_ex/src/types/mod.rs b/src/Tools/psxcdgen_ex/src/types/mod.rs index 9eebbb7f..8e968e97 100644 --- a/src/Tools/psxcdgen_ex/src/types/mod.rs +++ b/src/Tools/psxcdgen_ex/src/types/mod.rs @@ -23,7 +23,7 @@ pub struct CDDesc { impl CDDesc { pub fn new() -> CDDesc { - match Directory::new("root") { + match Directory::new("\x00") { Ok(root) => CDDesc{system_area: new_shared_ptr(SystemArea::new()), path_table: new_shared_ptr(PathTable::new()), pvd: new_shared_ptr(PrimaryVolumeDescriptor::new()), root: new_shared_ptr(root), vol_sector_count: 0}, Err(error) => panic!("Creating root directory failed with: {}", error) } @@ -201,7 +201,7 @@ impl DirectoryName { Some(self.as_str()?.to_owned()) } - fn as_str(&self) -> Option<&str> { + pub fn as_str(&self) -> Option<&str> { dstring_as_str(&self.name, self.len) } }