2022-04-13 20:50:25 +00:00
|
|
|
#include "lfs_backup.h"
|
|
|
|
|
|
|
|
#include <toolbox/tar/tar_archive.h>
|
|
|
|
|
2022-07-26 12:21:51 +00:00
|
|
|
#include <bt/bt_settings_filename.h>
|
|
|
|
#include <bt/bt_service/bt_keys_filename.h>
|
|
|
|
#include <dolphin/helpers/dolphin_state_filename.h>
|
|
|
|
#include <desktop/helpers/slideshow_filename.h>
|
2022-09-14 16:11:38 +00:00
|
|
|
#include <desktop/desktop_settings_filename.h>
|
2022-07-26 12:21:51 +00:00
|
|
|
#include <notification/notification_settings_filename.h>
|
|
|
|
|
|
|
|
#define LFS_BACKUP_DEFAULT_LOCATION EXT_PATH(LFS_BACKUP_DEFAULT_FILENAME)
|
|
|
|
|
2022-10-05 15:15:23 +00:00
|
|
|
static void backup_name_converter(FuriString* filename) {
|
|
|
|
if(furi_string_empty(filename) || (furi_string_get_char(filename, 0) == '.')) {
|
2022-07-26 12:21:51 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Filenames are already prefixed with '.' */
|
|
|
|
const char* const names[] = {
|
|
|
|
BT_SETTINGS_FILE_NAME,
|
|
|
|
BT_KEYS_STORAGE_FILE_NAME,
|
|
|
|
DESKTOP_SETTINGS_FILE_NAME,
|
|
|
|
NOTIFICATION_SETTINGS_FILE_NAME,
|
|
|
|
SLIDESHOW_FILE_NAME,
|
2022-07-26 17:13:09 +00:00
|
|
|
DOLPHIN_STATE_FILE_NAME,
|
2022-07-26 12:21:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
for(size_t i = 0; i < COUNT_OF(names); i++) {
|
2022-10-05 15:15:23 +00:00
|
|
|
if(furi_string_equal(filename, &names[i][1])) {
|
|
|
|
furi_string_set(filename, names[i]);
|
2022-07-26 12:21:51 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-13 20:50:25 +00:00
|
|
|
|
|
|
|
bool lfs_backup_create(Storage* storage, const char* destination) {
|
|
|
|
const char* final_destination =
|
|
|
|
destination && strlen(destination) ? destination : LFS_BACKUP_DEFAULT_LOCATION;
|
|
|
|
return storage_int_backup(storage, final_destination) == FSE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool lfs_backup_exists(Storage* storage, const char* source) {
|
|
|
|
const char* final_source = source && strlen(source) ? source : LFS_BACKUP_DEFAULT_LOCATION;
|
2022-09-15 13:55:55 +00:00
|
|
|
return storage_common_stat(storage, final_source, NULL) == FSE_OK;
|
2022-04-13 20:50:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool lfs_backup_unpack(Storage* storage, const char* source) {
|
|
|
|
const char* final_source = source && strlen(source) ? source : LFS_BACKUP_DEFAULT_LOCATION;
|
2022-07-26 12:21:51 +00:00
|
|
|
return storage_int_restore(storage, final_source, backup_name_converter) == FSE_OK;
|
2022-04-13 20:50:25 +00:00
|
|
|
}
|