Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions base/stat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -472,29 +472,37 @@ operm(st::StatStruct) = UInt8((filemode(st) ) & 0x7)

# mode predicate methods for file names

# The documentation in these files refer to taking the same argument as `stat`...
for f in Symbol[
:uperm,
:gperm,
:operm,
:filemode,
:filesize,
:mtime,
:ctime,
]
@eval ($f)(path...) = ($f)(stat(path...))
end

# ...whereas these files should really only take paths (and not e.g. Ints)
# See issue #51710
for f in Symbol[
:ispath,
:isfifo,
:ischardev,
:isdir,
:isblockdev,
:ispath,
:isfile,
:issocket,
:issetuid,
:issetgid,
:issticky,
:uperm,
:gperm,
:operm,
:filemode,
:filesize,
:mtime,
:ctime,
]
@eval ($f)(path...) = ($f)(stat(path...))
@eval ($f)(path::AbstractString, paths::AbstractString...) = ($f)(stat(path, paths...))
end

islink(path...) = islink(lstat(path...))
islink(path::AbstractString, paths::AbstractString...) = islink(lstat(path, paths...))

# samefile can be used for files and directories: #11145#issuecomment-99511194
function samefile(a::StatStruct, b::StatStruct)
Expand All @@ -513,8 +521,8 @@ samefile(a::AbstractString, b::AbstractString) = samefile(stat(a), stat(b))

Return `true` if `path` is a mount point, `false` otherwise.
"""
function ismount(path...)
path = joinpath(path...)
function ismount(path::AbstractString, paths::Vararg{AbstractString})
path = joinpath(path, paths...)
isdir(path) || return false
s1 = lstat(path)
# Symbolic links cannot be mount points
Expand Down
8 changes: 8 additions & 0 deletions test/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,14 @@ let path = tempname()
@test !ispath(path)
end

# Issue #51710
for f in [
isfifo, ischardev, isdir, isblockdev, ispath, isfile, issocket,
issetuid, issetgid, issticky
]
@test_throws MethodError f(1)
end

(p, f) = mktemp()
print(f, "Here is some text")
close(f)
Expand Down