Copyright | (c) 2019-2020 Vaclav Svejcar |
---|---|
License | BSD-3-Clause |
Maintainer | vaclav.svejcar@gmail.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Module providing functions for working with the local file system, its file and directories.
Synopsis
- findFiles :: MonadIO m => FilePath -> (FilePath -> Bool) -> m [FilePath]
- findFilesByExts :: MonadIO m => FilePath -> [Text] -> m [FilePath]
- findFilesByTypes :: MonadIO m => HeadersConfig -> [FileType] -> FilePath -> m [FilePath]
- listFiles :: MonadIO m => FilePath -> m [FilePath]
- loadFile :: MonadIO m => FilePath -> m Text
- doesFileExist :: MonadIO m => FilePath -> m Bool
- getCurrentDirectory :: MonadIO m => m FilePath
- createDirectory :: MonadIO m => FilePath -> m ()
- fileExtension :: FilePath -> Maybe Text
- excludePaths :: [Text] -> [FilePath] -> [FilePath]
Traversing the File System
:: MonadIO m | |
=> FilePath | path to search |
-> (FilePath -> Bool) | predicate to match filename |
-> m [FilePath] | found files |
Recursively finds files on given path whose filename matches the predicate.
:: MonadIO m | |
=> FilePath | path to search |
-> [Text] | list of file extensions (without dot) |
-> m [FilePath] | list of found files |
Recursively finds files on given path by file extensions.
:: MonadIO m | |
=> HeadersConfig | configuration of license headers |
-> [FileType] | list of file types |
-> FilePath | path to search |
-> m [FilePath] | list of found files |
Recursively find files on given path by their file types.
Recursively find all files on given path. If file reference is passed instead of directory, such file path is returned.
Loads file content in UTF8 encoding.
Working with Files/Directories
doesFileExist :: MonadIO m => FilePath -> m Bool #
Lifted doesFileExist
.
Since: unliftio-0.2.6.0
getCurrentDirectory :: MonadIO m => m FilePath #
Lifted getCurrentDirectory
.
Since: unliftio-0.2.6.0
createDirectory :: MonadIO m => FilePath -> m () #
Lifted createDirectory
.
Since: unliftio-0.2.6.0
Working with Files Metadata
fileExtension :: FilePath -> Maybe Text Source #
Returns file extension for given path (if file), or nothing otherwise.
>>>
fileExtension "path/to/some/file.txt"
Just "txt"
Other
:: [Text] | patterns describing paths to exclude |
-> [FilePath] | list of file paths |
-> [FilePath] | resulting list of file paths |
Takes list of patterns and file paths and returns list of file paths where those matching the given patterns are excluded.
>>>
excludePaths ["\\.hidden", "zzz"] ["foo/.hidden", "test/bar", "x/zzz/e"]
["test/bar"]