mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-29 02:08:10 -07:00
OFW be like rEnAmE = cOpY + dElEtE, bro stfu :/
This commit is contained in:
@@ -369,6 +369,39 @@ static FS_Error storage_process_common_remove(Storage* app, FuriString* path) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
static FS_Error storage_process_common_rename(Storage* app, FuriString* old, FuriString* new) {
|
||||
FS_Error ret;
|
||||
// Paths are already resolved, no aliases
|
||||
if(strncmp(furi_string_get_cstr(old), furi_string_get_cstr(new), STORAGE_PATH_PREFIX_LEN)) {
|
||||
// Different filesystems, use copy + remove
|
||||
ret = storage_common_copy(app, furi_string_get_cstr(old), furi_string_get_cstr(new));
|
||||
if(ret == FSE_OK) {
|
||||
if(!storage_simply_remove_recursive(app, furi_string_get_cstr(old))) {
|
||||
ret = FSE_INTERNAL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Same filesystem, use rename
|
||||
StorageData* storage;
|
||||
ret = storage_get_data(app, old, &storage);
|
||||
|
||||
do {
|
||||
if(storage_path_already_open(old, storage)) {
|
||||
ret = FSE_ALREADY_OPEN;
|
||||
break;
|
||||
}
|
||||
|
||||
storage_data_timestamp(storage);
|
||||
FS_CALL(
|
||||
storage,
|
||||
common.rename(
|
||||
storage, cstr_path_without_vfs_prefix(old), cstr_path_without_vfs_prefix(new)));
|
||||
} while(false);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static FS_Error storage_process_common_mkdir(Storage* app, FuriString* path) {
|
||||
StorageData* storage;
|
||||
FS_Error ret = storage_get_data(app, path, &storage);
|
||||
@@ -514,6 +547,7 @@ void storage_process_alias(
|
||||
|
||||
void storage_process_message_internal(Storage* app, StorageMessage* message) {
|
||||
FuriString* path = NULL;
|
||||
FuriString* opath = NULL;
|
||||
|
||||
switch(message->command) {
|
||||
// File operations
|
||||
@@ -614,6 +648,13 @@ void storage_process_message_internal(Storage* app, StorageMessage* message) {
|
||||
storage_process_alias(app, path, message->data->path.thread_id, false);
|
||||
message->return_data->error_value = storage_process_common_remove(app, path);
|
||||
break;
|
||||
case StorageCommandCommonRename:
|
||||
opath = furi_string_alloc_set(message->data->rename.old);
|
||||
storage_process_alias(app, opath, message->data->rename.thread_id, false);
|
||||
path = furi_string_alloc_set(message->data->rename.new);
|
||||
storage_process_alias(app, path, message->data->rename.thread_id, false);
|
||||
message->return_data->error_value = storage_process_common_rename(app, opath, path);
|
||||
break;
|
||||
case StorageCommandCommonMkDir:
|
||||
path = furi_string_alloc_set(message->data->path.path);
|
||||
storage_process_alias(app, path, message->data->path.thread_id, true);
|
||||
@@ -649,6 +690,9 @@ void storage_process_message_internal(Storage* app, StorageMessage* message) {
|
||||
if(path != NULL) { //-V547
|
||||
furi_string_free(path);
|
||||
}
|
||||
if(opath != NULL) { //-V547
|
||||
furi_string_free(opath);
|
||||
}
|
||||
|
||||
api_lock_unlock(message->lock);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user