os: filename => file_name

pull/4077/head
yuyi 2020-03-19 22:49:07 +08:00 committed by GitHub
parent 216c7a16d8
commit 010f3efcf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 20 additions and 20 deletions

View File

@ -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) {

View File

@ -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')

View File

@ -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]')

View File

@ -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) + '"'))
}
// ///////////////////////////////////////////////////////////////////

View File

@ -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 {

View File

@ -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()

View File

@ -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 {

View File

@ -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]...')

View File

@ -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 `!`

View File

@ -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.

View File

@ -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)

View File

@ -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))
}

View File

@ -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 ) )
}

View File

@ -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)
}

View File

@ -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()

View File

@ -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()

View File

@ -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