27 <<
" pzip file [file2 file3 ...]\n"
28 <<
" pzip -c <file >dest_file\n"
29 <<
" pzip -o dest_file file\n\n"
31 <<
"This program compresses the named file(s) using the Panda native\n"
32 <<
"compression algorithm (gzip in practice, but with a different file\n"
33 <<
"header). The compressed versions are written to a file with the\n"
34 <<
"same name as the original, but the extension .pz added to the\n"
35 <<
"filename, and the original file is removed (unless the version with\n"
36 <<
"-o is used, in which case you can compress only one file, you specify\n"
37 <<
"the destination file name, and the original file is not removed).\n\n"
39 <<
"In many cases, Panda can read the resulting .pz file directly,\n"
40 <<
"exactly as if it were still in its uncompressed original form.\n"
41 <<
"In fact, unless vfs-implicit-pz is set to false in your Config.prc\n"
42 <<
"file, you can also load the file by referencing it with its original\n"
43 <<
"filename (without the .pz extension), even though it no longer exists\n"
44 <<
"under that filename, and Panda will find the .pz file and transparently\n"
45 <<
"decompress it on the fly, as if the original, uncompressed file still\n"
48 <<
"Note that if you are adding files to a Panda multifile (.mf file) with\n"
49 <<
"the multify command, it is not necessary to compress them separately;\n"
50 <<
"multify has an inline compression option.\n\n"
54 <<
" -1 compress faster\n"
55 <<
" -6 compress default\n"
56 <<
" -9 compress better (intermediate compression levels supported also)\n\n";
61 main(
int argc,
char **argv) {
64 const char *optstr =
"o:c123456789h";
67 bool got_dest_filename =
false;
68 bool use_stdout =
false;
69 int compression_level = 6;
72 int flag = getopt(argc, argv, optstr);
78 got_dest_filename =
true;
86 compression_level = 1;
90 compression_level = 2;
94 compression_level = 3;
98 compression_level = 4;
102 compression_level = 5;
106 compression_level = 6;
110 compression_level = 7;
114 compression_level = 8;
118 compression_level = 9;
127 flag = getopt(argc, argv, optstr);
135 cerr <<
"No filenames allowed in conjunction with -c.\n";
139 bool success = compress_stream(cin, cout, compression_level);
141 cerr <<
"Failure compressing standard input\n";
152 if (got_dest_filename && argc > 2) {
153 cerr <<
"Only one input file allowed in conjunction with -o.\n";
158 for (
int i = 1; i < argc; i++) {
161 cerr << source_file <<
" already ends .pz; skipping.\n";
164 if (!got_dest_filename) {
169 pifstream read_stream;
171 if (!source_file.
open_read(read_stream)) {
172 cerr <<
"Couldn't read: " << source_file << endl;
177 pofstream write_stream;
179 if (!dest_file.
open_write(write_stream,
true)) {
180 cerr <<
"Failed to open: " << dest_file << endl;
184 cerr << dest_file <<
"\n";
185 bool success = compress_stream(read_stream, write_stream, compression_level);
188 write_stream.close();
191 cerr <<
"Failure writing " << dest_file <<
"\n";
196 if (!got_dest_filename) {
The name of a file, such as a texture file or an Egg file.
bool open_read(std::ifstream &stream) const
Opens the indicated ifstream for reading the file, if possible.
bool unlink() const
Permanently deletes the file associated with the filename, if possible.
void set_binary()
Indicates that the filename represents a binary file.
std::string get_fullpath() const
Returns the entire filename: directory, basename, extension.
static Filename from_os_specific(const std::string &os_specific, Type type=T_general)
This named constructor returns a Panda-style filename (that is, using forward slashes,...
bool open_write(std::ofstream &stream, bool truncate=true) const
Opens the indicated ifstream for writing the file, if possible.
std::string get_extension() const
Returns the file extension.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void preprocess_argv(int &argc, char **&argv)
Processes the argc, argv pair as needed before passing it to getopt().
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.