Skip to content

Commit

Permalink
.psu export bugfix
Browse files Browse the repository at this point in the history
Allow for zero-byte files and disable 0xFF padding for files already 1024 aligned
  • Loading branch information
MegaBitmap committed Feb 29, 2024
1 parent 8a64cbe commit ad4b47a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ static int cmd_ecc_img(const char *output)

static int cmd_export(const char* path, const char* output)
{
int r, fd, dd;
int r, fd, dd, foundfile;
struct io_dirent dirent;
struct MCFsEntry entry;
char filepath[256];
Expand Down Expand Up @@ -244,6 +244,7 @@ static int cmd_export(const char* path, const char* output)

do {
r = mcio_mcDread(dd, &dirent);
foundfile = r;
if (r && (strcmp(dirent.name, ".")) && (strcmp(dirent.name, ".."))) {
snprintf(filepath, sizeof(filepath), "%s/%s", path, dirent.name);
printf("Adding %-48s | %8d bytes\n", filepath, dirent.stat.size);
Expand Down Expand Up @@ -283,11 +284,11 @@ static int cmd_export(const char* path, const char* output)
}
free(p);

entry.length = 1024 - (dirent.stat.size % 1024);
entry.length = (1024 - (dirent.stat.size % 1024)) % 1024;
while(entry.length--)
fputc(0xFF, fh);
}
} while (r);
} while (foundfile);

mcio_mcDclose(dd);
fclose(fh);
Expand Down

0 comments on commit ad4b47a

Please sign in to comment.