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

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
SG 2021-07-25 21:55:23 +10:00 committed by GitHub
parent fb305eddb2
commit 81080a3a8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);