pak tool: Re-add the -f option and clean up the man page.

This commit is contained in:
Jeff Teunissen 2002-05-25 02:47:53 +00:00
parent 11a14c077e
commit a116529db1
2 changed files with 46 additions and 15 deletions

View file

@ -34,7 +34,7 @@
pak \- The QuakeForge Packfile Tool
.SH SYNOPSIS
.B pak
<\fIcommand\fP> [\fIoption\fP]... \fIARCHIVE\fP \fIFILE\fP...
<\fBcommand\fP> [\fBoptions\fP] \fIARCHIVE\fP \fIFILE\fP...
.SH DESCRIPTION
\fBpak\fP is a utility for managing pack (*.pak) archives. The format used is
compatible with Quake and Quake II. Pak archives are a convenient way to store
@ -45,7 +45,7 @@ internally.
used at a time.
.TP
.B \-c, \-\-create
Create an archive. Overwrites any contents.
Create an archive. Overwrites any contents the archive may have had.
.TP
.B \-t, \-\-test
Test an archive for valid formatting.
@ -62,18 +62,37 @@ Show the version of pak.
.SH OPTIONS
\fBpak\fP takes the following arguments as options.
.TP
.B \-f, \-\-file ARCHIVE
Use ARCHIVE as the archive filename, instead of the first non-option argument.
This option is provided for compatibility with older versions of \fBpak\fP.
.TP
.B \-p, \-\-pad
Can be useful when creating an archive. File space is padded to a 4\-byte
boundary, assisting in the speed of loading files from the archive.
boundary, assisting in the speed of loading files from the archive. The file
data itself is not changed.
.TP
.B \-q, \-\-quiet
Inhibit some of pak's normal output.
.TP
.B \-v, \-\-verbose
Display more output than usual.
.SH "SEE ALSO"
.BR quakeforge (1)
.SH "EXIT STATUS"
\fBpak\fP returns a zero exit status when it has completed a command
successfully (without error). Otherwise, it returns a non-zero exit status.
.SH BUGS
.PP
The program does not currently handle compression or decompression. This
is planned for a future version.
.PP
The program does not currently handle extraction of individual files inside an
archive. This is planned for a future version.
.PP
The program cannot modify an archive once it has been created.
.SH AUTHORS
\fBpak\fP was written by Bill Currie <taniwha@quakeforge.net> for QuakeForge.
Jeff Teunissen <deek@quakeforge.net> has also work on it, mostly in the
interface.
Bill Currie (taniwha@quakeforge.net) wrote most of the program.
.PP
Jeff Teunissen (deek@quakeforge.net) wrote the command-line interface and the
documentation.
.SH "SEE ALSO"
.BR quakeforge (1),
.BR qfcc (1)

View file

@ -32,6 +32,14 @@ static const char rcsid[] =
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <getopt.h>
#include <errno.h>
#include <string.h>
@ -61,7 +69,7 @@ static void
usage (int status)
{
printf ("%s - QuakeForge Packfile tool\n", this_program);
printf ("Usage: %s <command> [options] ARCHIVE FILE [FILE ...]\n",
printf ("Usage: %s <command> [options] ARCHIVE [FILE...]\n",
this_program);
printf ("Commands:\n"
@ -72,6 +80,7 @@ usage (int status)
" -V, --version Output version information and exit\n\n");
printf ("Options:\n"
" -f, --file ARCHIVE Use ARCHIVE for archive filename\n"
" -p, --pad Pad file space to a 32-bit boundary\n"
" -q, --quiet Inhibit usual output\n"
" -v, --verbose Display more output than usual\n");
@ -93,7 +102,7 @@ decode_args (int argc, char **argv)
"x" // extract archive contents
"h" // show help
"V" // show version
// "f:" // filename
"f:" // filename
"p" // pad
"q" // quiet
"v" // verbose
@ -115,6 +124,9 @@ decode_args (int argc, char **argv)
case 'x': // extract
options.mode = mo_extract;
break;
case 'f': // set filename
options.packfile = strdup (optarg);
break;
case 'q': // lower verbosity
options.verbosity--;
break;
@ -129,7 +141,7 @@ decode_args (int argc, char **argv)
}
}
if (argv[optind] && *(argv[optind]))
if ((!options.packfile) && argv[optind] && *(argv[optind]))
options.packfile = strdup (argv[optind++]);
return optind;
@ -146,9 +158,9 @@ main (int argc, char **argv)
decode_args (argc, argv);
if (!options.packfile) {
fprintf (stderr, "%s: no archive file specified, giving up.\n",
fprintf (stderr, "%s: no archive file specified.\n",
this_program);
return 1;
usage (1);
}
switch (options.mode) {
@ -198,9 +210,9 @@ main (int argc, char **argv)
pack_close (pack);
break;
default:
fprintf (stderr, "%s: No command given, bailing out.\n",
fprintf (stderr, "%s: No command given.\n",
this_program);
return 1;
usage (1);
}
return 0;
}