FlippyPass/project/backend/archive.c

60 lines
No EOL
1.3 KiB
C

// Header
#include "archive.h"
// Functions
bool archive_import(Manager* manager) {
// Loading the file
char* data = store_load(Store_File_Path_Archive, "Data");
// Did we fail to load the data?
if (!data) {return false;}
// Splitting the string up
int count = 0;
char** split = split_string(data, F_DELIMITER, &count);
// Free data after split
free(data);
// Going through all passwords
for (int i = 0; i < count; i++) {
// Skipping to each password
if (i % 4 == 0) {
// DEBUG
FURI_LOG_D(TAG, "(%i, %s) Adding password.", i, split[i]);
// Allocating memory for a password
Password* new_password = pass_init(
split[i],
split[i+1],
split[i+2],
0
);
// Saving the new password
manager_savepass(manager, new_password);
// Freeing that password
pass_free(new_password);
}
}
// Wiping the original file
store_save(Store_File_Path_Archive, "Data", "Done.");
// Cleanup
free(split);
// Return result
return true;
}
bool archive_export(Manager* manager) {
// Result
bool result = true;
// UNUSED variable
UNUSED(manager);
// Return result
return result;
}