Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion applications/services/storage/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ FS_Error storage_common_stat(Storage* storage, const char* path, FileInfo* filei
*/
FS_Error storage_common_remove(Storage* storage, const char* path);

/** Renames file/directory, file/directory must not be open
/** Renames file/directory, file/directory must not be open. Will overwrite existing file.
* @param app pointer to the api
* @param old_path old path
* @param new_path new path
Expand Down
11 changes: 10 additions & 1 deletion applications/services/storage/storage_external_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,16 @@ FS_Error storage_common_remove(Storage* storage, const char* path) {
}

FS_Error storage_common_rename(Storage* storage, const char* old_path, const char* new_path) {
FS_Error error = storage_common_copy(storage, old_path, new_path);
FS_Error error;

if(storage_file_exists(storage, new_path)) {
error = storage_common_remove(storage, new_path);
if(error != FSE_OK) {
return error;
}
}

error = storage_common_copy(storage, old_path, new_path);
if(error == FSE_OK) {
if(!storage_simply_remove_recursive(storage, old_path)) {
error = FSE_INTERNAL;
Expand Down