mirror of
https://github.com/mmozeiko/pkg2zip.git
synced 2026-09-03 03:29:59 +03:00
no need to create temporary zip anymore, name is known at beginning
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user