Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ismount function. #11279

Merged
merged 1 commit into from
May 27, 2015
Merged
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
1 change: 1 addition & 0 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,7 @@ export
isfifo,
isfile,
islink,
ismount,
ispath,
isreadable,
issetgid,
Expand Down
15 changes: 15 additions & 0 deletions base/stat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,18 @@ function samefile(a::AbstractString, b::AbstractString)
return false
end
end

function ismount(path...)
path = joinpath(path...)
isdir(path) || return false
s1 = lstat(path)
# Symbolic links cannot be mount points
islink(s1) && return false
parent_path = joinpath(path, "..")
s2 = lstat(parent_path)
# If a directory and its parent are on different devices, then the
# directory must be a mount point
(s1.device != s2.device) && return true
(s1.inode == s2.inode) && return true
false
end
4 changes: 4 additions & 0 deletions doc/stdlib/file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@

Returns ``true`` if ``path`` is a symbolic link, ``false`` otherwise.

.. function:: ismount(path) -> Bool

Returns ``true`` if ``path`` is a mount point, ``false`` otherwise.

.. function:: ispath(path) -> Bool

Returns ``true`` if ``path`` is a valid filesystem path, ``false`` otherwise.
Expand Down