From e4a639bc484e0121563e0a93ca4d5fd9a2ed683b Mon Sep 17 00:00:00 2001 From: Nicky Date: Sat, 30 Jan 2016 23:41:14 +0100 Subject: [PATCH] Widnows: Proper path handling for utf8 paths --- indra/llcommon/llsys.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp index 96dd9a6a8d..c101062f37 100755 --- a/indra/llcommon/llsys.cpp +++ b/indra/llcommon/llsys.cpp @@ -1349,7 +1349,18 @@ BOOL gunzip_file(const std::string& srcfile, const std::string& dstfile) LLFILE *dst = NULL; S32 bytes = 0; tmpfile = dstfile + ".t"; - src = gzopen(srcfile.c_str(), "rb"); + + // Proper UTF8->UTF16 handling for Windows + // src = gzopen(srcfile.c_str(), "rb"); +#if LL_WINDOWS + std::string utf8filename = srcfile; + llutf16string utf16filename = utf8str_to_utf16str(utf8filename); + src = gzopen_w(utf16filename.c_str(), "rb"); +#else + src = gzopen(srcfile.c_str(), "rb");/* Flawfinder: ignore */ +#endif + // + if (! src) goto err; dst = LLFile::fopen(tmpfile, "wb"); /* Flawfinder: ignore */ if (! dst) goto err; @@ -1383,7 +1394,18 @@ BOOL gzip_file(const std::string& srcfile, const std::string& dstfile) LLFILE *src = NULL; S32 bytes = 0; tmpfile = dstfile + ".t"; - dst = gzopen(tmpfile.c_str(), "wb"); /* Flawfinder: ignore */ + + // Proper UTF8->UTF16 handling for Windows + // dst = gzopen(tmpfile.c_str(), "wb"); /* Flawfinder: ignore */ +#if LL_WINDOWS + std::string utf8filename = tmpfile; + llutf16string utf16filename = utf8str_to_utf16str(utf8filename); + dst = gzopen_w(utf16filename.c_str(), "wb"); +#else + dst = gzopen(tmpfile.c_str(), "wb");/* Flawfinder: ignore */ +#endif + // + if (! dst) goto err; src = LLFile::fopen(srcfile, "rb"); /* Flawfinder: ignore */ if (! src) goto err;