mirror of
https://github.com/vlang/v.git
synced 2025-09-15 07:22:27 +03:00
os.read_file(): replace C code with V, return ?string
, handle errors
everywhere
This commit is contained in:
parent
b00a47be66
commit
8417fec5dc
3 changed files with 30 additions and 17 deletions
|
@ -762,13 +762,19 @@ fn new_v(args[]string) *V {
|
|||
// Location of all vlib files
|
||||
mut lang_dir = ''
|
||||
// First try fetching it from VROOT if it's defined
|
||||
for { // TODO tmp hack for optionals
|
||||
vroot_path := TmpPath + '/VROOT'
|
||||
if os.file_exists(vroot_path) {
|
||||
vroot := os.read_file(vroot_path).trim_space()
|
||||
mut vroot := os.read_file(vroot_path) or {
|
||||
break
|
||||
}
|
||||
vroot=vroot.trim_space()
|
||||
if os.dir_exists(vroot) && os.dir_exists(vroot + '/builtin') {
|
||||
lang_dir = vroot
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
// no "~/.vlang/VROOT" file, so the user must be running V for the first
|
||||
// time.
|
||||
if lang_dir == '' {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue