[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] #define USAGE "Usage is: %s output input/s\n", argv[0]
int main(int argc, char** argv) { int main(int argc, char** argv) {
switch(argc) { char* packfile;
case 1:
fprintf(stderr, "Missing output file\n");
goto usage;
break;
}
char* outfile = argv[1];
char** list; char** list;
uint32_t nlist; uint32_t nlist;
int i; 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; argv += 2;
if(nfiles == 0) { if(nfiles == 0) {
// No files, list what it has. // 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++) { 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[i]);
} }
free(list); free(list);
} else { } else { // Create a packfile.
pack_files(outfile, (const char**)argv, nfiles); pack_files(packfile, (const char**)argv, nfiles);
} }
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);