system-filepath-0.4.14: 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 | Haskell98

Filesystem.Path.CurrentOS

Contents

- Type conversions
- Rule‐specific path properties
- Orphan instances

Description

Re‐exports contents of Filesystem.Path.Rules, defaulting to the current OS’s rules when needed.

Also enables `Show` and `IsString` instances for `FilePath`.

Synopsis

- module Filesystem.Path
- module Filesystem.Path
- currentOS :: Rules platformTextFormat
- toText :: FilePath -> Either Text Text
- fromText :: Text -> FilePath
- encode :: FilePath -> platformTextFormat
- decode :: platformTextFormat -> FilePath
- encodeString :: FilePath -> String
- decodeString :: String -> FilePath
- valid :: FilePath -> Bool
- splitSearchPath :: platformTextFormat -> [FilePath]
- splitSearchPathString :: String -> [FilePath]

# Documentation

module Filesystem.Path

module Filesystem.Path

currentOS :: Rules platformTextFormat #

# Type conversions

toText :: FilePath -> Either Text Text #

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 :: Text -> FilePath #

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 :: FilePath -> platformTextFormat #

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

Note: The type `platformTextFormat` can change depending upon the underlying compilation platform. Consider using `toText` or `encodeString` instead. See `Rules` for more information.

Since: 0.3

decode :: platformTextFormat -> FilePath #

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

Note: The type `platformTextFormat` can change depending upon the underlying compilation platform. Consider using `fromText` or `decodeString` instead. See `Rules` for more information.

Since: 0.3

encodeString :: FilePath -> String #

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 `FilePath`s to a human‐readable format, use `toText`.

Since: 0.3.1

decodeString :: String -> FilePath #

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 :: FilePath -> Bool #

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

splitSearchPath :: platformTextFormat -> [FilePath] #

Split a search path, such as `$PATH` or `$PYTHONPATH`, into a list of `FilePath`s.

splitSearchPathString :: String -> [FilePath] #

splitSearchPathString is like `splitSearchPath`, but takes a string encoded in the format used by `System.IO`.

# Orphan instances

Show FilePath # |
Instance details Methods showsPrec :: Int -> FilePath -> ShowS # show :: FilePath -> String # showList :: [FilePath] -> ShowS #
IsString FilePath # |
Instance details Methods fromString :: String -> FilePath #