diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-04-02 13:25:08 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-04-02 13:25:08 -0400 |
commit | 7049485ebd0b997a097c12e094425d58db56e043 (patch) | |
tree | abe4e31d465e5ecacfa2bab2e76486ccd00a30f9 /indra/llcommon | |
parent | 1866d1a450b7857da82ceafbd2c6581d87b7f334 (diff) |
Fix std::filesystem::path - to - std::string conversions on Windows.
On Windows, std::filesystem::path::value_type is wchar_t, not char -- so
path::string_type is std::wstring, not std::string. So while Posix path
instances implicitly convert to string, Windows path instances do not. Add
explicit u8string() calls.
Also add LL.abspath() Lua entry point to further facilitate finding a resource
file relative to the calling Lua script. Use abspath() for both
test_luafloater_demo.lua and test_luafloater_gesture_list.lua.
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/lua_function.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/indra/llcommon/lua_function.cpp b/indra/llcommon/lua_function.cpp index 96282df554..cd83f40e85 100644 --- a/indra/llcommon/lua_function.cpp +++ b/indra/llcommon/lua_function.cpp @@ -711,7 +711,7 @@ std::pair<LuaFunction::Registry&, LuaFunction::Lookup&> LuaFunction::getState() lua_function(source_path, "return the source path of the running Lua script") { luaL_checkstack(L, 1, nullptr); - lua_pushstdstring(L, lluau::source_path(L)); + lua_pushstdstring(L, lluau::source_path(L).u8string()); return 1; } @@ -721,7 +721,19 @@ lua_function(source_path, "return the source path of the running Lua script") lua_function(source_dir, "return the source directory of the running Lua script") { luaL_checkstack(L, 1, nullptr); - lua_pushstdstring(L, lluau::source_path(L).parent_path()); + lua_pushstdstring(L, lluau::source_path(L).parent_path().u8string()); + return 1; +} + +/***************************************************************************** +* abspath() +*****************************************************************************/ +lua_function(abspath, + "for given filesystem path relative to running script, return absolute path") +{ + auto path{ lua_tostdstring(L, 1) }; + lua_pop(L, 1); + lua_pushstdstring(L, (lluau::source_path(L).parent_path() / path).u8string()); return 1; } |