License | BSD-3-Clause |
---|---|
Safe Haskell | None |
Language | GHC2021 |
Path.Extra
Description
Synopsis
- toFilePathNoTrailingSep :: Path loc Dir -> FilePath
- parseCollapsedAbsDir :: MonadThrow m => FilePath -> m (Path Abs Dir)
- parseCollapsedAbsFile :: MonadThrow m => FilePath -> m (Path Abs File)
- concatAndCollapseAbsDir :: MonadThrow m => Path Abs Dir -> FilePath -> m (Path Abs Dir)
- rejectMissingFile :: MonadIO m => Maybe (Path Abs File) -> m (Maybe (Path Abs File))
- rejectMissingDir :: MonadIO m => Maybe (Path Abs Dir) -> m (Maybe (Path Abs Dir))
- pathToByteString :: Path b t -> ByteString
- pathToLazyByteString :: Path b t -> ByteString
- pathToText :: Path b t -> Text
- tryGetModificationTime :: MonadIO m => Path Abs File -> m (Either () UTCTime)
- forgivingResolveDir :: MonadIO m => Path Abs Dir -> FilePath -> m (Maybe (Path Abs Dir))
- forgivingResolveFile :: MonadIO m => Path Abs Dir -> FilePath -> m (Maybe (Path Abs File))
- forgivingResolveFile' :: MonadIO m => FilePath -> m (Maybe (Path Abs File))
Documentation
toFilePathNoTrailingSep :: Path loc Dir -> FilePath Source #
Convert to FilePath but don't add a trailing slash.
parseCollapsedAbsDir :: MonadThrow m => FilePath -> m (Path Abs Dir) Source #
Collapse intermediate "." and ".." directories from path, then parse
it with parseAbsDir
.
(probably should be moved to the Path module)
parseCollapsedAbsFile :: MonadThrow m => FilePath -> m (Path Abs File) Source #
Collapse intermediate "." and ".." directories from path, then parse
it with parseAbsFile
.
(probably should be moved to the Path module)
concatAndCollapseAbsDir :: MonadThrow m => Path Abs Dir -> FilePath -> m (Path Abs Dir) Source #
Add a relative FilePath to the end of a Path We can't parse the FilePath first because we need to account for ".." in the FilePath (#2895)
rejectMissingFile :: MonadIO m => Maybe (Path Abs File) -> m (Maybe (Path Abs File)) Source #
If given file in Maybe
does not exist, ensure we have Nothing
. This
is to be used in conjunction with forgivingAbsence
and
resolveFile
.
Previously the idiom forgivingAbsence (resolveFile …)
alone was used, which
relied on canonicalizePath
throwing isDoesNotExistError
when path
does not exist. As it turns out, this behavior is actually not intentional
and unreliable, see https://github.com/haskell/directory/issues/44. This
was “fixed” in version 1.2.3.0
of directory
package (now it never
throws). To make it work with all versions, we need to use the following
idiom:
forgivingAbsence (resolveFile …) >>= rejectMissingFile
rejectMissingDir :: MonadIO m => Maybe (Path Abs Dir) -> m (Maybe (Path Abs Dir)) Source #
See rejectMissingFile
.
pathToByteString :: Path b t -> ByteString Source #
Convert to a ByteString using toFilePath and UTF8.
pathToLazyByteString :: Path b t -> ByteString Source #
Convert to a lazy ByteString using toFilePath and UTF8.
tryGetModificationTime :: MonadIO m => Path Abs File -> m (Either () UTCTime) Source #
Attempt to get the time at which the given file was last modified. Yields `Left ()` if the file does not exist.
The operation may fail with isPermissionError
if the user
is not permitted to read the modification time.
Caveat for POSIX systems: This function returns a timestamp with sub-second resolution only if this package is compiled against `unix-2.6.0.0` or later and the underlying filesystem supports them.
Arguments
:: MonadIO m | |
=> Path Abs Dir | Base directory |
-> FilePath | Path to resolve |
-> m (Maybe (Path Abs Dir)) |
resolveDir
(path-io
package) throws InvalidAbsDir
(path
package) in certain circumstances; this function yields Nothing
in those
circumstances.