mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
os api: basedir => base_dir
This commit is contained in:
parent
2bed0d1bb5
commit
23b11c84b1
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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')
|
||||
|
@ -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++
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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){
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user