1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
This commit is contained in:
Alexander Medvednikov
2019-12-20 00:29:37 +03:00
parent b6fe2ebc0b
commit 6210984c97
54 changed files with 1757 additions and 1993 deletions

View File

@ -1,10 +1,11 @@
module filepath
import(
import (
os
)
// return the extension in the file `path`
pub fn ext(path string) string {
pos := path.last_index_byte(`.`)
if pos != -1 {
@ -17,16 +18,19 @@ pub fn ext(path string) string {
pub fn is_abs(path string) bool {
$if windows {
return path[0] == `/` || // incase we're in MingGW bash
(path[0].is_letter() && path[1] == `:`)
(path[0].is_letter() && path[1] == `:`)
}
return path[0] == `/`
}
// pass directories as parameters, returns path as string
// pass directories as parameters, returns path as string
// TODO use []string.join once ...string becomes "[]string"
pub fn join(base string, dirs ...string) string {
mut result := []string
result << base.trim_right('\\/')
for d in dirs { result << d }
return result.join( os.path_separator )
for d in dirs {
result << d
}
return result.join(os.path_separator)
}