Skip to content

Commit

Permalink
Sys.exists becomes ispath
Browse files Browse the repository at this point in the history
  • Loading branch information
fatteneder committed Feb 16, 2024
1 parent d856dc0 commit 6491148
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
7 changes: 7 additions & 0 deletions base/stat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,13 @@ otherwise returns `false`.
This is the generalization of [`isfile`](@ref), [`isdir`](@ref) etc.
"""
ispath(st::StatStruct) = filemode(st) & 0xf000 != 0x0000
function ispath(path::String)
# 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
end
ispath(path::AbstractString) = ispath(String(path))

"""
isfifo(path) -> Bool
Expand Down
14 changes: 0 additions & 14 deletions base/sysinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export BINDIR,
isexecutable,
isreadable,
iswriteable,
exists,
username,
which

Expand Down Expand Up @@ -599,19 +598,6 @@ function iswriteable(path::String)
end
iswriteable(path::AbstractString) = iswriteable(String(path))

"""
Sys.exists(path::String)
Return `true` if the given `path` exists.
"""
function exists(path::String)
# We use `access()` and `F_OK` to determine if a given path is
# executable by the current user. `F_OK` comes from `unistd.h`.
F_OK = 0x00
return ccall(:jl_fs_access, Cint, (Ptr{UInt8}, Cint), path, F_OK) == 0
end
exists(path::AbstractString) = exists(String(path))

"""
Sys.which(program_name::String)
Expand Down

0 comments on commit 6491148

Please sign in to comment.