Revert "os: deprecate os.getwd in favor of os.get_current_dir (part 1) (#22966)"

This reverts commit 93009823f9.
This commit is contained in:
Delyan Angelov 2024-11-25 15:10:15 +02:00
parent 93009823f9
commit b801083f13
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED
34 changed files with 46 additions and 60 deletions

View file

@ -109,7 +109,7 @@ fn (mut c Context) amalgamate() ! {
if c.config.input_files.len == 0 {
// source += '/* ########## stdin */\n'
// 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 += '/* ########## stdin end */\n'
} else {

View file

@ -14,7 +14,7 @@ step := os.args[3] or { '500_000' }.int()
os.chdir(os.dir(@VEXE))!
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
println('running...')

View file

@ -53,7 +53,7 @@ fn main() {
elog('fast_job PATH: ${os.getenv('PATH')}')
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 {
elog('fast_job end')

View file

@ -370,7 +370,7 @@ pub fn (mut ts TestSession) add(file string) {
pub fn (mut ts TestSession) test() {
// Ensure that .tmp.c files generated from compiling _test.v files,
// 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 {
ts.root_relative = true
}

View file

@ -25,7 +25,7 @@ mut:
fn new_context() Context {
return Context{
cwd: os.get_current_dir()
cwd: os.getwd()
commit_after: 'master'
warmups: 4
}

View file

@ -78,7 +78,7 @@ fn main() {
eprintln('> args: ${args} | context: ${ctx}')
}
if ctx.show_wd {
ctx.println('WORK_DIR=${os.get_current_dir()}')
ctx.println('WORK_DIR=${os.getwd()}')
}
if ctx.show_env {
all := os.environ()

View file

@ -87,9 +87,9 @@ fn get_abs_path(path string) string {
if os.is_abs_path(path) {
return path
} else if path.starts_with('./') {
return os.join_path(os.get_current_dir(), path[2..])
return os.join_path(os.getwd(), path[2..])
} else {
return os.join_path(os.get_current_dir(), path)
return os.join_path(os.getwd(), path)
}
}

View file

@ -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 {
mut vexe := os.getenv('VEXE')
// prepare a V compiler with -g to have better backtraces if possible
wd := os.get_current_dir()
wd := os.getwd()
os.chdir(vroot) or {}
verbose_flag := if is_verbose { '-v' } else { '' }
vdbg_path := $if windows { '${vroot}/vdbg.exe' } $else { '${vroot}/vdbg' }

View file

@ -149,7 +149,7 @@ fn normalize_path(path string) string {
fn main() {
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..])
fp.application('v cover')
fp.version('0.0.2')

View file

@ -131,7 +131,7 @@ fn init_project(cmd Command) ! {
mut c := Create{
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') {
mod_dir_has_hyphens := dir_name.contains('-')
c.name = if mod_dir_has_hyphens { dir_name.replace('-', '_') } else { dir_name }

View file

@ -99,13 +99,13 @@ fn (mut a App) collect_info() {
a.line('OS', '${os_kind}, ${os_details}')
a.line('Processor', arch_details.join(', '))
a.println('')
get_current_dir := os.get_current_dir()
getwd := os.getwd()
vmodules := os.vmodules_dir()
vtmp_dir := os.vtmp_dir()
vexe := os.getenv('VEXE')
vroot := os.dir(vexe)
os.chdir(vroot) or {}
a.line('get_current_dir', get_current_dir)
a.line('getwd', getwd)
a.line('vexe', vexe)
a.line('vexe mtime', time.unix(os.file_last_mod_unix(vexe)).str())
a.println('')

View file

@ -35,6 +35,6 @@ fn setup_symlink_github() {
eprintln(' On windows, use `.\\v.exe symlink` instead.')
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.') }
}