Prechádzať zdrojové kódy

Also accept a .gz wherever a .pz file is accepted

rdb 9 rokov pred
rodič
commit
dc09e28ed9

+ 1 - 1
direct/src/directscripts/eggcacher.py

@@ -55,7 +55,7 @@ class EggCacher:
             size = os.path.getsize(path)
             size = os.path.getsize(path)
             eggs.append((path,size))
             eggs.append((path,size))
             return
             return
-        if (path.endswith(".egg.pz")):
+        if (path.endswith(".egg.pz") or path.endswith(".egg.gz")):
             size = os.path.getsize(path)
             size = os.path.getsize(path)
             if (self.pzkeep): eggs.append((path,size))
             if (self.pzkeep): eggs.append((path,size))
             else: eggs.append((path[:-3],size))
             else: eggs.append((path[:-3],size))

+ 1 - 1
direct/src/directscripts/packpanda.py

@@ -274,7 +274,7 @@ def CompileFiles(file):
     if (os.path.isfile(file)):
     if (os.path.isfile(file)):
         if (file.endswith(".egg")):
         if (file.endswith(".egg")):
             egg2bam(file, file[:-4]+'.bam')
             egg2bam(file, file[:-4]+'.bam')
-        elif (file.endswith(".egg.pz")):
+        elif (file.endswith(".egg.pz") or file.endswith(".egg.gz")):
             egg2bam(file, file[:-7]+'.bam')
             egg2bam(file, file[:-7]+'.bam')
         elif (file.endswith(".py")):
         elif (file.endswith(".py")):
             py2pyc(file)
             py2pyc(file)

+ 2 - 2
direct/src/p3d/Packager.py

@@ -61,7 +61,7 @@ class Packager:
                 self.newName = str(self.filename)
                 self.newName = str(self.filename)
 
 
             ext = Filename(self.newName).getExtension()
             ext = Filename(self.newName).getExtension()
-            if ext == 'pz':
+            if ext == 'pz' or ext == 'gz':
                 # Strip off a .pz extension; we can compress files
                 # Strip off a .pz extension; we can compress files
                 # within the Multifile without it.
                 # within the Multifile without it.
                 filename = Filename(self.newName)
                 filename = Filename(self.newName)
@@ -3772,7 +3772,7 @@ class Packager:
             self.currentPackage.addFile(filename, newName = newName,
             self.currentPackage.addFile(filename, newName = newName,
                                         explicit = False, unprocessed = unprocessed)
                                         explicit = False, unprocessed = unprocessed)
         else:
         else:
-            if ext == 'pz':
+            if ext == 'pz' or ext == 'gz':
                 # Strip off an implicit .pz extension.
                 # Strip off an implicit .pz extension.
                 newFilename = Filename(filename)
                 newFilename = Filename(filename)
                 newFilename.setExtension('')
                 newFilename.setExtension('')

+ 1 - 1
direct/src/p3d/PatchMaker.py

@@ -137,7 +137,7 @@ class PatchMaker:
 
 
             startFile, startPv, plan = self.getRecreateFilePlan()
             startFile, startPv, plan = self.getRecreateFilePlan()
 
 
-            if startFile.getExtension() == 'pz':
+            if startFile.getExtension() in ('pz', 'gz'):
                 # If the starting file is compressed, we have to
                 # If the starting file is compressed, we have to
                 # decompress it first.
                 # decompress it first.
                 assert startPv.tempFile is None
                 assert startPv.tempFile is None

+ 3 - 2
direct/src/plugin/p3dPackage.cxx

@@ -998,7 +998,8 @@ build_install_plans(TiXmlDocument *doc) {
           FileSpec new_file = patchfile->_file;
           FileSpec new_file = patchfile->_file;
           string new_filename = new_file.get_filename();
           string new_filename = new_file.get_filename();
           size_t dot = new_filename.rfind('.');
           size_t dot = new_filename.rfind('.');
-          assert(new_filename.substr(dot) == ".pz");
+          string extension = new_filename.substr(dot);
+          assert(extension == ".pz" || extension == ".gz");
           new_filename = new_filename.substr(0, dot);
           new_filename = new_filename.substr(0, dot);
           new_file.set_filename(new_filename);
           new_file.set_filename(new_filename);
           step = new InstallStepUncompressFile
           step = new InstallStepUncompressFile
@@ -1834,7 +1835,7 @@ thread_step() {
   z.next_in = (Bytef *)decompress_buffer;
   z.next_in = (Bytef *)decompress_buffer;
   z.avail_in = (size_t)read_count;
   z.avail_in = (size_t)read_count;
 
 
-  int result = inflateInit(&z);
+  int result = inflateInit2(&z, 32 + 15);
   if (result < 0) {
   if (result < 0) {
     nout << z.msg << "\n";
     nout << z.msg << "\n";
     return IT_step_failed;
     return IT_step_failed;

+ 2 - 2
dtool/src/parser-inc/zlib.h

@@ -21,8 +21,8 @@
 
 
 #include "zconf.h"
 #include "zconf.h"
 
 
-class z_stream {
-};
+typedef struct z_stream_s z_stream;
+typedef struct gz_header_s gz_header;
 
 
 #endif
 #endif
 
 

+ 1 - 1
panda/src/audiotraits/milesAudioManager.cxx

@@ -893,7 +893,7 @@ load(const Filename &file_name) {
   sd->_basename = file_name.get_basename();
   sd->_basename = file_name.get_basename();
 
 
   string extension = sd->_basename.get_extension();
   string extension = sd->_basename.get_extension();
-  if (extension == "pz") {
+  if (extension == "pz" || extension == "gz") {
     extension = Filename(sd->_basename.get_basename_wo_extension()).get_extension();
     extension = Filename(sd->_basename.get_basename_wo_extension()).get_extension();
   }
   }
 
 

+ 1 - 1
panda/src/collada/loaderFileTypeDae.cxx

@@ -56,7 +56,7 @@ get_additional_extensions() const {
 
 
 /**
 /**
  * Returns true if this file type can transparently load compressed files
  * Returns true if this file type can transparently load compressed files
- * (with a .pz extension), false otherwise.
+ * (with a .pz or .gz extension), false otherwise.
  */
  */
 bool LoaderFileTypeDae::
 bool LoaderFileTypeDae::
 supports_compressed() const {
 supports_compressed() const {

+ 1 - 1
panda/src/downloader/decompressor.cxx

@@ -55,7 +55,7 @@ Decompressor::
 int Decompressor::
 int Decompressor::
 initiate(const Filename &source_file) {
 initiate(const Filename &source_file) {
   string extension = source_file.get_extension();
   string extension = source_file.get_extension();
-  if (extension == "pz") {
+  if (extension == "pz" || extension == "gz") {
     Filename dest_file = source_file;
     Filename dest_file = source_file;
     dest_file = source_file.get_fullpath_wo_extension();
     dest_file = source_file.get_fullpath_wo_extension();
     return initiate(source_file, dest_file);
     return initiate(source_file, dest_file);

+ 1 - 1
panda/src/egg2pg/loaderFileTypeEgg.cxx

@@ -44,7 +44,7 @@ get_extension() const {
 
 
 /**
 /**
  * Returns true if this file type can transparently load compressed files
  * Returns true if this file type can transparently load compressed files
- * (with a .pz extension), false otherwise.
+ * (with a .pz or .gz extension), false otherwise.
  */
  */
 bool LoaderFileTypeEgg::
 bool LoaderFileTypeEgg::
 supports_compressed() const {
 supports_compressed() const {

+ 7 - 3
panda/src/express/virtualFileSimple.cxx

@@ -186,7 +186,7 @@ copy_file(VirtualFile *new_file) {
  * (which you should eventually delete when you are done reading). Returns
  * (which you should eventually delete when you are done reading). Returns
  * NULL on failure.
  * NULL on failure.
  *
  *
- * If auto_unwrap is true, an explicitly-named .pz file is automatically
+ * If auto_unwrap is true, an explicitly-named .pz/.gz file is automatically
  * decompressed and the decompressed contents are returned.  This is different
  * decompressed and the decompressed contents are returned.  This is different
  * than vfs-implicit-pz, which will automatically decompress a file if the
  * than vfs-implicit-pz, which will automatically decompress a file if the
  * extension .pz is *not* given.
  * extension .pz is *not* given.
@@ -195,7 +195,9 @@ istream *VirtualFileSimple::
 open_read_file(bool auto_unwrap) const {
 open_read_file(bool auto_unwrap) const {
 
 
   // Will we be automatically unwrapping a .pz file?
   // Will we be automatically unwrapping a .pz file?
-  bool do_uncompress = (_implicit_pz_file || (auto_unwrap && _local_filename.get_extension() == "pz"));
+  bool do_uncompress = (_implicit_pz_file ||
+    (auto_unwrap && (_local_filename.get_extension() == "pz" ||
+                     _local_filename.get_extension() == "gz")));
 
 
   Filename local_filename(_local_filename);
   Filename local_filename(_local_filename);
   if (do_uncompress) {
   if (do_uncompress) {
@@ -364,7 +366,9 @@ bool VirtualFileSimple::
 read_file(pvector<unsigned char> &result, bool auto_unwrap) const {
 read_file(pvector<unsigned char> &result, bool auto_unwrap) const {
 
 
   // Will we be automatically unwrapping a .pz file?
   // Will we be automatically unwrapping a .pz file?
-  bool do_uncompress = (_implicit_pz_file || (auto_unwrap && _local_filename.get_extension() == "pz"));
+  bool do_uncompress = (_implicit_pz_file ||
+    (auto_unwrap && (_local_filename.get_extension() == "pz" ||
+                     _local_filename.get_extension() == "gz")));
 
 
   Filename local_filename(_local_filename);
   Filename local_filename(_local_filename);
   if (do_uncompress) {
   if (do_uncompress) {

+ 3 - 3
panda/src/express/virtualFileSystem.I

@@ -88,7 +88,7 @@ ls_all(const Filename &filename) const {
  * Convenience function; returns the entire contents of the indicated file as
  * Convenience function; returns the entire contents of the indicated file as
  * a string.
  * a string.
  *
  *
- * If auto_unwrap is true, an explicitly-named .pz file is automatically
+ * If auto_unwrap is true, an explicitly-named .pz/.gz file is automatically
  * decompressed and the decompressed contents are returned.  This is different
  * decompressed and the decompressed contents are returned.  This is different
  * than vfs-implicit-pz, which will automatically decompress a file if the
  * than vfs-implicit-pz, which will automatically decompress a file if the
  * extension .pz is *not* given.
  * extension .pz is *not* given.
@@ -118,7 +118,7 @@ write_file(const Filename &filename, const string &data, bool auto_wrap) {
  * file, if it exists and can be read.  Returns true on success, false
  * file, if it exists and can be read.  Returns true on success, false
  * otherwise.
  * otherwise.
  *
  *
- * If auto_unwrap is true, an explicitly-named .pz file is automatically
+ * If auto_unwrap is true, an explicitly-named .pz/.gz file is automatically
  * decompressed and the decompressed contents are returned.  This is different
  * decompressed and the decompressed contents are returned.  This is different
  * than vfs-implicit-pz, which will automatically decompress a file if the
  * than vfs-implicit-pz, which will automatically decompress a file if the
  * extension .pz is *not* given.
  * extension .pz is *not* given.
@@ -134,7 +134,7 @@ read_file(const Filename &filename, string &result, bool auto_unwrap) const {
  * file, if it exists and can be read.  Returns true on success, false
  * file, if it exists and can be read.  Returns true on success, false
  * otherwise.
  * otherwise.
  *
  *
- * If auto_unwrap is true, an explicitly-named .pz file is automatically
+ * If auto_unwrap is true, an explicitly-named .pz/.gz file is automatically
  * decompressed and the decompressed contents are returned.  This is different
  * decompressed and the decompressed contents are returned.  This is different
  * than vfs-implicit-pz, which will automatically decompress a file if the
  * than vfs-implicit-pz, which will automatically decompress a file if the
  * extension .pz is *not* given.
  * extension .pz is *not* given.

+ 2 - 2
panda/src/express/zStreamBuf.cxx

@@ -87,9 +87,9 @@ open_read(istream *source, bool owns_source) {
   _z_source.opaque = Z_NULL;
   _z_source.opaque = Z_NULL;
   _z_source.msg = (char *)"no error message";
   _z_source.msg = (char *)"no error message";
 
 
-  int result = inflateInit(&_z_source);
+  int result = inflateInit2(&_z_source, 32 + 15);
   if (result < 0) {
   if (result < 0) {
-    show_zlib_error("inflateInit", result, _z_source);
+    show_zlib_error("inflateInit2", result, _z_source);
     close_read();
     close_read();
   }
   }
   thread_consider_yield();
   thread_consider_yield();

+ 1 - 1
panda/src/framework/windowFramework.cxx

@@ -591,7 +591,7 @@ load_model(const NodePath &parent, Filename filename) {
   bool is_image = false;
   bool is_image = false;
   string extension = filename.get_extension();
   string extension = filename.get_extension();
 #ifdef HAVE_ZLIB
 #ifdef HAVE_ZLIB
-  if (extension == "pz") {
+  if (extension == "pz" || extension == "gz") {
     extension = Filename(filename.get_basename_wo_extension()).get_extension();
     extension = Filename(filename.get_basename_wo_extension()).get_extension();
   }
   }
 #endif  // HAVE_ZLIB
 #endif  // HAVE_ZLIB

+ 2 - 2
panda/src/gobj/texture.I

@@ -2325,7 +2325,7 @@ INLINE bool Texture::
 is_txo_filename(const Filename &fullpath) {
 is_txo_filename(const Filename &fullpath) {
   string extension = fullpath.get_extension();
   string extension = fullpath.get_extension();
 #ifdef HAVE_ZLIB
 #ifdef HAVE_ZLIB
-  if (extension == "pz") {
+  if (extension == "pz" || extension == "gz") {
     extension = Filename(fullpath.get_basename_wo_extension()).get_extension();
     extension = Filename(fullpath.get_basename_wo_extension()).get_extension();
   }
   }
 #endif  // HAVE_ZLIB
 #endif  // HAVE_ZLIB
@@ -2340,7 +2340,7 @@ INLINE bool Texture::
 is_dds_filename(const Filename &fullpath) {
 is_dds_filename(const Filename &fullpath) {
   string extension = fullpath.get_extension();
   string extension = fullpath.get_extension();
 #ifdef HAVE_ZLIB
 #ifdef HAVE_ZLIB
-  if (extension == "pz") {
+  if (extension == "pz" || extension == "gz") {
     extension = Filename(fullpath.get_basename_wo_extension()).get_extension();
     extension = Filename(fullpath.get_basename_wo_extension()).get_extension();
   }
   }
 #endif  // HAVE_ZLIB
 #endif  // HAVE_ZLIB

+ 8 - 8
panda/src/pgraph/loader.cxx

@@ -140,10 +140,10 @@ load_file(const Filename &filename, const LoaderOptions &options) const {
     extension = this_filename.get_extension();
     extension = this_filename.get_extension();
   }
   }
 
 
-  bool pz_file = false;
+  bool compressed = false;
 #ifdef HAVE_ZLIB
 #ifdef HAVE_ZLIB
-  if (extension == "pz") {
-    pz_file = true;
+  if (extension == "pz" || extension == "gz") {
+    compressed = true;
     extension = Filename(this_filename.get_basename_wo_extension()).get_extension();
     extension = Filename(this_filename.get_basename_wo_extension()).get_extension();
   }
   }
 #endif  // HAVE_ZLIB
 #endif  // HAVE_ZLIB
@@ -182,7 +182,7 @@ load_file(const Filename &filename, const LoaderOptions &options) const {
         << extension << ") does not support loading.\n";
         << extension << ") does not support loading.\n";
     }
     }
     return NULL;
     return NULL;
-  } else if (pz_file && !requested_type->supports_compressed()) {
+  } else if (compressed && !requested_type->supports_compressed()) {
     if (report_errors) {
     if (report_errors) {
       loader_cat.error()
       loader_cat.error()
         << requested_type->get_name() << " file type (."
         << requested_type->get_name() << " file type (."
@@ -382,10 +382,10 @@ save_file(const Filename &filename, const LoaderOptions &options,
     extension = this_filename.get_extension();
     extension = this_filename.get_extension();
   }
   }
 
 
-  bool pz_file = false;
+  bool compressed = false;
 #ifdef HAVE_ZLIB
 #ifdef HAVE_ZLIB
-  if (extension == "pz") {
-    pz_file = true;
+  if (extension == "pz" || extension == "gz") {
+    compressed = true;
     extension = Filename(this_filename.get_basename_wo_extension()).get_extension();
     extension = Filename(this_filename.get_basename_wo_extension()).get_extension();
   }
   }
 #endif  // HAVE_ZLIB
 #endif  // HAVE_ZLIB
@@ -422,7 +422,7 @@ save_file(const Filename &filename, const LoaderOptions &options,
     }
     }
     return false;
     return false;
 
 
-  } else if (pz_file && !requested_type->supports_compressed()) {
+  } else if (compressed && !requested_type->supports_compressed()) {
     if (report_errors) {
     if (report_errors) {
       loader_cat.error()
       loader_cat.error()
         << requested_type->get_name() << " file type (."
         << requested_type->get_name() << " file type (."

+ 1 - 1
panda/src/pgraph/loaderFileType.cxx

@@ -48,7 +48,7 @@ get_additional_extensions() const {
 
 
 /**
 /**
  * Returns true if this file type can transparently load compressed files
  * Returns true if this file type can transparently load compressed files
- * (with a .pz extension), false otherwise.
+ * (with a .pz or .gz extension), false otherwise.
  */
  */
 bool LoaderFileType::
 bool LoaderFileType::
 supports_compressed() const {
 supports_compressed() const {

+ 1 - 1
panda/src/pgraph/loaderFileTypeBam.cxx

@@ -47,7 +47,7 @@ get_extension() const {
 
 
 /**
 /**
  * Returns true if this file type can transparently load compressed files
  * Returns true if this file type can transparently load compressed files
- * (with a .pz extension), false otherwise.
+ * (with a .pz or .gz extension), false otherwise.
  */
  */
 bool LoaderFileTypeBam::
 bool LoaderFileTypeBam::
 supports_compressed() const {
 supports_compressed() const {

+ 2 - 1
panda/src/pnmimage/pnmImageHeader.cxx

@@ -181,7 +181,8 @@ make_reader(istream *file, bool owns_file, const Filename &filename,
           << type->get_name() << ".\n";
           << type->get_name() << ".\n";
       } else {
       } else {
         pnmimage_cat.debug()
         pnmimage_cat.debug()
-          << "Unable to guess image file type from its extension.\n";
+          << "Unable to guess image file type from its extension ("
+          << filename.get_extension() << ").\n";
       }
       }
     }
     }
   }
   }

+ 1 - 1
panda/src/speedtree/loaderFileTypeSrt.cxx

@@ -42,7 +42,7 @@ get_extension() const {
 
 
 /**
 /**
  * Returns true if this file type can transparently load compressed files
  * Returns true if this file type can transparently load compressed files
- * (with a .pz extension), false otherwise.
+ * (with a .pz or .gz extension), false otherwise.
  */
  */
 bool LoaderFileTypeSrt::
 bool LoaderFileTypeSrt::
 supports_compressed() const {
 supports_compressed() const {

+ 1 - 1
panda/src/speedtree/loaderFileTypeStf.cxx

@@ -41,7 +41,7 @@ get_extension() const {
 
 
 /**
 /**
  * Returns true if this file type can transparently load compressed files
  * Returns true if this file type can transparently load compressed files
- * (with a .pz extension), false otherwise.
+ * (with a .pz or .gz extension), false otherwise.
  */
  */
 bool LoaderFileTypeStf::
 bool LoaderFileTypeStf::
 supports_compressed() const {
 supports_compressed() const {

+ 1 - 1
pandatool/src/assimp/loaderFileTypeAssimp.cxx

@@ -63,7 +63,7 @@ get_additional_extensions() const {
 
 
 /**
 /**
  * Returns true if this file type can transparently load compressed files
  * Returns true if this file type can transparently load compressed files
- * (with a .pz extension), false otherwise.
+ * (with a .pz or .gz extension), false otherwise.
  */
  */
 bool LoaderFileTypeAssimp::
 bool LoaderFileTypeAssimp::
 supports_compressed() const {
 supports_compressed() const {

+ 1 - 1
pandatool/src/ptloader/loaderFileTypePandatool.cxx

@@ -80,7 +80,7 @@ get_additional_extensions() const {
 
 
 /**
 /**
  * Returns true if this file type can transparently load compressed files
  * Returns true if this file type can transparently load compressed files
- * (with a .pz extension), false otherwise.
+ * (with a .pz or .gz extension), false otherwise.
  */
  */
 bool LoaderFileTypePandatool::
 bool LoaderFileTypePandatool::
 supports_compressed() const {
 supports_compressed() const {