From 57b1b12ab6509d905ad1ebee0c13f8d3d5b93601 Mon Sep 17 00:00:00 2001 From: yuyi Date: Tue, 10 Mar 2020 22:02:09 +0800 Subject: [PATCH] os: tmpdir => temp_dir --- cmd/tools/modules/testing/common.v | 2 +- cmd/tools/modules/vgit/vgit.v | 2 +- cmd/tools/vfmt.v | 4 ++-- vlib/compiler/vfmt.v | 6 +++--- vlib/compiler/vtmp.v | 2 +- vlib/os/os.v | 2 +- vlib/os/os_test.v | 4 ++-- vlib/v/fmt/fmt_keep_test.v | 2 +- vlib/v/fmt/fmt_test.v | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cmd/tools/modules/testing/common.v b/cmd/tools/modules/testing/common.v index fc78b88d78..a5b4f71637 100644 --- a/cmd/tools/modules/testing/common.v +++ b/cmd/tools/modules/testing/common.v @@ -80,7 +80,7 @@ pub fn (ts mut TestSession) test() { fn worker_trunner(p mut sync.PoolProcessor, idx int, thread_id int) voidptr { mut ts := &TestSession(p.get_shared_context()) - tmpd := os.tmpdir() + tmpd := os.temp_dir() show_stats := '-stats' in ts.vargs.split(' ') // tls_bench is used to format the step messages/timings mut tls_bench := &benchmark.Benchmark(p.get_thread_context(idx)) diff --git a/cmd/tools/modules/vgit/vgit.v b/cmd/tools/modules/vgit/vgit.v index 4da6843f69..33a37136ac 100644 --- a/cmd/tools/modules/vgit/vgit.v +++ b/cmd/tools/modules/vgit/vgit.v @@ -136,7 +136,7 @@ pub fn (vgit_context mut VGitContext) compile_oldv_if_needed() { } pub fn add_common_tool_options(context mut T, fp mut flag.FlagParser) []string { - tdir := os.tmpdir() + tdir := os.temp_dir() context.workdir = os.realpath(fp.string_('workdir', `w`, tdir, 'A writable base folder. Default: $tdir')) context.v_repo_url = fp.string('vrepo', 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', vgit.remote_vc_repo_url, 'The url of the vc repository. You can clone it diff --git a/cmd/tools/vfmt.v b/cmd/tools/vfmt.v index 3947cb2fd8..9d48737484 100644 --- a/cmd/tools/vfmt.v +++ b/cmd/tools/vfmt.v @@ -155,7 +155,7 @@ fn (foptions &FormatOptions) format_file(file string) { file_ast := parser.parse_file(file, table, .parse_comments) formatted_content := fmt.fmt(file_ast, table) file_name := os.filename(file) - vfmt_output_path := os.join_path(os.tmpdir(), 'vfmt_' + file_name) + vfmt_output_path := os.join_path(os.temp_dir(), 'vfmt_' + file_name) os.write_file(vfmt_output_path, formatted_content ) if foptions.is_verbose { eprintln('vfmt2 fmt.fmt worked and ${formatted_content.len} bytes were written to ${vfmt_output_path} .') @@ -163,7 +163,7 @@ fn (foptions &FormatOptions) format_file(file string) { eprintln('${FORMATTED_FILE_TOKEN}${vfmt_output_path}') return } - tmpfolder := os.tmpdir() + tmpfolder := os.temp_dir() mut compiler_params := &pref.Preferences{} target_os := file_to_target_os(file) if target_os != '' { diff --git a/vlib/compiler/vfmt.v b/vlib/compiler/vfmt.v index 55f2b6b7c4..91d3bced6e 100644 --- a/vlib/compiler/vfmt.v +++ b/vlib/compiler/vfmt.v @@ -171,8 +171,8 @@ fn (p mut Parser) fnext() { p.fgen_nl() p.fmt_inc() } - if p.token_idx >= p.tokens.len { - return + if p.token_idx >= p.tokens.len { + return } // Skip comments and add them to vfmt output if p.tokens[p.token_idx].tok in [.line_comment, .mline_comment] { @@ -298,7 +298,7 @@ fn (p &Parser) gen_fmt() { } fn write_formatted_source(file_name string, s string) string { - path := os.tmpdir() + '/' + file_name + path := os.temp_dir() + '/' + file_name mut out := os.create(path) or { verror('failed to create file $path') return '' diff --git a/vlib/compiler/vtmp.v b/vlib/compiler/vtmp.v index 3e86c08f62..f941519193 100644 --- a/vlib/compiler/vtmp.v +++ b/vlib/compiler/vtmp.v @@ -6,7 +6,7 @@ module compiler import os fn get_vtmp_folder() string { - vtmp := os.join_path(os.tmpdir(), 'v') + vtmp := os.join_path(os.temp_dir(), 'v') if !os.is_dir(vtmp) { os.mkdir(vtmp) or { panic(err) diff --git a/vlib/os/os.v b/vlib/os/os.v index ce4bcb6ab4..bd756a3853 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -1106,7 +1106,7 @@ pub fn cache_dir() string { } // tmpdir returns the path to a folder, that is suitable for storing temporary files -pub fn tmpdir() string { +pub fn temp_dir() string { mut path := os.getenv('TMPDIR') $if windows { if path == '' { diff --git a/vlib/os/os_test.v b/vlib/os/os_test.v index 1997486d57..1ffc59eaaf 100644 --- a/vlib/os/os_test.v +++ b/vlib/os/os_test.v @@ -164,7 +164,7 @@ fn test_cp_r() { } fn test_tmpdir(){ - t := os.tmpdir() + t := os.temp_dir() assert t.len > 0 assert os.is_dir(t) @@ -247,7 +247,7 @@ fn test_symlink() { } fn test_is_executable_writable_readable() { - file_name := os.tmpdir() + os.path_separator + 'rwxfile.exe' + file_name := os.temp_dir() + os.path_separator + 'rwxfile.exe' mut f := os.create(file_name) or { eprintln('failed to create file $file_name') diff --git a/vlib/v/fmt/fmt_keep_test.v b/vlib/v/fmt/fmt_keep_test.v index 221d05a136..a45f5498f2 100644 --- a/vlib/v/fmt/fmt_keep_test.v +++ b/vlib/v/fmt/fmt_keep_test.v @@ -21,7 +21,7 @@ fn test_fmt() { exit(error_missing_vexe) } vroot := os.dir(vexe) - tmpfolder := os.tmpdir() + tmpfolder := os.temp_dir() diff_cmd := find_working_diff_command() or { '' } diff --git a/vlib/v/fmt/fmt_test.v b/vlib/v/fmt/fmt_test.v index dae112015f..cfe6485759 100644 --- a/vlib/v/fmt/fmt_test.v +++ b/vlib/v/fmt/fmt_test.v @@ -21,7 +21,7 @@ fn test_fmt() { exit(error_missing_vexe) } vroot := os.dir(vexe) - tmpfolder := os.tmpdir() + tmpfolder := os.temp_dir() diff_cmd := find_working_diff_command() or { '' }