Skip to content

Commit

Permalink
implement file header removal arg
Browse files Browse the repository at this point in the history
  • Loading branch information
GeffDev committed Feb 24, 2024
1 parent 44b2619 commit 4d1394b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/extract.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

FILE *data_packs[DATA_FILE_NUM] = {0};

bool remove_header = true;

i32 extractPacks() {
const u8 *file_name_base = "Pack/Data";

Expand Down Expand Up @@ -137,6 +139,12 @@ i32 extractPacks() {
strcat(full_file_path, path);
FILE *unpacked_file = fopen(full_file_path, "wb+");

// TODO: some files are under 48 bytes? which is the size of the file header?
if (remove_header && size > 0x30) {
offset += 0x30;
size -= 0x30;
}

fseek(data_packs[pack], offset, SEEK_SET);

u8 *file_buffer = malloc(size);
Expand Down
2 changes: 2 additions & 0 deletions src/extract.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ typedef struct {
// TODO: don't hardcode the number of data packs
extern FILE *data_packs[DATA_FILE_NUM];

extern bool remove_header;

i32 extractPacks();

#endif
9 changes: 8 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@

#include "extract.h"

i32 main() {
i32 main(i32 argc, u8 *argv[]) {
printLog("pennyunpacker\n");

for (i32 i = 0; i < argc; i++) {
if (strcmp(argv[i], "--rmheader") == 0) {
remove_header = true;
}
}
printLog("%d", remove_header);

extractPacks();

return 0;
Expand Down

0 comments on commit 4d1394b

Please sign in to comment.