mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-22 10:43:11 +00:00
4bf29827f8
* Quicksave 1 * Header stage complete * Source stage complete * Lint & merge fixes * Includes * Documentation step 1 * FBT: output free size considering BT STACK * Documentation step 2 * py lint * Fix music player plugin * unit test stage 1: string allocator, mem, getters, setters, appends, compare, search. * unit test: string equality * unit test: string replace * unit test: string start_with, end_with * unit test: string trim * unit test: utf-8 * Rename * Revert fw_size changes * Simplify CLI backspace handling * Simplify CLI character insert * Merge fixes * Furi: correct filenaming and spelling * Bt: remove furi string include Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
51 lines
1.8 KiB
C
51 lines
1.8 KiB
C
#include "lfs_backup.h"
|
|
|
|
#include <toolbox/tar/tar_archive.h>
|
|
|
|
#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>
|
|
#include <desktop/desktop_settings_filename.h>
|
|
#include <notification/notification_settings_filename.h>
|
|
|
|
#define LFS_BACKUP_DEFAULT_LOCATION EXT_PATH(LFS_BACKUP_DEFAULT_FILENAME)
|
|
|
|
static void backup_name_converter(FuriString* filename) {
|
|
if(furi_string_empty(filename) || (furi_string_get_char(filename, 0) == '.')) {
|
|
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,
|
|
DOLPHIN_STATE_FILE_NAME,
|
|
};
|
|
|
|
for(size_t i = 0; i < COUNT_OF(names); i++) {
|
|
if(furi_string_equal(filename, &names[i][1])) {
|
|
furi_string_set(filename, names[i]);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
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;
|
|
return storage_common_stat(storage, final_source, NULL) == FSE_OK;
|
|
}
|
|
|
|
bool lfs_backup_unpack(Storage* storage, const char* source) {
|
|
const char* final_source = source && strlen(source) ? source : LFS_BACKUP_DEFAULT_LOCATION;
|
|
return storage_int_restore(storage, final_source, backup_name_converter) == FSE_OK;
|
|
}
|