Fix T50630: Fluid fails on win32 w/ unicode paths
authorCampbell Barton <ideasman42@gmail.com>
Tue, 30 Jan 2018 03:30:28 +0000 (14:30 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 30 Jan 2018 03:31:04 +0000 (14:31 +1100)
Allow overriding gzip open w/ elbeem.

intern/elbeem/CMakeLists.txt
intern/elbeem/intern/ntl_blenderdumper.cpp

index 30c5615f1d2c45ca725f960248b07ea19f1ea4c2..1534219a0529469562ea5633ff3f5688787755db 100644 (file)
@@ -107,6 +107,14 @@ add_definitions(
        -DNEWDIRVELMOTEST=0
 )
 
+if(WIN32)
+       # We need BLI_gzopen on win32 for unicode paths
+       add_definitions(
+               -DLBM_GZIP_OVERRIDE_H="${CMAKE_SOURCE_DIR}/source/blender/blenlib/BLI_fileops.h"
+               -D LBM_GZIP_OPEN_FN="\(gzFile\)BLI_gzopen"
+       )
+endif()
+
 if(WITH_OPENMP)
        add_definitions(-DPARALLEL=1)
 else()
index ec05c25004d70f9e374afeb65fc7ee1fef39108c..af99dc03add9b332cc8dfaf8a93bf4e0e15f73e1 100644 (file)
 
 #include <zlib.h>
 
-
+#ifdef LBM_GZIP_OVERRIDE_H
+#  include LBM_GZIP_OVERRIDE_H
+#else
+#  define LBM_GZIP_OPEN_FN(a, b) gzopen(a, b)
+#endif
 
 /******************************************************************************
  * Constructor
@@ -141,7 +145,8 @@ int ntlBlenderDumper::renderScene( void )
                                        std::ostringstream bvelfilename;
                                        bvelfilename << boutfilename.str();
                                        bvelfilename << ".bvel.gz";
-                                       gzf = gzopen(bvelfilename.str().c_str(), "wb9");
+                                       /* wraps gzopen */
+                                       gzf = LBM_GZIP_OPEN_FN(bvelfilename.str().c_str(), "wb9");
                                        if(gzf) {
                                                int numVerts;
                                                if(sizeof(numVerts)!=4) { errMsg("ntlBlenderDumper::renderScene","Invalid int size"); return 1; }
@@ -162,7 +167,8 @@ int ntlBlenderDumper::renderScene( void )
 
                                // compress all bobj's 
                                boutfilename << ".bobj.gz";
-                               gzf = gzopen(boutfilename.str().c_str(), "wb1"); // wb9 is slow for large meshes!
+                               /* wraps gzopen */
+                               gzf = LBM_GZIP_OPEN_FN(boutfilename.str().c_str(), "wb1"); // wb9 is slow for large meshes!
                                if (!gzf) {
                                        errMsg("ntlBlenderDumper::renderScene","Unable to open output '" + boutfilename.str() + "' ");
                                        return 1; }