[FL-3662] Do not remove file when renaming to itself (#3193)
* Do not allow overwriting a file with dir and support renaming file to itself * Fix operator precedence error * Add support for storage-specific path equivalence checks * Fix typo * Fix updater compilation * Update Doxygen comments in storage.h Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
co-authored by
Aleksandr Kutuzov
parent
615a147973
commit
ba074068b0
@@ -596,6 +596,16 @@ static FS_Error storage_ext_common_fs_info(
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool storage_ext_common_equivalent_path(const char* path1, const char* path2) {
|
||||
#ifdef FURI_RAM_EXEC
|
||||
UNUSED(path1);
|
||||
UNUSED(path2);
|
||||
return false;
|
||||
#else
|
||||
return strcasecmp(path1, path2) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/******************* Init Storage *******************/
|
||||
static const FS_Api fs_api = {
|
||||
.file =
|
||||
@@ -624,6 +634,7 @@ static const FS_Api fs_api = {
|
||||
.mkdir = storage_ext_common_mkdir,
|
||||
.remove = storage_ext_common_remove,
|
||||
.fs_info = storage_ext_common_fs_info,
|
||||
.equivalent_path = storage_ext_common_equivalent_path,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -686,6 +686,10 @@ static FS_Error storage_int_common_fs_info(
|
||||
return storage_int_parse_error(result);
|
||||
}
|
||||
|
||||
static bool storage_int_common_equivalent_path(const char* path1, const char* path2) {
|
||||
return strcmp(path1, path2) == 0;
|
||||
}
|
||||
|
||||
/******************* Init Storage *******************/
|
||||
static const FS_Api fs_api = {
|
||||
.file =
|
||||
@@ -714,6 +718,7 @@ static const FS_Api fs_api = {
|
||||
.mkdir = storage_int_common_mkdir,
|
||||
.remove = storage_int_common_remove,
|
||||
.fs_info = storage_int_common_fs_info,
|
||||
.equivalent_path = storage_int_common_equivalent_path,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user