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

Portabilityportable
Maintainerjmillikin@gmail.com

System.FilePath.Rules

Contents

Description

 

Synopsis

Documentation

data Rules platformFormat Source

Instances

Show (Rules a) 

posix :: Rules ByteStringSource

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

windows :: Rules TextSource

Windows and DOS

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 toBytes 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 fromBytes.

Since: 0.2

encode :: Rules platformFormat -> FilePath -> platformFormatSource

Convert a FilePath to the platform’s underlying format.

Since: 0.3

decode :: Rules platformFormat -> platformFormat -> FilePathSource

Convert the platform’s underlying format to a FilePath.

Since: 0.3

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.