Skip to content

Commit 36b08e7

Browse files
committed
use Sys.readable for permission check
1 parent a7d6bc7 commit 36b08e7

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

base/loading.jl

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,16 +1946,25 @@ const include_callbacks = Any[]
19461946
const _concrete_dependencies = Pair{PkgId,UInt128}[] # these dependency versions are "set in stone", and the process should try to avoid invalidating them
19471947
const _require_dependencies = Any[] # a list of (mod, abspath, fsize, hash, mtime) tuples that are the file dependencies of the module currently being precompiled
19481948
const _track_dependencies = Ref(false) # set this to true to track the list of file dependencies
1949-
function _include_dependency(mod::Module, _path::AbstractString; track_content=true)
1949+
function _include_dependency(mod::Module, _path::AbstractString; track_content=true,
1950+
path_maybe_dir=false)
19501951
prev = source_path(nothing)
19511952
if prev === nothing
19521953
path = abspath(_path)
19531954
else
19541955
path = normpath(joinpath(dirname(prev), _path))
19551956
end
1956-
ispath(path) || throw(ArgumentError("$(repr(path)): No such file or directory"))
1957-
uperm(path) & 0x04 == 0x04 || throw(ArgumentError("$(repr(path)): Missing read permission"))
1958-
if _track_dependencies[]
1957+
if !_track_dependencies[]
1958+
if !path_maybe_dir && !isfile(path)
1959+
throw(ArgumentError("including $(repr(path)): No such file"))
1960+
elseif path_maybe_dir && !ispath(path)
1961+
throw(ArgumentError("including $(repr(path)): No such file or directory"))
1962+
end
1963+
readable = @static Sys.iswindows() ? uperm(path) & 0x04 == 0x04 : Sys.isreadable(path)
1964+
if !readable
1965+
throw(ArgumentError("including $(repr(path)): Missing read permission"))
1966+
end
1967+
else
19591968
@lock require_lock begin
19601969
if track_content
19611970
hash = isdir(path) ? _crc32c(join(readdir(path))) : open(_crc32c, path, "r")
@@ -1985,7 +1994,7 @@ no effect outside of compilation.
19851994
Keyword argument `track_content` requires at least Julia 1.11.
19861995
"""
19871996
function include_dependency(path::AbstractString; track_content::Bool=false)
1988-
_include_dependency(Main, path, track_content=track_content)
1997+
_include_dependency(Main, path, track_content=track_content, path_maybe_dir=true)
19891998
return nothing
19901999
end
19912000

0 commit comments

Comments
 (0)