mirror of https://github.com/vinc/moros.git
Add move command
This commit is contained in:
parent
27e6314db4
commit
1877ce471f
|
@ -1,5 +1,6 @@
|
|||
pub mod date;
|
||||
pub mod read;
|
||||
pub mod r#move;
|
||||
pub mod shell;
|
||||
pub mod uptime;
|
||||
pub mod write;
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
use crate::print;
|
||||
use crate::kernel::fs;
|
||||
|
||||
pub fn main(args: &[&str]) {
|
||||
if args.len() != 3 {
|
||||
return;
|
||||
}
|
||||
|
||||
let from = args[1];
|
||||
let to = args[2];
|
||||
|
||||
if to.starts_with("/dev") || to.starts_with("/sys") {
|
||||
print!("Permission denied to write to '{}'\n", to);
|
||||
} else {
|
||||
if let Some(file_from) = fs::File::open(from) {
|
||||
if let Some(mut file_to) = fs::File::create(to) {
|
||||
file_to.write(&file_from.read());
|
||||
} else {
|
||||
print!("Permission denied to write to '{}'\n", to);
|
||||
}
|
||||
} else {
|
||||
print!("File not found '{}'\n", from);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -59,7 +59,7 @@ pub fn key_handle(key: DecodedKey) {
|
|||
"j" | "jd" | "jump" | "jump-dir" => print!("TODO\n"),
|
||||
"k" | "kill" => print!("TODO\n"),
|
||||
"l" | "list" | "ls" => print!("TODO\n"), // same as `rd`
|
||||
"m" | "move" | "mv" => print!("TODO\n"),
|
||||
"m" | "move" | "mv" => user::r#move::main(&args),
|
||||
"n" => print!("?\n"),
|
||||
"o" => print!("?\n"),
|
||||
"p" | "print" => print!("TODO\n"),
|
||||
|
|
Loading…
Reference in New Issue