Skip to content

Commit

Permalink
Revamped files a bit, removed a bunch of disk images, and fixed the r…
Browse files Browse the repository at this point in the history
…emoval bug.
  • Loading branch information
otisdog8 committed Aug 7, 2020
1 parent 6526a23 commit e8f13f1
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 8 deletions.
Binary file removed os/os.dsk
Binary file not shown.
Binary file removed os/os.img
Binary file not shown.
Binary file removed os/os.qcow2
Binary file not shown.
Binary file modified os/os.tar
Binary file not shown.
Binary file renamed os/os.tar.orig → os/os.tar.1
Binary file not shown.
Binary file removed os/os.tar.backup
Binary file not shown.
Binary file removed os/os.tar.orig1
Binary file not shown.
Binary file removed os/osb.img
Binary file not shown.
18 changes: 10 additions & 8 deletions os/src/ustar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,6 @@ impl USTARItem for Directory {

fn set_name(&mut self, name: String) {
self.name = name.clone();
self.name.reserve_exact(100 - self.name.len());
while self.name.len() < 100 {
self.name.push('\0');
}
}

fn get_name_and_prefix(&self) -> String {
Expand Down Expand Up @@ -963,10 +959,6 @@ impl USTARItem for File {

fn set_name(&mut self, name: String) {
self.name = name.clone();
self.name.reserve_exact(100 - self.name.len());
while self.name.len() < 100 {
self.name.push('\0');
}
}

fn get_name_and_prefix(&self) -> String {
Expand Down Expand Up @@ -1152,6 +1144,15 @@ impl USTARFileSystem {
self.block_used_ptr = counter as u64;
// Somehow sort the thing
}
for f in self.files.iter() {
if !self.is_absolute(&f.lock().get_name()) {
let mut strng = String::from("/");
strng.push_str(&f.lock().get_name());
f.lock().set_name(strng);
f.lock().should_write();
}
}
self.write();
}

#[allow(clippy::all)]
Expand Down Expand Up @@ -1640,6 +1641,7 @@ impl USTARFileSystem {
// Removes a file if it exists, does nothing if it doesn't
pub fn remove_file(&mut self, file: String, id: Option<u64>) {
if let Some(file) = self.resolve_file(file, id) {
println!("{}", file.lock().name);
let (first, _) = self.split_last_and_first(file.lock().name.to_string());
if let Some(directory) = self.resolve_directory( first, id) {
file.lock().name = "defrag".to_string();
Expand Down

0 comments on commit e8f13f1

Please sign in to comment.