1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

os api: rmdir_recursive => rmdir_all

This commit is contained in:
yuyi 2020-03-03 22:02:50 +08:00 committed by GitHub
parent 3f67ba08b1
commit 448ed41562
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 12 deletions

View File

@ -43,7 +43,7 @@ pub fn rmrf(path string) {
verbose_trace(@FN, 'rm -rf $path') verbose_trace(@FN, 'rm -rf $path')
if os.exists(path) { if os.exists(path) {
if os.is_dir(path) { if os.is_dir(path) {
os.rmdir_recursive(path) os.rmdir_all(path)
}else{ }else{
os.rm(path) os.rm(path)
} }

View File

@ -275,7 +275,7 @@ fn vpm_remove(module_names []string) {
} }
println('Removing module "$name"...') println('Removing module "$name"...')
verbose_println('removing folder $final_module_path') verbose_println('removing folder $final_module_path')
os.rmdir_recursive(final_module_path) os.rmdir_all(final_module_path)
// delete author directory if it is empty // delete author directory if it is empty
author := name.split('.')[0] author := name.split('.')[0]
author_dir := os.realpath(filepath.join(settings.vmodules_path,author)) author_dir := os.realpath(filepath.join(settings.vmodules_path,author))

View File

@ -8,7 +8,7 @@ import sync
import filepath import filepath
fn test_the_v_compiler_can_be_invoked() { fn test_the_v_compiler_can_be_invoked() {
vexec := runner.full_path_to_v(5) vexec := runner.full_path_to_v(5)
println('vexecutable: $vexec') println('vexecutable: $vexec')
assert vexec != '' assert vexec != ''
vcmd := '"$vexec" --version' vcmd := '"$vexec" --version'
@ -73,30 +73,30 @@ fn process_in_thread( session mut Session, thread_id int ){
session.ntask++ session.ntask++
idx := session.ntask-1 idx := session.ntask-1
session.ntask_mtx.unlock() session.ntask_mtx.unlock()
if idx >= session.options.files.len { break } if idx >= session.options.files.len { break }
tls_bench.cstep = idx tls_bench.cstep = idx
tfolder := filepath.join( cdir, 'vrepl_tests_$idx') tfolder := filepath.join( cdir, 'vrepl_tests_$idx')
if os.is_dir( tfolder ) { if os.is_dir( tfolder ) {
os.rmdir_recursive( tfolder ) os.rmdir_all( tfolder )
} }
os.mkdir( tfolder ) or { panic(err) } os.mkdir( tfolder ) or { panic(err) }
file := session.options.files[ idx ] file := session.options.files[ idx ]
session.bmark.step() session.bmark.step()
tls_bench.step() tls_bench.step()
fres := runner.run_repl_file(tfolder, session.options.vexec, file) or { fres := runner.run_repl_file(tfolder, session.options.vexec, file) or {
session.bmark.fail() session.bmark.fail()
tls_bench.fail() tls_bench.fail()
os.rmdir_recursive( tfolder ) os.rmdir_all( tfolder )
eprintln(tls_bench.step_message_fail(err)) eprintln(tls_bench.step_message_fail(err))
assert false assert false
continue continue
} }
session.bmark.ok() session.bmark.ok()
tls_bench.ok() tls_bench.ok()
os.rmdir_recursive( tfolder ) os.rmdir_all( tfolder )
println(tls_bench.step_message_ok(fres)) println(tls_bench.step_message_ok(fres))
assert true assert true
} }

View File

@ -624,13 +624,18 @@ pub fn rmdir(path string) {
} }
} }
[deprecated]
pub fn rmdir_recursive(path string) { pub fn rmdir_recursive(path string) {
panic('Use `os.rmdir_all` instead of `os.rmdir_recursive`')
}
pub fn rmdir_all(path string) {
items := os.ls(path) or { items := os.ls(path) or {
return return
} }
for item in items { for item in items {
if os.is_dir(filepath.join(path,item)) { if os.is_dir(filepath.join(path,item)) {
rmdir_recursive(filepath.join(path,item)) rmdir_all(filepath.join(path,item))
} }
os.rm(filepath.join(path,item)) os.rm(filepath.join(path,item))
} }

View File

@ -303,8 +303,8 @@ fn cleanup_leftovers() {
os.rm('cp_new_example.txt') os.rm('cp_new_example.txt')
// possible leftovers from test_cp_r // possible leftovers from test_cp_r
os.rmdir_recursive('ex') os.rmdir_all('ex')
os.rmdir_recursive('ex2') os.rmdir_all('ex2')
os.rm('ex1.txt') os.rm('ex1.txt')
os.rm('ex2.txt') os.rm('ex2.txt')
} }