shake-0.2: Build system library, like Make, but properly supports generated files.

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 -> FilePathSource

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 -> FilePathSource

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 -> FilePathSource

Normalise a FilePath, applying the standard FilePath normalisation, plus translating any path separators to / and removing foo/.. components where possible.

toNative :: FilePath -> FilePathSource

Convert to native path separators, namely \ on Windows.

(</>) :: FilePath -> FilePath -> FilePathSource

Combine two file paths, an alias for combine.

combine :: FilePath -> FilePath -> FilePathSource

Combine two file paths. Any leading ./ or ../ components in the right file are eliminated.

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