feat: add rm command

This commit is contained in:
2026-03-25 07:39:49 +01:00
parent 5918dc4ee5
commit eb0763b078
2 changed files with 31 additions and 1 deletions
+31
View File
@@ -0,0 +1,31 @@
/*
* main.cpp
* rm - command to remove files
* Copyright (c) 2026 Daniel Hammer
*/
#include <montauk/syscall.h>
#include <montauk/string.h>
extern "C" void _start() {
char args[256];
montauk::getargs((char *)&args, 256);
if (*args) {
const char* arg = montauk::skip_spaces((const char *)&args);
if (*arg != '\0') {
int fd = montauk::open(arg);
if (fd < 0) {
montauk::print("file not found\n");
} else {
montauk::close(fd);
montauk::fdelete(arg);
}
}
} else {
montauk::print("usage: rm [file]\n");
}
montauk::exit(0);
}