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

os: make os.ls('') return an error, make os.walk_ext more memory efficient on deep hierarchies, add tests for os.walk_ext

This commit is contained in:
Delyan Angelov
2021-10-24 18:38:44 +03:00
parent d9c6c9a7df
commit d1c4b470bc
4 changed files with 103 additions and 38 deletions

View File

@@ -254,6 +254,9 @@ fn init_os_args(argc int, argv &&byte) []string {
}
pub fn ls(path string) ?[]string {
if path.len == 0 {
return error('ls() expects a folder, not an empty string')
}
mut res := []string{}
dir := unsafe { C.opendir(&char(path.str)) }
if isnil(dir) {