Correctly handle cases where files already exist on the filesystem.

Also: patched a bug wherein the filename filter was acting up, transforming `file.zip` to `file-zip.zip`, for example.
This commit is contained in:
Dylan G
2021-06-17 01:43:50 +01:00
parent 3f2e4c03f3
commit 18cb5c616f
4 changed files with 145 additions and 68 deletions

View File

@@ -391,14 +391,7 @@ bool init_qr(void)
if(mode != MODE_AMOUNT)
{
char path_to_file[0x107] = {0};
sprintf(path_to_file, "%s%s", main_paths[mode], filename);
char * extension = strrchr(path_to_file, '.');
if (extension == NULL || strcmp(extension, ".zip"))
strcat(path_to_file, ".zip");
remake_file(fsMakePath(PATH_ASCII, path_to_file), ArchiveSD, zip_size);
buf_to_file(zip_size, fsMakePath(PATH_ASCII, path_to_file), ArchiveSD, zip_buf);
save_zip_to_sd(filename, zip_size, zip_buf, mode);
success = true;
}
else