From d3dd01dab28ad30cb228257715cf32bac7f5eca6 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Fri, 1 Mar 2024 09:17:47 -0500 Subject: [PATCH] use _readdirx for walkdir --- base/file.jl | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/base/file.jl b/base/file.jl index 659c39d7415f8..b7adb8e1a3fbd 100644 --- a/base/file.jl +++ b/base/file.jl @@ -1089,18 +1089,16 @@ function walkdir(root; topdown=true, follow_symlinks=false, onerror=throw) end return end - content = tryf(readdir, root) - content === nothing && return - dirs = Vector{eltype(content)}() - files = Vector{eltype(content)}() - for name in content - path = joinpath(root, name) - + entries = tryf(_readdirx, root) + entries === nothing && return + dirs = Vector{String}() + files = Vector{String}() + for entry in entries # If we're not following symlinks, then treat all symlinks as files - if (!follow_symlinks && something(tryf(islink, path), true)) || !something(tryf(isdir, path), false) - push!(files, name) + if (!follow_symlinks && something(tryf(islink, entry), true)) || !something(tryf(isdir, entry), false) + push!(files, entry.name) else - push!(dirs, name) + push!(dirs, entry.name) end end