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

Portabilityportable
Maintainerjmillikin@gmail.com

System.FilePath.Rules

Contents

Description

 

Synopsis

Documentation

data Rules Source

Instances

Rule-specific path properties

valid :: Rules -> FilePath -> BoolSource

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

normalise :: Rules -> FilePath -> FilePathSource

Remove redundant characters. On case-insensitive platforms, also lowercases any ASCII uppercase characters.

equivalent :: Rules -> FilePath -> FilePath -> BoolSource

Check if two different FilePaths refer to the same file. This does not perform any link resolution, so some equivalent files might be missed.

Parsing file paths

toBytes :: Rules -> FilePath -> ByteStringSource

Convert a FilePath into a strict ByteString, suitable for passing to OS libraries.

toString :: Rules -> FilePath -> StringSource

Convert a FilePath into a lazy String. This is useful for interoperating with legacy libraries. No decoding is performed; the string's character ordinals are equal to the path's original bytes. If you need to display a FilePath to the user, use toLazyBytes and an appropriate decoding function.

fromBytes :: Rules -> ByteString -> FilePathSource

Parse a strict ByteString, such as those received from OS libraries, into a FilePath.

fromString :: Rules -> String -> FilePathSource

Parse a lazy String into a FilePath. This is useful for interoperating with legacy libraries. No encoding is performed; characters are truncated to 8 bits. If you need to accept a FilePath from the user, use fromLazyBytes and an appropriate encoding function.

Parsing search paths

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

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