Fix filename problem

Close #163
This commit is contained in:
Francesco Abbate
2021-05-01 19:27:29 +02:00
parent 857807b23a
commit 5766329313
4 changed files with 22 additions and 8 deletions
+7 -2
View File
@@ -247,6 +247,11 @@ local function split_on_slash(s, sep_pattern)
end
function common.path_belongs_to(filename, path)
return string.find(filename, path .. PATHSEP, 1, true) == 1
end
function common.relative_path(ref_dir, dir)
local ref_ls = split_on_slash(ref_dir)
local dir_ls = split_on_slash(dir)
@@ -259,9 +264,9 @@ function common.relative_path(ref_dir, dir)
end
local ups = ""
for k = i, #ref_ls do
ups = ups .. "../"
ups = ups .. ".." .. PATHSEP
end
local rel_path = ups .. table.concat(dir_ls, "/", i)
local rel_path = ups .. table.concat(dir_ls, PATHSEP, i)
return rel_path ~= "" and rel_path or "."
end