From c97dd9c311234f3635ce8578d6fd38a6749a0bcc Mon Sep 17 00:00:00 2001 From: Martins Mozeiko Date: Sun, 24 Sep 2017 15:47:00 -0700 Subject: [PATCH] no need to create temporary zip anymore, name is known at beginning --- pkg2zip.c | 30 +++++++++++------------------- pkg2zip_sys.c | 21 --------------------- pkg2zip_sys.h | 2 -- 3 files changed, 11 insertions(+), 42 deletions(-) diff --git a/pkg2zip.c b/pkg2zip.c index 0245080..d2f5b1e 100644 --- a/pkg2zip.c +++ b/pkg2zip.c @@ -249,9 +249,15 @@ int main(int argc, char* argv[]) const char* id2 = id + 13; char path[1024]; - snprintf(path, sizeof(path), ".~%.*s.zip", 9, id); - - printf("[*] creating temporary '%s' archive\n", path); + if (dlc) + { + snprintf(path, sizeof(path), "%s [%.9s] [%s] [DLC].zip", title, id, get_region(id)); + } + else + { + snprintf(path, sizeof(path), "%s [%.9s] [%s].zip", title, id, get_region(id)); + } + printf("[*] creating '%s' archive\n", path); zip z; zip_create(&z, path); @@ -405,7 +411,6 @@ int main(int argc, char* argv[]) zip_end_file(&z); } - printf("[*] creating work.bin\n"); if (dlc) { zip_add_folder(&z, "license/"); @@ -417,10 +422,12 @@ int main(int argc, char* argv[]) snprintf(path, sizeof(path), "license/addcont/%.9s/%s/", id, id2); zip_add_folder(&z, path); + printf("[*] creating DLC rif file\n"); snprintf(path, sizeof(path), "license/addcont/%.9s/%s/6488b73b912a753a492e2714e9b38bc7.rif", id, id2); } else { + printf("[*] creating work.bin\n"); snprintf(path, sizeof(path), "app/%.9s/sce_sys/package/work.bin", id); } @@ -440,20 +447,5 @@ int main(int argc, char* argv[]) zip_close(&z); - snprintf(path, sizeof(path), ".~%.*s.zip", 9, id); - - char target[1024]; - if (dlc) - { - snprintf(target, sizeof(target), "%s [%.9s] [%s] [DLC].zip", title, id, get_region(id)); - } - else - { - snprintf(target, sizeof(target), "%s [%.9s] [%s].zip", title, id, get_region(id)); - } - - printf("[*] renaming to '%s'\n", target); - sys_rename(path, target); - printf("[*] done!\n"); } diff --git a/pkg2zip_sys.c b/pkg2zip_sys.c index 46a16bf..0ee12ba 100644 --- a/pkg2zip_sys.c +++ b/pkg2zip_sys.c @@ -75,19 +75,6 @@ void sys_write(sys_file file, uint64_t offset, const void* buffer, uint32_t size } } -void sys_rename(const char* src, const char* dst) -{ - WCHAR wsrc[MAX_PATH]; - WCHAR wdst[MAX_PATH]; - MultiByteToWideChar(CP_UTF8, 0, src, -1, wsrc, MAX_PATH); - MultiByteToWideChar(CP_UTF8, 0, dst, -1, wdst, MAX_PATH); - - if (!MoveFileExW(wsrc, wdst, MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING)) - { - fatal("ERROR: failed to rename '%s' to '%s'\n", src, dst); - } -} - #else #define _FILE_OFFSET_BITS 64 @@ -151,12 +138,4 @@ void sys_write(sys_file file, uint64_t offset, const void* buffer, uint32_t size } } -void sys_rename(const char* src, const char* dst) -{ - if (rename(src, dst) != 0) - { - fatal("ERROR: failed to rename '%s' to '%s'\n", src, dst); - } -} - #endif diff --git a/pkg2zip_sys.h b/pkg2zip_sys.h index 1579b07..2be4a8c 100644 --- a/pkg2zip_sys.h +++ b/pkg2zip_sys.h @@ -10,5 +10,3 @@ sys_file sys_create(const char* fname); void sys_close(sys_file file); void sys_read(sys_file file, uint64_t offset, void* buffer, uint32_t size); void sys_write(sys_file file, uint64_t offset, const void* buffer, uint32_t size); - -void sys_rename(const char* src, const char* dst);