mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 20:49:49 +04:00
Storage, common_rename: check that old path is exists (#2698)
* Storage, common_rename: check that old path is exists * Storage, common_rename: return correct status
This commit is contained in:
@@ -424,19 +424,25 @@ 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 storage_common_rename(Storage* storage, const char* old_path, const char* new_path) {
|
||||||
FS_Error error;
|
FS_Error error;
|
||||||
|
|
||||||
if(storage_file_exists(storage, new_path)) {
|
do {
|
||||||
error = storage_common_remove(storage, new_path);
|
if(!storage_common_exists(storage, old_path)) {
|
||||||
if(error != FSE_OK) {
|
error = FSE_INVALID_NAME;
|
||||||
return error;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(storage_file_exists(storage, new_path)) {
|
||||||
|
storage_common_remove(storage, new_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
error = storage_common_copy(storage, old_path, new_path);
|
error = storage_common_copy(storage, old_path, new_path);
|
||||||
if(error == FSE_OK) {
|
if(error != FSE_OK) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if(!storage_simply_remove_recursive(storage, old_path)) {
|
if(!storage_simply_remove_recursive(storage, old_path)) {
|
||||||
error = FSE_INTERNAL;
|
error = FSE_INTERNAL;
|
||||||
}
|
}
|
||||||
}
|
} while(false);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user