Просмотр исходного кода

[FL-1191] Storage: CLI mkdir command #603

Co-authored-by: あく <alleteam@gmail.com>
SG 4 лет назад
Родитель
Сommit
81080a3a8b
1 измененных файлов с 17 добавлено и 0 удалено
  1. 17 0
      applications/storage/storage-cli.c

+ 17 - 0
applications/storage/storage-cli.c

@@ -30,6 +30,7 @@ void storage_cli_print_usage() {
         "\twrite\t - read data from cli and append it to file, <args> should contain how many bytes you want to write\r\n");
     printf("\tcopy\t - copy file to new file, <args> must contain new path\r\n");
     printf("\trename\t - move file to new file, <args> must contain new path\r\n");
+    printf("\tmkdir\t - creates a new directory\r\n");
 };
 
 void storage_cli_print_error(FS_Error error) {
@@ -285,6 +286,17 @@ void storage_cli_rename(Cli* cli, string_t old_path, string_t args) {
     furi_record_close("storage");
 }
 
+void storage_cli_mkdir(Cli* cli, string_t path) {
+    Storage* api = furi_record_open("storage");
+    FS_Error error = storage_common_mkdir(api, string_get_cstr(path));
+
+    if(error != FSE_OK) {
+        storage_cli_print_error(error);
+    }
+
+    furi_record_close("storage");
+}
+
 void storage_cli(Cli* cli, string_t args, void* context) {
     string_t cmd;
     string_t path;
@@ -342,6 +354,11 @@ void storage_cli(Cli* cli, string_t args, void* context) {
             break;
         }
 
+        if(string_cmp_str(cmd, "mkdir") == 0) {
+            storage_cli_mkdir(cli, path);
+            break;
+        }
+
         storage_cli_print_usage();
     } while(false);