mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
os: fix rmdir_all panic with hidden dirs (#9271)
This commit is contained in:
parent
e09a8a47b0
commit
fecf4a6f58
@ -142,8 +142,9 @@ pub fn rmdir_all(path string) ? {
|
||||
fullpath := join_path(path, item)
|
||||
if is_dir(fullpath) {
|
||||
rmdir_all(fullpath) or { ret_err = err.msg }
|
||||
} else {
|
||||
rm(fullpath) or { ret_err = err.msg }
|
||||
}
|
||||
rm(fullpath) or { ret_err = err.msg }
|
||||
}
|
||||
rmdir(path) or { ret_err = err.msg }
|
||||
if ret_err.len > 0 {
|
||||
|
@ -399,6 +399,21 @@ fn test_join() {
|
||||
}
|
||||
}
|
||||
|
||||
fn test_rmdir_all() {
|
||||
mut dirs := ['some/dir', 'some/.hidden/directory']
|
||||
$if windows {
|
||||
for mut d in dirs {
|
||||
d = d.replace('/', '\\')
|
||||
}
|
||||
}
|
||||
for d in dirs {
|
||||
os.mkdir_all(d) or { panic(err) }
|
||||
assert os.is_dir(d)
|
||||
}
|
||||
os.rmdir_all('some') or { assert false }
|
||||
assert !os.exists('some')
|
||||
}
|
||||
|
||||
fn test_dir() {
|
||||
$if windows {
|
||||
assert os.dir('C:\\a\\b\\c') == 'C:\\a\\b'
|
||||
|
Loading…
Reference in New Issue
Block a user