From 23b11c84b16fc2efca7c2e7884e0ec3c458d720b Mon Sep 17 00:00:00 2001 From: yuyi Date: Sun, 8 Mar 2020 22:43:56 +0800 Subject: [PATCH] os api: basedir => base_dir --- cmd/tools/vfmt.v | 4 ++-- vlib/compiler/main.v | 2 +- vlib/compiler/modules.v | 2 +- vlib/compiler/v_mod_cache.v | 2 +- vlib/freetype/freetype.v | 2 +- vlib/log/log.v | 2 +- vlib/os/os.v | 2 +- vlib/os/os_test.v | 6 +++--- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/tools/vfmt.v b/cmd/tools/vfmt.v index b4db5f9b4a..e33e21a75e 100644 --- a/cmd/tools/vfmt.v +++ b/cmd/tools/vfmt.v @@ -179,13 +179,13 @@ fn (foptions &FormatOptions) format_file(file string) { is_test_file := file.ends_with('_test.v') mod_name,is_module_file := file_to_mod_name_and_is_module_file(file) use_tmp_main_program := is_module_file && !is_test_file - mod_folder := os.basedir(file) + mod_folder := os.base_dir(file) if use_tmp_main_program { // TODO: remove the need for this // This makes a small program that imports the module, // so that the module files will get processed by the // vfmt implementation. - mod_folder_parent = os.basedir(mod_folder) + mod_folder_parent = os.base_dir(mod_folder) mut main_program_content := if mod_name == 'builtin' || mod_name == 'main' { 'fn main(){}\n' } else { 'import ${mod_name}\n' + 'fn main(){}\n' } main_program_file := os.join(tmpfolder,'vfmt_tmp_${mod_name}_program.v') if os.exists(main_program_file) { diff --git a/vlib/compiler/main.v b/vlib/compiler/main.v index 4783b30828..83f1720b1d 100644 --- a/vlib/compiler/main.v +++ b/vlib/compiler/main.v @@ -780,7 +780,7 @@ pub fn (v &V) get_user_files() []string { v.log('> That brings in all other ordinary .v files in the same module too .') } user_files << single_test_v_file - dir = os.basedir(single_test_v_file) + dir = os.base_dir(single_test_v_file) } if dir.ends_with('.v') || dir.ends_with('.vsh') { single_v_file := dir diff --git a/vlib/compiler/modules.v b/vlib/compiler/modules.v index c00e59a786..562206fe09 100644 --- a/vlib/compiler/modules.v +++ b/vlib/compiler/modules.v @@ -167,7 +167,7 @@ fn (v mut V) set_module_lookup_paths() { // 3.2) search in ~/.vmodules/ (i.e. modules installed with vpm) v.module_lookup_paths = [] if v.pref.is_test { - v.module_lookup_paths << os.basedir(v.compiled_dir) // pdir of _test.v + v.module_lookup_paths << os.base_dir(v.compiled_dir) // pdir of _test.v } v.module_lookup_paths << v.compiled_dir v.module_lookup_paths << os.join(v.compiled_dir,'modules') diff --git a/vlib/compiler/v_mod_cache.v b/vlib/compiler/v_mod_cache.v index 679b756be8..fb9e15afc1 100644 --- a/vlib/compiler/v_mod_cache.v +++ b/vlib/compiler/v_mod_cache.v @@ -103,7 +103,7 @@ fn (mcache mut ModFileCacher) traverse(mfolder string) ([]string, ModFileAndFold if mcache.check_for_stop( cfolder, files ) { break } - cfolder = os.basedir( cfolder ) + cfolder = os.base_dir( cfolder ) folders_so_far << cfolder levels++ } diff --git a/vlib/freetype/freetype.v b/vlib/freetype/freetype.v index 2b3b3961e3..21a44b0247 100644 --- a/vlib/freetype/freetype.v +++ b/vlib/freetype/freetype.v @@ -204,7 +204,7 @@ pub fn new_context(cfg gg.Cfg) &FreeType { } if !os.exists(font_path) { exe_path := os.executable() - exe_dir := os.basedir(exe_path) + exe_dir := os.base_dir(exe_path) font_path = '$exe_dir/$font_path' } if !os.exists(font_path) { diff --git a/vlib/log/log.v b/vlib/log/log.v index 5ee32919d7..119995892f 100644 --- a/vlib/log/log.v +++ b/vlib/log/log.v @@ -69,7 +69,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_path( os.basedir( rlog_file ) ) + l.set_output_path( os.base_dir( rlog_file ) ) } pub fn (l mut Log) set_output_label(label string){ diff --git a/vlib/os/os.v b/vlib/os/os.v index 822b2bb465..73196c3173 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -667,7 +667,7 @@ pub fn dir(path string) string { return path[..pos] } -pub fn basedir(path string) string { +pub fn base_dir(path string) string { pos := path.last_index(path_separator) or { return path } diff --git a/vlib/os/os_test.v b/vlib/os/os_test.v index e589b6d9bb..9df42a47e3 100644 --- a/vlib/os/os_test.v +++ b/vlib/os/os_test.v @@ -325,12 +325,12 @@ fn test_dir() { fn test_basedir() { $if windows { - assert os.basedir('v\\vlib\\os') == 'v\\vlib' + assert os.base_dir('v\\vlib\\os') == 'v\\vlib' } $else { - assert os.basedir('v/vlib/os') == 'v/vlib' + assert os.base_dir('v/vlib/os') == 'v/vlib' } - assert os.basedir('filename') == 'filename' + assert os.base_dir('filename') == 'filename' } // this function is called by both test_aaa_setup & test_zzz_cleanup