1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/cmd/tools/vwipe-cache.v
Delyan Angelov f427a5241a
os,tools: add os.vtmp_dir()
Use it to consistently place all temporary files created by tests in a overridable folder specific to the user, that is easy to cleanup later.

NOTE: os.temp_dir() on macos returns `/tmp`, and using `/tmp/v` is a problem when multiple unix users are trying to access/create/write to it.
2022-11-03 10:19:51 +02:00

18 lines
360 B
V

module main
import os
import v.vcache
fn main() {
wipe_path(vcache.new_cache_manager([]).basepath, 'V cache')
wipe_path(os.vtmp_dir(), 'V tmp.c and tests folder')
}
fn wipe_path(cpath string, label string) {
if os.exists(cpath) && os.is_dir(cpath) {
os.rmdir_all(cpath) or {}
}
os.mkdir_all(cpath) or {}
println('$label folder $cpath was wiped.')
}