Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bulk encrypted saves copy #204

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/saves.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ enum cmd_code_enum
CMD_COPY_ALL_SAVES_USB,
CMD_COPY_SAVES_HDD,
CMD_COPY_ALL_SAVES_HDD,
CMD_COPY_ALL_ENCRYPTED_SAVES_HDD,
CMD_DUMP_FINGERPRINTS,
CMD_SAVE_WEBSERVER,
CMD_EXP_SAVES_VMC,
Expand Down
44 changes: 44 additions & 0 deletions source/exec_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,44 @@ static void copyAllSavesUSB(const save_entry_t* save, const char* dst_path, int
show_message("All Saves copied to:\n%s", dst_path);
}

static void copyAllEncSavesHDD(const save_entry_t* save, int all)
{
int err_count = 0;
uint64_t progress = 0;
list_node_t *node;
save_entry_t *item;
// This pointer holds the entire saves list:
list_t *list = ((void**)save->dir_name)[0];

init_progress_bar("Copying all encrypted saves to HDD...");

LOG("Copying all encrypted saves from '%s' to HDD...", save->path);
for (node = list_head(list); (item = list_get(node)); node = list_next(node))
{
update_progress_bar(progress++, list_count(list), item->name);

// only copy encrypted PS4 saves
// if "all=1" or the user flagged it selected.
if (item->type == FILE_TYPE_PS4 &&
(item->flags & SAVE_FLAG_LOCKED) &&
(all || (item->flags & SAVE_FLAG_SELECTED)))
{
// copySavePFS() actually performs the single encrypted-save copy to HDD
// If you care about errors, I guess it's better to make copySavePFS() return int instead of void as in copyAllSavesUSB
// Alternatively I could just call copySavePFS(item); directly (no check), and the function will always “report success or fail” with a message box
if (!copySavePFS_return(item))
err_count++;
}
}
end_progress_bar();

if (err_count)
show_message("Error: %d Saves couldn't be copied to HDD", err_count);
else
show_message("All encrypted saves copied to HDD!");
}


static void exportAllSavesVMC(const save_entry_t* save, int dev, int all)
{
char outPath[256];
Expand Down Expand Up @@ -1503,6 +1541,12 @@ void execCodeCommand(code_entry_t* code, const char* codecmd)
copyAllSavesHDD(selected_entry, codecmd[0] == CMD_COPY_ALL_SAVES_HDD);
code->activated = 0;
break;

case CMD_COPY_ALL_ENCRYPTED_SAVES_HDD:
copyAllEncSavesHDD(selected_entry, 1); // "1" means copy all
code->activated = 0;
break;


case CMD_SAVE_WEBSERVER:
enableWebServer(webReqHandler, ((void**)selected_entry->dir_name)[0], 8080);
Expand Down
3 changes: 3 additions & 0 deletions source/saves.c
Original file line number Diff line number Diff line change
Expand Up @@ -2192,6 +2192,9 @@ list_t * ReadUsbList(const char* userPath)

cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_COPY " Copy all decrypted Saves to HDD", CMD_COPY_ALL_SAVES_HDD);
list_append(item->codes, cmd);

cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_LOCK " Copy all encrypted Saves to HDD", CMD_COPY_ALL_ENCRYPTED_SAVES_HDD);
list_append(item->codes, cmd);

cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_NET " Start local Web Server", CMD_SAVE_WEBSERVER);
list_append(item->codes, cmd);
Expand Down
Loading