mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-26 14:30:25 +00:00
[FL-3334] Storage: explosive rename fix (#2876)
Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
6605740ce9
commit
e073c603a4
1 changed files with 14 additions and 0 deletions
|
@ -430,6 +430,20 @@ FS_Error storage_common_rename(Storage* storage, const char* old_path, const cha
|
|||
break;
|
||||
}
|
||||
|
||||
if(storage_dir_exists(storage, old_path)) {
|
||||
FuriString* dir_path = furi_string_alloc_set_str(old_path);
|
||||
if(!furi_string_end_with_str(dir_path, "/")) {
|
||||
furi_string_cat_str(dir_path, "/");
|
||||
}
|
||||
const char* dir_path_s = furi_string_get_cstr(dir_path);
|
||||
if(strncmp(new_path, dir_path_s, strlen(dir_path_s)) == 0) {
|
||||
error = FSE_INVALID_NAME;
|
||||
furi_string_free(dir_path);
|
||||
break;
|
||||
}
|
||||
furi_string_free(dir_path);
|
||||
}
|
||||
|
||||
if(storage_file_exists(storage, new_path)) {
|
||||
storage_common_remove(storage, new_path);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue