Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/flipperzero-firmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSkorpionm <85568270+Skorpionm@users.noreply.github.com>2021-11-11 15:49:19 +0300
committerGitHub <noreply@github.com>2021-11-11 15:49:19 +0300
commitac8b1457f27412ddd0aac065a7babc7818d5bb78 (patch)
tree96fbd8da8b0aed4690257b57c3c462afa0a3a619 /applications/storage
parent5209701add1fd6b9aaea387beb5b99fcb3b8afe5 (diff)
[FL-1931, FL-2005] SubGhz: migration in flipper file format (#807)
* SubGhz: add save key in flipper file format * [FL-2005] SubGhz: fix stored signals cannot be deleted * SubGhz: add load key in flipper file format * SubGhz: fix syntax * SubGhz: fix bad file upload * Storage: add function to get the next free filename * SubGhz: add save RAW in flipper file format * SubGhz: add load RAW in flipper file format * SubGhz: refactoring protocol * SubGhz: refactoring scene * SubGhz: fix SubGhzNotificationState define * Makefile: proper comapre for FORCE Co-authored-by: あく <alleteam@gmail.com>
Diffstat (limited to 'applications/storage')
-rw-r--r--applications/storage/storage-external-api.c25
-rw-r--r--applications/storage/storage.h16
2 files changed, 41 insertions, 0 deletions
diff --git a/applications/storage/storage-external-api.c b/applications/storage/storage-external-api.c
index 7f275894..ae798ecb 100644
--- a/applications/storage/storage-external-api.c
+++ b/applications/storage/storage-external-api.c
@@ -463,3 +463,28 @@ bool storage_simply_mkdir(Storage* storage, const char* path) {
result = storage_common_mkdir(storage, path);
return result == FSE_OK || result == FSE_EXIST;
}
+
+void storage_get_next_filename(
+ Storage* storage,
+ const char* dirname,
+ const char* filename,
+ const char* fileextension,
+ string_t nextfilename) {
+ string_t temp_str;
+ uint16_t num = 0;
+
+ string_init_printf(temp_str, "%s/%s%s", dirname, filename, fileextension);
+
+ while(storage_common_stat(storage, string_get_cstr(temp_str), NULL) == FSE_OK) {
+ num++;
+ string_printf(temp_str, "%s/%s%d%s", dirname, filename, num, fileextension);
+ }
+
+ if(num) {
+ string_printf(nextfilename, "%s%d", filename, num);
+ } else {
+ string_printf(nextfilename, "%s", filename);
+ }
+
+ string_clear(temp_str);
+}
diff --git a/applications/storage/storage.h b/applications/storage/storage.h
index 9351e155..fc7ac665 100644
--- a/applications/storage/storage.h
+++ b/applications/storage/storage.h
@@ -262,6 +262,22 @@ bool storage_simply_remove_recursive(Storage* storage, const char* path);
*/
bool storage_simply_mkdir(Storage* storage, const char* path);
+/**
+ * @brief Get next free filename.
+ *
+ * @param storage
+ * @param dirname
+ * @param filename
+ * @param fileextension
+ * @param nextfilename return name
+ */
+void storage_get_next_filename(
+ Storage* storage,
+ const char* dirname,
+ const char* filename,
+ const char* fileextension,
+ string_t nextfilename);
+
#ifdef __cplusplus
}
#endif