|
|
@@ -2,29 +2,30 @@
|
|
|
|
|
|
void nfc_playlist_name_new_playlist_menu_callback(void* context) {
|
|
|
NfcPlaylist* nfc_playlist = context;
|
|
|
- Storage* storage = furi_record_open(RECORD_STORAGE);
|
|
|
- FuriString* file_name = furi_string_alloc();
|
|
|
|
|
|
- furi_string_printf(file_name, "/ext/apps_data/nfc_playlist/%s.txt", nfc_playlist->text_input_output);
|
|
|
+ FuriString* file_name = furi_string_alloc_printf("/ext/apps_data/nfc_playlist/%s.txt", nfc_playlist->text_input_output);
|
|
|
+ char const* file_name_cstr = furi_string_get_cstr(file_name);
|
|
|
|
|
|
+ Storage* storage = furi_record_open(RECORD_STORAGE);
|
|
|
File* file = storage_file_alloc(storage);
|
|
|
- if (storage_file_open(file, furi_string_get_cstr(file_name), FSAM_READ_WRITE, FSOM_CREATE_NEW)) {
|
|
|
- storage_file_close(file);
|
|
|
- furi_string_swap(nfc_playlist->settings.playlist_path, file_name);
|
|
|
+ if (!storage_file_exists(storage, file_name_cstr)) {
|
|
|
+ if (storage_file_open(file, file_name_cstr, FSAM_READ_WRITE, FSOM_CREATE_NEW)) {
|
|
|
+ storage_file_close(file);
|
|
|
+ furi_string_swap(nfc_playlist->settings.playlist_path, file_name);
|
|
|
+ nfc_playlist->settings.playlist_length = 0;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- nfc_playlist->settings.playlist_length = 0;
|
|
|
-
|
|
|
storage_file_free(file);
|
|
|
- furi_string_free(file_name);
|
|
|
furi_record_close(RECORD_STORAGE);
|
|
|
+
|
|
|
+ furi_string_free(file_name);
|
|
|
scene_manager_previous_scene(nfc_playlist->scene_manager);
|
|
|
}
|
|
|
|
|
|
void nfc_playlist_name_new_playlist_scene_on_enter(void* context) {
|
|
|
NfcPlaylist* nfc_playlist = context;
|
|
|
|
|
|
- nfc_playlist->text_input_output = (char*)malloc(PLAYLIST_NAME_LEN);
|
|
|
+ nfc_playlist->text_input_output = malloc(PLAYLIST_NAME_LEN);
|
|
|
text_input_set_header_text(nfc_playlist->text_input, "Enter file name");
|
|
|
text_input_set_minimum_length(nfc_playlist->text_input, 1);
|
|
|
text_input_set_result_callback(nfc_playlist->text_input, nfc_playlist_name_new_playlist_menu_callback, nfc_playlist, nfc_playlist->text_input_output, PLAYLIST_NAME_LEN, true);
|