mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-17 22:50:51 +00:00
convert \ to / while extracting and accecpt file names on the command line
to control extraction.
This commit is contained in:
parent
6eef62cff8
commit
1ed772a933
3 changed files with 42 additions and 4 deletions
|
@ -52,6 +52,7 @@ typedef struct pack_s {
|
|||
|
||||
pack_t *pack_new (const char *name);
|
||||
void pack_del (pack_t *pack);
|
||||
void pack_rehash (pack_t *pack);
|
||||
pack_t *pack_open (const char *name);
|
||||
void pack_close (pack_t *pack);
|
||||
pack_t *pack_create (const char *name);
|
||||
|
|
|
@ -88,6 +88,16 @@ pack_del (pack_t *pack)
|
|||
free (pack);
|
||||
}
|
||||
|
||||
void
|
||||
pack_rehash (pack_t *pack)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < pack->numfiles; i++) {
|
||||
Hash_Add (pack->file_hash, &pack->files[i]);
|
||||
}
|
||||
}
|
||||
|
||||
pack_t *
|
||||
pack_open (const char *name)
|
||||
{
|
||||
|
|
|
@ -151,7 +151,8 @@ int
|
|||
main (int argc, char **argv)
|
||||
{
|
||||
pack_t *pack;
|
||||
int i;
|
||||
int i, j, rehash = 0;
|
||||
dpackfile_t *pf;
|
||||
|
||||
this_program = argv[0];
|
||||
|
||||
|
@ -172,9 +173,35 @@ main (int argc, char **argv)
|
|||
return 1;
|
||||
}
|
||||
for (i = 0; i < pack->numfiles; i++) {
|
||||
if (options.verbosity > 0)
|
||||
printf ("%s\n", pack->files[i].name);
|
||||
pack_extract (pack, &pack->files[i]);
|
||||
pf = &pack->files[i];
|
||||
for (j = 0; j < PAK_PATH_LENGTH; j++) {
|
||||
if (!pf->name[j])
|
||||
break;
|
||||
if (pf->name[j] == '\\') {
|
||||
pf->name[j] = '/';
|
||||
rehash = 1;
|
||||
}
|
||||
}
|
||||
if (optind == argc) {
|
||||
if (options.verbosity > 0)
|
||||
printf ("%s\n", pf->name);
|
||||
pack_extract (pack, pf);
|
||||
}
|
||||
}
|
||||
if (optind < argc) {
|
||||
if (rehash)
|
||||
pack_rehash (pack);
|
||||
while (optind < argc) {
|
||||
pf = pack_find_file (pack, argv[optind]);
|
||||
if (!pf) {
|
||||
fprintf (stderr, "could not file %s\n", argv[optind]);
|
||||
continue;
|
||||
}
|
||||
if (options.verbosity > 0)
|
||||
printf ("%s\n", pf->name);
|
||||
pack_extract (pack, pf);
|
||||
optind++;
|
||||
}
|
||||
}
|
||||
pack_close (pack);
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue