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:

committed by
Alexander Medvednikov

parent
200fcd41ce
commit
be7cf3e812
21
vlib/compiler/vtmp.v
Normal file
21
vlib/compiler/vtmp.v
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (c) 2019 Alexander Medvednikov. All rights reserved.
|
||||
// Use of this source code is governed by an MIT license
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
module compiler
|
||||
|
||||
import os
|
||||
import filepath
|
||||
|
||||
pub fn get_vtmp_folder() string {
|
||||
vtmp := filepath.join(os.tmpdir(),'v')
|
||||
if !os.dir_exists( vtmp ) {
|
||||
os.mkdir(vtmp)
|
||||
}
|
||||
return vtmp
|
||||
}
|
||||
|
||||
pub fn get_vtmp_filename(base_file_name string, postfix string) string {
|
||||
vtmp := get_vtmp_folder()
|
||||
return os.realpath( filepath.join(vtmp, os.filename( base_file_name ) + postfix) )
|
||||
}
|
Reference in New Issue
Block a user