os api: rmdir_recursive => rmdir_all

pull/3929/head
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')
if os.exists(path) {
if os.is_dir(path) {
os.rmdir_recursive(path)
os.rmdir_all(path)
}else{
os.rm(path)
}

View File

@ -275,7 +275,7 @@ fn vpm_remove(module_names []string) {
}
println('Removing module "$name"...')
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
author := name.split('.')[0]
author_dir := os.realpath(filepath.join(settings.vmodules_path,author))

View File

@ -79,7 +79,7 @@ fn process_in_thread( session mut Session, thread_id int ){
tfolder := filepath.join( cdir, 'vrepl_tests_$idx')
if os.is_dir( tfolder ) {
os.rmdir_recursive( tfolder )
os.rmdir_all( tfolder )
}
os.mkdir( tfolder ) or { panic(err) }
@ -89,14 +89,14 @@ fn process_in_thread( session mut Session, thread_id int ){
fres := runner.run_repl_file(tfolder, session.options.vexec, file) or {
session.bmark.fail()
tls_bench.fail()
os.rmdir_recursive( tfolder )
os.rmdir_all( tfolder )
eprintln(tls_bench.step_message_fail(err))
assert false
continue
}
session.bmark.ok()
tls_bench.ok()
os.rmdir_recursive( tfolder )
os.rmdir_all( tfolder )
println(tls_bench.step_message_ok(fres))
assert true
}

View File

@ -624,13 +624,18 @@ pub fn rmdir(path string) {
}
}
[deprecated]
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 {
return
}
for item in items {
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))
}

View File

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