system-filepath-0.3.7: High-level, byte-based file and directory path manipulations

Portabilityportable
Maintainerjmillikin@gmail.com
Safe HaskellSafe-Infered

Filesystem.Path.Rules

Contents

Description

 

Synopsis

Documentation

data Rules platformFormat Source

Instances

Show (Rules a) 

posix :: Rules ByteStringSource

Linux, BSD, and other UNIX or UNIX-like operating systems.

posix_ghc702 :: Rules ByteStringSource

Linux, BSD, and other UNIX or UNIX-like operating systems.

This is a variant of posix for use with GHC 7.2, which tries to decode file paths in its IO computations.

Since: 0.3.3

posix_ghc704 :: Rules ByteStringSource

Linux, BSD, and other UNIX or UNIX-like operating systems.

This is a variant of posix for use with GHC 7.4 or later, which tries to decode file paths in its IO computations.

Since: 0.3.7

windows :: Rules TextSource

Windows and DOS

darwin :: Rules TextSource

Darwin and Mac OS X.

This is almost identical to posix, but with a native path type of Text rather than ByteString.

Since: 0.3.4

darwin_ghc702 :: Rules TextSource

Darwin and Mac OS X.

This is a variant of darwin for use with GHC 7.2 or later, which tries to decode file paths in its IO computations.

Since: 0.3.4

Type conversions

toText :: Rules platformFormat -> FilePath -> Either Text TextSource

Attempt to convert a FilePath to human‐readable text.

If the path is decoded successfully, the result is a Right containing the decoded text. Successfully decoded text can be converted back to the original path using fromText.

If the path cannot be decoded, the result is a Left containing an approximation of the original path. If displayed to the user, this value should be accompanied by some warning that the path has an invalid encoding. Approximated text cannot be converted back to the original path.

This function ignores the user’s locale, and assumes all file paths are encoded in UTF8. If you need to display file paths with an unusual or obscure encoding, use encode and then decode them manually.

Since: 0.2

fromText :: Rules platformFormat -> Text -> FilePathSource

Convert human‐readable text into a FilePath.

This function ignores the user’s locale, and assumes all file paths are encoded in UTF8. If you need to create file paths with an unusual or obscure encoding, encode them manually and then use decode.

Since: 0.2

encode :: Rules platformFormat -> FilePath -> platformFormatSource

Convert a FilePath to a platform‐specific format, suitable for use with external OS functions.

Since: 0.3

decode :: Rules platformFormat -> platformFormat -> FilePathSource

Convert a FilePath from a platform‐specific format, suitable for use with external OS functions.

Since: 0.3

encodeString :: Rules platformFormat -> FilePath -> StringSource

Attempt to convert a FilePath to a string suitable for use with functions in System.IO. The contents of this string are platform‐dependent, and are not guaranteed to be human‐readable. For converting FilePaths to a human‐readable format, use toText.

Since: 0.3.1

decodeString :: Rules platformFormat -> String -> FilePathSource

Attempt to parse a FilePath from a string suitable for use with functions in System.IO. Do not use this function for parsing human‐readable paths, as the character set decoding is platform‐dependent. For converting human‐readable text to a FilePath, use fromText.

Since: 0.3.1

Rule‐specific path properties

valid :: Rules platformFormat -> FilePath -> BoolSource

Check if a FilePath is valid; it must not contain any illegal characters, and must have a root appropriate to the current Rules.

splitSearchPath :: Rules platformFormat -> platformFormat -> [FilePath]Source

Split a search path, such as $PATH or $PYTHONPATH, into a list of FilePaths.