diff options
author | Sebastián Barschkis <sebbas@sebbas.org> | 2020-02-21 17:29:32 +0300 |
---|---|---|
committer | Sebastián Barschkis <sebbas@sebbas.org> | 2020-02-21 17:29:32 +0300 |
commit | b8af5e10620fe92f45c5e5003bfb6ef8d91e29bb (patch) | |
tree | e4eec6e4e63bcefc9fdca76c26196158c53a872f /extern/mantaflow/preprocessed/fileio | |
parent | ec5fc1adccb0cc7a9d10bf9e3004e9d792349294 (diff) |
Fluid: Updated manta pp files
Updates include:
- A fix from Jacques that changed the loop order in the mesh creation function (the fix speeds up the function significantly due to fewer cache misses).
- Some of the grid copy helper functions are now multithreaded.
- A fix for Windows file IO. Now it possible to load files with non ASCII characters on Windows too.
Diffstat (limited to 'extern/mantaflow/preprocessed/fileio')
-rw-r--r-- | extern/mantaflow/preprocessed/fileio/ioutil.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/extern/mantaflow/preprocessed/fileio/ioutil.cpp b/extern/mantaflow/preprocessed/fileio/ioutil.cpp index 0bbbc7b6d11..e04633c5634 100644 --- a/extern/mantaflow/preprocessed/fileio/ioutil.cpp +++ b/extern/mantaflow/preprocessed/fileio/ioutil.cpp @@ -23,21 +23,36 @@ extern "C" { # include <zlib.h> } +# if defined(WIN32) || defined(_WIN32) +# include <windows.h> +# include <string> +# endif + +using namespace std; + namespace Manta { -//! helper to handle non ascii filenames correctly, mainly problematic on windows +# if defined(WIN32) || defined(_WIN32) +static wstring stringToWstring(const char *str) +{ + const int length_wc = MultiByteToWideChar(CP_UTF8, 0, str, strlen(str), NULL, 0); + wstring strWide(length_wc, 0); + MultiByteToWideChar(CP_UTF8, 0, str, strlen(str), &strWide[0], length_wc); + return strWide; +} +# endif + void *safeGzopen(const char *filename, const char *mode) { gzFile gzfile; -# if 0 - UTF16_ENCODE(filename); - // gzopen_w() is supported since zlib v1.2.7 - gzfile = gzopen_w(filename_16, mode); - UTF16_UN_ENCODE(filename); +# if defined(WIN32) || defined(_WIN32) + wstring filenameWide = stringToWstring(filename); + gzfile = gzopen_w(filenameWide.c_str(), mode); # else gzfile = gzopen(filename, mode); # endif + return gzfile; } #endif |