Add `common.is_absolute_path`
This commit is contained in:
parent
13d062479a
commit
9a428648a9
|
@ -385,6 +385,11 @@ function common.normalize_path(filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function common.is_absolute_path(path)
|
||||||
|
return path:sub(1, 1) == PATHSEP or path:match("^(%a):\\")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function common.path_belongs_to(filename, path)
|
function common.path_belongs_to(filename, path)
|
||||||
return string.find(filename, path .. PATHSEP, 1, true) == 1
|
return string.find(filename, path .. PATHSEP, 1, true) == 1
|
||||||
end
|
end
|
||||||
|
|
|
@ -605,7 +605,7 @@ end
|
||||||
-- This function should get only filenames normalized using
|
-- This function should get only filenames normalized using
|
||||||
-- common.normalize_path function.
|
-- common.normalize_path function.
|
||||||
function core.project_absolute_path(filename)
|
function core.project_absolute_path(filename)
|
||||||
if filename:match('^%a:\\') or filename:find('/', 1, true) == 1 then
|
if common.is_absolute_path(filename) then
|
||||||
return common.normalize_path(filename)
|
return common.normalize_path(filename)
|
||||||
elseif not core.project_dir then
|
elseif not core.project_dir then
|
||||||
local cwd = system.absolute_path(".")
|
local cwd = system.absolute_path(".")
|
||||||
|
|
Loading…
Reference in New Issue