From c7d7c73d280a0fe4a12ee4a89b208bf28ae9a5ab Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Wed, 30 Dec 2020 12:41:50 -0500
Subject: [PATCH] More windows UTF16 path fixes to resolve random failures

---
 indra/llcommon/llsys.cpp | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp
index edd19149f16..61922da380d 100644
--- a/indra/llcommon/llsys.cpp
+++ b/indra/llcommon/llsys.cpp
@@ -144,11 +144,18 @@ LLOSInfo::LLOSInfo() :
 
 #if LL_WINDOWS
 
-	if (IsWindowsVersionOrGreater(10, 0, 0))
+	if (IsWindows10OrGreater())
 	{
 		mMajorVer = 10;
 		mMinorVer = 0;
-		mOSStringSimple = "Microsoft Windows 10 ";
+		if (IsWindowsServer())
+		{
+			mOSStringSimple = "Windows Server ";
+		}
+		else
+		{
+			mOSStringSimple = "Microsoft Windows 10 ";
+		}
 	}
 	else if (IsWindows8Point1OrGreater())
 	{
@@ -1316,7 +1323,14 @@ 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");
+
+#if LL_WINDOWS
+	std::wstring utf16filename = ll_convert_string_to_wide(srcfile);
+	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;
@@ -1350,7 +1364,14 @@ 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 */
+
+#if LL_WINDOWS
+	std::wstring utf16filename = ll_convert_string_to_wide(tmpfile);
+	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;
-- 
GitLab