From c87ae5612ac1a974c177741c0e400bac7f4d2c45 Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Thu, 5 May 2016 11:19:27 +0200 Subject: [PATCH] Fix #2362 by using generic path strings In windows native strings in Lua incorrectly interpreted because native separators must be escaped. Use of generic strings prevent use of backslashes and "Generic paths are portable and independent of the operating system.". --- include/util/lua_util.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/util/lua_util.hpp b/include/util/lua_util.hpp index 4d4fe17be..4af7473f9 100644 --- a/include/util/lua_util.hpp +++ b/include/util/lua_util.hpp @@ -43,8 +43,7 @@ inline bool luaFunctionExists(lua_State *lua_state, const char *name) inline void luaAddScriptFolderToLoadPath(lua_State *lua_state, const char *file_name) { boost::filesystem::path profile_path = boost::filesystem::canonical(file_name); - std::string folder = profile_path.parent_path().string(); - // TODO: This code is most probably not Windows safe since it uses UNIX'ish path delimiters + std::string folder = profile_path.parent_path().generic_string(); const std::string lua_code = "package.path = \"" + folder + "/?.lua;\" .. package.path"; luaL_dostring(lua_state, lua_code.c_str()); }