mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
os: replace dir_exists with is_dir; file_exists() => exists()
This commit is contained in:
@ -587,13 +587,13 @@ pub fn (v V) run_compiled_executable_and_exit() {
|
||||
|
||||
pub fn (v &V) v_files_from_dir(dir string) []string {
|
||||
mut res := []string
|
||||
if !os.file_exists(dir) {
|
||||
if dir == 'compiler' && os.dir_exists('vlib') {
|
||||
if !os.exists(dir) {
|
||||
if dir == 'compiler' && os.is_dir('vlib') {
|
||||
println('looks like you are trying to build V with an old command')
|
||||
println('use `v -o v v.v` instead of `v -o v compiler`')
|
||||
}
|
||||
verror("$dir doesn't exist")
|
||||
} else if !os.dir_exists(dir) {
|
||||
} else if !os.is_dir(dir) {
|
||||
verror("$dir isn't a directory")
|
||||
}
|
||||
mut files := os.ls(dir) or { panic(err) }
|
||||
@ -639,7 +639,7 @@ pub fn (v mut V) add_v_files_to_compile() {
|
||||
}
|
||||
// Builtin cache exists? Use it.
|
||||
builtin_vh := '${v.pref.vlib_path}${os.path_separator}builtin.vh'
|
||||
if v.pref.is_cache && os.file_exists(builtin_vh) {
|
||||
if v.pref.is_cache && os.exists(builtin_vh) {
|
||||
v.cached_mods << 'builtin'
|
||||
builtin_files = [builtin_vh]
|
||||
}
|
||||
@ -685,7 +685,7 @@ pub fn (v mut V) add_v_files_to_compile() {
|
||||
if v.pref.vpath != '' && v.pref.build_mode != .build_module && !mod.contains('vweb') {
|
||||
mod_path := mod.replace('.', os.path_separator)
|
||||
vh_path := '$v_modules_path${os.path_separator}vlib${os.path_separator}${mod_path}.vh'
|
||||
if v.pref.is_cache && os.file_exists(vh_path) {
|
||||
if v.pref.is_cache && os.exists(vh_path) {
|
||||
eprintln('using cached module `$mod`: $vh_path')
|
||||
v.cached_mods << mod
|
||||
v.files << vh_path
|
||||
@ -850,7 +850,7 @@ pub fn (v &V) log(s string) {
|
||||
|
||||
pub fn new_v(args[]string) &V {
|
||||
// Create modules dirs if they are missing
|
||||
if !os.dir_exists(v_modules_path) {
|
||||
if !os.is_dir(v_modules_path) {
|
||||
os.mkdir(v_modules_path) or { panic(err) }
|
||||
os.mkdir('$v_modules_path${os.path_separator}cache') or { panic(err) }
|
||||
}
|
||||
@ -923,7 +923,7 @@ pub fn new_v(args[]string) &V {
|
||||
}
|
||||
is_test := dir.ends_with('_test.v')
|
||||
is_script := dir.ends_with('.v') || dir.ends_with('.vsh')
|
||||
if is_script && !os.file_exists(dir) {
|
||||
if is_script && !os.exists(dir) {
|
||||
println('`$dir` does not exist')
|
||||
exit(1)
|
||||
}
|
||||
@ -933,7 +933,7 @@ pub fn new_v(args[]string) &V {
|
||||
// Building V? Use v2, since we can't overwrite a running
|
||||
// executable on Windows + the precompiled V is more
|
||||
// optimized.
|
||||
if out_name == 'v' && os.dir_exists('vlib/compiler') {
|
||||
if out_name == 'v' && os.is_dir('vlib/compiler') {
|
||||
println('Saving the resulting V executable in `./v2`')
|
||||
println('Use `v -o v v.v` if you want to replace current '+
|
||||
'V executable.')
|
||||
@ -948,7 +948,7 @@ pub fn new_v(args[]string) &V {
|
||||
// `v -o dir/exec`, create "dir/" if it doesn't exist
|
||||
if out_name.contains(os.path_separator) {
|
||||
d := out_name.all_before_last(os.path_separator)
|
||||
if !os.dir_exists(d) {
|
||||
if !os.is_dir(d) {
|
||||
println('creating a new directory "$d"')
|
||||
os.mkdir(d) or { panic(err) }
|
||||
}
|
||||
@ -989,7 +989,7 @@ pub fn new_v(args[]string) &V {
|
||||
}
|
||||
//println('VROOT=$vroot')
|
||||
// v.exe's parent directory should contain vlib
|
||||
if !os.dir_exists(vlib_path) || !os.dir_exists(vlib_path + os.path_separator + 'builtin') {
|
||||
if !os.is_dir(vlib_path) || !os.is_dir(vlib_path + os.path_separator + 'builtin') {
|
||||
//println('vlib not found, downloading it...')
|
||||
/*
|
||||
ret := os.system('git clone --depth=1 https://github.com/vlang/v .')
|
||||
@ -1104,7 +1104,7 @@ pub fn env_vflags_and_os_args() []string {
|
||||
pub fn vfmt(args[]string) {
|
||||
println('running vfmt...')
|
||||
file := args.last()
|
||||
if !os.file_exists(file) {
|
||||
if !os.exists(file) {
|
||||
println('"$file" does not exist')
|
||||
exit(1)
|
||||
}
|
||||
|
Reference in New Issue
Block a user