Skip to content

Commit daa1d41

Browse files
author
梶塚太智
committed
ディレクトリ作成とアイテム削除を可能にした
1 parent 3ea9283 commit daa1d41

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/main.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,28 @@ impl Executor {
884884
}
885885
}
886886

887+
// ディレクトリを作成
888+
"mkdir" => {
889+
let name = self.pop_stack().get_string();
890+
if let Err(e) = fs::create_dir(name) {
891+
self.log_print(format!("エラー! {e}"))
892+
}
893+
}
894+
895+
// アイテムを削除
896+
"rm" => {
897+
let name = self.pop_stack().get_string();
898+
if Path::new(name.as_str()).is_dir() {
899+
if let Err(e) = fs::remove_dir(name) {
900+
self.log_print(format!("エラー! {e}"))
901+
}
902+
} else {
903+
if let Err(e) = fs::remove_file(name) {
904+
self.log_print(format!("エラー! {e}"))
905+
}
906+
}
907+
}
908+
887909
// ファイル一覧のリスト
888910
"ls" => {
889911
if let Ok(entries) = fs::read_dir(".") {

0 commit comments

Comments
 (0)