[Change] Minor cleanup in packfile.

This commit is contained in:
Allanis 2013-05-16 15:56:57 +01:00
parent 54cd8f90a1
commit b38d4e1f74

View File

@ -7,31 +7,32 @@
#define USAGE "Usage is: %s output input/s\n", argv[0]
int main(int argc, char** argv) {
switch(argc) {
case 1:
fprintf(stderr, "Missing output file\n");
goto usage;
break;
}
char* outfile = argv[1];
char* packfile;
char** list;
uint32_t nlist;
int i;
uint32_t nfiles = (uint32_t)argc - 2;
uint32_t nfiles;
if(argc == 1) {
fprintf(stderr, "Missing output file\n");
goto usage;
}
packfile = argv[1];
nfiles = (uint32_t)argc - 2;
argv += 2;
if(nfiles == 0) {
// No files, list what it has.
fprintf(stdout, "Packfile '%s' contains:\n", outfile);
list = pack_listfiles(packfile, &nlist);
fprintf(stdout, "Packfile '%s' contains:\n", packfile);
for(i = 0; i < nlist; i++) {
fprintf(stdout, " %03d) %s\n", i, list[i]);
fprintf(stdout, " %03d %s\n", i, list[i]);
free(list[i]);
}
free(list);
} else {
pack_files(outfile, (const char**)argv, nfiles);
} else { // Create a packfile.
pack_files(packfile, (const char**)argv, nfiles);
}
exit(EXIT_SUCCESS);