Skip to content

Commit

Permalink
Manually error if path does not exist
Browse files Browse the repository at this point in the history
For whatever reason, Julia < 1.2 on Windows does not error on realpath
if the path does not exist.  This is nonstandard behaviour, but the
behaviour nonetheless.  We need to try to construct the real path, and
then manually check if the path exists.
  • Loading branch information
jakewilliami committed Sep 26, 2022
1 parent a8adc6e commit 50f0731
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/HiddenFiles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ end
# Each OS branch defines its own _ishidden function. In the main ishidden function, we check that the path exists, expand
# the real path out, and apply the branch's _ishidden function to that path to get a final result
function ishidden(f::AbstractString)
# If path does not exist, `realpath` will error™
try
rp = realpath(f)
catch e
Expand All @@ -201,7 +202,13 @@ function ishidden(f::AbstractString)
# If this fails for some other reason, rethrow
rethrow()
end
return _ishidden(f, realpath(f))

# Julia < 1.2 on Windows does not error on `realpath` if path does not exist, so we
# must do so manually here
ispath(rp) || throw(Base.uv_error("ishidden($(repr(f)))", Base.UV_ENOENT))

# If we got here, the path exists, and we can continue safely with our _ishidden checks
return _ishidden(f, rp)
end


Expand Down

0 comments on commit 50f0731

Please sign in to comment.