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

compiler: support storing temporary files under TMPDIR/v/

Fix for filepath.join not \0 terminating its result
This commit is contained in:
Delyan Angelov
2019-11-17 05:45:20 +02:00
committed by Alexander Medvednikov
parent 200fcd41ce
commit be7cf3e812
6 changed files with 92 additions and 21 deletions

View File

@ -2,7 +2,6 @@ module filepath
import(
os
strings
)
// return the extension in the file `path`
@ -26,11 +25,8 @@ pub fn is_abs(path string) bool {
// 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 path := strings.new_builder(50)
path.write(base.trim_right('\\/'))
for d in dirs {
path.write(os.path_separator)
path.write(d)
}
return path.str()
mut result := []string
result << base.trim_right('\\/')
for d in dirs { result << d }
return result.join( os.path_separator )
}