path.translate now uses the target OS separator by default instead of Windows separator.
This commit is contained in:
parent
dd68adaf53
commit
f60a1b391f
@ -32,7 +32,20 @@ int path_translate(lua_State* L)
|
||||
char buffer[0x4000];
|
||||
|
||||
if (lua_gettop(L) == 1) {
|
||||
sep = "\\";
|
||||
// Get target OS
|
||||
lua_getglobal(L, "os");
|
||||
lua_getfield(L, -1, "get");
|
||||
lua_call(L, 0, 1);
|
||||
const char* os = luaL_checkstring(L, -1);
|
||||
lua_pop(L, 2);
|
||||
|
||||
// Use target OS separator
|
||||
if (strcmp(os, "windows") == 0) {
|
||||
sep = "\\";
|
||||
}
|
||||
else {
|
||||
sep = "/";
|
||||
}
|
||||
}
|
||||
else {
|
||||
sep = luaL_checkstring(L, 2);
|
||||
|
@ -389,6 +389,18 @@
|
||||
test.isequal("dir/dir/file", actual)
|
||||
end
|
||||
|
||||
function suite.translate_ReturnsTargetOSSeparator_Windows()
|
||||
_OPTIONS["os"] = "windows"
|
||||
test.isequal("dir\\dir\\file", path.translate("dir/dir\\file"))
|
||||
_OPTIONS["os"] = nil
|
||||
end
|
||||
|
||||
function suite.translate_ReturnsTargetOSSeparator_Linux()
|
||||
_OPTIONS["os"] = "linux"
|
||||
test.isequal("dir/dir/file", path.translate("dir/dir\\file"))
|
||||
_OPTIONS["os"] = nil
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- path.wildcards tests
|
||||
|
Loading…
Reference in New Issue
Block a user