os: realpath => real_path
parent
5f32663714
commit
2f27758a4b
|
@ -10,7 +10,7 @@ fn main() {
|
||||||
files_paths := os.args[1..]
|
files_paths := os.args[1..]
|
||||||
mut errors := 0
|
mut errors := 0
|
||||||
for file_path in files_paths {
|
for file_path in files_paths {
|
||||||
real_path := os.realpath(file_path)
|
real_path := os.real_path(file_path)
|
||||||
lines := os.read_lines(real_path) or {
|
lines := os.read_lines(real_path) or {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ pub fn (ts mut TestSession) test() {
|
||||||
mut remaining_files := []string
|
mut remaining_files := []string
|
||||||
for dot_relative_file in ts.files {
|
for dot_relative_file in ts.files {
|
||||||
relative_file := dot_relative_file.replace('./', '')
|
relative_file := dot_relative_file.replace('./', '')
|
||||||
file := os.realpath(relative_file)
|
file := os.real_path(relative_file)
|
||||||
$if windows {
|
$if windows {
|
||||||
if file.contains('sqlite') || file.contains('httpbin') {
|
if file.contains('sqlite') || file.contains('httpbin') {
|
||||||
continue
|
continue
|
||||||
|
@ -92,7 +92,7 @@ fn worker_trunner(p mut sync.PoolProcessor, idx int, thread_id int) voidptr {
|
||||||
tls_bench.cstep = idx
|
tls_bench.cstep = idx
|
||||||
dot_relative_file := p.get_string_item(idx)
|
dot_relative_file := p.get_string_item(idx)
|
||||||
relative_file := dot_relative_file.replace('./', '')
|
relative_file := dot_relative_file.replace('./', '')
|
||||||
file := os.realpath(relative_file)
|
file := os.real_path(relative_file)
|
||||||
// Ensure that the generated binaries will be stored in the temporary folder.
|
// Ensure that the generated binaries will be stored in the temporary folder.
|
||||||
// Remove them after a test passes/fails.
|
// Remove them after a test passes/fails.
|
||||||
fname := os.file_name(file)
|
fname := os.file_name(file)
|
||||||
|
|
|
@ -41,7 +41,7 @@ pub fn line_to_timestamp_and_commit(line string) (int,string) {
|
||||||
|
|
||||||
pub fn normalized_workpath_for_commit(workdir string, commit string) string {
|
pub fn normalized_workpath_for_commit(workdir string, commit string) string {
|
||||||
nc := 'v_at_' + commit.replace('^', '_').replace('-', '_').replace('/', '_')
|
nc := 'v_at_' + commit.replace('^', '_').replace('-', '_').replace('/', '_')
|
||||||
return os.realpath(workdir + os.path_separator + nc)
|
return os.real_path(workdir + os.path_separator + nc)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn prepare_vc_source(vcdir string, cdir string, commit string) (string,string) {
|
pub fn prepare_vc_source(vcdir string, cdir string, commit string) (string,string) {
|
||||||
|
@ -96,7 +96,7 @@ pub mut:
|
||||||
|
|
||||||
pub fn (vgit_context mut VGitContext) compile_oldv_if_needed() {
|
pub fn (vgit_context mut VGitContext) compile_oldv_if_needed() {
|
||||||
vgit_context.vexename = if os.user_os() == 'windows' { 'v.exe' } else { 'v' }
|
vgit_context.vexename = if os.user_os() == 'windows' { 'v.exe' } else { 'v' }
|
||||||
vgit_context.vexepath = os.realpath(os.join_path(vgit_context.path_v, vgit_context.vexename))
|
vgit_context.vexepath = os.real_path(os.join_path(vgit_context.path_v, vgit_context.vexename))
|
||||||
mut command_for_building_v_from_c_source := ''
|
mut command_for_building_v_from_c_source := ''
|
||||||
mut command_for_selfbuilding := ''
|
mut command_for_selfbuilding := ''
|
||||||
if 'windows' == os.user_os() {
|
if 'windows' == os.user_os() {
|
||||||
|
@ -137,7 +137,7 @@ pub fn (vgit_context mut VGitContext) compile_oldv_if_needed() {
|
||||||
|
|
||||||
pub fn add_common_tool_options<T>(context mut T, fp mut flag.FlagParser) []string {
|
pub fn add_common_tool_options<T>(context mut T, fp mut flag.FlagParser) []string {
|
||||||
tdir := os.temp_dir()
|
tdir := os.temp_dir()
|
||||||
context.workdir = os.realpath(fp.string('workdir', `w`, tdir, 'A writable base folder. Default: $tdir'))
|
context.workdir = os.real_path(fp.string('workdir', `w`, tdir, 'A writable base folder. Default: $tdir'))
|
||||||
context.v_repo_url = fp.string('vrepo', 0, vgit.remote_v_repo_url, 'The url of the V repository. You can clone it locally too. See also --vcrepo below.')
|
context.v_repo_url = fp.string('vrepo', 0, vgit.remote_v_repo_url, 'The url of the V repository. You can clone it locally too. See also --vcrepo below.')
|
||||||
context.vc_repo_url = fp.string('vcrepo', 0, vgit.remote_vc_repo_url, 'The url of the vc repository. You can clone it
|
context.vc_repo_url = fp.string('vcrepo', 0, vgit.remote_vc_repo_url, 'The url of the vc repository. You can clone it
|
||||||
${flag.SPACE}beforehand, and then just give the local folder
|
${flag.SPACE}beforehand, and then just give the local folder
|
||||||
|
@ -158,11 +158,11 @@ ${flag.SPACE}to script it/run it in a restrictive vps/docker.
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.is_dir(context.v_repo_url) {
|
if os.is_dir(context.v_repo_url) {
|
||||||
context.v_repo_url = os.realpath( context.v_repo_url )
|
context.v_repo_url = os.real_path( context.v_repo_url )
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.is_dir(context.vc_repo_url) {
|
if os.is_dir(context.vc_repo_url) {
|
||||||
context.vc_repo_url = os.realpath( context.vc_repo_url )
|
context.vc_repo_url = os.real_path( context.vc_repo_url )
|
||||||
}
|
}
|
||||||
|
|
||||||
commits := fp.finalize() or {
|
commits := fp.finalize() or {
|
||||||
|
|
|
@ -3,7 +3,7 @@ module vhelp
|
||||||
import os
|
import os
|
||||||
|
|
||||||
pub fn show_topic(topic string) {
|
pub fn show_topic(topic string) {
|
||||||
vexe := os.realpath(os.getenv('VEXE'))
|
vexe := os.real_path(os.getenv('VEXE'))
|
||||||
vroot := os.dir(vexe)
|
vroot := os.dir(vexe)
|
||||||
target_topic := os.join_path(vroot,'cmd','v','internal','help','${topic}.txt')
|
target_topic := os.join_path(vroot,'cmd','v','internal','help','${topic}.txt')
|
||||||
content := os.read_file(target_topic) or {
|
content := os.read_file(target_topic) or {
|
||||||
|
|
|
@ -164,7 +164,7 @@ fn (c Context) compare_v_performance(label string, commands []string) string {
|
||||||
hyperfine_commands_arguments << " \'cd ${c.a:-34s} ; ./$cmd \' ".replace_each(['@COMPILER@', source_location_a, '@DEBUG@', debug_option_a])
|
hyperfine_commands_arguments << " \'cd ${c.a:-34s} ; ./$cmd \' ".replace_each(['@COMPILER@', source_location_a, '@DEBUG@', debug_option_a])
|
||||||
}
|
}
|
||||||
// /////////////////////////////////////////////////////////////////////////////
|
// /////////////////////////////////////////////////////////////////////////////
|
||||||
cmd_stats_file := os.realpath([c.workdir, 'v_performance_stats_${label}.json'].join(os.path_separator))
|
cmd_stats_file := os.real_path([c.workdir, 'v_performance_stats_${label}.json'].join(os.path_separator))
|
||||||
comparison_cmd := 'hyperfine $c.hyperfineopts ' + '--export-json ${cmd_stats_file} ' + '--time-unit millisecond ' + '--style full --warmup $c.warmups ' + hyperfine_commands_arguments.join(' ')
|
comparison_cmd := 'hyperfine $c.hyperfineopts ' + '--export-json ${cmd_stats_file} ' + '--time-unit millisecond ' + '--style full --warmup $c.warmups ' + hyperfine_commands_arguments.join(' ')
|
||||||
// /////////////////////////////////////////////////////////////////////////////
|
// /////////////////////////////////////////////////////////////////////////////
|
||||||
if c.verbose {
|
if c.verbose {
|
||||||
|
|
|
@ -19,7 +19,7 @@ fn cb_assertion_failed(filename string, line int, sourceline string, funcname st
|
||||||
else {
|
else {
|
||||||
true}
|
true}
|
||||||
}
|
}
|
||||||
final_filename := if use_relative_paths { filename } else { os.realpath(filename) }
|
final_filename := if use_relative_paths { filename } else { os.real_path(filename) }
|
||||||
final_funcname := funcname.replace('main__', '').replace('__', '.')
|
final_funcname := funcname.replace('main__', '').replace('__', '.')
|
||||||
mut fail_message := 'FAILED assertion'
|
mut fail_message := 'FAILED assertion'
|
||||||
if color_on {
|
if color_on {
|
||||||
|
|
|
@ -108,7 +108,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
mut errors := 0
|
mut errors := 0
|
||||||
for file in files {
|
for file in files {
|
||||||
fpath := os.realpath(file)
|
fpath := os.real_path(file)
|
||||||
mut worker_command_array := cli_args_no_files.clone()
|
mut worker_command_array := cli_args_no_files.clone()
|
||||||
worker_command_array << ['-worker', fpath]
|
worker_command_array << ['-worker', fpath]
|
||||||
worker_cmd := worker_command_array.join(' ')
|
worker_cmd := worker_command_array.join(' ')
|
||||||
|
@ -371,7 +371,7 @@ fn get_compile_name_of_potential_v_project(file string) string {
|
||||||
// This function get_compile_name_of_potential_v_project returns:
|
// This function get_compile_name_of_potential_v_project returns:
|
||||||
// a) the file's folder, if file is part of a v project
|
// a) the file's folder, if file is part of a v project
|
||||||
// b) the file itself, if the file is a standalone v program
|
// b) the file itself, if the file is a standalone v program
|
||||||
pfolder := os.realpath(os.dir(file))
|
pfolder := os.real_path(os.dir(file))
|
||||||
// a .v project has many 'module main' files in one folder
|
// a .v project has many 'module main' files in one folder
|
||||||
// if there is only one .v file, then it must be a standalone
|
// if there is only one .v file, then it must be a standalone
|
||||||
all_files_in_pfolder := os.ls(pfolder) or {
|
all_files_in_pfolder := os.ls(pfolder) or {
|
||||||
|
|
|
@ -73,7 +73,7 @@ fn main(){
|
||||||
mut files := []string
|
mut files := []string
|
||||||
locations := fp.finalize() or { eprintln('Error: ' + err) exit(1) }
|
locations := fp.finalize() or { eprintln('Error: ' + err) exit(1) }
|
||||||
for xloc in locations {
|
for xloc in locations {
|
||||||
loc := os.realpath(xloc)
|
loc := os.real_path(xloc)
|
||||||
xfiles := if os.is_dir(loc){ os.walk_ext(loc,'.v') } else { [loc] }
|
xfiles := if os.is_dir(loc){ os.walk_ext(loc,'.v') } else { [loc] }
|
||||||
filtered_files := xfiles.filter(!it.ends_with('_js.v'))
|
filtered_files := xfiles.filter(!it.ends_with('_js.v'))
|
||||||
files << filtered_files
|
files << filtered_files
|
||||||
|
|
|
@ -146,7 +146,7 @@ fn vpm_install(module_names []string) {
|
||||||
println('Skipping module "$name", since it uses an unsupported VCS {$vcs} .')
|
println('Skipping module "$name", since it uses an unsupported VCS {$vcs} .')
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
final_module_path := os.realpath(os.join_path(settings.vmodules_path,mod.name.replace('.', os.path_separator)))
|
final_module_path := os.real_path(os.join_path(settings.vmodules_path,mod.name.replace('.', os.path_separator)))
|
||||||
if os.exists(final_module_path) {
|
if os.exists(final_module_path) {
|
||||||
vpm_update([name])
|
vpm_update([name])
|
||||||
continue
|
continue
|
||||||
|
@ -237,7 +237,7 @@ fn vpm_remove(module_names []string) {
|
||||||
os.rmdir_all(final_module_path)
|
os.rmdir_all(final_module_path)
|
||||||
// delete author directory if it is empty
|
// delete author directory if it is empty
|
||||||
author := name.split('.')[0]
|
author := name.split('.')[0]
|
||||||
author_dir := os.realpath(os.join_path(settings.vmodules_path,author))
|
author_dir := os.real_path(os.join_path(settings.vmodules_path,author))
|
||||||
if os.is_dir_empty(author_dir) {
|
if os.is_dir_empty(author_dir) {
|
||||||
verbose_println('removing author folder $author_dir')
|
verbose_println('removing author folder $author_dir')
|
||||||
os.rmdir(author_dir)
|
os.rmdir(author_dir)
|
||||||
|
@ -247,7 +247,7 @@ fn vpm_remove(module_names []string) {
|
||||||
|
|
||||||
fn valid_final_path_of_existing_module(name string) ?string {
|
fn valid_final_path_of_existing_module(name string) ?string {
|
||||||
name_of_vmodules_folder := os.join_path(settings.vmodules_path,name.replace('.', os.path_separator))
|
name_of_vmodules_folder := os.join_path(settings.vmodules_path,name.replace('.', os.path_separator))
|
||||||
final_module_path := os.realpath(name_of_vmodules_folder)
|
final_module_path := os.real_path(name_of_vmodules_folder)
|
||||||
if !os.exists(final_module_path) {
|
if !os.exists(final_module_path) {
|
||||||
println('No module with name "$name" exists at $name_of_vmodules_folder')
|
println('No module with name "$name" exists at $name_of_vmodules_folder')
|
||||||
return none
|
return none
|
||||||
|
@ -279,7 +279,7 @@ fn vpm_help() {
|
||||||
fn vcs_used_in_dir(dir string) ?[]string {
|
fn vcs_used_in_dir(dir string) ?[]string {
|
||||||
mut vcs := []string
|
mut vcs := []string
|
||||||
for repo_subfolder in supported_vcs_folders {
|
for repo_subfolder in supported_vcs_folders {
|
||||||
checked_folder := os.realpath(os.join_path(dir,repo_subfolder))
|
checked_folder := os.real_path(os.join_path(dir,repo_subfolder))
|
||||||
if os.is_dir(checked_folder) {
|
if os.is_dir(checked_folder) {
|
||||||
vcs << repo_subfolder.replace('.', '')
|
vcs << repo_subfolder.replace('.', '')
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,7 +216,7 @@ fn main() {
|
||||||
// so that the repl can be launched in parallel by several different
|
// so that the repl can be launched in parallel by several different
|
||||||
// threads by the REPL test runner.
|
// threads by the REPL test runner.
|
||||||
args := cmdline.options_after(os.args, ['repl'])
|
args := cmdline.options_after(os.args, ['repl'])
|
||||||
replfolder := os.realpath( cmdline.option(args, '-replfolder', '.') )
|
replfolder := os.real_path( cmdline.option(args, '-replfolder', '.') )
|
||||||
replprefix := cmdline.option(args, '-replprefix', 'noprefix.')
|
replprefix := cmdline.option(args, '-replprefix', 'noprefix.')
|
||||||
os.chdir( replfolder )
|
os.chdir( replfolder )
|
||||||
if !os.exists(os.getenv('VEXE')) {
|
if !os.exists(os.getenv('VEXE')) {
|
||||||
|
|
|
@ -15,8 +15,8 @@ fn launch_tool(verbosity pref.VerboseLevel, tool_name string) {
|
||||||
compiler.set_vroot_folder(vroot)
|
compiler.set_vroot_folder(vroot)
|
||||||
|
|
||||||
tool_args := os.args[1..].join(' ')
|
tool_args := os.args[1..].join(' ')
|
||||||
tool_exe := path_of_executable(os.realpath('$vroot/cmd/tools/$tool_name'))
|
tool_exe := path_of_executable(os.real_path('$vroot/cmd/tools/$tool_name'))
|
||||||
tool_source := os.realpath('$vroot/cmd/tools/${tool_name}.v')
|
tool_source := os.real_path('$vroot/cmd/tools/${tool_name}.v')
|
||||||
tool_command := '"$tool_exe" $tool_args'
|
tool_command := '"$tool_exe" $tool_args'
|
||||||
if verbosity.is_higher_or_equal(.level_two) {
|
if verbosity.is_higher_or_equal(.level_two) {
|
||||||
eprintln('launch_tool vexe : $vroot')
|
eprintln('launch_tool vexe : $vroot')
|
||||||
|
|
|
@ -19,7 +19,7 @@ import sdl.ttf as ttf
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Title = 'tVintris'
|
Title = 'tVintris'
|
||||||
BASE = os.dir( os.realpath( os.executable() ) )
|
BASE = os.dir( os.real_path( os.executable() ) )
|
||||||
FontName = BASE + '/../../assets/fonts/RobotoMono-Regular.ttf'
|
FontName = BASE + '/../../assets/fonts/RobotoMono-Regular.ttf'
|
||||||
MusicName = BASE + '/sounds/TwintrisThosenine.mod'
|
MusicName = BASE + '/sounds/TwintrisThosenine.mod'
|
||||||
SndBlockName = BASE + '/sounds/block.wav'
|
SndBlockName = BASE + '/sounds/block.wav'
|
||||||
|
|
|
@ -176,7 +176,7 @@ fn (v mut V) new_parser_from_file(path string) Parser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mut p := v.new_parser(new_scanner_file(path))
|
mut p := v.new_parser(new_scanner_file(path))
|
||||||
path_dir := os.realpath(os.dir(path))
|
path_dir := os.real_path(os.dir(path))
|
||||||
p = {
|
p = {
|
||||||
p |
|
p |
|
||||||
file_path:path,
|
file_path:path,
|
||||||
|
@ -418,7 +418,7 @@ fn (p mut Parser) statements_from_text(text string, rcbr bool, fpath string) {
|
||||||
|
|
||||||
fn (p mut Parser) parse(pass Pass) {
|
fn (p mut Parser) parse(pass Pass) {
|
||||||
p.cgen.line = 0
|
p.cgen.line = 0
|
||||||
p.cgen.file = cescaped_path(os.realpath(p.file_path))
|
p.cgen.file = cescaped_path(os.real_path(p.file_path))
|
||||||
// ///////////////////////////////////
|
// ///////////////////////////////////
|
||||||
p.pass = pass
|
p.pass = pass
|
||||||
p.token_idx = 0
|
p.token_idx = 0
|
||||||
|
|
|
@ -57,7 +57,7 @@ fn (cf &CFlag) format() string {
|
||||||
}
|
}
|
||||||
// convert to absolute path
|
// convert to absolute path
|
||||||
if cf.name == '-I' || cf.name == '-L' || value.ends_with('.o') {
|
if cf.name == '-I' || cf.name == '-L' || value.ends_with('.o') {
|
||||||
value = '"' + os.realpath(value) + '"'
|
value = '"' + os.real_path(value) + '"'
|
||||||
}
|
}
|
||||||
return '$cf.name $value'.trim_space()
|
return '$cf.name $value'.trim_space()
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,7 +272,7 @@ fn (g mut CGen) add_to_main(s string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (v &V) build_thirdparty_obj_file(path string, moduleflags []CFlag) {
|
fn (v &V) build_thirdparty_obj_file(path string, moduleflags []CFlag) {
|
||||||
obj_path := os.realpath(path)
|
obj_path := os.real_path(path)
|
||||||
if os.exists(obj_path) {
|
if os.exists(obj_path) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -284,7 +284,7 @@ fn (v &V) build_thirdparty_obj_file(path string, moduleflags []CFlag) {
|
||||||
mut cfiles := ''
|
mut cfiles := ''
|
||||||
for file in files {
|
for file in files {
|
||||||
if file.ends_with('.c') {
|
if file.ends_with('.c') {
|
||||||
cfiles += '"' + os.realpath(parent + os.path_separator + file) + '" '
|
cfiles += '"' + os.real_path(parent + os.path_separator + file) + '" '
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
btarget := moduleflags.c_options_before_target()
|
btarget := moduleflags.c_options_before_target()
|
||||||
|
|
|
@ -162,7 +162,7 @@ fn (s &Scanner) get_error_filepath() string {
|
||||||
}
|
}
|
||||||
return s.file_path
|
return s.file_path
|
||||||
}
|
}
|
||||||
return os.realpath(s.file_path)
|
return os.real_path(s.file_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (s &Scanner) is_color_output_on() bool {
|
fn (s &Scanner) is_color_output_on() bool {
|
||||||
|
|
|
@ -78,7 +78,7 @@ fn (v &V) generate_hot_reload_code() {
|
||||||
mut cgen := v.cgen
|
mut cgen := v.cgen
|
||||||
// Hot code reloading
|
// Hot code reloading
|
||||||
if v.pref.is_live {
|
if v.pref.is_live {
|
||||||
mut file := os.realpath(v.pref.path)
|
mut file := os.real_path(v.pref.path)
|
||||||
file_base := os.file_name(file).replace('.v', '')
|
file_base := os.file_name(file).replace('.v', '')
|
||||||
so_name := file_base + '.so'
|
so_name := file_base + '.so'
|
||||||
// Need to build .so file before building the live application
|
// Need to build .so file before building the live application
|
||||||
|
|
|
@ -38,7 +38,7 @@ pub mut:
|
||||||
mod_file_cacher &ModFileCacher // used during lookup for v.mod to support @VROOT
|
mod_file_cacher &ModFileCacher // used during lookup for v.mod to support @VROOT
|
||||||
out_name_c string // name of the temporary C file
|
out_name_c string // name of the temporary C file
|
||||||
files []string // all V files that need to be parsed and compiled
|
files []string // all V files that need to be parsed and compiled
|
||||||
compiled_dir string // contains os.realpath() of the dir of the final file beeing compiled, or the dir itself when doing `v .`
|
compiled_dir string // contains os.real_path() of the dir of the final file beeing compiled, or the dir itself when doing `v .`
|
||||||
table &Table // table with types, vars, functions etc
|
table &Table // table with types, vars, functions etc
|
||||||
cgen &CGen // C code generator
|
cgen &CGen // C code generator
|
||||||
//x64 &x64.Gen
|
//x64 &x64.Gen
|
||||||
|
@ -56,7 +56,7 @@ pub mut:
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_v(pref &pref.Preferences) &V {
|
pub fn new_v(pref &pref.Preferences) &V {
|
||||||
rdir := os.realpath(pref.path)
|
rdir := os.real_path(pref.path)
|
||||||
|
|
||||||
mut out_name_c := get_vtmp_filename(pref.out_name, '.tmp.c')
|
mut out_name_c := get_vtmp_filename(pref.out_name, '.tmp.c')
|
||||||
if pref.is_so {
|
if pref.is_so {
|
||||||
|
@ -105,13 +105,13 @@ pub fn (v &V) finalize_compilation() {
|
||||||
pub fn (v mut V) add_parser(parser Parser) int {
|
pub fn (v mut V) add_parser(parser Parser) int {
|
||||||
pidx := v.parsers.len
|
pidx := v.parsers.len
|
||||||
v.parsers << parser
|
v.parsers << parser
|
||||||
file_path := if os.is_abs_path(parser.file_path) { parser.file_path } else { os.realpath(parser.file_path) }
|
file_path := if os.is_abs_path(parser.file_path) { parser.file_path } else { os.real_path(parser.file_path) }
|
||||||
v.file_parser_idx[file_path] = pidx
|
v.file_parser_idx[file_path] = pidx
|
||||||
return pidx
|
return pidx
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (v &V) get_file_parser_index(file string) ?int {
|
pub fn (v &V) get_file_parser_index(file string) ?int {
|
||||||
file_path := if os.is_abs_path(file) { file } else { os.realpath(file) }
|
file_path := if os.is_abs_path(file) { file } else { os.real_path(file) }
|
||||||
if file_path in v.file_parser_idx {
|
if file_path in v.file_parser_idx {
|
||||||
return v.file_parser_idx[file_path]
|
return v.file_parser_idx[file_path]
|
||||||
}
|
}
|
||||||
|
@ -441,7 +441,7 @@ pub fn (v mut V) generate_main() {
|
||||||
lines_so_far := cgen.lines.join('\n').count('\n') + 5
|
lines_so_far := cgen.lines.join('\n').count('\n') + 5
|
||||||
cgen.genln('')
|
cgen.genln('')
|
||||||
cgen.genln('// Reset the file/line numbers')
|
cgen.genln('// Reset the file/line numbers')
|
||||||
cgen.lines << '#line $lines_so_far "${cescaped_path(os.realpath(cgen.out_path))}"'
|
cgen.lines << '#line $lines_so_far "${cescaped_path(os.real_path(cgen.out_path))}"'
|
||||||
cgen.genln('')
|
cgen.genln('')
|
||||||
}
|
}
|
||||||
// Make sure the main function exists
|
// Make sure the main function exists
|
||||||
|
@ -743,7 +743,7 @@ pub fn (v &V) get_user_files() []string {
|
||||||
}
|
}
|
||||||
if is_internal_module_test {
|
if is_internal_module_test {
|
||||||
// v volt/slack_test.v: compile all .v files to get the environment
|
// v volt/slack_test.v: compile all .v files to get the environment
|
||||||
single_test_v_file := os.realpath(dir)
|
single_test_v_file := os.real_path(dir)
|
||||||
if v.pref.verbosity.is_higher_or_equal(.level_two) {
|
if v.pref.verbosity.is_higher_or_equal(.level_two) {
|
||||||
v.log('> Compiling an internal module _test.v file $single_test_v_file .')
|
v.log('> Compiling an internal module _test.v file $single_test_v_file .')
|
||||||
v.log('> That brings in all other ordinary .v files in the same module too .')
|
v.log('> That brings in all other ordinary .v files in the same module too .')
|
||||||
|
@ -903,7 +903,7 @@ pub fn set_vroot_folder(vroot_path string) {
|
||||||
// VEXE env variable is needed so that compiler.vexe_path()
|
// VEXE env variable is needed so that compiler.vexe_path()
|
||||||
// can return it later to whoever needs it:
|
// can return it later to whoever needs it:
|
||||||
vname := if os.user_os() == 'windows' { 'v.exe' } else { 'v' }
|
vname := if os.user_os() == 'windows' { 'v.exe' } else { 'v' }
|
||||||
os.setenv('VEXE', os.realpath([vroot_path, vname].join(os.path_separator)), true)
|
os.setenv('VEXE', os.real_path([vroot_path, vname].join(os.path_separator)), true)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (v mut V) generate_str_definitions() {
|
pub fn (v mut V) generate_str_definitions() {
|
||||||
|
|
|
@ -162,7 +162,7 @@ fn find_msvc() ?MsvcResult {
|
||||||
return error('Unable to find visual studio')
|
return error('Unable to find visual studio')
|
||||||
}
|
}
|
||||||
return MsvcResult{
|
return MsvcResult{
|
||||||
full_cl_exe_path: os.realpath(vs.exe_path + os.path_separator + 'cl.exe')
|
full_cl_exe_path: os.real_path(vs.exe_path + os.path_separator + 'cl.exe')
|
||||||
exe_path: vs.exe_path
|
exe_path: vs.exe_path
|
||||||
um_lib_path: wk.um_lib_path
|
um_lib_path: wk.um_lib_path
|
||||||
ucrt_lib_path: wk.ucrt_lib_path
|
ucrt_lib_path: wk.ucrt_lib_path
|
||||||
|
@ -187,7 +187,7 @@ pub fn (v mut V) cc_msvc() {
|
||||||
verror('Cannot find MSVC on this OS')
|
verror('Cannot find MSVC on this OS')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
out_name_obj := os.realpath(v.out_name_c + '.obj')
|
out_name_obj := os.real_path(v.out_name_c + '.obj')
|
||||||
// Default arguments
|
// Default arguments
|
||||||
// volatile:ms enables atomic volatile (gcc _Atomic)
|
// volatile:ms enables atomic volatile (gcc _Atomic)
|
||||||
// -w: no warnings
|
// -w: no warnings
|
||||||
|
@ -214,7 +214,7 @@ pub fn (v mut V) cc_msvc() {
|
||||||
else if !v.pref.out_name.ends_with('.exe') {
|
else if !v.pref.out_name.ends_with('.exe') {
|
||||||
v.pref.out_name += '.exe'
|
v.pref.out_name += '.exe'
|
||||||
}
|
}
|
||||||
v.pref.out_name = os.realpath(v.pref.out_name)
|
v.pref.out_name = os.real_path(v.pref.out_name)
|
||||||
// alibs := []string // builtin.o os.o http.o etc
|
// alibs := []string // builtin.o os.o http.o etc
|
||||||
if v.pref.build_mode == .build_module {
|
if v.pref.build_mode == .build_module {
|
||||||
// Compile only
|
// Compile only
|
||||||
|
@ -222,7 +222,7 @@ pub fn (v mut V) cc_msvc() {
|
||||||
}
|
}
|
||||||
else if v.pref.build_mode == .default_mode {
|
else if v.pref.build_mode == .default_mode {
|
||||||
/*
|
/*
|
||||||
b := os.realpath( '$v_modules_path/vlib/builtin.obj' )
|
b := os.real_path( '$v_modules_path/vlib/builtin.obj' )
|
||||||
alibs << '"$b"'
|
alibs << '"$b"'
|
||||||
if !os.exists(b) {
|
if !os.exists(b) {
|
||||||
println('`builtin.obj` not found')
|
println('`builtin.obj` not found')
|
||||||
|
@ -232,7 +232,7 @@ pub fn (v mut V) cc_msvc() {
|
||||||
if imp == 'webview' {
|
if imp == 'webview' {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
alibs << '"' + os.realpath( '$v_modules_path/vlib/${imp}.obj' ) + '"'
|
alibs << '"' + os.real_path( '$v_modules_path/vlib/${imp}.obj' ) + '"'
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
@ -241,7 +241,7 @@ pub fn (v mut V) cc_msvc() {
|
||||||
}
|
}
|
||||||
// The C file we are compiling
|
// The C file we are compiling
|
||||||
// a << '"$TmpPath/$v.out_name_c"'
|
// a << '"$TmpPath/$v.out_name_c"'
|
||||||
a << '"' + os.realpath(v.out_name_c) + '"'
|
a << '"' + os.real_path(v.out_name_c) + '"'
|
||||||
// Emily:
|
// Emily:
|
||||||
// Not all of these are needed (but the compiler should discard them if they are not used)
|
// Not all of these are needed (but the compiler should discard them if they are not used)
|
||||||
// these are the defaults used by msbuild and visual studio
|
// these are the defaults used by msbuild and visual studio
|
||||||
|
@ -307,7 +307,7 @@ fn build_thirdparty_obj_file_with_msvc(path string, moduleflags []CFlag) {
|
||||||
}
|
}
|
||||||
// msvc expects .obj not .o
|
// msvc expects .obj not .o
|
||||||
mut obj_path := '${path}bj'
|
mut obj_path := '${path}bj'
|
||||||
obj_path = os.realpath(obj_path)
|
obj_path = os.real_path(obj_path)
|
||||||
if os.exists(obj_path) {
|
if os.exists(obj_path) {
|
||||||
println('$obj_path already built.')
|
println('$obj_path already built.')
|
||||||
return
|
return
|
||||||
|
@ -320,7 +320,7 @@ fn build_thirdparty_obj_file_with_msvc(path string, moduleflags []CFlag) {
|
||||||
mut cfiles := ''
|
mut cfiles := ''
|
||||||
for file in files {
|
for file in files {
|
||||||
if file.ends_with('.c') {
|
if file.ends_with('.c') {
|
||||||
cfiles += '"' + os.realpath(parent + os.path_separator + file) + '" '
|
cfiles += '"' + os.real_path(parent + os.path_separator + file) + '" '
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
include_string := '-I "$msvc.ucrt_include_path" -I "$msvc.vs_include_path" -I "$msvc.um_include_path" -I "$msvc.shared_include_path"'
|
include_string := '-I "$msvc.ucrt_include_path" -I "$msvc.vs_include_path" -I "$msvc.um_include_path" -I "$msvc.shared_include_path"'
|
||||||
|
@ -392,7 +392,7 @@ fn (cflags []CFlag) msvc_string_flags() MsvcStringFlags {
|
||||||
}
|
}
|
||||||
mut lpaths := []string
|
mut lpaths := []string
|
||||||
for l in lib_paths {
|
for l in lib_paths {
|
||||||
lpaths << '/LIBPATH:"' + os.realpath(l) + '"'
|
lpaths << '/LIBPATH:"' + os.real_path(l) + '"'
|
||||||
}
|
}
|
||||||
return MsvcStringFlags{
|
return MsvcStringFlags{
|
||||||
real_libs:real_libs
|
real_libs:real_libs
|
||||||
|
|
|
@ -561,7 +561,7 @@ fn (s mut Scanner) scan() ScanRes {
|
||||||
return scan_res(.string, s.fn_name)
|
return scan_res(.string, s.fn_name)
|
||||||
}
|
}
|
||||||
if name == 'FILE' {
|
if name == 'FILE' {
|
||||||
return scan_res(.string, cescaped_path(os.realpath(s.file_path)))
|
return scan_res(.string, cescaped_path(os.real_path(s.file_path)))
|
||||||
}
|
}
|
||||||
if name == 'LINE' {
|
if name == 'LINE' {
|
||||||
return scan_res(.string, (s.line_nr + 1).str())
|
return scan_res(.string, (s.line_nr + 1).str())
|
||||||
|
|
|
@ -22,8 +22,8 @@ pub fn full_path_to_v(dirs_in int) string {
|
||||||
vexec := os.join_path(path, vname)
|
vexec := os.join_path(path, vname)
|
||||||
/*
|
/*
|
||||||
args := os.args
|
args := os.args
|
||||||
vreal := os.realpath('v')
|
vreal := os.real_path('v')
|
||||||
myself := os.realpath( os.executable() )
|
myself := os.real_path( os.executable() )
|
||||||
wd := os.getwd()
|
wd := os.getwd()
|
||||||
println('args are: $args')
|
println('args are: $args')
|
||||||
println('vreal : $vreal')
|
println('vreal : $vreal')
|
||||||
|
@ -56,9 +56,9 @@ pub fn run_repl_file(wd string, vexec string, file string) ?string {
|
||||||
|
|
||||||
fname := os.file_name( file )
|
fname := os.file_name( file )
|
||||||
|
|
||||||
input_temporary_filename := os.realpath(os.join_path( wd, 'input_temporary_filename.txt'))
|
input_temporary_filename := os.real_path(os.join_path( wd, 'input_temporary_filename.txt'))
|
||||||
os.write_file(input_temporary_filename, input)
|
os.write_file(input_temporary_filename, input)
|
||||||
os.write_file( os.realpath(os.join_path( wd, 'original.txt' ) ), fcontent )
|
os.write_file( os.real_path(os.join_path( wd, 'original.txt' ) ), fcontent )
|
||||||
rcmd := '"$vexec" repl -replfolder "$wd" -replprefix "${fname}." < $input_temporary_filename'
|
rcmd := '"$vexec" repl -replfolder "$wd" -replprefix "${fname}." < $input_temporary_filename'
|
||||||
r := os.exec(rcmd) or {
|
r := os.exec(rcmd) or {
|
||||||
os.rm(input_temporary_filename)
|
os.rm(input_temporary_filename)
|
||||||
|
|
|
@ -17,5 +17,5 @@ fn get_vtmp_folder() string {
|
||||||
|
|
||||||
fn get_vtmp_filename(base_file_name string, postfix string) string {
|
fn get_vtmp_filename(base_file_name string, postfix string) string {
|
||||||
vtmp := get_vtmp_folder()
|
vtmp := get_vtmp_folder()
|
||||||
return os.realpath(os.join_path(vtmp, os.file_name(os.realpath(base_file_name)) + postfix))
|
return os.real_path(os.join_path(vtmp, os.file_name(os.real_path(base_file_name)) + postfix))
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ pub fn (l mut Log) set_output_level(level LogLevel) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (l mut Log) set_full_logpath(full_log_path string) {
|
pub fn (l mut Log) set_full_logpath(full_log_path string) {
|
||||||
rlog_file := os.realpath( full_log_path )
|
rlog_file := os.real_path( full_log_path )
|
||||||
l.set_output_label( os.file_name( rlog_file ) )
|
l.set_output_label( os.file_name( rlog_file ) )
|
||||||
l.set_output_path( os.base_dir( rlog_file ) )
|
l.set_output_path( os.base_dir( rlog_file ) )
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ pub fn (l mut Log) set_output_label(label string){
|
||||||
pub fn (l mut Log) set_output_path(output_file_path string) {
|
pub fn (l mut Log) set_output_path(output_file_path string) {
|
||||||
if l.ofile.is_opened() { l.ofile.close() }
|
if l.ofile.is_opened() { l.ofile.close() }
|
||||||
l.output_to_file = true
|
l.output_to_file = true
|
||||||
l.output_file_name = os.join_path( os.realpath( output_file_path ) , l.output_label )
|
l.output_file_name = os.join_path( os.real_path( output_file_path ) , l.output_label )
|
||||||
ofile := os.open_append( l.output_file_name ) or {
|
ofile := os.open_append( l.output_file_name ) or {
|
||||||
panic('error while opening log file ${l.output_file_name} for appending')
|
panic('error while opening log file ${l.output_file_name} for appending')
|
||||||
}
|
}
|
||||||
|
|
14
vlib/os/os.v
14
vlib/os/os.v
|
@ -171,8 +171,8 @@ pub fn cp_r(osource_path, odest_path string, overwrite bool) ?bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cp_all(osource_path, odest_path string, overwrite bool) ?bool {
|
pub fn cp_all(osource_path, odest_path string, overwrite bool) ?bool {
|
||||||
source_path := os.realpath(osource_path)
|
source_path := os.real_path(osource_path)
|
||||||
dest_path := os.realpath(odest_path)
|
dest_path := os.real_path(odest_path)
|
||||||
if !os.exists(source_path) {
|
if !os.exists(source_path) {
|
||||||
return error("Source path doesn\'t exist")
|
return error("Source path doesn\'t exist")
|
||||||
}
|
}
|
||||||
|
@ -530,7 +530,7 @@ pub fn is_executable(path string) bool {
|
||||||
// 02 Write-only
|
// 02 Write-only
|
||||||
// 04 Read-only
|
// 04 Read-only
|
||||||
// 06 Read and write
|
// 06 Read and write
|
||||||
p := os.realpath( path )
|
p := os.real_path( path )
|
||||||
return ( os.exists( p ) && p.ends_with('.exe') )
|
return ( os.exists( p ) && p.ends_with('.exe') )
|
||||||
} $else {
|
} $else {
|
||||||
return C.access(path.str, X_OK) != -1
|
return C.access(path.str, X_OK) != -1
|
||||||
|
@ -874,7 +874,7 @@ fn executable_fallback() string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exepath = os.realpath(exepath)
|
exepath = os.real_path(exepath)
|
||||||
return exepath
|
return exepath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -972,7 +972,7 @@ pub fn getwd() string {
|
||||||
// Also https://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html
|
// Also https://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html
|
||||||
// and https://insanecoding.blogspot.com/2007/11/implementing-realpath-in-c.html
|
// and https://insanecoding.blogspot.com/2007/11/implementing-realpath-in-c.html
|
||||||
// NB: this particular rabbit hole is *deep* ...
|
// NB: this particular rabbit hole is *deep* ...
|
||||||
pub fn realpath(fpath string) string {
|
pub fn real_path(fpath string) string {
|
||||||
mut fullpath := vcalloc(MAX_PATH)
|
mut fullpath := vcalloc(MAX_PATH)
|
||||||
mut ret := charptr(0)
|
mut ret := charptr(0)
|
||||||
$if windows {
|
$if windows {
|
||||||
|
@ -1184,10 +1184,10 @@ pub const (
|
||||||
// It gives a convenient way to access program resources like images, fonts, sounds and so on,
|
// It gives a convenient way to access program resources like images, fonts, sounds and so on,
|
||||||
// *no matter* how the program was started, and what is the current working directory.
|
// *no matter* how the program was started, and what is the current working directory.
|
||||||
pub fn resource_abs_path(path string) string {
|
pub fn resource_abs_path(path string) string {
|
||||||
mut base_path := os.realpath(os.dir(os.executable()))
|
mut base_path := os.real_path(os.dir(os.executable()))
|
||||||
vresource := os.getenv('V_RESOURCE_PATH')
|
vresource := os.getenv('V_RESOURCE_PATH')
|
||||||
if vresource.len != 0 {
|
if vresource.len != 0 {
|
||||||
base_path = vresource
|
base_path = vresource
|
||||||
}
|
}
|
||||||
return os.realpath(os.join_path(base_path, path))
|
return os.real_path(os.join_path(base_path, path))
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ pub fn mkdir(path string) ?bool {
|
||||||
if path == '.' {
|
if path == '.' {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
apath := os.realpath(path)
|
apath := os.real_path(path)
|
||||||
/*
|
/*
|
||||||
$if linux {
|
$if linux {
|
||||||
$if !android {
|
$if !android {
|
||||||
|
|
|
@ -62,7 +62,7 @@ fn test_write_and_read_bytes() {
|
||||||
file_name := './byte_reader_writer.tst'
|
file_name := './byte_reader_writer.tst'
|
||||||
payload := [`I`, `D`, `D`, `Q`, `D`]
|
payload := [`I`, `D`, `D`, `Q`, `D`]
|
||||||
|
|
||||||
mut file_write := os.create(os.realpath(file_name)) or {
|
mut file_write := os.create(os.real_path(file_name)) or {
|
||||||
eprintln('failed to create file $file_name')
|
eprintln('failed to create file $file_name')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ fn test_write_and_read_bytes() {
|
||||||
|
|
||||||
assert payload.len == os.file_size(file_name)
|
assert payload.len == os.file_size(file_name)
|
||||||
|
|
||||||
mut file_read := os.open(os.realpath(file_name)) or {
|
mut file_read := os.open(os.real_path(file_name)) or {
|
||||||
eprintln('failed to open file $file_name')
|
eprintln('failed to open file $file_name')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,7 @@ pub fn (f mut File) writeln(s string) {
|
||||||
// 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 {
|
||||||
if path == '.' { return true }
|
if path == '.' { return true }
|
||||||
apath := os.realpath( path )
|
apath := os.real_path( path )
|
||||||
if !C.CreateDirectory(apath.to_wide(), 0) {
|
if !C.CreateDirectory(apath.to_wide(), 0) {
|
||||||
return error('mkdir failed for "$apath", because CreateDirectory returned ' + get_error_msg(int(C.GetLastError())))
|
return error('mkdir failed for "$apath", because CreateDirectory returned ' + get_error_msg(int(C.GetLastError())))
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ pub:
|
||||||
table &table.Table
|
table &table.Table
|
||||||
checker checker.Checker
|
checker checker.Checker
|
||||||
os pref.OS // the OS to build for
|
os pref.OS // the OS to build for
|
||||||
compiled_dir string // contains os.realpath() of the dir of the final file beeing compiled, or the dir itself when doing `v .`
|
compiled_dir string // contains os.real_path() of the dir of the final file beeing compiled, or the dir itself when doing `v .`
|
||||||
module_path string
|
module_path string
|
||||||
mut:
|
mut:
|
||||||
module_search_paths []string
|
module_search_paths []string
|
||||||
|
|
|
@ -21,7 +21,7 @@ pub fn (p mut Preferences) fill_with_defaults() {
|
||||||
for i, path in p.lookup_path {
|
for i, path in p.lookup_path {
|
||||||
p.lookup_path[i] = path.replace('@vlib', vlib_path).replace('@vmodules', default_module_path)
|
p.lookup_path[i] = path.replace('@vlib', vlib_path).replace('@vmodules', default_module_path)
|
||||||
}
|
}
|
||||||
rpath := os.realpath(p.path)
|
rpath := os.real_path(p.path)
|
||||||
if p.out_name == ''{
|
if p.out_name == ''{
|
||||||
filename := os.file_name(rpath).trim_space()
|
filename := os.file_name(rpath).trim_space()
|
||||||
mut base := filename.all_before_last('.')
|
mut base := filename.all_before_last('.')
|
||||||
|
@ -79,7 +79,7 @@ pub fn vexe_path() string {
|
||||||
if vexe != '' {
|
if vexe != '' {
|
||||||
return vexe
|
return vexe
|
||||||
}
|
}
|
||||||
real_vexe_path := os.realpath(os.executable())
|
real_vexe_path := os.real_path(os.executable())
|
||||||
os.setenv('VEXE', real_vexe_path, true)
|
os.setenv('VEXE', real_vexe_path, true)
|
||||||
return real_vexe_path
|
return real_vexe_path
|
||||||
}
|
}
|
||||||
|
|
|
@ -571,7 +571,7 @@ pub fn (s mut Scanner) scan() token.Token {
|
||||||
return s.scan_res(.string, s.fn_name)
|
return s.scan_res(.string, s.fn_name)
|
||||||
}
|
}
|
||||||
if name == 'FILE' {
|
if name == 'FILE' {
|
||||||
return s.scan_res(.string, cescaped_path(os.realpath(s.file_path)))
|
return s.scan_res(.string, cescaped_path(os.real_path(s.file_path)))
|
||||||
}
|
}
|
||||||
if name == 'LINE' {
|
if name == 'LINE' {
|
||||||
return s.scan_res(.string, (s.line_nr + 1).str())
|
return s.scan_res(.string, (s.line_nr + 1).str())
|
||||||
|
|
Loading…
Reference in New Issue