1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

filepath: path separator (#3756)

This commit is contained in:
yuyi
2020-02-18 03:31:23 +08:00
committed by GitHub
parent 6079025985
commit 6849a4e770
26 changed files with 105 additions and 99 deletions

View File

@@ -24,12 +24,12 @@ pub fn join(base string, dirs ...string) string {
for d in dirs {
result << d
}
return result.join(path_separator)
return result.join(separator)
}
// dir returns all but the last element of path, typically the path's directory.
pub fn dir(path string) string {
pos := path.last_index(path_separator) or {
pos := path.last_index(separator) or {
return '.'
}
return path[..pos]
@@ -37,7 +37,7 @@ pub fn dir(path string) string {
// basedir returns a directory name from path
pub fn basedir(path string) string {
pos := path.last_index(path_separator) or {
pos := path.last_index(separator) or {
return path
}
// NB: *without* terminating /
@@ -46,5 +46,5 @@ pub fn basedir(path string) string {
// filename returns a file name from path
pub fn filename(path string) string {
return path.all_after(path_separator)
return path.all_after(separator)
}