mirror of
https://github.com/vlang/v.git
synced 2025-09-08 14:51:53 -04:00
Revert "os: deprecate os.getwd
in favor of os.get_current_dir
(part 1) (#22966)"
This reverts commit 93009823f992176166bf5e5d90c9627adb46bdc0.
This commit is contained in:
parent
93009823f9
commit
b801083f13
@ -109,7 +109,7 @@ fn (mut c Context) amalgamate() ! {
|
|||||||
if c.config.input_files.len == 0 {
|
if c.config.input_files.len == 0 {
|
||||||
// source += '/* ########## stdin */\n'
|
// source += '/* ########## stdin */\n'
|
||||||
// if there are no input files, read from stdin
|
// if there are no input files, read from stdin
|
||||||
local_dir := os.get_current_dir()
|
local_dir := os.getwd()
|
||||||
source += c.handle_includes(local_dir, os.get_raw_lines_joined())!
|
source += c.handle_includes(local_dir, os.get_raw_lines_joined())!
|
||||||
// source += '/* ########## stdin end */\n'
|
// source += '/* ########## stdin end */\n'
|
||||||
} else {
|
} else {
|
||||||
|
@ -14,7 +14,7 @@ step := os.args[3] or { '500_000' }.int()
|
|||||||
os.chdir(os.dir(@VEXE))!
|
os.chdir(os.dir(@VEXE))!
|
||||||
vcmd := 'v ${flags} cmd/tools/bench/map_clear.v'
|
vcmd := 'v ${flags} cmd/tools/bench/map_clear.v'
|
||||||
|
|
||||||
println('>> start: ${start} | end: ${end} | step: ${step} | workdir: "${os.get_current_dir()}" | flags: "${flags}" | vcmd: "${vcmd}"')
|
println('>> start: ${start} | end: ${end} | step: ${step} | workdir: "${os.getwd()}" | flags: "${flags}" | vcmd: "${vcmd}"')
|
||||||
assert os.system(vcmd) == 0
|
assert os.system(vcmd) == 0
|
||||||
|
|
||||||
println('running...')
|
println('running...')
|
||||||
|
@ -53,7 +53,7 @@ fn main() {
|
|||||||
elog('fast_job PATH: ${os.getenv('PATH')}')
|
elog('fast_job PATH: ${os.getenv('PATH')}')
|
||||||
|
|
||||||
os.chdir(fast_dir)!
|
os.chdir(fast_dir)!
|
||||||
elog('fast_job start in os.get_current_dir(): ${os.get_current_dir()}')
|
elog('fast_job start in os.getwd(): ${os.getwd()}')
|
||||||
|
|
||||||
defer {
|
defer {
|
||||||
elog('fast_job end')
|
elog('fast_job end')
|
||||||
|
@ -370,7 +370,7 @@ pub fn (mut ts TestSession) add(file string) {
|
|||||||
pub fn (mut ts TestSession) test() {
|
pub fn (mut ts TestSession) test() {
|
||||||
// Ensure that .tmp.c files generated from compiling _test.v files,
|
// Ensure that .tmp.c files generated from compiling _test.v files,
|
||||||
// are easy to delete at the end, *without* affecting the existing ones.
|
// are easy to delete at the end, *without* affecting the existing ones.
|
||||||
current_wd := os.get_current_dir()
|
current_wd := os.getwd()
|
||||||
if current_wd == os.wd_at_startup && current_wd == ts.vroot {
|
if current_wd == os.wd_at_startup && current_wd == ts.vroot {
|
||||||
ts.root_relative = true
|
ts.root_relative = true
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ mut:
|
|||||||
|
|
||||||
fn new_context() Context {
|
fn new_context() Context {
|
||||||
return Context{
|
return Context{
|
||||||
cwd: os.get_current_dir()
|
cwd: os.getwd()
|
||||||
commit_after: 'master'
|
commit_after: 'master'
|
||||||
warmups: 4
|
warmups: 4
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ fn main() {
|
|||||||
eprintln('> args: ${args} | context: ${ctx}')
|
eprintln('> args: ${args} | context: ${ctx}')
|
||||||
}
|
}
|
||||||
if ctx.show_wd {
|
if ctx.show_wd {
|
||||||
ctx.println('WORK_DIR=${os.get_current_dir()}')
|
ctx.println('WORK_DIR=${os.getwd()}')
|
||||||
}
|
}
|
||||||
if ctx.show_env {
|
if ctx.show_env {
|
||||||
all := os.environ()
|
all := os.environ()
|
||||||
|
@ -87,9 +87,9 @@ fn get_abs_path(path string) string {
|
|||||||
if os.is_abs_path(path) {
|
if os.is_abs_path(path) {
|
||||||
return path
|
return path
|
||||||
} else if path.starts_with('./') {
|
} else if path.starts_with('./') {
|
||||||
return os.join_path(os.get_current_dir(), path[2..])
|
return os.join_path(os.getwd(), path[2..])
|
||||||
} else {
|
} else {
|
||||||
return os.join_path(os.get_current_dir(), path)
|
return os.join_path(os.getwd(), path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ fn get_vdoctor_output(is_verbose bool) string {
|
|||||||
fn get_v_build_output(is_verbose bool, is_yes bool, file_path string) string {
|
fn get_v_build_output(is_verbose bool, is_yes bool, file_path string) string {
|
||||||
mut vexe := os.getenv('VEXE')
|
mut vexe := os.getenv('VEXE')
|
||||||
// prepare a V compiler with -g to have better backtraces if possible
|
// prepare a V compiler with -g to have better backtraces if possible
|
||||||
wd := os.get_current_dir()
|
wd := os.getwd()
|
||||||
os.chdir(vroot) or {}
|
os.chdir(vroot) or {}
|
||||||
verbose_flag := if is_verbose { '-v' } else { '' }
|
verbose_flag := if is_verbose { '-v' } else { '' }
|
||||||
vdbg_path := $if windows { '${vroot}/vdbg.exe' } $else { '${vroot}/vdbg' }
|
vdbg_path := $if windows { '${vroot}/vdbg.exe' } $else { '${vroot}/vdbg' }
|
||||||
|
@ -149,7 +149,7 @@ fn normalize_path(path string) string {
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
mut ctx := Context{}
|
mut ctx := Context{}
|
||||||
ctx.working_folder = normalize_path(os.real_path(os.get_current_dir()))
|
ctx.working_folder = normalize_path(os.real_path(os.getwd()))
|
||||||
mut fp := flag.new_flag_parser(os.args#[1..])
|
mut fp := flag.new_flag_parser(os.args#[1..])
|
||||||
fp.application('v cover')
|
fp.application('v cover')
|
||||||
fp.version('0.0.2')
|
fp.version('0.0.2')
|
||||||
|
@ -131,7 +131,7 @@ fn init_project(cmd Command) ! {
|
|||||||
mut c := Create{
|
mut c := Create{
|
||||||
template: get_template(cmd)
|
template: get_template(cmd)
|
||||||
}
|
}
|
||||||
dir_name := check_name(os.file_name(os.get_current_dir()))
|
dir_name := check_name(os.file_name(os.getwd()))
|
||||||
if !os.exists('v.mod') {
|
if !os.exists('v.mod') {
|
||||||
mod_dir_has_hyphens := dir_name.contains('-')
|
mod_dir_has_hyphens := dir_name.contains('-')
|
||||||
c.name = if mod_dir_has_hyphens { dir_name.replace('-', '_') } else { dir_name }
|
c.name = if mod_dir_has_hyphens { dir_name.replace('-', '_') } else { dir_name }
|
||||||
|
@ -99,13 +99,13 @@ fn (mut a App) collect_info() {
|
|||||||
a.line('OS', '${os_kind}, ${os_details}')
|
a.line('OS', '${os_kind}, ${os_details}')
|
||||||
a.line('Processor', arch_details.join(', '))
|
a.line('Processor', arch_details.join(', '))
|
||||||
a.println('')
|
a.println('')
|
||||||
get_current_dir := os.get_current_dir()
|
getwd := os.getwd()
|
||||||
vmodules := os.vmodules_dir()
|
vmodules := os.vmodules_dir()
|
||||||
vtmp_dir := os.vtmp_dir()
|
vtmp_dir := os.vtmp_dir()
|
||||||
vexe := os.getenv('VEXE')
|
vexe := os.getenv('VEXE')
|
||||||
vroot := os.dir(vexe)
|
vroot := os.dir(vexe)
|
||||||
os.chdir(vroot) or {}
|
os.chdir(vroot) or {}
|
||||||
a.line('get_current_dir', get_current_dir)
|
a.line('getwd', getwd)
|
||||||
a.line('vexe', vexe)
|
a.line('vexe', vexe)
|
||||||
a.line('vexe mtime', time.unix(os.file_last_mod_unix(vexe)).str())
|
a.line('vexe mtime', time.unix(os.file_last_mod_unix(vexe)).str())
|
||||||
a.println('')
|
a.println('')
|
||||||
|
@ -35,6 +35,6 @@ fn setup_symlink_github() {
|
|||||||
eprintln(' On windows, use `.\\v.exe symlink` instead.')
|
eprintln(' On windows, use `.\\v.exe symlink` instead.')
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
content += '\n${os.get_current_dir()}\n'
|
content += '\n${os.getwd()}\n'
|
||||||
os.write_file(os.getenv('GITHUB_PATH'), content) or { panic('Failed to write to GITHUB_PATH.') }
|
os.write_file(os.getenv('GITHUB_PATH'), content) or { panic('Failed to write to GITHUB_PATH.') }
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ pub fn is_abs_path(path string) bool {
|
|||||||
// with the given `path` (if the `path` is relative)
|
// with the given `path` (if the `path` is relative)
|
||||||
// and returns the absolute path representation.
|
// and returns the absolute path representation.
|
||||||
pub fn abs_path(path string) string {
|
pub fn abs_path(path string) string {
|
||||||
wd := get_current_dir()
|
wd := getwd()
|
||||||
if path == '' {
|
if path == '' {
|
||||||
return wd
|
return wd
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ fn test_norm_path() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn test_abs_path() {
|
fn test_abs_path() {
|
||||||
wd := get_current_dir()
|
wd := getwd()
|
||||||
wd_w_sep := wd + path_separator
|
wd_w_sep := wd + path_separator
|
||||||
$if windows {
|
$if windows {
|
||||||
assert abs_path('path/to/file.v') == '${wd_w_sep}path\\to\\file.v'
|
assert abs_path('path/to/file.v') == '${wd_w_sep}path\\to\\file.v'
|
||||||
@ -147,7 +147,7 @@ fn test_abs_path() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn test_existing_path() {
|
fn test_existing_path() {
|
||||||
wd := get_current_dir()
|
wd := getwd()
|
||||||
$if windows {
|
$if windows {
|
||||||
assert existing_path('') or { '' } == ''
|
assert existing_path('') or { '' } == ''
|
||||||
assert existing_path('..') or { '' } == '..'
|
assert existing_path('..') or { '' } == '..'
|
||||||
|
@ -10,7 +10,7 @@ fn test_find_abs_path_of_executable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
original_path := os.getenv('PATH')
|
original_path := os.getenv('PATH')
|
||||||
original_wdir := os.get_current_dir()
|
original_wdir := os.getwd()
|
||||||
defer {
|
defer {
|
||||||
os.chdir(original_wdir) or {}
|
os.chdir(original_wdir) or {}
|
||||||
}
|
}
|
||||||
|
@ -756,16 +756,8 @@ pub fn chdir(path string) ! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getwd returns the absolute path of the current directory.
|
// getwd returns the absolute path of the current directory.
|
||||||
// @[deprecated: 'use `get_current_dir()` instead']
|
|
||||||
// TODO: uncomment the deprecation here, after 2024-11-27
|
|
||||||
@[deprecated_after: '2024-12-24']
|
|
||||||
pub fn getwd() string {
|
|
||||||
return get_current_dir()
|
|
||||||
}
|
|
||||||
|
|
||||||
// get_current_dir returns the absolute path of the current directory.
|
|
||||||
@[manualfree]
|
@[manualfree]
|
||||||
pub fn get_current_dir() string {
|
pub fn getwd() string {
|
||||||
unsafe {
|
unsafe {
|
||||||
buf := [max_path_buffer_size]u8{}
|
buf := [max_path_buffer_size]u8{}
|
||||||
$if windows {
|
$if windows {
|
||||||
|
@ -7,7 +7,7 @@ import strings
|
|||||||
|
|
||||||
pub const max_path_len = 4096
|
pub const max_path_len = 4096
|
||||||
|
|
||||||
pub const wd_at_startup = get_current_dir()
|
pub const wd_at_startup = getwd()
|
||||||
|
|
||||||
const f_ok = 0
|
const f_ok = 0
|
||||||
|
|
||||||
|
@ -152,10 +152,6 @@ pub fn read_file(s string) !string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn getwd() string {
|
pub fn getwd() string {
|
||||||
return get_current_dir()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_current_dir() string {
|
|
||||||
res := ''
|
res := ''
|
||||||
#res.str = $process.cwd()
|
#res.str = $process.cwd()
|
||||||
|
|
||||||
|
@ -445,7 +445,7 @@ fn test_realpath_removes_dots() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn test_realpath_absolutizes_existing_relative_paths() {
|
fn test_realpath_absolutizes_existing_relative_paths() {
|
||||||
old_wd := os.get_current_dir()
|
old_wd := os.getwd()
|
||||||
defer {
|
defer {
|
||||||
os.chdir(old_wd) or { panic(err) }
|
os.chdir(old_wd) or { panic(err) }
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ fn test_getpid() {
|
|||||||
|
|
||||||
fn test_set_work_folder() {
|
fn test_set_work_folder() {
|
||||||
new_work_folder := os.real_path(os.temp_dir())
|
new_work_folder := os.real_path(os.temp_dir())
|
||||||
parent_working_folder := os.get_current_dir()
|
parent_working_folder := os.getwd()
|
||||||
dump(new_work_folder)
|
dump(new_work_folder)
|
||||||
dump(parent_working_folder)
|
dump(parent_working_folder)
|
||||||
if new_work_folder == parent_working_folder {
|
if new_work_folder == parent_working_folder {
|
||||||
@ -57,7 +57,7 @@ fn test_set_work_folder() {
|
|||||||
child_work_folder := output.find_between('stdout, WORK_DIR=', '\n').trim_space()
|
child_work_folder := output.find_between('stdout, WORK_DIR=', '\n').trim_space()
|
||||||
dump(child_work_folder)
|
dump(child_work_folder)
|
||||||
assert child_work_folder == new_work_folder
|
assert child_work_folder == new_work_folder
|
||||||
new_parent_work_folder := os.get_current_dir()
|
new_parent_work_folder := os.getwd()
|
||||||
dump(new_parent_work_folder)
|
dump(new_parent_work_folder)
|
||||||
assert new_parent_work_folder == parent_working_folder
|
assert new_parent_work_folder == parent_working_folder
|
||||||
assert new_parent_work_folder != child_work_folder
|
assert new_parent_work_folder != child_work_folder
|
||||||
|
@ -405,7 +405,7 @@ pub fn (b &Builder) find_module_path(mod string, fpath string) !string {
|
|||||||
module_lookup_paths << vmod_file_location.vmod_folder
|
module_lookup_paths << vmod_file_location.vmod_folder
|
||||||
}
|
}
|
||||||
module_lookup_paths << b.module_search_paths
|
module_lookup_paths << b.module_search_paths
|
||||||
module_lookup_paths << os.get_current_dir()
|
module_lookup_paths << os.getwd()
|
||||||
// go up through parents looking for modules a folder.
|
// go up through parents looking for modules a folder.
|
||||||
// we need a proper solution that works most of the time. look at vdoc.get_parent_mod
|
// we need a proper solution that works most of the time. look at vdoc.get_parent_mod
|
||||||
if fpath.contains(os.path_separator + 'modules' + os.path_separator) {
|
if fpath.contains(os.path_separator + 'modules' + os.path_separator) {
|
||||||
|
@ -636,7 +636,7 @@ pub fn (mut v Builder) cc() {
|
|||||||
vdir := os.dir(vexe)
|
vdir := os.dir(vexe)
|
||||||
mut tried_compilation_commands := []string{}
|
mut tried_compilation_commands := []string{}
|
||||||
mut tcc_output := os.Result{}
|
mut tcc_output := os.Result{}
|
||||||
original_pwd := os.get_current_dir()
|
original_pwd := os.getwd()
|
||||||
for {
|
for {
|
||||||
// try to compile with the chosen compiler
|
// try to compile with the chosen compiler
|
||||||
// if compilation fails, retry again with another
|
// if compilation fails, retry again with another
|
||||||
@ -1109,7 +1109,7 @@ fn (mut v Builder) build_thirdparty_obj_file(mod string, path string, moduleflag
|
|||||||
println(rebuild_reason_message)
|
println(rebuild_reason_message)
|
||||||
}
|
}
|
||||||
// prepare for tcc, it needs relative paths to thirdparty/tcc to work:
|
// prepare for tcc, it needs relative paths to thirdparty/tcc to work:
|
||||||
current_folder := os.get_current_dir()
|
current_folder := os.getwd()
|
||||||
os.chdir(v.pref.vroot) or {}
|
os.chdir(v.pref.vroot) or {}
|
||||||
|
|
||||||
mut all_options := []string{}
|
mut all_options := []string{}
|
||||||
|
@ -28,7 +28,7 @@ fn check_if_output_folder_is_writable(pref_ &pref.Preferences) {
|
|||||||
// without a folder component, just use the current folder instead:
|
// without a folder component, just use the current folder instead:
|
||||||
mut output_folder := odir
|
mut output_folder := odir
|
||||||
if odir.len == pref_.out_name.len {
|
if odir.len == pref_.out_name.len {
|
||||||
output_folder = os.get_current_dir()
|
output_folder = os.getwd()
|
||||||
}
|
}
|
||||||
os.ensure_folder_is_writable(output_folder) or {
|
os.ensure_folder_is_writable(output_folder) or {
|
||||||
// An early error here, is better than an unclear C error later:
|
// An early error here, is better than an unclear C error later:
|
||||||
|
@ -176,7 +176,7 @@ pub fn (mut b Builder) find_invalidated_modules_by_files(all_files []string) []s
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn (mut b Builder) v_build_module(vexe string, imp_path string) {
|
fn (mut b Builder) v_build_module(vexe string, imp_path string) {
|
||||||
pwd := os.get_current_dir()
|
pwd := os.getwd()
|
||||||
defer {
|
defer {
|
||||||
os.chdir(pwd) or {}
|
os.chdir(pwd) or {}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ fn (mut c Checker) ident_autocomplete(node ast.Ident) {
|
|||||||
// Mini LS hack (v -line-info "a.v:16")
|
// Mini LS hack (v -line-info "a.v:16")
|
||||||
println(
|
println(
|
||||||
'checker.ident() info.line_nr=${c.pref.linfo.line_nr} node.line_nr=${node.pos.line_nr} ' +
|
'checker.ident() info.line_nr=${c.pref.linfo.line_nr} node.line_nr=${node.pos.line_nr} ' +
|
||||||
' pwd="${os.get_current_dir()}" file="${c.file.path}", ' +
|
' pwd="${os.getwd()}" file="${c.file.path}", ' +
|
||||||
' pref.linfo.path="${c.pref.linfo.path}" node.name="${node.name}" expr="${c.pref.linfo.expr}"')
|
' pref.linfo.path="${c.pref.linfo.path}" node.name="${node.name}" expr="${c.pref.linfo.expr}"')
|
||||||
// Make sure this ident is on the same line as requeste, in the same file, and has the same name
|
// Make sure this ident is on the same line as requeste, in the same file, and has the same name
|
||||||
same_line := node.pos.line_nr in [c.pref.linfo.line_nr - 1, c.pref.linfo.line_nr + 1, c.pref.linfo.line_nr]
|
same_line := node.pos.line_nr in [c.pref.linfo.line_nr - 1, c.pref.linfo.line_nr + 1, c.pref.linfo.line_nr]
|
||||||
@ -21,7 +21,7 @@ fn (mut c Checker) ident_autocomplete(node ast.Ident) {
|
|||||||
if !same_name {
|
if !same_name {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
abs_path := os.join_path(os.get_current_dir(), c.file.path)
|
abs_path := os.join_path(os.getwd(), c.file.path)
|
||||||
if c.pref.linfo.path !in [c.file.path, abs_path] {
|
if c.pref.linfo.path !in [c.file.path, abs_path] {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -422,8 +422,7 @@ pub fn (mut c Checker) check_files(ast_files []&ast.File) {
|
|||||||
// After the main checker run, run the line info check, print line info, and exit (if it's present)
|
// After the main checker run, run the line info check, print line info, and exit (if it's present)
|
||||||
if !c.pref.linfo.is_running && c.pref.line_info != '' { //'' && c.pref.linfo.line_nr == 0 {
|
if !c.pref.linfo.is_running && c.pref.line_info != '' { //'' && c.pref.linfo.line_nr == 0 {
|
||||||
// c.do_line_info(c.pref.line_info, ast_files)
|
// c.do_line_info(c.pref.line_info, ast_files)
|
||||||
println('setting is_running=true, pref.path=${c.pref.linfo.path} curdir' +
|
println('setting is_running=true, pref.path=${c.pref.linfo.path} curdir' + os.getwd())
|
||||||
os.get_current_dir())
|
|
||||||
c.pref.linfo.is_running = true
|
c.pref.linfo.is_running = true
|
||||||
for i, file in ast_files {
|
for i, file in ast_files {
|
||||||
// println(file.path)
|
// println(file.path)
|
||||||
@ -433,8 +432,7 @@ pub fn (mut c Checker) check_files(ast_files []&ast.File) {
|
|||||||
exit(0)
|
exit(0)
|
||||||
} else if file.path.starts_with('./') {
|
} else if file.path.starts_with('./') {
|
||||||
// Maybe it's a "./foo.v", linfo.path has an absolute path
|
// Maybe it's a "./foo.v", linfo.path has an absolute path
|
||||||
abs_path := os.join_path(os.get_current_dir(), file.path).replace('/./',
|
abs_path := os.join_path(os.getwd(), file.path).replace('/./', '/') // TODO: join_path shouldn't have /./
|
||||||
'/') // TODO: join_path shouldn't have /./
|
|
||||||
if abs_path == c.pref.linfo.path {
|
if abs_path == c.pref.linfo.path {
|
||||||
c.check_files([ast_files[i]])
|
c.check_files([ast_files[i]])
|
||||||
exit(0)
|
exit(0)
|
||||||
|
@ -202,7 +202,7 @@ fn (mut p Parser) free_scanner() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const normalised_working_folder = (os.real_path(os.get_current_dir()) + os.path_separator).replace('\\',
|
const normalised_working_folder = (os.real_path(os.getwd()) + os.path_separator).replace('\\',
|
||||||
'/')
|
'/')
|
||||||
|
|
||||||
pub fn (mut p Parser) set_path(path string) {
|
pub fn (mut p Parser) set_path(path string) {
|
||||||
|
@ -891,7 +891,7 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
|
|||||||
res.is_o = true
|
res.is_o = true
|
||||||
}
|
}
|
||||||
if !os.is_abs_path(res.out_name) {
|
if !os.is_abs_path(res.out_name) {
|
||||||
res.out_name = os.join_path(os.get_current_dir(), res.out_name)
|
res.out_name = os.join_path(os.getwd(), res.out_name)
|
||||||
}
|
}
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ pub fn new_scanner_file(file_path string, comments_mode CommentsMode, pref_ &pre
|
|||||||
mut raw_text := util.read_file(file_path) or { return err }
|
mut raw_text := util.read_file(file_path) or { return err }
|
||||||
if pref_.line_info != '' {
|
if pref_.line_info != '' {
|
||||||
// Add line info expr to the scanner text
|
// Add line info expr to the scanner text
|
||||||
abs_path := os.join_path(os.get_current_dir(), file_path)
|
abs_path := os.join_path(os.getwd(), file_path)
|
||||||
if pref_.linfo.path in [file_path, abs_path] {
|
if pref_.linfo.path in [file_path, abs_path] {
|
||||||
raw_text = pref.add_line_info_expr_to_program_text(raw_text, pref_.linfo)
|
raw_text = pref.add_line_info_expr_to_program_text(raw_text, pref_.linfo)
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ pub fn full_path_to_v(dirs_in int) string {
|
|||||||
args := os.args
|
args := os.args
|
||||||
vreal := os.real_path('v')
|
vreal := os.real_path('v')
|
||||||
myself := os.real_path( os.executable() )
|
myself := os.real_path( os.executable() )
|
||||||
wd := os.get_current_dir()
|
wd := os.getwd()
|
||||||
println('args are: $args')
|
println('args are: $args')
|
||||||
println('vreal : $vreal')
|
println('vreal : $vreal')
|
||||||
println('myself : $myself')
|
println('myself : $myself')
|
||||||
@ -90,13 +90,13 @@ pub fn run_prod_file(wd string, vexec string, file string) !string {
|
|||||||
|
|
||||||
pub fn new_options() RunnerOptions {
|
pub fn new_options() RunnerOptions {
|
||||||
vexec := full_path_to_v(5)
|
vexec := full_path_to_v(5)
|
||||||
mut wd := os.get_current_dir()
|
mut wd := os.getwd()
|
||||||
mut files := []string{}
|
mut files := []string{}
|
||||||
if os.args.len > 1 {
|
if os.args.len > 1 {
|
||||||
files = os.args[1..].clone()
|
files = os.args[1..].clone()
|
||||||
} else {
|
} else {
|
||||||
os.chdir(os.dir(vexec)) or {}
|
os.chdir(os.dir(vexec)) or {}
|
||||||
wd = os.get_current_dir()
|
wd = os.getwd()
|
||||||
files = os.walk_ext('.', '.repl')
|
files = os.walk_ext('.', '.repl')
|
||||||
}
|
}
|
||||||
return RunnerOptions{
|
return RunnerOptions{
|
||||||
@ -107,7 +107,7 @@ pub fn new_options() RunnerOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_prod_options() RunnerOptions {
|
pub fn new_prod_options() RunnerOptions {
|
||||||
wd := os.get_current_dir()
|
wd := os.getwd()
|
||||||
vexec := full_path_to_v(4)
|
vexec := full_path_to_v(4)
|
||||||
mut files := []string{}
|
mut files := []string{}
|
||||||
if os.args.len > 1 {
|
if os.args.len > 1 {
|
||||||
|
@ -64,8 +64,8 @@ pub fn qualify_module(pref_ &pref.Preferences, mod string, file_path string) str
|
|||||||
// TODO: 2022-01-30: That makes lookup dependent on fragile environment factors.
|
// TODO: 2022-01-30: That makes lookup dependent on fragile environment factors.
|
||||||
// TODO: 2022-01-30: The lookup should be relative to the folder, in which the current file is,
|
// TODO: 2022-01-30: The lookup should be relative to the folder, in which the current file is,
|
||||||
// TODO: 2022-01-30: *NOT* to the working folder of the compiler, which can change easily.
|
// TODO: 2022-01-30: *NOT* to the working folder of the compiler, which can change easily.
|
||||||
if clean_file_path.replace(os.get_current_dir() + os.path_separator, '') == mod {
|
if clean_file_path.replace(os.getwd() + os.path_separator, '') == mod {
|
||||||
trace_qualify(@FN, mod, file_path, 'module_res 2', mod, 'clean_file_path - get_current_dir == mod, clean_file_path: ${clean_file_path}')
|
trace_qualify(@FN, mod, file_path, 'module_res 2', mod, 'clean_file_path - getwd == mod, clean_file_path: ${clean_file_path}')
|
||||||
return mod
|
return mod
|
||||||
}
|
}
|
||||||
if m1 := mod_path_to_full_name(pref_, mod, clean_file_path) {
|
if m1 := mod_path_to_full_name(pref_, mod, clean_file_path) {
|
||||||
|
@ -277,7 +277,7 @@ pub fn launch_tool(is_verbose bool, tool_name string, args []string) {
|
|||||||
println('Compiling ${tool_name} with: "${compilation_command}"')
|
println('Compiling ${tool_name} with: "${compilation_command}"')
|
||||||
}
|
}
|
||||||
|
|
||||||
current_work_dir := os.get_current_dir()
|
current_work_dir := os.getwd()
|
||||||
tlog('recompiling ${tool_source}')
|
tlog('recompiling ${tool_source}')
|
||||||
lockfile := tool_exe + '.lock'
|
lockfile := tool_exe + '.lock'
|
||||||
tlog('lockfile: ${lockfile}')
|
tlog('lockfile: ${lockfile}')
|
||||||
|
@ -56,7 +56,7 @@ pub fn (mut sh StaticHandler) handle_static(directory_path string, root bool) !b
|
|||||||
// ```
|
// ```
|
||||||
pub fn (mut sh StaticHandler) host_handle_static(host string, directory_path string, root bool) !bool {
|
pub fn (mut sh StaticHandler) host_handle_static(host string, directory_path string, root bool) !bool {
|
||||||
if !os.exists(directory_path) {
|
if !os.exists(directory_path) {
|
||||||
return error('directory `${directory_path}` does not exist. The directory should be relative to the current working directory: ${os.get_current_dir()}')
|
return error('directory `${directory_path}` does not exist. The directory should be relative to the current working directory: ${os.getwd()}')
|
||||||
}
|
}
|
||||||
dir_path := directory_path.trim_space().trim_right('/')
|
dir_path := directory_path.trim_space().trim_right('/')
|
||||||
mut mount_path := ''
|
mut mount_path := ''
|
||||||
@ -84,7 +84,7 @@ pub fn (mut sh StaticHandler) host_mount_static_folder_at(host string, directory
|
|||||||
if mount_path == '' || mount_path[0] != `/` {
|
if mount_path == '' || mount_path[0] != `/` {
|
||||||
return error('invalid mount path! The path should start with `/`')
|
return error('invalid mount path! The path should start with `/`')
|
||||||
} else if !os.exists(directory_path) {
|
} else if !os.exists(directory_path) {
|
||||||
return error('directory `${directory_path}` does not exist. The directory should be relative to the current working directory: ${os.get_current_dir()}')
|
return error('directory `${directory_path}` does not exist. The directory should be relative to the current working directory: ${os.getwd()}')
|
||||||
}
|
}
|
||||||
|
|
||||||
dir_path := directory_path.trim_right('/')
|
dir_path := directory_path.trim_right('/')
|
||||||
|
@ -56,7 +56,7 @@ pub fn (mut sh StaticHandler) handle_static(directory_path string, root bool) !b
|
|||||||
// ```
|
// ```
|
||||||
pub fn (mut sh StaticHandler) host_handle_static(host string, directory_path string, root bool) !bool {
|
pub fn (mut sh StaticHandler) host_handle_static(host string, directory_path string, root bool) !bool {
|
||||||
if !os.exists(directory_path) {
|
if !os.exists(directory_path) {
|
||||||
return error('directory `${directory_path}` does not exist. The directory should be relative to the current working directory: ${os.get_current_dir()}')
|
return error('directory `${directory_path}` does not exist. The directory should be relative to the current working directory: ${os.getwd()}')
|
||||||
}
|
}
|
||||||
dir_path := directory_path.trim_space().trim_right('/')
|
dir_path := directory_path.trim_space().trim_right('/')
|
||||||
mut mount_path := ''
|
mut mount_path := ''
|
||||||
@ -84,7 +84,7 @@ pub fn (mut sh StaticHandler) host_mount_static_folder_at(host string, directory
|
|||||||
if mount_path == '' || mount_path[0] != `/` {
|
if mount_path == '' || mount_path[0] != `/` {
|
||||||
return error('invalid mount path! The path should start with `/`')
|
return error('invalid mount path! The path should start with `/`')
|
||||||
} else if !os.exists(directory_path) {
|
} else if !os.exists(directory_path) {
|
||||||
return error('directory `${directory_path}` does not exist. The directory should be relative to the current working directory: ${os.get_current_dir()}')
|
return error('directory `${directory_path}` does not exist. The directory should be relative to the current working directory: ${os.getwd()}')
|
||||||
}
|
}
|
||||||
|
|
||||||
dir_path := directory_path.trim_right('/')
|
dir_path := directory_path.trim_right('/')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user