Use function to update DirectoryRecord
This commit is contained in:
parent
6bd789a39f
commit
7355879a35
|
@ -108,7 +108,6 @@ fn process_pvd(pvd: &PrimaryVolumeDescriptor, path_table: SharedPtr<PathTable>,
|
|||
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<PathTable>,
|
|||
|
||||
//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<PathTable>) -> Result<std::cell::R
|
|||
else {
|
||||
Ok(path_table)
|
||||
}
|
||||
}
|
||||
|
||||
fn update_dir_record(dir_record: &mut DirectoryRecord, dir: &Directory) -> 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(())
|
||||
}
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue