+readability, hopefully

This commit is contained in:
ep 2021-07-26 10:22:56 +07:00 committed by Francesco
parent 2df363747b
commit af22a6a824
1 changed files with 3 additions and 3 deletions

View File

@ -285,9 +285,9 @@ end
function common.relative_path(ref_dir, dir)
if #ref_dir>2 and ref_dir:sub(2,2)==':'
and #dir>2 and dir:sub(2,2)==':'
and ref_dir:sub(1,1)~=dir:sub(1,1) then
local drive_pattern = "^(%a):\\"
local drive, ref_drive = dir:match(drive_pattern), ref_dir:match(drive_pattern)
if drive and ref_drive and drive ~= ref_drive then
-- Windows, different drives, system.absolute_path fails for C:\..\D:\
return dir
end