Portability | portable |
---|---|
Maintainer | jmillikin@gmail.com |
System.FilePath.Rules
Description
- data Rules
- posix :: Rules
- windows :: Rules
- valid :: Rules -> FilePath -> Bool
- normalise :: Rules -> FilePath -> FilePath
- equivalent :: Rules -> FilePath -> FilePath -> Bool
- toBytes :: Rules -> FilePath -> ByteString
- toLazyBytes :: Rules -> FilePath -> ByteString
- toString :: Rules -> FilePath -> String
- fromBytes :: Rules -> ByteString -> FilePath
- fromLazyBytes :: Rules -> ByteString -> FilePath
- fromString :: Rules -> String -> FilePath
- splitSearchPath :: Rules -> ByteString -> [FilePath]
Documentation
Rule-specific path properties
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 FilePath
s 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.
toLazyBytes :: Rules -> FilePath -> ByteStringSource
Convert a FilePath
into a lazy ByteString
.
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
.
fromLazyBytes :: Rules -> ByteString -> FilePathSource
Parse a lazy ByteString
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 FilePath
s.