summaryrefslogtreecommitdiff
path: root/examples/host
diff options
context:
space:
mode:
Diffstat (limited to 'examples/host')
-rw-r--r--examples/host/msc_file_explorer/src/msc_app.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/examples/host/msc_file_explorer/src/msc_app.c b/examples/host/msc_file_explorer/src/msc_app.c
index a1822b422..4500aedd2 100644
--- a/examples/host/msc_file_explorer/src/msc_app.c
+++ b/examples/host/msc_file_explorer/src/msc_app.c
@@ -275,6 +275,7 @@ void cli_cmd_cp(EmbeddedCli *cli, char *args, void *context);
void cli_cmd_ls(EmbeddedCli *cli, char *args, void *context);
void cli_cmd_mkdir(EmbeddedCli *cli, char *args, void *context);
void cli_cmd_mv(EmbeddedCli *cli, char *args, void *context);
+void cli_cmd_rm(EmbeddedCli *cli, char *args, void *context);
void cli_write_char(EmbeddedCli *cli, char c)
{
@@ -347,12 +348,20 @@ bool cli_init(void)
embeddedCliAddBinding(_cli, (CliCommandBinding) {
"mv",
- "Usage: mv SOURCE DEST...\r\n\tRename SOURCE to DEST",
+ "Usage: mv SOURCE DEST...\r\n\tRename SOURCE to DEST.",
true,
NULL,
cli_cmd_mv
});
+ embeddedCliAddBinding(_cli, (CliCommandBinding) {
+ "rm",
+ "Usage: rm [FILE]...\r\n\tRemove (unlink) the FILE(s).",
+ true,
+ NULL,
+ cli_cmd_rm
+ });
+
return true;
}
@@ -566,3 +575,27 @@ void cli_cmd_mv(EmbeddedCli *cli, char *args, void *context)
return;
}
}
+
+void cli_cmd_rm(EmbeddedCli *cli, char *args, void *context)
+{
+ (void) cli; (void) context;
+
+ uint16_t argc = embeddedCliGetTokenCount(args);
+
+ // need at least 1 argument
+ if ( argc == 0 )
+ {
+ printf("invalid arguments\r\n");
+ return;
+ }
+
+ for(uint16_t i=0; i<argc; i++)
+ {
+ const char* fpath = embeddedCliGetToken(args, i+1); // token count from 1
+
+ if ( FR_OK != f_unlink(fpath) )
+ {
+ printf("cannot remove '%s': No such file or directory\r\n", fpath);
+ }
+ }
+}