Skip to content

Commit

Permalink
Replace redundant function:
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Hsiao authored and Nathan Hsiao committed Sep 6, 2024
1 parent 531c847 commit e06c19b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
2 changes: 1 addition & 1 deletion applications/cd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn main(args: Vec<String>) -> isize {
} else {
let path = matches.free[0].as_ref();

match curr_env.lock().chdir_path(path) {
match curr_env.lock().chdir(path) {
Err(environment::Error::NotADirectory) => {
println!("not a directory: {}", path);
return -1;
Expand Down
14 changes: 0 additions & 14 deletions kernel/environment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,6 @@ impl Environment {
/// Changes the current working directory.
#[doc(alias("change"))]
pub fn chdir(&mut self, path: &Path) -> Result<()> {
for component in path.components() {
let new = self.working_dir.lock().get(component.as_ref());
match new {
Some(FileOrDir::Dir(dir)) => {
self.working_dir = dir;
}
Some(FileOrDir::File(_)) => return Err(Error::NotADirectory),
None => return Err(Error::NotFound),
}
}
Ok(())
}

pub fn chdir_path(&mut self, path: &Path) -> Result<()> {
match path.get(&self.working_dir) {
Some(FileOrDir::Dir(dir)) => {
self.working_dir = dir;
Expand Down

0 comments on commit e06c19b

Please sign in to comment.