From 89eb8c6e9d38aca3c70e5accc115cd952649f87f Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Wed, 3 Mar 2021 19:18:14 -0500
Subject: [PATCH] Linux build fix

---
 indra/llcommon/llfile.cpp           | 31 +++++++++++++++++++++++++++++
 indra/llcommon/llfile.h             |  2 ++
 indra/llfilesystem/llfilesystem.cpp |  4 ----
 3 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp
index ff25f1fde5e..3711f520bf6 100644
--- a/indra/llcommon/llfile.cpp
+++ b/indra/llcommon/llfile.cpp
@@ -454,6 +454,37 @@ bool LLFile::copy(const std::string& from, const std::string& to)
 	return copied;
 }
 
+bool LLFile::copy(const boost::filesystem::path& from, const boost::filesystem::path& to)
+{
+	bool copied = false;
+	LLFILE* in = LLFile::fopen(from, TEXT("rb"));		/* Flawfinder: ignore */
+	if (in)
+	{
+		LLFILE* out = LLFile::fopen(to, TEXT("wb"));		/* Flawfinder: ignore */
+		if (out)
+		{
+			char buf[16384];		/* Flawfinder: ignore */
+			size_t readbytes;
+			bool write_ok = true;
+			while (write_ok && (readbytes = fread(buf, 1, 16384, in))) /* Flawfinder: ignore */
+			{
+				if (fwrite(buf, 1, readbytes, out) != readbytes)
+				{
+					LL_WARNS("LLFile") << "Short write" << LL_ENDL;
+					write_ok = false;
+				}
+			}
+			if (write_ok)
+			{
+				copied = true;
+			}
+			fclose(out);
+		}
+		fclose(in);
+	}
+	return copied;
+}
+
 int	LLFile::stat(const std::string& filename, llstat* filestatus)
 {
 #if LL_WINDOWS
diff --git a/indra/llcommon/llfile.h b/indra/llcommon/llfile.h
index 7bc56247314..7c24cbf1c2f 100644
--- a/indra/llcommon/llfile.h
+++ b/indra/llcommon/llfile.h
@@ -64,6 +64,7 @@ typedef struct stat		llstat;
 #define MODE_T const wchar_t*
 #else
 #define MODE_T const char*
+#define TEXT(quote)
 #endif
 
 class LL_COMMON_API LLFile
@@ -87,6 +88,7 @@ class LL_COMMON_API LLFile
 	static	int		rename(const std::string& filename,const std::string& newname, int supress_error = 0);
 	static	int		rename(const boost::filesystem::path& filename, const boost::filesystem::path& newname, int supress_error = 0);
 	static  bool	copy(const std::string& from, const std::string& to);
+	static  bool	copy(const boost::filesystem::path& from, const boost::filesystem::path& to);
 
 	static	int		stat(const std::string&	filename, llstat* file_status);
 	static	int		stat(const boost::filesystem::path& filename, llstat* file_status);
diff --git a/indra/llfilesystem/llfilesystem.cpp b/indra/llfilesystem/llfilesystem.cpp
index 4bc3785a0dd..039e7b2d8fc 100644
--- a/indra/llfilesystem/llfilesystem.cpp
+++ b/indra/llfilesystem/llfilesystem.cpp
@@ -36,10 +36,6 @@
 
 #include <boost/filesystem.hpp>
 
-#ifndef TEXT
-#define TEXT(quote)
-#endif
-
 LLFileSystem::LLFileSystem(const LLUUID& file_id, const LLAssetType::EType file_type, S32 mode)
 	: mFileID(file_id), 
     mFileType(file_type),
-- 
GitLab