23 lines
677 B
VimL
23 lines
677 B
VimL
vim9script
|
|
|
|
import autoload "tui/util/osinfo.vim"
|
|
|
|
export def GetFileSeparator(): string
|
|
return osinfo.GetFileSeparator()
|
|
enddef
|
|
|
|
export def Normalize(path: string): string
|
|
assert_true(!empty(path) && !empty(split(path)))
|
|
|
|
const path_joined = join(filter(split(path, '[/\\]'), '!empty(split(v:val))'), GetFileSeparator())
|
|
return expand(match(path, '^[/\\]') != -1 ? (GetFileSeparator() .. path_joined) : path_joined)
|
|
enddef
|
|
|
|
export def Join(parent: string, ...subs: list<string>): string
|
|
assert_true(!empty(parent) && !empty(split(parent)))
|
|
|
|
const path_joined = join(extend([parent], subs), GetFileSeparator())
|
|
return Normalize(path_joined)
|
|
enddef
|
|
|