Skip to content

Commit

Permalink
storage_simply_mkdir added
Browse files Browse the repository at this point in the history
Co-Authored-By: Augusto Zanellato <augusto.zanellato@gmail.com>
  • Loading branch information
zinongli and augustozanellato committed Aug 4, 2024
1 parent 458b1f4 commit 9381730
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions t5577_writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,24 +259,6 @@ static void t5577_writer_edit_block_slc_change(VariableItem* item) {
furi_string_free(buffer);
}

void ensure_dir_exists(Storage* storage) {
// If apps_data directory doesn't exist, create it.
if(!storage_dir_exists(storage, T5577_WRITER_APPS_DATA_FOLDER)) {
FURI_LOG_I(TAG, "Creating directory: %s", T5577_WRITER_APPS_DATA_FOLDER);
storage_simply_mkdir(storage, T5577_WRITER_APPS_DATA_FOLDER);
} else {
FURI_LOG_I(TAG, "Directory exists: %s", T5577_WRITER_APPS_DATA_FOLDER);
}

// If t5577_writer directory doesn't exist, create it.
if(!storage_dir_exists(storage, T5577_WRITER_FILE_FOLDER)) {
FURI_LOG_I(TAG, "Creating directory: %s", T5577_WRITER_FILE_FOLDER);
storage_simply_mkdir(storage, T5577_WRITER_FILE_FOLDER);
} else {
FURI_LOG_I(TAG, "Directory exists: %s", T5577_WRITER_FILE_FOLDER);
}
}

static const char* tag_name_entry_text = "Enter name";
static const char* tag_name_default_value = "Tag_1";
static void t5577_writer_file_saver(void* context) {
Expand All @@ -302,7 +284,7 @@ static void t5577_writer_file_saver(void* context) {
T5577_WRITER_FILE_EXTENSION);

Storage* storage = furi_record_open(RECORD_STORAGE);
ensure_dir_exists(storage);
storage_simply_mkdir(storage, STORAGE_APP_DATA_PATH_PREFIX);
File* data_file = storage_file_alloc(storage);
if(storage_file_open(
data_file, furi_string_get_cstr(file_path), FSAM_WRITE, FSOM_OPEN_ALWAYS)) {
Expand Down Expand Up @@ -469,7 +451,7 @@ void t5577_writer_view_load_callback(void* context) {
T5577WriterModel* model = view_get_model(app->view_write);
DialogsFileBrowserOptions browser_options;
Storage* storage = furi_record_open(RECORD_STORAGE);
ensure_dir_exists(storage);
storage_simply_mkdir(storage, STORAGE_APP_DATA_PATH_PREFIX);
File* data_file = storage_file_alloc(storage);
dialog_file_browser_set_basic_options(&browser_options, T5577_WRITER_FILE_EXTENSION, &I_icon);
browser_options.base_path = T5577_WRITER_FILE_FOLDER;
Expand Down

0 comments on commit 9381730

Please sign in to comment.