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

compiler: fix depgraph. will also make it work with new b-tree map

This commit is contained in:
joe-conigliaro
2020-01-24 07:08:17 +11:00
committed by Alexander Medvednikov
parent 20f6cdc53a
commit 6d6b2fdda8
4 changed files with 78 additions and 51 deletions

View File

@ -1,9 +1,5 @@
module filepath
import (
os
)
// ext returns the extension in the file `path`.
pub fn ext(path string) string {
pos := path.last_index('.') or {
@ -28,15 +24,12 @@ pub fn join(base string, dirs ...string) string {
for d in dirs {
result << d
}
return result.join(os.path_separator)
return result.join(path_separator)
}
// dir returns all but the last element of path, typically the path's directory.
pub fn dir(path string) string {
if path == '.' {
return os.getwd()
}
pos := path.last_index(os.path_separator) or {
pos := path.last_index(path_separator) or {
return '.'
}
return path[..pos]
@ -44,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(os.path_separator) or {
pos := path.last_index(path_separator) or {
return path
}
// NB: *without* terminating /
@ -53,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(os.path_separator)
return path.all_after(path_separator)
}

View File

@ -0,0 +1,6 @@
module filepath
const (
path_separator = '/'
)

View File

@ -0,0 +1,6 @@
module filepath
const (
path_separator = '\\'
)