Skip to content

Commit

Permalink
wip: temporary fix for ispath
Browse files Browse the repository at this point in the history
  • Loading branch information
fatteneder committed Feb 15, 2024
1 parent 7c7c8aa commit 06c6c56
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion base/stat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,15 @@ This is the generalization of [`isfile`](@ref), [`isdir`](@ref) etc.
"""
ispath(st::StatStruct) = filemode(st) & 0xf000 != 0x0000
function ispath(path::String)
if contains(path, '\0')
throw(ArgumentError("embedded NULs are not allowed in C strings: \"$(repr(path))\""))
end
# We use `access()` and `F_OK` to determine if a given path exists.
# `F_OK` comes from `unistd.h`.
F_OK = 0x00
return ccall(:jl_fs_access, Cint, (Ptr{UInt8}, Cint), path, F_OK) == 0
res = ccall(:jl_fs_access, Cint, (Ptr{UInt8}, Cint), path, F_OK)
@assert res in (0, Base.UV_ENOENT)
return res == 0
end
ispath(path::AbstractString) = ispath(String(path))

Expand Down

0 comments on commit 06c6c56

Please sign in to comment.