41
41
42
42
local function file_new (cwd , name )
43
43
local absolute_path = utils .path_join ({cwd , name })
44
+ local relative_path = utils .path_relative (absolute_path , luv .cwd ())
44
45
local is_exec = luv .fs_access (absolute_path , ' X' )
45
46
return {
46
47
name = name ,
47
48
absolute_path = absolute_path ,
49
+ relative_path = relative_path ,
48
50
executable = is_exec ,
49
51
extension = string.match (name , " .?[^.]+%.(.*)" ) or " " ,
50
52
match_name = path_to_matching_str (name ),
@@ -62,6 +64,8 @@ local function link_new(cwd, name)
62
64
--- I dont know if this is needed, because in my understanding, there isnt hard links in windows, but just to be sure i changed it.
63
65
local absolute_path = utils .path_join ({ cwd , name })
64
66
local link_to = luv .fs_realpath (absolute_path )
67
+ -- if links to a file outside cwd, relative_path equals absolute_path
68
+ local relative_path = utils .path_relative (link_to , luv .cwd ())
65
69
local stat = luv .fs_stat (absolute_path )
66
70
local open , entries
67
71
if (link_to ~= nil ) and luv .fs_stat (link_to ).type == ' directory' then
@@ -77,6 +81,7 @@ local function link_new(cwd, name)
77
81
return {
78
82
name = name ,
79
83
absolute_path = absolute_path ,
84
+ relative_path = relative_path ,
80
85
link_to = link_to ,
81
86
last_modified = last_modified ,
82
87
open = open ,
0 commit comments