Development.Shake.FilePath

shake-0.15.10: Build system library, like Make, but more accurate dependencies.

Safe Haskell | Safe
Language | Haskell2010

Development.Shake.FilePath

Description

A module for `FilePath` operations exposing System.FilePath plus some additional operations.

Windows note: The extension methods (`<.>`, `takeExtension` etc) use the Posix variants since on Windows `"//*" `<.>` "txt"` produces `"//*\\.txt"` (which is bad for `FilePattern` values).

Synopsis

- module System.FilePath
- module System.FilePath.Posix
- dropDirectory1 :: FilePath -> FilePath
- takeDirectory1 :: FilePath -> FilePath
- normaliseEx :: FilePath -> FilePath
- toNative :: FilePath -> FilePath
- toStandard :: FilePath -> FilePath
- exe :: String

# Documentation

module System.FilePath

module System.FilePath.Posix

dropDirectory1 :: FilePath -> FilePath #

Drop the first directory from a `FilePath`. Should only be used on relative paths.

    dropDirectory1 "aaa/bbb" == "bbb"
    dropDirectory1 "aaa/" == ""
    dropDirectory1 "aaa" == ""
    dropDirectory1 "" == ""

takeDirectory1 :: FilePath -> FilePath #

Take the first component of a `FilePath`. Should only be used on relative paths.

    takeDirectory1 "aaa/bbb" == "aaa"
    takeDirectory1 "aaa/" == "aaa"
    takeDirectory1 "aaa" == "aaa"

normaliseEx :: FilePath -> FilePath #

Normalise a `FilePath`, applying the rules:

- All `pathSeparators` become `pathSeparator` (`/` on Linux, `\` on Windows)
- `foo/bar/../baz` becomes `foo/baz` (not universally true in the presence of symlinks)
- `foo/./bar` becomes `foo/bar`
- `foo//bar` becomes `foo/bar`

This function is not based on the `normalise` function from the `filepath` library, as that function is quite broken.

toNative :: FilePath -> FilePath #

Convert to native path separators, namely `\` on Windows.

toStandard :: FilePath -> FilePath #

Convert all path separators to `/`, even on Windows.

exe :: String #

The extension of executables, `"exe"` on Windows and `""` otherwise.