Copyright | (c) Fuzz Leonard 2019 |
---|---|
License | BSD-3 |
Maintainer | fuzz@kt-22.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | Safe |
Language | Haskell2010 |
SymbolicLink provides tools for working with symbolic links on POSIX systems.
The executable symlink
changes to the user's home directory, reads in a
sequence of source/target mappings from a YAML file in .symlinks
and attempts
to create them. If the target exists and is a symbolic link it will be removed
and replaced, otherwise symlink will refuse to clobber it.
The function filePathExist
works like fileExist
from System.Posix.Files
or doesPathExist
from System.Directory
but does not follow symlinks, thus
making it suitable for working with unreferenced symlinks. Unreferenced
symlinks are not necessarily "broken"; one should not have to handle exceptions
to work with them.
Conceptually filePathExist
is concerned with the perspective of the current
user environment, thus we consider the path to not exist if the user does not
have the necessary permissions or if any other error occurs while attempting
to get the FilePath
status.
Synopsis
- data FileType
- filePathExist :: FilePath -> IO Bool
- filePathExistEither :: FilePath -> IO (Either IOError Bool)
- fileType :: FilePath -> IO FileType
- fileTypeEither :: FilePath -> IO (Either IOError FileType)
- fileTypeMaybe :: FilePath -> IO (Maybe FileType)
- getFileTypeFromStatus :: FileStatus -> FileType
Documentation
filePathExist :: FilePath -> IO Bool Source #
filePathExist
works like fileExist
except it doesn't follow symlinks.
filePathExistEither :: FilePath -> IO (Either IOError Bool) Source #
Like filePathExist
but get the IOError
instead of False
fileType :: FilePath -> IO FileType Source #
Return the actual FileType
of a FilePath
without following
symbolic links. This is unsafe; you should ensure you can get a
FileStatus
before evaluation.
fileTypeEither :: FilePath -> IO (Either IOError FileType) Source #
Like fileType
but with errors wrapped for your protection.
fileTypeMaybe :: FilePath -> IO (Maybe FileType) Source #
Like fileType
without errors because life is short.
getFileTypeFromStatus :: FileStatus -> FileType Source #
Remember that FileStatus
can go stale and thus so can FileType
.