|
@@ -2,7 +2,6 @@
|
|
|
|
|
|
|
|
void nfc_playlist_playlist_rename_menu_callback(void* context) {
|
|
void nfc_playlist_playlist_rename_menu_callback(void* context) {
|
|
|
NfcPlaylist* nfc_playlist = context;
|
|
NfcPlaylist* nfc_playlist = context;
|
|
|
- Storage* storage = furi_record_open(RECORD_STORAGE);
|
|
|
|
|
|
|
|
|
|
char const* old_file_path = (char*)furi_string_get_cstr(nfc_playlist->settings.playlist_path);
|
|
char const* old_file_path = (char*)furi_string_get_cstr(nfc_playlist->settings.playlist_path);
|
|
|
char const* old_file_name = strchr(old_file_path, '/') != NULL ? &strrchr(old_file_path, '/')[1] : old_file_path;
|
|
char const* old_file_name = strchr(old_file_path, '/') != NULL ? &strrchr(old_file_path, '/')[1] : old_file_path;
|
|
@@ -11,12 +10,14 @@ void nfc_playlist_playlist_rename_menu_callback(void* context) {
|
|
|
furi_string_replace(new_file_path, old_file_name, nfc_playlist->text_input_output);
|
|
furi_string_replace(new_file_path, old_file_name, nfc_playlist->text_input_output);
|
|
|
furi_string_cat_str(new_file_path, ".txt");
|
|
furi_string_cat_str(new_file_path, ".txt");
|
|
|
|
|
|
|
|
- if (storage_common_rename_safe(storage, old_file_path, furi_string_get_cstr(new_file_path)) == 0) {
|
|
|
|
|
|
|
+ Storage* storage = furi_record_open(RECORD_STORAGE);
|
|
|
|
|
+ if (!storage_file_exists(storage, furi_string_get_cstr(new_file_path))) {
|
|
|
|
|
+ storage_common_rename(storage, old_file_path, furi_string_get_cstr(new_file_path));
|
|
|
furi_string_swap(nfc_playlist->settings.playlist_path, new_file_path);
|
|
furi_string_swap(nfc_playlist->settings.playlist_path, new_file_path);
|
|
|
}
|
|
}
|
|
|
|
|
+ furi_record_close(RECORD_STORAGE);
|
|
|
|
|
|
|
|
furi_string_free(new_file_path);
|
|
furi_string_free(new_file_path);
|
|
|
- furi_record_close(RECORD_STORAGE);
|
|
|
|
|
|
|
|
|
|
scene_manager_search_and_switch_to_previous_scene(nfc_playlist->scene_manager, NfcPlaylistScene_MainMenu);
|
|
scene_manager_search_and_switch_to_previous_scene(nfc_playlist->scene_manager, NfcPlaylistScene_MainMenu);
|
|
|
}
|
|
}
|
|
@@ -30,7 +31,8 @@ void nfc_playlist_playlist_rename_scene_on_enter(void* context) {
|
|
|
FuriString* tmp_file_name_furi = furi_string_alloc_set_str(tmp_file_name);
|
|
FuriString* tmp_file_name_furi = furi_string_alloc_set_str(tmp_file_name);
|
|
|
furi_string_replace(tmp_file_name_furi, ".txt", "");
|
|
furi_string_replace(tmp_file_name_furi, ".txt", "");
|
|
|
|
|
|
|
|
- nfc_playlist->text_input_output = strdup(furi_string_get_cstr(tmp_file_name_furi));
|
|
|
|
|
|
|
+ nfc_playlist->text_input_output = malloc(PLAYLIST_NAME_LEN);
|
|
|
|
|
+ strcpy(nfc_playlist->text_input_output, furi_string_get_cstr(tmp_file_name_furi));
|
|
|
furi_string_free(tmp_file_name_furi);
|
|
furi_string_free(tmp_file_name_furi);
|
|
|
|
|
|
|
|
text_input_set_header_text(nfc_playlist->text_input, "Enter new file name");
|
|
text_input_set_header_text(nfc_playlist->text_input, "Enter new file name");
|