os: replace dir_exists with is_dir; file_exists() => exists()
parent
fb237b9e53
commit
a57e29dfc5
|
@ -9,7 +9,7 @@ fn main() {
|
||||||
exe := os.executable()
|
exe := os.executable()
|
||||||
dir := os.dir(exe)
|
dir := os.dir(exe)
|
||||||
vdir := os.dir(os.dir(dir))
|
vdir := os.dir(os.dir(dir))
|
||||||
if !os.file_exists('$vdir/v') && !os.dir_exists('$vdir/vlib') {
|
if !os.exists('$vdir/v') && !os.is_dir('$vdir/vlib') {
|
||||||
println('fast.html generator needs to be located in `v/tools/fast/`')
|
println('fast.html generator needs to be located in `v/tools/fast/`')
|
||||||
}
|
}
|
||||||
println('fast.html generator\n')
|
println('fast.html generator\n')
|
||||||
|
@ -18,7 +18,7 @@ fn main() {
|
||||||
exec('git pull --rebase')
|
exec('git pull --rebase')
|
||||||
mut commit_hash := exec('git rev-parse HEAD')
|
mut commit_hash := exec('git rev-parse HEAD')
|
||||||
commit_hash = commit_hash[..7]
|
commit_hash = commit_hash[..7]
|
||||||
if !os.file_exists('table.html') {
|
if !os.exists('table.html') {
|
||||||
os.create('table.html') or { panic(err) }
|
os.create('table.html') or { panic(err) }
|
||||||
}
|
}
|
||||||
mut table := os.read_file('table.html') or { panic(err) }
|
mut table := os.read_file('table.html') or { panic(err) }
|
||||||
|
|
|
@ -198,11 +198,11 @@ fn (gen_vc mut GenVC) generate() {
|
||||||
gen_vc.gen_error = false
|
gen_vc.gen_error = false
|
||||||
|
|
||||||
// check if gen_vc dir exists
|
// check if gen_vc dir exists
|
||||||
if !os.dir_exists(gen_vc.options.work_dir) {
|
if !os.is_dir(gen_vc.options.work_dir) {
|
||||||
// try create
|
// try create
|
||||||
os.mkdir(gen_vc.options.work_dir) or { panic(err) }
|
os.mkdir(gen_vc.options.work_dir) or { panic(err) }
|
||||||
// still dosen't exist... we have a problem
|
// still dosen't exist... we have a problem
|
||||||
if !os.dir_exists(gen_vc.options.work_dir) {
|
if !os.is_dir(gen_vc.options.work_dir) {
|
||||||
gen_vc.logger.error('error creating directory: $gen_vc.options.work_dir')
|
gen_vc.logger.error('error creating directory: $gen_vc.options.work_dir')
|
||||||
gen_vc.gen_error = true
|
gen_vc.gen_error = true
|
||||||
return
|
return
|
||||||
|
@ -216,7 +216,7 @@ fn (gen_vc mut GenVC) generate() {
|
||||||
// rather than deleting and re-downloading the repo each time
|
// rather than deleting and re-downloading the repo each time
|
||||||
// first check to see if the local v repo is behind master
|
// first check to see if the local v repo is behind master
|
||||||
// if it isn't behind theres no point continuing further
|
// if it isn't behind theres no point continuing further
|
||||||
if !gen_vc.options.serve && os.dir_exists(git_repo_dir_v) {
|
if !gen_vc.options.serve && os.is_dir(git_repo_dir_v) {
|
||||||
gen_vc.cmd_exec('git -C $git_repo_dir_v checkout master')
|
gen_vc.cmd_exec('git -C $git_repo_dir_v checkout master')
|
||||||
// fetch the remote repo just in case there are newer commits there
|
// fetch the remote repo just in case there are newer commits there
|
||||||
gen_vc.cmd_exec('git -C $git_repo_dir_v fetch')
|
gen_vc.cmd_exec('git -C $git_repo_dir_v fetch')
|
||||||
|
@ -349,12 +349,12 @@ fn (gen_vc mut GenVC) command_execute_dry(cmd string) string {
|
||||||
fn (gen_vc mut GenVC) purge_repos() {
|
fn (gen_vc mut GenVC) purge_repos() {
|
||||||
// delete old repos (better to be fully explicit here, since these are destructive operations)
|
// delete old repos (better to be fully explicit here, since these are destructive operations)
|
||||||
mut repo_dir := '$gen_vc.options.work_dir/$git_repo_dir_v'
|
mut repo_dir := '$gen_vc.options.work_dir/$git_repo_dir_v'
|
||||||
if os.dir_exists(repo_dir) {
|
if os.is_dir(repo_dir) {
|
||||||
gen_vc.logger.info('purging local repo: "$repo_dir"')
|
gen_vc.logger.info('purging local repo: "$repo_dir"')
|
||||||
gen_vc.cmd_exec('rm -rf $repo_dir')
|
gen_vc.cmd_exec('rm -rf $repo_dir')
|
||||||
}
|
}
|
||||||
repo_dir = '$gen_vc.options.work_dir/$git_repo_dir_vc'
|
repo_dir = '$gen_vc.options.work_dir/$git_repo_dir_vc'
|
||||||
if os.dir_exists(repo_dir) {
|
if os.is_dir(repo_dir) {
|
||||||
gen_vc.logger.info('purging local repo: "$repo_dir"')
|
gen_vc.logger.info('purging local repo: "$repo_dir"')
|
||||||
gen_vc.cmd_exec('rm -rf $repo_dir')
|
gen_vc.cmd_exec('rm -rf $repo_dir')
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ fn (gen_vc mut GenVC) purge_repos() {
|
||||||
|
|
||||||
// check if file size is too short
|
// check if file size is too short
|
||||||
fn (gen_vc mut GenVC) assert_file_exists_and_is_not_too_short(f string, emsg string){
|
fn (gen_vc mut GenVC) assert_file_exists_and_is_not_too_short(f string, emsg string){
|
||||||
if !os.file_exists(f) {
|
if !os.exists(f) {
|
||||||
gen_vc.logger.error('$err_msg_build: $emsg .')
|
gen_vc.logger.error('$err_msg_build: $emsg .')
|
||||||
gen_vc.gen_error = true
|
gen_vc.gen_error = true
|
||||||
return
|
return
|
||||||
|
|
|
@ -94,7 +94,7 @@ pub fn (ts mut TestSession) test() {
|
||||||
|
|
||||||
pub fn vlib_should_be_present( parent_dir string ) {
|
pub fn vlib_should_be_present( parent_dir string ) {
|
||||||
vlib_dir := filepath.join( parent_dir, 'vlib' )
|
vlib_dir := filepath.join( parent_dir, 'vlib' )
|
||||||
if !os.dir_exists( vlib_dir ){
|
if !os.is_dir( vlib_dir ){
|
||||||
eprintln('$vlib_dir is missing, it must be next to the V executable')
|
eprintln('$vlib_dir is missing, it must be next to the V executable')
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,7 @@ fn get_vmodules_dir_path() string {
|
||||||
|
|
||||||
fn ensure_vmodules_dir_exist() {
|
fn ensure_vmodules_dir_exist() {
|
||||||
home_vmodules := get_vmodules_dir_path()
|
home_vmodules := get_vmodules_dir_path()
|
||||||
if !os.dir_exists( home_vmodules ) {
|
if !os.is_dir( home_vmodules ) {
|
||||||
println('Creating $home_vmodules/ ...')
|
println('Creating $home_vmodules/ ...')
|
||||||
os.mkdir(home_vmodules) or { panic(err) }
|
os.mkdir(home_vmodules) or { panic(err) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,7 +200,7 @@ fn print_output(s os.Result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
if os.args.len < 2 || !os.file_exists(os.args[1]) {
|
if os.args.len < 2 || !os.exists(os.args[1]) {
|
||||||
println('Usage:')
|
println('Usage:')
|
||||||
println(' vrepl vexepath\n')
|
println(' vrepl vexepath\n')
|
||||||
println(' ... where vexepath is the full path to the v executable file')
|
println(' ... where vexepath is the full path to the v executable file')
|
||||||
|
|
|
@ -26,7 +26,7 @@ fn v_test_compiler(vargs string){
|
||||||
os.chdir( parent_dir )
|
os.chdir( parent_dir )
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if !os.file_exists(parent_dir + '/v.v') {
|
if !os.exists(parent_dir + '/v.v') {
|
||||||
eprintln('v.v is missing, it must be next to the V executable')
|
eprintln('v.v is missing, it must be next to the V executable')
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ fn v_test_compiler(vargs string){
|
||||||
|
|
||||||
// Make sure v.c can be compiled without warnings
|
// Make sure v.c can be compiled without warnings
|
||||||
$if mac {
|
$if mac {
|
||||||
if os.file_exists('/v.v') {
|
if os.exists('/v.v') {
|
||||||
os.system('$vexe -o v.c v.v')
|
os.system('$vexe -o v.c v.v')
|
||||||
if os.system('cc -Werror v.c') != 0 {
|
if os.system('cc -Werror v.c') != 0 {
|
||||||
eprintln('cc failed to build v.c without warnings')
|
eprintln('cc failed to build v.c without warnings')
|
||||||
|
@ -63,7 +63,7 @@ fn v_test_compiler(vargs string){
|
||||||
if ret != 0 {
|
if ret != 0 {
|
||||||
eprintln('failed to run v install')
|
eprintln('failed to run v install')
|
||||||
}
|
}
|
||||||
if !os.file_exists(v_modules_path + '/nedpals/args') {
|
if !os.exists(v_modules_path + '/nedpals/args') {
|
||||||
eprintln('v failed to install a test module')
|
eprintln('v failed to install a test module')
|
||||||
}
|
}
|
||||||
vmark.stop()
|
vmark.stop()
|
||||||
|
|
|
@ -32,11 +32,11 @@ pub fn main() {
|
||||||
|
|
||||||
mut ts := testing.new_test_sesion(args_before)
|
mut ts := testing.new_test_sesion(args_before)
|
||||||
for targ in args_after.split(' ') {
|
for targ in args_after.split(' ') {
|
||||||
if os.file_exists(targ) && targ.ends_with('_test.v') {
|
if os.exists(targ) && targ.ends_with('_test.v') {
|
||||||
ts.files << targ
|
ts.files << targ
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if os.dir_exists(targ) {
|
if os.is_dir(targ) {
|
||||||
// Fetch all tests from the directory
|
// Fetch all tests from the directory
|
||||||
ts.files << os.walk_ext( targ.trim_right(os.path_separator), '_test.v')
|
ts.files << os.walk_ext( targ.trim_right(os.path_separator), '_test.v')
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -8,7 +8,7 @@ fn main() {
|
||||||
println(s.output)
|
println(s.output)
|
||||||
$if windows {
|
$if windows {
|
||||||
v_backup_file := '$vroot/v_old.exe'
|
v_backup_file := '$vroot/v_old.exe'
|
||||||
if os.file_exists( v_backup_file ) {
|
if os.exists( v_backup_file ) {
|
||||||
os.rm( v_backup_file )
|
os.rm( v_backup_file )
|
||||||
}
|
}
|
||||||
os.mv_by_cp('$vroot/v.exe', v_backup_file) or { panic(err) }
|
os.mv_by_cp('$vroot/v.exe', v_backup_file) or { panic(err) }
|
||||||
|
|
|
@ -8,11 +8,11 @@ fn test_syscallwrappers() {
|
||||||
vdir := os.dir(exe)
|
vdir := os.dir(exe)
|
||||||
if vdir.len > 1 {
|
if vdir.len > 1 {
|
||||||
dot_checks := vdir + "/.checks"
|
dot_checks := vdir + "/.checks"
|
||||||
assert os.dir_exists(dot_checks)
|
assert os.is_dir(dot_checks)
|
||||||
|
|
||||||
os.chdir(dot_checks)
|
os.chdir(dot_checks)
|
||||||
checks_v := "checks.v"
|
checks_v := "checks.v"
|
||||||
assert os.file_exists(checks_v)
|
assert os.exists(checks_v)
|
||||||
rc := os.exec("v run $checks_v") or { panic(err) }
|
rc := os.exec("v run $checks_v") or { panic(err) }
|
||||||
assert !rc.output.contains("V panic: An assertion failed.")
|
assert !rc.output.contains("V panic: An assertion failed.")
|
||||||
assert !rc.output.contains("failed")
|
assert !rc.output.contains("failed")
|
||||||
|
|
|
@ -38,7 +38,7 @@ fn (v mut V) cc() {
|
||||||
$if !js {
|
$if !js {
|
||||||
if v.out_name.ends_with('.js') {
|
if v.out_name.ends_with('.js') {
|
||||||
vjs_path := vexe + 'js'
|
vjs_path := vexe + 'js'
|
||||||
if !os.file_exists(vjs_path) {
|
if !os.exists(vjs_path) {
|
||||||
println('V.js compiler not found, building...')
|
println('V.js compiler not found, building...')
|
||||||
// Build V.js. Specifying `-os js` makes V include
|
// Build V.js. Specifying `-os js` makes V include
|
||||||
// only _js.v files and ignore _c.v files.
|
// only _js.v files and ignore _c.v files.
|
||||||
|
@ -98,7 +98,7 @@ fn (v mut V) cc() {
|
||||||
tcc_3rd := '$vdir/thirdparty/tcc/bin/tcc'
|
tcc_3rd := '$vdir/thirdparty/tcc/bin/tcc'
|
||||||
//println('tcc third "$tcc_3rd"')
|
//println('tcc third "$tcc_3rd"')
|
||||||
tcc_path := '/var/tmp/tcc/bin/tcc'
|
tcc_path := '/var/tmp/tcc/bin/tcc'
|
||||||
if os.file_exists(tcc_3rd) && !os.file_exists(tcc_path) {
|
if os.exists(tcc_3rd) && !os.exists(tcc_path) {
|
||||||
//println('moving tcc')
|
//println('moving tcc')
|
||||||
// if there's tcc in thirdparty/, that means this is
|
// if there's tcc in thirdparty/, that means this is
|
||||||
// a prebuilt V_linux.zip.
|
// a prebuilt V_linux.zip.
|
||||||
|
@ -106,7 +106,7 @@ fn (v mut V) cc() {
|
||||||
// it to /var/tmp/
|
// it to /var/tmp/
|
||||||
os.system('mv $vdir/thirdparty/tcc /var/tmp/')
|
os.system('mv $vdir/thirdparty/tcc /var/tmp/')
|
||||||
}
|
}
|
||||||
if v.pref.ccompiler == 'cc' && os.file_exists(tcc_path) {
|
if v.pref.ccompiler == 'cc' && os.exists(tcc_path) {
|
||||||
// TODO tcc bug, needs an empty libtcc1.a fila
|
// TODO tcc bug, needs an empty libtcc1.a fila
|
||||||
//os.mkdir('/var/tmp/tcc/lib/tcc/') or { panic(err) }
|
//os.mkdir('/var/tmp/tcc/lib/tcc/') or { panic(err) }
|
||||||
//os.create('/var/tmp/tcc/lib/tcc/libtcc1.a')
|
//os.create('/var/tmp/tcc/lib/tcc/libtcc1.a')
|
||||||
|
@ -136,7 +136,7 @@ fn (v mut V) cc() {
|
||||||
'$v_modules_path${os.path_separator}$v.dir'
|
'$v_modules_path${os.path_separator}$v.dir'
|
||||||
}
|
}
|
||||||
pdir := out_dir.all_before_last(os.path_separator)
|
pdir := out_dir.all_before_last(os.path_separator)
|
||||||
if !os.dir_exists(pdir) {
|
if !os.is_dir(pdir) {
|
||||||
os.mkdir_all(pdir)
|
os.mkdir_all(pdir)
|
||||||
}
|
}
|
||||||
v.out_name = '${out_dir}.o' //v.out_name
|
v.out_name = '${out_dir}.o' //v.out_name
|
||||||
|
@ -202,7 +202,7 @@ fn (v mut V) cc() {
|
||||||
else if v.pref.is_cache {
|
else if v.pref.is_cache {
|
||||||
builtin_o_path := filepath.join(v_modules_path, 'cache', 'vlib', 'builtin.o')
|
builtin_o_path := filepath.join(v_modules_path, 'cache', 'vlib', 'builtin.o')
|
||||||
a << builtin_o_path.replace('builtin.o', 'strconv.o') // TODO hack no idea why this is needed
|
a << builtin_o_path.replace('builtin.o', 'strconv.o') // TODO hack no idea why this is needed
|
||||||
if os.file_exists(builtin_o_path) {
|
if os.exists(builtin_o_path) {
|
||||||
libs = builtin_o_path
|
libs = builtin_o_path
|
||||||
} else {
|
} else {
|
||||||
println('$builtin_o_path not found... building module builtin')
|
println('$builtin_o_path not found... building module builtin')
|
||||||
|
@ -215,7 +215,7 @@ fn (v mut V) cc() {
|
||||||
imp_path := imp.replace('.', os.path_separator)
|
imp_path := imp.replace('.', os.path_separator)
|
||||||
path := '$v_modules_path${os.path_separator}cache${os.path_separator}vlib${os.path_separator}${imp_path}.o'
|
path := '$v_modules_path${os.path_separator}cache${os.path_separator}vlib${os.path_separator}${imp_path}.o'
|
||||||
//println('adding ${imp_path}.o')
|
//println('adding ${imp_path}.o')
|
||||||
if os.file_exists(path) {
|
if os.exists(path) {
|
||||||
libs += ' ' + path
|
libs += ' ' + path
|
||||||
} else {
|
} else {
|
||||||
println('$path not found... building module $imp')
|
println('$path not found... building module $imp')
|
||||||
|
@ -253,7 +253,7 @@ fn (v mut V) cc() {
|
||||||
//
|
//
|
||||||
// Output executable name
|
// Output executable name
|
||||||
a << '-o "$v.out_name"'
|
a << '-o "$v.out_name"'
|
||||||
if os.dir_exists(v.out_name) {
|
if os.is_dir(v.out_name) {
|
||||||
verror('\'$v.out_name\' is a directory')
|
verror('\'$v.out_name\' is a directory')
|
||||||
}
|
}
|
||||||
// macOS code can include objective C TODO remove once objective C is replaced with C
|
// macOS code can include objective C TODO remove once objective C is replaced with C
|
||||||
|
@ -426,7 +426,7 @@ fn (c mut V) cc_windows_cross() {
|
||||||
mut libs := ''
|
mut libs := ''
|
||||||
if c.pref.build_mode == .default_mode {
|
if c.pref.build_mode == .default_mode {
|
||||||
libs = '"$v_modules_path/vlib/builtin.o"'
|
libs = '"$v_modules_path/vlib/builtin.o"'
|
||||||
if !os.file_exists(libs) {
|
if !os.exists(libs) {
|
||||||
println('`$libs` not found')
|
println('`$libs` not found')
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
|
@ -442,7 +442,7 @@ fn (c mut V) cc_windows_cross() {
|
||||||
}
|
}
|
||||||
println('Cross compiling for Windows...')
|
println('Cross compiling for Windows...')
|
||||||
winroot := '$v_modules_path/winroot'
|
winroot := '$v_modules_path/winroot'
|
||||||
if !os.dir_exists(winroot) {
|
if !os.is_dir(winroot) {
|
||||||
winroot_url := 'https://github.com/vlang/v/releases/download/v0.1.10/winroot.zip'
|
winroot_url := 'https://github.com/vlang/v/releases/download/v0.1.10/winroot.zip'
|
||||||
println('"$winroot" not found.')
|
println('"$winroot" not found.')
|
||||||
println('Download it from $winroot_url and save it in $v_modules_path')
|
println('Download it from $winroot_url and save it in $v_modules_path')
|
||||||
|
@ -502,7 +502,7 @@ fn find_c_compiler() string {
|
||||||
|
|
||||||
fn find_c_compiler_default() string {
|
fn find_c_compiler_default() string {
|
||||||
//fast_clang := '/usr/local/Cellar/llvm/8.0.0/bin/clang'
|
//fast_clang := '/usr/local/Cellar/llvm/8.0.0/bin/clang'
|
||||||
//if os.file_exists(fast_clang) {
|
//if os.exists(fast_clang) {
|
||||||
// return fast_clang
|
// return fast_clang
|
||||||
//}
|
//}
|
||||||
// TODO fix $if after 'string'
|
// TODO fix $if after 'string'
|
||||||
|
|
|
@ -255,7 +255,7 @@ fn (g mut CGen) add_to_main(s string) {
|
||||||
|
|
||||||
fn build_thirdparty_obj_file(path string, moduleflags []CFlag) {
|
fn build_thirdparty_obj_file(path string, moduleflags []CFlag) {
|
||||||
obj_path := os.realpath(path)
|
obj_path := os.realpath(path)
|
||||||
if os.file_exists(obj_path) {
|
if os.exists(obj_path) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
println('$obj_path not found, building it...')
|
println('$obj_path not found, building it...')
|
||||||
|
|
|
@ -153,12 +153,12 @@ fn (p mut Parser) comp_time() {
|
||||||
if p.pref.is_debug {
|
if p.pref.is_debug {
|
||||||
println('compiling tmpl $path')
|
println('compiling tmpl $path')
|
||||||
}
|
}
|
||||||
if !os.file_exists(path) {
|
if !os.exists(path) {
|
||||||
// Can't find the template file in current directory,
|
// Can't find the template file in current directory,
|
||||||
// try looking next to the vweb program, in case it's run with
|
// try looking next to the vweb program, in case it's run with
|
||||||
// v path/to/vweb_app.v
|
// v path/to/vweb_app.v
|
||||||
path = os.dir(p.scanner.file_path) + '/' + path
|
path = os.dir(p.scanner.file_path) + '/' + path
|
||||||
if !os.file_exists(path) {
|
if !os.exists(path) {
|
||||||
p.error('vweb HTML template "$path" not found')
|
p.error('vweb HTML template "$path" not found')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,7 +191,7 @@ void reload_so() {
|
||||||
sprintf(compile_cmd, "$vexe $msvc -o %s -shared $file", new_so_base);
|
sprintf(compile_cmd, "$vexe $msvc -o %s -shared $file", new_so_base);
|
||||||
os__system(tos2(compile_cmd));
|
os__system(tos2(compile_cmd));
|
||||||
|
|
||||||
if( !os__file_exists(tos2(new_so_name)) ) {
|
if( !os__exists(tos2(new_so_name)) ) {
|
||||||
fprintf(stderr, "Errors while compiling $file\\n");
|
fprintf(stderr, "Errors while compiling $file\\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -587,13 +587,13 @@ pub fn (v V) run_compiled_executable_and_exit() {
|
||||||
|
|
||||||
pub fn (v &V) v_files_from_dir(dir string) []string {
|
pub fn (v &V) v_files_from_dir(dir string) []string {
|
||||||
mut res := []string
|
mut res := []string
|
||||||
if !os.file_exists(dir) {
|
if !os.exists(dir) {
|
||||||
if dir == 'compiler' && os.dir_exists('vlib') {
|
if dir == 'compiler' && os.is_dir('vlib') {
|
||||||
println('looks like you are trying to build V with an old command')
|
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`')
|
println('use `v -o v v.v` instead of `v -o v compiler`')
|
||||||
}
|
}
|
||||||
verror("$dir doesn't exist")
|
verror("$dir doesn't exist")
|
||||||
} else if !os.dir_exists(dir) {
|
} else if !os.is_dir(dir) {
|
||||||
verror("$dir isn't a directory")
|
verror("$dir isn't a directory")
|
||||||
}
|
}
|
||||||
mut files := os.ls(dir) or { panic(err) }
|
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 cache exists? Use it.
|
||||||
builtin_vh := '${v.pref.vlib_path}${os.path_separator}builtin.vh'
|
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'
|
v.cached_mods << 'builtin'
|
||||||
builtin_files = [builtin_vh]
|
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') {
|
if v.pref.vpath != '' && v.pref.build_mode != .build_module && !mod.contains('vweb') {
|
||||||
mod_path := mod.replace('.', os.path_separator)
|
mod_path := mod.replace('.', os.path_separator)
|
||||||
vh_path := '$v_modules_path${os.path_separator}vlib${os.path_separator}${mod_path}.vh'
|
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')
|
eprintln('using cached module `$mod`: $vh_path')
|
||||||
v.cached_mods << mod
|
v.cached_mods << mod
|
||||||
v.files << vh_path
|
v.files << vh_path
|
||||||
|
@ -850,7 +850,7 @@ pub fn (v &V) log(s string) {
|
||||||
|
|
||||||
pub fn new_v(args[]string) &V {
|
pub fn new_v(args[]string) &V {
|
||||||
// Create modules dirs if they are missing
|
// 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) or { panic(err) }
|
||||||
os.mkdir('$v_modules_path${os.path_separator}cache') 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_test := dir.ends_with('_test.v')
|
||||||
is_script := dir.ends_with('.v') || dir.ends_with('.vsh')
|
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')
|
println('`$dir` does not exist')
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
|
@ -933,7 +933,7 @@ pub fn new_v(args[]string) &V {
|
||||||
// Building V? Use v2, since we can't overwrite a running
|
// Building V? Use v2, since we can't overwrite a running
|
||||||
// executable on Windows + the precompiled V is more
|
// executable on Windows + the precompiled V is more
|
||||||
// optimized.
|
// 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('Saving the resulting V executable in `./v2`')
|
||||||
println('Use `v -o v v.v` if you want to replace current '+
|
println('Use `v -o v v.v` if you want to replace current '+
|
||||||
'V executable.')
|
'V executable.')
|
||||||
|
@ -948,7 +948,7 @@ pub fn new_v(args[]string) &V {
|
||||||
// `v -o dir/exec`, create "dir/" if it doesn't exist
|
// `v -o dir/exec`, create "dir/" if it doesn't exist
|
||||||
if out_name.contains(os.path_separator) {
|
if out_name.contains(os.path_separator) {
|
||||||
d := out_name.all_before_last(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"')
|
println('creating a new directory "$d"')
|
||||||
os.mkdir(d) or { panic(err) }
|
os.mkdir(d) or { panic(err) }
|
||||||
}
|
}
|
||||||
|
@ -989,7 +989,7 @@ pub fn new_v(args[]string) &V {
|
||||||
}
|
}
|
||||||
//println('VROOT=$vroot')
|
//println('VROOT=$vroot')
|
||||||
// v.exe's parent directory should contain vlib
|
// 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...')
|
//println('vlib not found, downloading it...')
|
||||||
/*
|
/*
|
||||||
ret := os.system('git clone --depth=1 https://github.com/vlang/v .')
|
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) {
|
pub fn vfmt(args[]string) {
|
||||||
println('running vfmt...')
|
println('running vfmt...')
|
||||||
file := args.last()
|
file := args.last()
|
||||||
if !os.file_exists(file) {
|
if !os.exists(file) {
|
||||||
println('"$file" does not exist')
|
println('"$file" does not exist')
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ fn generate_vh(mod string) {
|
||||||
dir := if mod.starts_with('vlib') { '$compiler.v_modules_path${os.path_separator}$mod' } else { mod }
|
dir := if mod.starts_with('vlib') { '$compiler.v_modules_path${os.path_separator}$mod' } else { mod }
|
||||||
path := dir + '.vh'
|
path := dir + '.vh'
|
||||||
pdir := dir.all_before_last(os.path_separator)
|
pdir := dir.all_before_last(os.path_separator)
|
||||||
if !os.dir_exists(pdir) {
|
if !os.is_dir(pdir) {
|
||||||
os.mkdir_all(pdir)
|
os.mkdir_all(pdir)
|
||||||
// os.mkdir(os.realpath(dir)) or { panic(err) }
|
// os.mkdir(os.realpath(dir)) or { panic(err) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,7 +170,7 @@ fn (v &V) find_module_path(mod string) ?string {
|
||||||
}
|
}
|
||||||
for try_path in tried_paths {
|
for try_path in tried_paths {
|
||||||
if v.pref.is_verbose { println(' >> trying to find $mod in $try_path ...') }
|
if v.pref.is_verbose { println(' >> trying to find $mod in $try_path ...') }
|
||||||
if os.dir_exists(try_path) {
|
if os.is_dir(try_path) {
|
||||||
return try_path
|
return try_path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ fn find_vs(vswhere_dir string, host_arch string) ?VsInstallation {
|
||||||
lib_path := '$res.output\\VC\\Tools\\MSVC\\$v\\lib\\$host_arch'
|
lib_path := '$res.output\\VC\\Tools\\MSVC\\$v\\lib\\$host_arch'
|
||||||
include_path := '$res.output\\VC\\Tools\\MSVC\\$v\\include'
|
include_path := '$res.output\\VC\\Tools\\MSVC\\$v\\include'
|
||||||
|
|
||||||
if os.file_exists('$lib_path\\vcruntime.lib') {
|
if os.exists('$lib_path\\vcruntime.lib') {
|
||||||
p := '$res.output\\VC\\Tools\\MSVC\\$v\\bin\\Host$host_arch\\$host_arch'
|
p := '$res.output\\VC\\Tools\\MSVC\\$v\\bin\\Host$host_arch\\$host_arch'
|
||||||
|
|
||||||
// println('$lib_path $include_path')
|
// println('$lib_path $include_path')
|
||||||
|
@ -274,7 +274,7 @@ pub fn (v mut V) cc_msvc() {
|
||||||
/*
|
/*
|
||||||
b := os.realpath( '$v_modules_path/vlib/builtin.obj' )
|
b := os.realpath( '$v_modules_path/vlib/builtin.obj' )
|
||||||
alibs << '"$b"'
|
alibs << '"$b"'
|
||||||
if !os.file_exists(b) {
|
if !os.exists(b) {
|
||||||
println('`builtin.obj` not found')
|
println('`builtin.obj` not found')
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
|
@ -390,7 +390,7 @@ fn build_thirdparty_obj_file_with_msvc(path string, moduleflags []CFlag) {
|
||||||
|
|
||||||
obj_path = os.realpath(obj_path)
|
obj_path = os.realpath(obj_path)
|
||||||
|
|
||||||
if os.file_exists(obj_path) {
|
if os.exists(obj_path) {
|
||||||
println('$obj_path already build.')
|
println('$obj_path already build.')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ mut:
|
||||||
|
|
||||||
// new scanner from file.
|
// new scanner from file.
|
||||||
fn new_scanner_file(file_path string) &Scanner {
|
fn new_scanner_file(file_path string) &Scanner {
|
||||||
if !os.file_exists(file_path) {
|
if !os.exists(file_path) {
|
||||||
verror("$file_path doesn't exist")
|
verror("$file_path doesn't exist")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import filepath
|
||||||
|
|
||||||
pub fn get_vtmp_folder() string {
|
pub fn get_vtmp_folder() string {
|
||||||
vtmp := filepath.join(os.tmpdir(),'v')
|
vtmp := filepath.join(os.tmpdir(),'v')
|
||||||
if !os.dir_exists( vtmp ) {
|
if !os.is_dir( vtmp ) {
|
||||||
os.mkdir(vtmp) or { panic(err) }
|
os.mkdir(vtmp) or { panic(err) }
|
||||||
}
|
}
|
||||||
return vtmp
|
return vtmp
|
||||||
|
|
|
@ -15,7 +15,7 @@ pub fn launch_tool(tname string){
|
||||||
//println('Launching: "$tool_command" ...')
|
//println('Launching: "$tool_command" ...')
|
||||||
|
|
||||||
mut tool_should_be_recompiled := false
|
mut tool_should_be_recompiled := false
|
||||||
if !os.file_exists( tool_exe ) {
|
if !os.exists( tool_exe ) {
|
||||||
// fresh checkout
|
// fresh checkout
|
||||||
tool_should_be_recompiled = true
|
tool_should_be_recompiled = true
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -173,12 +173,12 @@ pub fn new_context(cfg gg.Cfg) &FreeType {
|
||||||
if font_path == '' {
|
if font_path == '' {
|
||||||
font_path = 'RobotoMono-Regular.ttf'
|
font_path = 'RobotoMono-Regular.ttf'
|
||||||
}
|
}
|
||||||
if !os.file_exists(font_path) {
|
if !os.exists(font_path) {
|
||||||
exe_path := os.executable()
|
exe_path := os.executable()
|
||||||
exe_dir := os.basedir(exe_path)
|
exe_dir := os.basedir(exe_path)
|
||||||
font_path = '$exe_dir/$font_path'
|
font_path = '$exe_dir/$font_path'
|
||||||
}
|
}
|
||||||
if !os.file_exists(font_path) {
|
if !os.exists(font_path) {
|
||||||
println('failed to load $font_path')
|
println('failed to load $font_path')
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -363,7 +363,7 @@ pub fn create_image(file string) u32 {
|
||||||
if file.contains('twitch') {
|
if file.contains('twitch') {
|
||||||
return u32(0)// TODO
|
return u32(0)// TODO
|
||||||
}
|
}
|
||||||
if !os.file_exists(file) {
|
if !os.exists(file) {
|
||||||
println('gg create image no such file "$file"')
|
println('gg create image no such file "$file"')
|
||||||
return u32(0)
|
return u32(0)
|
||||||
}
|
}
|
||||||
|
|
42
vlib/os/os.v
42
vlib/os/os.v
|
@ -164,7 +164,7 @@ pub fn cp(old, new string) ?bool {
|
||||||
pub fn cp_r(osource_path, odest_path string, overwrite bool) ?bool{
|
pub fn cp_r(osource_path, odest_path string, overwrite bool) ?bool{
|
||||||
source_path := os.realpath( osource_path )
|
source_path := os.realpath( osource_path )
|
||||||
dest_path := os.realpath( odest_path )
|
dest_path := os.realpath( odest_path )
|
||||||
if !os.file_exists(source_path) {
|
if !os.exists(source_path) {
|
||||||
return error('Source path doesn\'t exist')
|
return error('Source path doesn\'t exist')
|
||||||
}
|
}
|
||||||
//single file copy
|
//single file copy
|
||||||
|
@ -174,7 +174,7 @@ pub fn cp_r(osource_path, odest_path string, overwrite bool) ?bool{
|
||||||
} else {
|
} else {
|
||||||
dest_path
|
dest_path
|
||||||
}
|
}
|
||||||
if os.file_exists(adjasted_path) {
|
if os.exists(adjasted_path) {
|
||||||
if overwrite {
|
if overwrite {
|
||||||
os.rm(adjasted_path)
|
os.rm(adjasted_path)
|
||||||
}
|
}
|
||||||
|
@ -523,16 +523,21 @@ pub fn unsetenv(name string) int {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// file_exists returns true if `path` exists.
|
// exists returns true if `path` exists.
|
||||||
pub fn file_exists(_path string) bool {
|
pub fn exists(path string) bool {
|
||||||
$if windows {
|
$if windows {
|
||||||
path := _path.replace('/', '\\')
|
p := path.replace('/', '\\')
|
||||||
return C._waccess(path.to_wide(), 0) != -1
|
return C._waccess(p.to_wide(), 0) != -1
|
||||||
} $else {
|
} $else {
|
||||||
return C.access(_path.str, 0 ) != -1
|
return C.access(path.str, 0 ) != -1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[deprecated]
|
||||||
|
pub fn file_exists(_path string) bool {
|
||||||
|
panic('use os.exists(path) instead of os.file_exists(path)')
|
||||||
|
}
|
||||||
|
|
||||||
// rm removes file in `path`.
|
// rm removes file in `path`.
|
||||||
pub fn rm(path string) {
|
pub fn rm(path string) {
|
||||||
$if windows {
|
$if windows {
|
||||||
|
@ -822,13 +827,24 @@ pub fn executable() string {
|
||||||
return os.args[0]
|
return os.args[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[deprecated]
|
||||||
|
pub fn dir_exists(path string) bool {
|
||||||
|
panic('use os.is_dir()')
|
||||||
|
//return false
|
||||||
|
}
|
||||||
|
|
||||||
// is_dir returns a boolean indicating whether the given path is a directory.
|
// is_dir returns a boolean indicating whether the given path is a directory.
|
||||||
pub fn is_dir(path string) bool {
|
pub fn is_dir(path string) bool {
|
||||||
$if windows {
|
$if windows {
|
||||||
return dir_exists(path)
|
_path := path.replace('/', '\\')
|
||||||
//val := int(C.GetFileAttributes(path.to_wide()))
|
attr := C.GetFileAttributesW(_path.to_wide())
|
||||||
// Note: this return is broke (wrong). we have dir_exists already how will this differ?
|
if int(attr) == int(C.INVALID_FILE_ATTRIBUTES) {
|
||||||
//return (val &FILE_ATTRIBUTE_DIRECTORY) > 0
|
return false
|
||||||
|
}
|
||||||
|
if (int(attr) & C.FILE_ATTRIBUTE_DIRECTORY) != 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
$else {
|
$else {
|
||||||
statbuf := C.stat{}
|
statbuf := C.stat{}
|
||||||
|
@ -927,7 +943,7 @@ pub fn walk(path string, fnc fn(path string)) {
|
||||||
if os.is_dir(p) {
|
if os.is_dir(p) {
|
||||||
walk(p, fnc)
|
walk(p, fnc)
|
||||||
}
|
}
|
||||||
else if os.file_exists(p) {
|
else if os.exists(p) {
|
||||||
fnc(p)
|
fnc(p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -996,7 +1012,7 @@ pub fn mkdir_all(path string) {
|
||||||
mut p := if path.starts_with(os.path_separator) { os.path_separator } else { '' }
|
mut p := if path.starts_with(os.path_separator) { os.path_separator } else { '' }
|
||||||
for subdir in path.split(os.path_separator) {
|
for subdir in path.split(os.path_separator) {
|
||||||
p += subdir + os.path_separator
|
p += subdir + os.path_separator
|
||||||
if !os.dir_exists(p) {
|
if !os.is_dir(p) {
|
||||||
os.mkdir(p) or { panic(err) }
|
os.mkdir(p) or { panic(err) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,12 +47,11 @@ pub fn ls(path string) ?[]string {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dir_exists(path string) bool {
|
/*
|
||||||
/*
|
pub fn is_dir(path string) bool {
|
||||||
$if linux {
|
//$if linux {
|
||||||
C.syscall(4, path.str) // sys_newstat
|
//C.syscall(4, path.str) // sys_newstat
|
||||||
}
|
//}
|
||||||
*/
|
|
||||||
dir := C.opendir(path.str)
|
dir := C.opendir(path.str)
|
||||||
res := !isnil(dir)
|
res := !isnil(dir)
|
||||||
if res {
|
if res {
|
||||||
|
@ -60,6 +59,7 @@ pub fn dir_exists(path string) bool {
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// mkdir creates a new directory with the specified path.
|
// mkdir creates a new directory with the specified path.
|
||||||
pub fn mkdir(path string) ?bool {
|
pub fn mkdir(path string) ?bool {
|
||||||
|
|
|
@ -76,14 +76,14 @@ fn test_write_and_read_bytes() {
|
||||||
fn test_create_and_delete_folder() {
|
fn test_create_and_delete_folder() {
|
||||||
folder := './test1'
|
folder := './test1'
|
||||||
os.mkdir(folder) or { panic(err) }
|
os.mkdir(folder) or { panic(err) }
|
||||||
assert os.dir_exists(folder)
|
assert os.is_dir(folder)
|
||||||
|
|
||||||
folder_contents := os.ls(folder) or { panic(err) }
|
folder_contents := os.ls(folder) or { panic(err) }
|
||||||
assert folder_contents.len == 0
|
assert folder_contents.len == 0
|
||||||
|
|
||||||
os.rmdir(folder)
|
os.rmdir(folder)
|
||||||
|
|
||||||
folder_exists := os.dir_exists(folder)
|
folder_exists := os.is_dir(folder)
|
||||||
|
|
||||||
assert folder_exists == false
|
assert folder_exists == false
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,13 +89,13 @@ fn init_os_args(argc int, argv &byteptr) []string {
|
||||||
pub fn ls(path string) ?[]string {
|
pub fn ls(path string) ?[]string {
|
||||||
mut find_file_data := Win32finddata{}
|
mut find_file_data := Win32finddata{}
|
||||||
mut dir_files := []string
|
mut dir_files := []string
|
||||||
// We can also check if the handle is valid. but using dir_exists instead
|
// We can also check if the handle is valid. but using is_dir instead
|
||||||
// h_find_dir := C.FindFirstFile(path.str, &find_file_data)
|
// h_find_dir := C.FindFirstFile(path.str, &find_file_data)
|
||||||
// if (INVALID_HANDLE_VALUE == h_find_dir) {
|
// if (INVALID_HANDLE_VALUE == h_find_dir) {
|
||||||
// return dir_files
|
// return dir_files
|
||||||
// }
|
// }
|
||||||
// C.FindClose(h_find_dir)
|
// C.FindClose(h_find_dir)
|
||||||
if !dir_exists(path) {
|
if !is_dir(path) {
|
||||||
return error('ls() couldnt open dir "$path": directory does not exist')
|
return error('ls() couldnt open dir "$path": directory does not exist')
|
||||||
}
|
}
|
||||||
// NOTE: Should eventually have path struct & os dependant path seperator (eg os.PATH_SEPERATOR)
|
// NOTE: Should eventually have path struct & os dependant path seperator (eg os.PATH_SEPERATOR)
|
||||||
|
@ -118,7 +118,8 @@ pub fn ls(path string) ?[]string {
|
||||||
return dir_files
|
return dir_files
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dir_exists(path string) bool {
|
/*
|
||||||
|
pub fn is_dir(path string) bool {
|
||||||
_path := path.replace('/', '\\')
|
_path := path.replace('/', '\\')
|
||||||
attr := C.GetFileAttributesW(_path.to_wide())
|
attr := C.GetFileAttributesW(_path.to_wide())
|
||||||
if int(attr) == int(C.INVALID_FILE_ATTRIBUTES) {
|
if int(attr) == int(C.INVALID_FILE_ATTRIBUTES) {
|
||||||
|
@ -129,6 +130,7 @@ pub fn dir_exists(path string) bool {
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ fn (am mut AssetManager) combine(asset_type string, to_file bool) string {
|
||||||
out_file := '$am.cache_dir/${cache_key}.$asset_type'
|
out_file := '$am.cache_dir/${cache_key}.$asset_type'
|
||||||
mut out := ''
|
mut out := ''
|
||||||
// use cache
|
// use cache
|
||||||
if os.file_exists(out_file) {
|
if os.exists(out_file) {
|
||||||
if to_file {
|
if to_file {
|
||||||
return out_file
|
return out_file
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ fn (am mut AssetManager) combine(asset_type string, to_file bool) string {
|
||||||
if !to_file {
|
if !to_file {
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
if !os.dir_exists(am.cache_dir) {
|
if !os.is_dir(am.cache_dir) {
|
||||||
os.mkdir(am.cache_dir) or { panic(err) }
|
os.mkdir(am.cache_dir) or { panic(err) }
|
||||||
}
|
}
|
||||||
mut file := os.create(out_file) or {
|
mut file := os.create(out_file) or {
|
||||||
|
@ -153,7 +153,7 @@ fn (am mut AssetManager) include(asset_type string, combine bool) string {
|
||||||
// dont return option until size limit is removed
|
// dont return option until size limit is removed
|
||||||
// fn (am mut AssetManager) add(asset_type, file string) ?bool {
|
// fn (am mut AssetManager) add(asset_type, file string) ?bool {
|
||||||
fn (am mut AssetManager) add(asset_type, file string) bool {
|
fn (am mut AssetManager) add(asset_type, file string) bool {
|
||||||
if !os.file_exists(file) {
|
if !os.exists(file) {
|
||||||
// return error('vweb.assets: cannot add asset $file, it does not exist')
|
// return error('vweb.assets: cannot add asset $file, it does not exist')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ pub fn compile_template(path string) string {
|
||||||
panic('html failed')
|
panic('html failed')
|
||||||
}
|
}
|
||||||
mut header := ''
|
mut header := ''
|
||||||
if os.file_exists('header.html') {
|
if os.exists('header.html') {
|
||||||
h := os.read_file('header.html') or {
|
h := os.read_file('header.html') or {
|
||||||
panic('html failed')
|
panic('html failed')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue