summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-04-03 12:31:43 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-04-03 12:31:43 -0400
commite399b02e3306a249cb161f07cac578d3f2617bab (patch)
tree7cb453600a066cde4b90cec3cc2cf7dd0e62ea84 /indra/newview
parent3b25bc10febc84f10348715dabc9590458923c0b (diff)
Introduce fsyspath subclass of std::filesystem::path.
Our std::strings are UTF-8 encoded, so conversion from std::string to std::filesystem::path must use UTF-8 decoding. The native Windows std::filesystem::path constructor and assignment operator accepting std::string use "native narrow encoding," which mangles path strings containing UTF-8 encoded non-ASCII characters. fsyspath's std::string constructor and assignment operator explicitly engage std::filesystem::u8path() to handle encoding. u8path() is deprecated in C++20, but once we adapt fsyspath's conversion to C++20 conventions, consuming code need not be modified.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llluamanager.cpp8
-rw-r--r--indra/newview/llluamanager.h6
2 files changed, 7 insertions, 7 deletions
diff --git a/indra/newview/llluamanager.cpp b/indra/newview/llluamanager.cpp
index 9059db9967..82be85a153 100644
--- a/indra/newview/llluamanager.cpp
+++ b/indra/newview/llluamanager.cpp
@@ -28,6 +28,7 @@
#include "llviewerprecompiledheaders.h"
#include "llluamanager.h"
+#include "fsyspath.h"
#include "llcoros.h"
#include "llerror.h"
#include "lleventcoro.h"
@@ -37,7 +38,6 @@
#include "stringize.h"
#include <boost/algorithm/string/replace.hpp>
-#include <filesystem>
#include "luau/luacode.h"
#include "luau/lua.h"
@@ -314,7 +314,7 @@ void LLRequireResolver::resolveRequire(lua_State *L, std::string path)
}
LLRequireResolver::LLRequireResolver(lua_State *L, const std::string& path) :
- mPathToResolve(std::filesystem::path(path).lexically_normal()),
+ mPathToResolve(fsyspath(path).lexically_normal()),
L(L)
{
mSourceDir = lluau::source_path(L).parent_path();
@@ -377,12 +377,12 @@ void LLRequireResolver::findModule()
fail();
}
- std::vector<std::filesystem::path> lib_paths
+ std::vector<fsyspath> lib_paths
{
gDirUtilp->getExpandedFilename(LL_PATH_SCRIPTS, "lua"),
#ifdef LL_TEST
// Build-time tests don't have the app bundle - use source tree.
- std::filesystem::path(__FILE__).parent_path() / "scripts" / "lua",
+ fsyspath(__FILE__).parent_path() / "scripts" / "lua",
#endif
};
diff --git a/indra/newview/llluamanager.h b/indra/newview/llluamanager.h
index bd581376b4..3c00450179 100644
--- a/indra/newview/llluamanager.h
+++ b/indra/newview/llluamanager.h
@@ -27,9 +27,9 @@
#ifndef LL_LLLUAMANAGER_H
#define LL_LLLUAMANAGER_H
+#include "fsyspath.h"
#include "llcoros.h"
#include "llsd.h"
-#include <filesystem>
#include <functional>
#include <string>
#include <utility> // std::pair
@@ -89,8 +89,8 @@ class LLRequireResolver
static void resolveRequire(lua_State *L, std::string path);
private:
- std::filesystem::path mPathToResolve;
- std::filesystem::path mSourceDir;
+ fsyspath mPathToResolve;
+ fsyspath mSourceDir;
LLRequireResolver(lua_State *L, const std::string& path);