1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

v.util,tools: use os.join_path_single

This commit is contained in:
Delyan Angelov
2021-11-22 21:42:43 +02:00
parent bd9564e38b
commit d431145a39
9 changed files with 24 additions and 24 deletions

View File

@@ -110,7 +110,7 @@ fn (mut p Parser) comptime_call() ast.ComptimeCall {
// check absolute path first
if !os.exists(abs_path) {
// ... look relative to the source file:
epath = os.real_path(os.join_path(os.dir(p.file_name), epath))
epath = os.real_path(os.join_path_single(os.dir(p.file_name), epath))
if !os.exists(epath) {
p.error_with_pos('"$epath" does not exist so it cannot be embedded',
spos)
@@ -144,11 +144,11 @@ fn (mut p Parser) comptime_call() ast.ComptimeCall {
tmpl_path := if is_html { '${fn_path.last()}.html' } else { path_of_literal_string_param }
// Looking next to the vweb program
dir := os.dir(compiled_vfile_path)
mut path := os.join_path(dir, fn_path_joined)
mut path := os.join_path_single(dir, fn_path_joined)
path += '.html'
path = os.real_path(path)
if !is_html {
path = os.join_path(dir, tmpl_path)
path = os.join_path_single(dir, tmpl_path)
}
if !os.exists(path) {
if is_html {

View File

@@ -135,7 +135,7 @@ mut sb := strings.new_builder($lstartlength)\n
// an absolute path
templates_folder = ''
}
file_path := os.real_path(os.join_path(templates_folder, '$file_name$file_ext'))
file_path := os.real_path(os.join_path_single(templates_folder, '$file_name$file_ext'))
$if trace_tmpl ? {
eprintln('>>> basepath: "$basepath" , template_file: "$template_file" , fn_name: "$fn_name" , @include line: "$line" , file_name: "$file_name" , file_ext: "$file_ext" , templates_folder: "$templates_folder" , file_path: "$file_path"')
}

View File

@@ -72,11 +72,11 @@ pub fn color_compare_files(diff_cmd string, file1 string, file2 string) string {
}
pub fn color_compare_strings(diff_cmd string, unique_prefix string, expected string, found string) string {
cdir := os.join_path(os.cache_dir(), unique_prefix)
cdir := os.join_path_single(os.cache_dir(), unique_prefix)
os.mkdir(cdir) or {}
ctime := time.sys_mono_now()
e_file := os.join_path(cdir, '${ctime}.expected.txt')
f_file := os.join_path(cdir, '${ctime}.found.txt')
e_file := os.join_path_single(cdir, '${ctime}.expected.txt')
f_file := os.join_path_single(cdir, '${ctime}.found.txt')
os.write_file(e_file, expected) or { panic(err) }
os.write_file(f_file, found) or { panic(err) }
res := color_compare_files(diff_cmd, e_file, f_file)

View File

@@ -13,7 +13,7 @@ pub fn qualify_import(pref &pref.Preferences, mod string, file_path string) stri
mod_paths << os.vmodules_paths()
mod_path := mod.replace('.', os.path_separator)
for search_path in mod_paths {
try_path := os.join_path(search_path, mod_path)
try_path := os.join_path_single(search_path, mod_path)
if os.is_dir(try_path) {
if m1 := mod_path_to_full_name(pref, mod, try_path) {
trace_mod_path_to_full_name(@LINE, mod, try_path, m1)
@@ -70,7 +70,7 @@ pub fn mod_path_to_full_name(pref &pref.Preferences, mod string, path string) ?s
mod_path := mod.replace('.', os.path_separator)
// go back through each parent in path_parts and join with `mod_path` to see the dir exists
for i := path_parts.len - 1; i > 0; i-- {
try_path := os.join_path(path_parts[0..i].join(os.path_separator), mod_path)
try_path := os.join_path_single(path_parts[0..i].join(os.path_separator), mod_path)
// found module path
if os.is_dir(try_path) {
// we know we are in one of the `vmod_folders`

View File

@@ -9,7 +9,7 @@ import os
// V from source.
pub fn disabling_file(vroot string) string {
tools_folder := os.join_path(vroot, 'cmd', 'tools')
res := os.join_path(tools_folder, '.disable_autorecompilation')
res := os.join_path_single(tools_folder, '.disable_autorecompilation')
return res
}

View File

@@ -46,7 +46,7 @@ pub fn set_vroot_folder(vroot_path string) {
// VEXE env variable is needed so that compiler.vexe_path()
// can return it later to whoever needs it:
vname := if os.user_os() == 'windows' { 'v.exe' } else { 'v' }
os.setenv('VEXE', os.real_path(os.join_path(vroot_path, vname)), true)
os.setenv('VEXE', os.real_path(os.join_path_single(vroot_path, vname)), true)
os.setenv('VCHILD', 'true', true)
}
@@ -121,11 +121,11 @@ pub fn launch_tool(is_verbose bool, tool_name string, args []string) {
set_vroot_folder(vroot)
tool_args := args_quote_paths(args)
tools_folder := os.join_path(vroot, 'cmd', 'tools')
tool_basename := os.real_path(os.join_path(tools_folder, tool_name))
tool_basename := os.real_path(os.join_path_single(tools_folder, tool_name))
mut tool_exe := ''
mut tool_source := ''
if os.is_dir(tool_basename) {
tool_exe = path_of_executable(os.join_path(tool_basename, tool_name))
tool_exe = path_of_executable(os.join_path_single(tool_basename, tool_name))
tool_source = tool_basename
} else {
tool_exe = path_of_executable(tool_basename)
@@ -240,7 +240,7 @@ pub fn should_recompile_tool(vexe string, tool_source string, tool_name string,
fn tool_source2name_and_exe(tool_source string) (string, string) {
sfolder := os.dir(tool_source)
tool_name := os.base(tool_source).replace('.v', '')
tool_exe := os.join_path(sfolder, path_of_executable(tool_name))
tool_exe := os.join_path_single(sfolder, path_of_executable(tool_name))
return tool_name, tool_exe
}
@@ -357,8 +357,8 @@ fn non_empty(arg []string) []string {
}
pub fn check_module_is_installed(modulename string, is_verbose bool) ?bool {
mpath := os.join_path(os.vmodules_dir(), modulename)
mod_v_file := os.join_path(mpath, 'v.mod')
mpath := os.join_path_single(os.vmodules_dir(), modulename)
mod_v_file := os.join_path_single(mpath, 'v.mod')
murl := 'https://github.com/vlang/$modulename'
if is_verbose {
eprintln('check_module_is_installed: mpath: $mpath')
@@ -484,7 +484,7 @@ pub fn get_vtmp_folder() string {
return vtmp
}
uid := os.getuid()
vtmp = os.join_path(os.temp_dir(), 'v_$uid')
vtmp = os.join_path_single(os.temp_dir(), 'v_$uid')
if !os.exists(vtmp) || !os.is_dir(vtmp) {
os.mkdir_all(vtmp) or { panic(err) }
}

View File

@@ -14,7 +14,7 @@ pub fn filter_vtest_only(paths []string, config FilterVTestConfig) []string {
for relative_path in paths {
mut file := relative_path
if config.basepath.len > 0 {
file = os.join_path(config.basepath, file)
file = os.join_path_single(config.basepath, file)
}
if config.fix_slashes {
file = file.replace('\\', '/')