system-filepath-0.4.14.1: High-level, byte-based file and directory path manipulations (deprecated)

Copyright | 2010 John Millikin
License | MIT
Maintainer | jmillikin@gmail.com
Portability | portable
Safe Haskell | Safe-Inferred
Language | Haskell2010

Filesystem.Path

Contents

- Basic properties
- Basic operations
- Extensions
- Orphan instances

Description

High‐level, byte‐based file and directory path manipulations. You probably want to import Filesystem.Path.CurrentOS instead, since it handles detecting which rules to use in the current compilation.

Synopsis

- data FilePath
- empty :: FilePath
- null :: FilePath -> Bool
- root :: FilePath -> FilePath
- directory :: FilePath -> FilePath
- parent :: FilePath -> FilePath
- filename :: FilePath -> FilePath
- dirname :: FilePath -> FilePath
- basename :: FilePath -> FilePath
- absolute :: FilePath -> Bool
- relative :: FilePath -> Bool
- append :: FilePath -> FilePath -> FilePath
- (</>) :: FilePath -> FilePath -> FilePath
- concat :: [FilePath] -> FilePath
- commonPrefix :: [FilePath] -> FilePath
- stripPrefix :: FilePath -> FilePath -> Maybe FilePath
- collapse :: FilePath -> FilePath
- splitDirectories :: FilePath -> [FilePath]
- extension :: FilePath -> Maybe Text
- extensions :: FilePath -> [Text]
- hasExtension :: FilePath -> Text -> Bool
- addExtension :: FilePath -> Text -> FilePath
- (<.>) :: FilePath -> Text -> FilePath
- dropExtension :: FilePath -> FilePath
- replaceExtension :: FilePath -> Text -> FilePath
- addExtensions :: FilePath -> [Text] -> FilePath
- dropExtensions :: FilePath -> FilePath
- replaceExtensions :: FilePath -> [Text] -> FilePath
- splitExtension :: FilePath -> (FilePath, Maybe Text)
- splitExtensions :: FilePath -> (FilePath, [Text])

# Documentation

data FilePath Source #

#### Instances

Instances details

NFData FilePath Source # |
Instance details Defined in Filesystem.Path.Internal Methods rnf :: FilePath -> () Source #
Monoid FilePath Source # |
Instance details Defined in Filesystem.Path Methods mempty :: FilePath Source # mappend :: FilePath -> FilePath -> FilePath Source # mconcat :: [FilePath] -> FilePath Source #
Semigroup FilePath Source # |
Instance details Defined in Filesystem.Path Methods (<>) :: FilePath -> FilePath -> FilePath Source # sconcat :: NonEmpty FilePath -> FilePath Source # stimes :: Integral b => b -> FilePath -> FilePath Source #
Data FilePath Source # |

Instance details

Defined in Filesystem.Path.Internal

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> FilePath -> c FilePath Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c FilePath Source #

toConstr :: FilePath -> Constr Source #

dataTypeOf :: FilePath -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c FilePath) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FilePath) Source #

gmapT :: (forall b. Data b => b -> b) -> FilePath -> FilePath Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> FilePath -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> FilePath -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> FilePath -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> FilePath -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> FilePath -> m FilePath Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> FilePath -> m FilePath Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> FilePath -> m FilePath Source #

IsString FilePath Source # |
Instance details Defined in Filesystem.Path.CurrentOS Methods fromString :: String -> FilePath Source #
Show FilePath Source # |
Instance details Defined in Filesystem.Path.CurrentOS Methods showsPrec :: Int -> FilePath -> ShowS Source # show :: FilePath -> String Source # showList :: [FilePath] -> ShowS Source #
Eq FilePath Source # |
Instance details Defined in Filesystem.Path.Internal Methods (==) :: FilePath -> FilePath -> Bool Source # (/=) :: FilePath -> FilePath -> Bool Source #
Ord FilePath Source # |
Instance details Defined in Filesystem.Path.Internal Methods compare :: FilePath -> FilePath -> Ordering Source # (<) :: FilePath -> FilePath -> Bool Source # (<=) :: FilePath -> FilePath -> Bool Source # (>) :: FilePath -> FilePath -> Bool Source # (>=) :: FilePath -> FilePath -> Bool Source # max :: FilePath -> FilePath -> FilePath Source # min :: FilePath -> FilePath -> FilePath Source #

empty :: FilePath Source #

A file path with no root, directory, or filename

# Basic properties

null :: FilePath -> Bool Source #

    null p = (p == empty)

root :: FilePath -> FilePath Source #

Retrieves the `FilePath`’s root.

directory :: FilePath -> FilePath Source #

Retrieves the `FilePath`’s directory. If the path is already a directory, it is returned unchanged.

parent :: FilePath -> FilePath Source #

Retrieves the `FilePath`’s parent directory.

filename :: FilePath -> FilePath Source #

Retrieve a `FilePath`’s filename component.

    filename "foo/bar.txt" == "bar.txt"

dirname :: FilePath -> FilePath Source #

Retrieve a `FilePath`’s directory name. This is only the file name of the directory, not its full path.

    dirname "foo/bar/baz.txt" == "bar"
    dirname "/" == ""

Since: 0.4.1

basename :: FilePath -> FilePath Source #

Retrieve a `FilePath`’s basename component.

    basename "foo/bar.txt" == "bar"

absolute :: FilePath -> Bool Source #

Test whether a path is absolute.

relative :: FilePath -> Bool Source #

Test whether a path is relative.

# Basic operations

append :: FilePath -> FilePath -> FilePath Source #

Appends two `FilePath`s. If the second path is absolute, it is returned unchanged.

(</>) :: FilePath -> FilePath -> FilePath Source #

An alias for `append`.

concat :: [FilePath] -> FilePath Source #

A fold over `append`.

commonPrefix :: [FilePath] -> FilePath Source #

Find the greatest common prefix between a list of `FilePath`s.

stripPrefix :: FilePath -> FilePath -> Maybe FilePath Source #

Remove a prefix from a path.

    stripPrefix "/foo/" "/foo/bar/baz.txt" == Just "bar/baz.txt"
    stripPrefix "/foo/" "/bar/baz.txt" == Nothing

This function operates on logical prefixes, rather than by counting characters. The prefix `"/foo/bar/baz"` is interpreted the path `("/foo/bar/", "baz")`, and will be stripped accordingly:

    stripPrefix "/foo/bar/baz" "/foo/bar/baz/qux" == Nothing
    stripPrefix "/foo/bar/baz" "/foo/bar/baz.txt" == Just ".txt"

Since: 0.4.1

collapse :: FilePath -> FilePath Source #

Remove intermediate `"."` and `".."` directories from a path.

    collapse "/foo/./bar" == "/foo/bar"
    collapse "/foo/bar/../baz" == "/foo/baz"
    collapse "/foo/../../bar" == "/bar"
    collapse "./foo/bar" == "./foo/baz"

Note that if any of the elements are symbolic links, `collapse` may change which file the path resolves to.

Since: 0.2

splitDirectories :: FilePath -> [FilePath] Source #

expand a FilePath into a list of the root name, directories, and file name

Since: 0.4.7

# Extensions

extension :: FilePath -> Maybe Text Source #

Get a `FilePath`’s last extension, or `Nothing` if it has no extensions.

extensions :: FilePath -> [Text] Source #

Get a `FilePath`’s full extension list.

hasExtension :: FilePath -> Text -> Bool Source #

Get whether a `FilePath`’s last extension is the predicate.

addExtension :: FilePath -> Text -> FilePath Source #

Append an extension to the end of a `FilePath`.

(<.>) :: FilePath -> Text -> FilePath Source #

An alias for `addExtension`.

dropExtension :: FilePath -> FilePath Source #

Remove a `FilePath`’s last extension.

replaceExtension :: FilePath -> Text -> FilePath Source #

Replace a `FilePath`’s last extension.

addExtensions :: FilePath -> [Text] -> FilePath Source #

Append many extensions to the end of a `FilePath`.

dropExtensions :: FilePath -> FilePath Source #

Remove all extensions from a `FilePath`.

replaceExtensions :: FilePath -> [Text] -> FilePath Source #

Remove all extensions from a `FilePath`, and replace them with a new list.

splitExtension :: FilePath -> (FilePath, Maybe Text) Source #

    splitExtension p = (dropExtension p, extension p)

splitExtensions :: FilePath -> (FilePath, [Text]) Source #

    splitExtensions p = (dropExtensions p, extensions p)

# Orphan instances

Monoid FilePath Source # |
Instance details Methods mempty :: FilePath Source # mappend :: FilePath -> FilePath -> FilePath Source # mconcat :: [FilePath] -> FilePath Source #
Semigroup FilePath Source # |
Instance details Methods (<>) :: FilePath -> FilePath -> FilePath Source # sconcat :: NonEmpty FilePath -> FilePath Source # stimes :: Integral b => b -> FilePath -> FilePath Source #