File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
autoload/vital/__vital__/System Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -197,12 +197,23 @@ function! s:is_case_tolerant() abort
197
197
endfunction
198
198
199
199
200
+ function ! s: expand_home (path ) abort
201
+ if a: path [:0 ] !=# ' ~'
202
+ return a: path
203
+ endif
204
+ let post_home_idx = match (a: path , s: path_sep_pattern )
205
+ return post_home_idx is # -1
206
+ \ ? s: remove_last_separator (expand (a: path ))
207
+ \ : s: remove_last_separator (expand (a: path [0 : post_home_idx - 1 ]))
208
+ \ . a: path [post_home_idx :]
209
+ endfunction
210
+
200
211
function ! s: abspath (path ) abort
201
212
if s: is_absolute (a: path )
202
213
return a: path
203
214
endif
204
- " Note:
205
- " the behavior of ':p' for non existing file path/directory is not defined
215
+ " NOTE: The behavior of ':p' for a non existing file/directory path
216
+ " is not defined.
206
217
return (filereadable (a: path ) || isdirectory (a: path ))
207
218
\ ? fnamemodify (a: path , ' :p' )
208
219
\ : s: join (fnamemodify (getcwd (), ' :p' ), a: path )
Original file line number Diff line number Diff line change @@ -97,6 +97,15 @@ is_case_tolerant() *Vital.System.Filepath.is_case_tolerant()*
97
97
Return non-zero if filesystem ignores alphabetic case of a filename,
98
98
zero otherwise.
99
99
100
+ expand_home({path} ) *Vital.System.Filepath.expand_home()*
101
+ Return a home-expanded path of {path} . The home directory expansion
102
+ will not have a trailing directory separator.
103
+
104
+ Like | expand() | , but only expanding a leading "~" home directory
105
+ sequence, or like | fnamemodify() | with the ":p" modifier, but without
106
+ full path expansion or unpredictable results if a file name doesn't
107
+ exist and doesn't have an absolute path. See | filename-modifiers | .
108
+
100
109
abspath({path} ) *Vital.System.Filepath.abspath()*
101
110
Return an absolute path of {path} .
102
111
If the {path} is already an absolute path, it returns the {path} .
You can’t perform that action at this time.
0 commit comments