headroom-0.2.2.1: License Header Manager
Copyright(c) 2019-2020 Vaclav Svejcar
LicenseBSD-3-Clause
Maintainervaclav.svejcar@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Headroom.FileSystem

Description

Module providing functions for working with the local file system, its file and directories.

Synopsis

Traversing the File System

findFiles Source #

Arguments

:: 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.

findFilesByExts Source #

Arguments

:: 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.

findFilesByTypes Source #

Arguments

:: 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.

listFiles Source #

Arguments

:: MonadIO m 
=> FilePath

path to search

-> m [FilePath]

list of found files

Recursively find all files on given path. If file reference is passed instead of directory, such file path is returned.

loadFile Source #

Arguments

:: MonadIO m 
=> FilePath

file path

-> m Text

file content

Loads file content in UTF8 encoding.

Working with Files/Directories

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

excludePaths Source #

Arguments

:: [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"]