From 999bae804480825d2c5c74233fc7c09a41d8e675 Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 27 Oct 2008 19:09:54 +0000 Subject: [PATCH] fix broken implicit-unwrapping of pz files --- panda/src/express/virtualFileSimple.cxx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/panda/src/express/virtualFileSimple.cxx b/panda/src/express/virtualFileSimple.cxx index f5f8a20dcc..82c2ebb8b9 100644 --- a/panda/src/express/virtualFileSimple.cxx +++ b/panda/src/express/virtualFileSimple.cxx @@ -94,15 +94,25 @@ is_regular_file() const { //////////////////////////////////////////////////////////////////// istream *VirtualFileSimple:: open_read_file(bool auto_unwrap) const { - istream *result = _mount->open_read_file(_local_filename); + + // Will we be automatically unwrapping a .pz file? + bool do_unwrap = (_implicit_pz_file || (auto_unwrap && _local_filename.get_extension() == "pz")); + + Filename local_filename(_local_filename); + if (do_unwrap) { + // .pz files are always binary, of course. + local_filename.set_binary(); + } + + istream *result = _mount->open_read_file(local_filename); #ifdef HAVE_ZLIB - if (result != (istream *)NULL && - (_implicit_pz_file || (auto_unwrap && _local_filename.get_extension() == "pz"))) { + if (result != (istream *)NULL && do_unwrap) { // We have to slip in a layer to decompress the file on the fly. IDecompressStream *wrapper = new IDecompressStream(result, true); result = wrapper; } #endif // HAVE_ZLIB + return result; }