os: fix os.walk, when passing paths ending with path_separator (#8672)

pull/8675/head
SurmanPP 2021-02-10 17:48:01 +01:00 committed by GitHub
parent 4646c414d8
commit f2ad6dd4d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -463,8 +463,12 @@ pub fn walk(path string, f fn (string)) {
return return
} }
mut files := ls(path) or { return } mut files := ls(path) or { return }
mut local_path_separator := path_separator
if path.ends_with(path_separator) {
local_path_separator = ''
}
for file in files { for file in files {
p := path + path_separator + file p := path + local_path_separator + file
if is_dir(p) && !is_link(p) { if is_dir(p) && !is_link(p) {
walk(p, f) walk(p, f)
} else if exists(p) { } else if exists(p) {