Skip to content

Commit

Permalink
improve zip creation
Browse files Browse the repository at this point in the history
use libzip
  • Loading branch information
bucanero committed Nov 5, 2023
1 parent cc53883 commit 64b3c0f
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 52 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ jobs:
repository: bucanero/dbglogger
path: dbglogger

- name: Checkout zip
uses: actions/checkout@v3
with:
repository: bucanero/zip
path: zip

- name: Checkout vdpm
uses: actions/checkout@v3
with:
Expand All @@ -49,6 +43,7 @@ jobs:
working-directory: vdpm
run: |
./vdpm zlib
./vdpm bzip2
./vdpm libpng
./vdpm freetype
./vdpm taihen
Expand All @@ -62,9 +57,14 @@ jobs:
./vdpm libxmp-lite
- name: Install zip
working-directory: zip
run: |
make -f Makefile.vita install
curl -sL https://libzip.org/download/libzip-1.9.2.tar.gz | tar xz -C ./
cd libzip-1.9.2
cmake -DCMAKE_TOOLCHAIN_FILE=${VITASDK}/share/vita.toolchain.cmake -DBUILD_SHARED=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TOOLS=OFF -DBUILD_REGRESS=OFF -DBUILD_DOC=OFF -DENABLE_LZMA=OFF -DENABLE_ZSTD=OFF .
make
cp zipconf.h ${VITASDK}/arm-vita-eabi/include/zipconf.h
cp lib/zip.h ${VITASDK}/arm-vita-eabi/include/zip.h
cp lib/libzip.a ${VITASDK}/arm-vita-eabi/lib/libzip.a
- name: Install dbglogger
working-directory: dbglogger
Expand All @@ -88,4 +88,3 @@ jobs:
name: apollo-vita-build_${{ env.sha_name }}
path: apollo-vita.vpk
if-no-files-found: error
retention-days: 7 # don't keep artifacts for too long
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,12 @@ target_link_libraries(${PROJECT_NAME}
png
pthread
unrar
mzip
zip
un7zip
stdc++
xmp-lite
xml2
bz2
z
)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ You need to have installed:
- [polarSSL](https://github.com/vitasdk/packages/tree/master/polarssl) library
- [cURL](https://github.com/vitasdk/packages/tree/master/curl) library
- [libxmp-lite](https://github.com/vitasdk/packages/tree/master/libxmp-lite) library
- [Zip](https://github.com/bucanero/zip) library
- [libZip](https://github.com/vitasdk/packages/tree/master/libzip) library
- [dbglogger](https://github.com/bucanero/dbglogger) library

Run `cmake . && make` to create a release build. If you want to include the [latest save patches](https://github.com/bucanero/apollo-patches) in your `.vpk` file, run `make createzip`.
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ You need to have installed:
- [polarSSL](https://github.com/vitasdk/packages/tree/master/polarssl) library
- [cURL](https://github.com/vitasdk/packages/tree/master/curl) library
- [libxmp-lite](https://github.com/vitasdk/packages/tree/master/libxmp-lite) library
- [Zip](https://github.com/bucanero/zip) library
- [libZip](https://github.com/vitasdk/packages/tree/master/libzip) library
- [dbglogger](https://github.com/bucanero/dbglogger) library

Run `cmake . && make` to create a release build. If you want to include the [latest save patches](https://github.com/bucanero/apollo-patches) in your `.vpk` file, run `make createzip`.
Expand Down
26 changes: 17 additions & 9 deletions source/exec_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ static void downloadSave(const save_entry_t* entry, const char* file, int dst)
unlink_secure(APOLLO_LOCAL_CACHE "tmpsave.zip");
}

static uint32_t get_filename_id(const char* dir)
static uint32_t get_filename_id(const char* dir, const char* title_id)
{
char path[128];
uint32_t tid = 0;

do
{
tid++;
snprintf(path, sizeof(path), "%s%08d.zip", dir, tid);
snprintf(path, sizeof(path), "%s%s-%08d.zip", dir, title_id, tid);
}
while (file_exists(path) == SUCCESS);

Expand All @@ -94,8 +94,8 @@ static void zipSave(const save_entry_t* entry, int dst)

init_loading_screen("Exporting save game...");

fid = get_filename_id(exp_path);
snprintf(export_file, sizeof(export_file), "%s%08d.zip", exp_path, fid);
fid = get_filename_id(exp_path, entry->title_id);
snprintf(export_file, sizeof(export_file), "%s%s-%08d.zip", exp_path, entry->title_id, fid);

tmp = strdup(entry->path);
*strrchr(tmp, '/') = 0;
Expand All @@ -110,7 +110,7 @@ static void zipSave(const save_entry_t* entry, int dst)
FILE* f = fopen(export_file, "a");
if (f)
{
fprintf(f, "%08d.zip=[%s] %s\n", fid, entry->title_id, entry->name);
fprintf(f, "%s-%08d.zip=%s\n", entry->title_id, fid, entry->name);
fclose(f);
}

Expand All @@ -125,7 +125,7 @@ static void zipSave(const save_entry_t* entry, int dst)
return;
}

show_message("Zip file successfully saved to:\n%s%08d.zip", exp_path, fid);
show_message("Zip file successfully saved to:\n%s%s-%08d.zip", exp_path, entry->title_id, fid);
}

static void copySave(const save_entry_t* save, int dev)
Expand Down Expand Up @@ -296,6 +296,7 @@ static void extractArchive(const char* file_path)
case 'z':
case 'Z':
/* ZIP */
strcat(exp_path, "/");
ret = extract_zip(file_path, exp_path);
break;

Expand Down Expand Up @@ -354,6 +355,7 @@ static void exportFingerprint(const save_entry_t* save, int silent)

static void exportTrophyZip(const save_entry_t *trop, int dev)
{
int ret;
char exp_path[256];
char trp_path[256];
char* export_file;
Expand All @@ -373,14 +375,14 @@ static void exportTrophyZip(const save_entry_t *trop, int dev)

tmp = strdup(trp_path);
*strrchr(tmp, '/') = 0;
zip_directory(tmp, trop->path, export_file);
ret = zip_directory(tmp, trop->path, export_file);

snprintf(trp_path, sizeof(trp_path), TROPHY_PATH_HDD "conf/%s/", apollo_config.user_id, trop->title_id);
zip_append_directory(tmp, trp_path, export_file);
ret &= zip_append_directory(tmp, trp_path, export_file);

trp_path[1] = 'x';
sprintf(tmp, "%.12s", trp_path);
zip_append_directory(tmp, trp_path, export_file);
ret &= zip_append_directory(tmp, trp_path, export_file);

sprintf(export_file, "%s%s", exp_path, OWNER_XML_FILE);
save_xml_owner(export_file);
Expand All @@ -389,6 +391,12 @@ static void exportTrophyZip(const save_entry_t *trop, int dev)
free(tmp);

stop_loading_screen();
if (!ret)
{
show_message("Failed to export Trophy Set %s", trop->title_id);
return;
}

show_message("Trophy Set successfully exported to:\n%strophy_%s.zip", exp_path, trop->title_id);
}

Expand Down
2 changes: 1 addition & 1 deletion source/menu_about.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void Draw_AboutMenu_Ani(void)
static void _draw_LeonLuna(void)
{
DrawTextureCenteredY(&menu_textures[leon_luna_jpg_index], 0, SCREEN_HEIGHT/2, 0, menu_textures[leon_luna_jpg_index].width, menu_textures[leon_luna_jpg_index].height, 0xFFFFFF00 | 0xFF);
DrawTexture(&menu_textures[help_png_index], 0, 420, 0, SCREEN_WIDTH + 10, 40, 0xFFFFFF00 | 0xFF);
DrawTexture(&menu_textures[help_png_index], 0, 420, 0, SCREEN_WIDTH + 20, 50, 0xFFFFFF00 | 0xFF);

SetFontColor(APP_FONT_MENU_COLOR | 0xFF, 0);
draw_sinetext(430, "... in memory of Leon & Luna - may your days be filled with eternal joy ...");
Expand Down
5 changes: 4 additions & 1 deletion source/saves.c
Original file line number Diff line number Diff line change
Expand Up @@ -799,11 +799,13 @@ list_t * ReadBackupList(const char* userPath)

item = _createSaveEntry(SAVE_FLAG_ZIP, CHAR_ICON_ZIP " Extract Archives (RAR, Zip, 7z)");
item->path = strdup("ux0:data/");
item->title_id = strdup(item->path);
item->type = FILE_TYPE_ZIP;
list_append(list, item);

item = _createSaveEntry(SAVE_FLAG_PSV, CHAR_ICON_COPY " Export NoNpDRM Licenses to zRIF");
item->path = strdup(PSV_LICENSE_PATH);
item->title_id = strdup(item->path);
item->type = FILE_TYPE_RIF;
list_append(list, item);

Expand All @@ -813,7 +815,8 @@ list_t * ReadBackupList(const char* userPath)
list_append(list, item);

item = _createSaveEntry(SAVE_FLAG_PSP, CHAR_ICON_COPY " Manage PSP Save-game Key Dumper plugin");
item->path = strdup(UX0_PATH);
asprintf(&item->path, PSP_EMULATOR_PATH, "ux0");
item->title_id = strdup(item->path);
item->type = FILE_TYPE_PRX;
list_append(list, item);

Expand Down
2 changes: 1 addition & 1 deletion source/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ int save_xml_owner(const char *xmlfile)
snprintf(buff, sizeof(buff), "%016llX %016llX", apollo_config.idps[0], apollo_config.idps[1]);
xmlNewProp(node1, BAD_CAST "idps", BAD_CAST buff);

snprintf(buff, sizeof(buff), "%016X %016X", 0, 0);
snprintf(buff, sizeof(buff), "%016llX %016llX", apollo_config.psid[0], apollo_config.psid[1]);
xmlNewProp(node1, BAD_CAST "psid", BAD_CAST buff);

node1 = xmlNewChild(node, NULL, BAD_CAST "user", NULL);
Expand Down
Loading

0 comments on commit 64b3c0f

Please sign in to comment.