From 010f3efcf05af6bd6cfa4fec2f79ed57103c8593 Mon Sep 17 00:00:00 2001 From: yuyi Date: Thu, 19 Mar 2020 22:49:07 +0800 Subject: [PATCH] os: filename => file_name --- cmd/tools/modules/testing/common.v | 2 +- cmd/tools/oldv.v | 2 +- cmd/tools/performance_compare.v | 2 +- cmd/tools/preludes/tests_with_stats.v | 2 +- cmd/tools/vbin2v.v | 2 +- cmd/tools/vcreate.v | 2 +- cmd/tools/vfmt.v | 2 +- cmd/tools/vnames.v | 2 +- vlib/compiler/aparser.v | 2 +- vlib/compiler/live.v | 4 ++-- vlib/compiler/tests/repl/runner/runner.v | 2 +- vlib/compiler/vtmp.v | 2 +- vlib/log/log.v | 2 +- vlib/os/os.v | 4 ++-- vlib/v/fmt/fmt_keep_test.v | 2 +- vlib/v/fmt/fmt_test.v | 2 +- vlib/v/pref/default.v | 4 ++-- 17 files changed, 20 insertions(+), 20 deletions(-) diff --git a/cmd/tools/modules/testing/common.v b/cmd/tools/modules/testing/common.v index a5b4f71637..65a0cbcd65 100644 --- a/cmd/tools/modules/testing/common.v +++ b/cmd/tools/modules/testing/common.v @@ -95,7 +95,7 @@ fn worker_trunner(p mut sync.PoolProcessor, idx int, thread_id int) voidptr { file := os.realpath(relative_file) // Ensure that the generated binaries will be stored in the temporary folder. // Remove them after a test passes/fails. - fname := os.filename(file) + fname := os.file_name(file) generated_binary_fname := if os.user_os() == 'windows' { fname.replace('.v', '.exe') } else { fname.replace('.v', '') } generated_binary_fpath := os.join_path(tmpd, generated_binary_fname) if os.exists(generated_binary_fpath) { diff --git a/cmd/tools/oldv.v b/cmd/tools/oldv.v index 24beca3fd5..4e3bde5438 100644 --- a/cmd/tools/oldv.v +++ b/cmd/tools/oldv.v @@ -69,7 +69,7 @@ fn main() { scripting.used_tools_must_exist(['git', 'cc']) mut context := Context{} mut fp := flag.new_flag_parser(os.args) - fp.application(os.filename(os.executable())) + fp.application(os.file_name(os.executable())) fp.version(tool_version) fp.description(tool_description) fp.arguments_description('VCOMMIT') diff --git a/cmd/tools/performance_compare.v b/cmd/tools/performance_compare.v index 6357a12ff3..b32c70052d 100644 --- a/cmd/tools/performance_compare.v +++ b/cmd/tools/performance_compare.v @@ -180,7 +180,7 @@ fn main() { scripting.used_tools_must_exist(['cp', 'rm', 'strip', 'make', 'git', 'upx', 'cc', 'wc', 'tail', 'hyperfine']) mut context := new_context() mut fp := flag.new_flag_parser(os.args) - fp.application(os.filename(os.executable())) + fp.application(os.file_name(os.executable())) fp.version(tool_version) fp.description(tool_description) fp.arguments_description('COMMIT_BEFORE [COMMIT_AFTER]') diff --git a/cmd/tools/preludes/tests_with_stats.v b/cmd/tools/preludes/tests_with_stats.v index b6aaeedf69..bcbfa890eb 100644 --- a/cmd/tools/preludes/tests_with_stats.v +++ b/cmd/tools/preludes/tests_with_stats.v @@ -80,7 +80,7 @@ fn (b &BenchedTests) fn_name() string { // Called at the end of the test program produced by `v -stats file_test.v` fn (b mut BenchedTests) end_testing() { b.bench.stop() - println(INNER_INDENT + b.bench.total_message('running V tests in "' + os.filename(b.test_suit_file) + '"')) + println(INNER_INDENT + b.bench.total_message('running V tests in "' + os.file_name(b.test_suit_file) + '"')) } // /////////////////////////////////////////////////////////////////// diff --git a/cmd/tools/vbin2v.v b/cmd/tools/vbin2v.v index 38f9db5b85..1d7e5b3756 100644 --- a/cmd/tools/vbin2v.v +++ b/cmd/tools/vbin2v.v @@ -41,7 +41,7 @@ fn (context Context) footer() { } fn (context Context) file2v(file string) { - fname := os.filename(file) + fname := os.file_name(file) fname_no_dots := fname.replace('.', '_') byte_name := '${context.prefix}${fname_no_dots}' fbytes := os.read_bytes(file) or { diff --git a/cmd/tools/vcreate.v b/cmd/tools/vcreate.v index 185dbe8817..c8fd155b48 100644 --- a/cmd/tools/vcreate.v +++ b/cmd/tools/vcreate.v @@ -142,7 +142,7 @@ fn init() { exit(3) } mut c := Create{} - c.name = os.filename(os.getwd()) + c.name = os.file_name(os.getwd()) c.description = '' c.init_vmod() c.init_main() diff --git a/cmd/tools/vfmt.v b/cmd/tools/vfmt.v index e41acacc2b..01e436f51c 100644 --- a/cmd/tools/vfmt.v +++ b/cmd/tools/vfmt.v @@ -158,7 +158,7 @@ fn (foptions &FormatOptions) format_file(file string) { table := table.new_table() file_ast := parser.parse_file(file, table, .parse_comments) formatted_content := fmt.fmt(file_ast, table) - file_name := os.filename(file) + file_name := os.file_name(file) vfmt_output_path := os.join_path(os.temp_dir(), 'vfmt_' + file_name) os.write_file(vfmt_output_path, formatted_content ) if foptions.is_verbose { diff --git a/cmd/tools/vnames.v b/cmd/tools/vnames.v index a476e86640..fc8204f5b0 100644 --- a/cmd/tools/vnames.v +++ b/cmd/tools/vnames.v @@ -58,7 +58,7 @@ fn main(){ compiler.set_vroot_folder(os.dir(os.dir(os.dir(toolexe)))) mut fp := flag.new_flag_parser(os.args) - fp.application(os.filename(toolexe)) + fp.application(os.file_name(toolexe)) fp.version( tool_version ) fp.description( tool_description ) fp.arguments_description('FILE.v/FOLDER [FILE.v/FOLDER]...') diff --git a/vlib/compiler/aparser.v b/vlib/compiler/aparser.v index 02fe1c0315..7d2f97087e 100644 --- a/vlib/compiler/aparser.v +++ b/vlib/compiler/aparser.v @@ -2481,7 +2481,7 @@ struct IndexConfig { // for debugging only fn (p &Parser) fileis(s string) bool { - return os.filename(p.scanner.file_path).contains(s) + return os.file_name(p.scanner.file_path).contains(s) } // in and dot have higher priority than `!` diff --git a/vlib/compiler/live.v b/vlib/compiler/live.v index 3e8ba99818..12932e52af 100644 --- a/vlib/compiler/live.v +++ b/vlib/compiler/live.v @@ -54,7 +54,7 @@ fn (v &V) generate_hotcode_reloading_main_caller() { // We are in live code reload mode, so start the .so loader in the background mut cgen := v.cgen cgen.genln('') - file_base := os.filename(v.pref.path).replace('.v', '') + file_base := os.file_name(v.pref.path).replace('.v', '') if v.pref.os != .windows { // unix: so_name := file_base + '.so' @@ -79,7 +79,7 @@ fn (v &V) generate_hot_reload_code() { // Hot code reloading if v.pref.is_live { mut file := os.realpath(v.pref.path) - file_base := os.filename(file).replace('.v', '') + file_base := os.file_name(file).replace('.v', '') so_name := file_base + '.so' // Need to build .so file before building the live application // The live app needs to load this .so file on initialization. diff --git a/vlib/compiler/tests/repl/runner/runner.v b/vlib/compiler/tests/repl/runner/runner.v index 0761a3d4d4..2b30d0c9a7 100644 --- a/vlib/compiler/tests/repl/runner/runner.v +++ b/vlib/compiler/tests/repl/runner/runner.v @@ -54,7 +54,7 @@ pub fn run_repl_file(wd string, vexec string, file string) ?string { input := content.all_before('===output===\n') output := content.all_after('===output===\n') - fname := os.filename( file ) + fname := os.file_name( file ) input_temporary_filename := os.realpath(os.join_path( wd, 'input_temporary_filename.txt')) os.write_file(input_temporary_filename, input) diff --git a/vlib/compiler/vtmp.v b/vlib/compiler/vtmp.v index f941519193..ee4285b10e 100644 --- a/vlib/compiler/vtmp.v +++ b/vlib/compiler/vtmp.v @@ -17,5 +17,5 @@ fn get_vtmp_folder() string { fn get_vtmp_filename(base_file_name string, postfix string) string { vtmp := get_vtmp_folder() - return os.realpath(os.join_path(vtmp, os.filename(os.realpath(base_file_name)) + postfix)) + return os.realpath(os.join_path(vtmp, os.file_name(os.realpath(base_file_name)) + postfix)) } diff --git a/vlib/log/log.v b/vlib/log/log.v index f1bc5e530c..2674bbd0f3 100644 --- a/vlib/log/log.v +++ b/vlib/log/log.v @@ -68,7 +68,7 @@ pub fn (l mut Log) set_output_level(level LogLevel) { pub fn (l mut Log) set_full_logpath(full_log_path string) { rlog_file := os.realpath( full_log_path ) - l.set_output_label( os.filename( rlog_file ) ) + l.set_output_label( os.file_name( rlog_file ) ) l.set_output_path( os.base_dir( rlog_file ) ) } diff --git a/vlib/os/os.v b/vlib/os/os.v index f41b4a9c6a..69067e78a2 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -178,7 +178,7 @@ pub fn cp_all(osource_path, odest_path string, overwrite bool) ?bool { } // single file copy if !os.is_dir(source_path) { - adjasted_path := if os.is_dir(dest_path) { os.join_path(dest_path,os.filename(source_path)) } else { dest_path } + adjasted_path := if os.is_dir(dest_path) { os.join_path(dest_path,os.file_name(source_path)) } else { dest_path } if os.exists(adjasted_path) { if overwrite { os.rm(adjasted_path) @@ -633,7 +633,7 @@ pub fn base_dir(path string) string { return path[..posx] } -pub fn filename(path string) string { +pub fn file_name(path string) string { return path.all_after(path_separator) } diff --git a/vlib/v/fmt/fmt_keep_test.v b/vlib/v/fmt/fmt_keep_test.v index a45f5498f2..8f75912c8a 100644 --- a/vlib/v/fmt/fmt_keep_test.v +++ b/vlib/v/fmt/fmt_keep_test.v @@ -35,7 +35,7 @@ fn test_fmt() { for istep, ipath in input_files { fmt_bench.cstep = istep fmt_bench.step() - ifilename := os.filename(ipath) + ifilename := os.file_name(ipath) opath := ipath expected_ocontent := os.read_file(opath) or { fmt_bench.fail() diff --git a/vlib/v/fmt/fmt_test.v b/vlib/v/fmt/fmt_test.v index cfe6485759..eb442d8c0b 100644 --- a/vlib/v/fmt/fmt_test.v +++ b/vlib/v/fmt/fmt_test.v @@ -32,7 +32,7 @@ fn test_fmt() { for istep, ipath in input_files { fmt_bench.cstep = istep fmt_bench.step() - ifilename := os.filename(ipath) + ifilename := os.file_name(ipath) opath := ipath.replace('_input.vv', '_expected.vv') if !os.exists(opath) { fmt_bench.fail() diff --git a/vlib/v/pref/default.v b/vlib/v/pref/default.v index 03e8e562e1..962280a3e7 100644 --- a/vlib/v/pref/default.v +++ b/vlib/v/pref/default.v @@ -23,7 +23,7 @@ pub fn (p mut Preferences) fill_with_defaults() { } rpath := os.realpath(p.path) if p.out_name == ''{ - filename := os.filename(rpath).trim_space() + filename := os.file_name(rpath).trim_space() mut base := filename.all_before_last('.') if base == '' { // The file name is just `.v` or `.vsh` or `.*` @@ -41,7 +41,7 @@ pub fn (p mut Preferences) fill_with_defaults() { p.out_name = 'v2' } } - rpath_name := os.filename(rpath) + rpath_name := os.file_name(rpath) p.building_v = !p.is_repl && (rpath_name == 'v' || rpath_name == 'vfmt.v') if p.os == ._auto { // No OS specifed? Use current system