Skip to content

Commit

Permalink
Added ismount function.
Browse files Browse the repository at this point in the history
  • Loading branch information
malmaud committed May 25, 2015
1 parent 96cc970 commit 969df71
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
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

0 comments on commit 969df71

Please sign in to comment.