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

Safe HaskellNone
LanguageHaskell2010

Development.Shake.FilePath

Description

A module for FilePath operations, to be used instead of System.FilePath when writing build systems. In build systems, when using the file name as a key for indexing rules, it is important that two different strings do not refer to the same on-disk file. We therefore follow the conventions:

  • Always use / as the directory separator, even on Windows.
  • When combining FilePath values with </> we squash any /./ components.

Synopsis

Documentation

dropDirectory1 :: FilePath -> FilePath Source

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 Source

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

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

normalise :: FilePath -> FilePath Source

Normalise a FilePath, trying to do:

  • All pathSeparators become /
  • foo/bar/../baz becomes foo/baz
  • 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.

(-<.>) :: FilePath -> String -> FilePath infixr 7 Source

Remove the current extension and add another, an alias for replaceExtension.

toNative :: FilePath -> FilePath Source

Convert to native path separators, namely \ on Windows.

toStandard :: FilePath -> FilePath Source

Convert all path separators to /, even on Windows.

(</>) :: FilePath -> FilePath -> FilePath infixr 5 Source

Combine two file paths, an alias for combine.

combine :: FilePath -> FilePath -> FilePath Source

Combine two file paths. Any redundant ./ or ../ components in the resulting path are eliminated - the result will always have normalise applied.

combine "aaa/bbb" "ccc" == "aaa/bbb/ccc"
combine "aaa/bbb" "./ccc" == "aaa/bbb/ccc"
combine "aaa/bbb" "../ccc" == "aaa/ccc"

exe :: String Source

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