<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>System.FilePath.Windows</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[ window.onload = function () {pageLoad();setSynopsis("mini_System-FilePath-Windows.html");}; //]]> </script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">filepath-1.3.0.0: Library for manipulating FilePaths in a cross platform way.</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>portable</td></tr><tr><th>Stability</th><td>stable</td></tr><tr><th>Maintainer</th><td>libraries@haskell.org</td></tr><tr><th>Safe Haskell</th><td>Safe</td></tr></table><p class="caption">System.FilePath.Windows</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Separator predicates </a></li><li><a href="#g:2">Path methods (environment $PATH) </a></li><li><a href="#g:3">Extension methods </a></li><li><a href="#g:4">Drive methods </a></li><li><a href="#g:5">Operations on a FilePath, as a list of directories </a></li><li><a href="#g:6">Low level FilePath operators </a></li><li><a href="#g:7">File name manipulators </a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>A library for FilePath manipulations, using Windows style paths on all platforms. Importing <a href="System-FilePath.html">System.FilePath</a> is usually better. </p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">type</span> <a href="#t:FilePath">FilePath</a> = <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></li><li class="src short"><a href="#v:pathSeparator">pathSeparator</a> :: <a href="../base-4.5.1.0/Data-Char.html#t:Char">Char</a></li><li class="src short"><a href="#v:pathSeparators">pathSeparators</a> :: [<a href="../base-4.5.1.0/Data-Char.html#t:Char">Char</a>]</li><li class="src short"><a href="#v:isPathSeparator">isPathSeparator</a> :: <a href="../base-4.5.1.0/Data-Char.html#t:Char">Char</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:searchPathSeparator">searchPathSeparator</a> :: <a href="../base-4.5.1.0/Data-Char.html#t:Char">Char</a></li><li class="src short"><a href="#v:isSearchPathSeparator">isSearchPathSeparator</a> :: <a href="../base-4.5.1.0/Data-Char.html#t:Char">Char</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:extSeparator">extSeparator</a> :: <a href="../base-4.5.1.0/Data-Char.html#t:Char">Char</a></li><li class="src short"><a href="#v:isExtSeparator">isExtSeparator</a> :: <a href="../base-4.5.1.0/Data-Char.html#t:Char">Char</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:splitSearchPath">splitSearchPath</a> :: <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> [<a href="System-FilePath-Windows.html#t:FilePath">FilePath</a>]</li><li class="src short"><a href="#v:getSearchPath">getSearchPath</a> :: <a href="../base-4.5.1.0/System-IO.html#t:IO">IO</a> [<a href="System-FilePath-Windows.html#t:FilePath">FilePath</a>]</li><li class="src short"><a href="#v:splitExtension">splitExtension</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> (<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>, <a href="../base-4.5.1.0/Data-String.html#t:String">String</a>)</li><li class="src short"><a href="#v:takeExtension">takeExtension</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></li><li class="src short"><a href="#v:replaceExtension">replaceExtension</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></li><li class="src short"><a href="#v:dropExtension">dropExtension</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></li><li class="src short"><a href="#v:addExtension">addExtension</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></li><li class="src short"><a href="#v:hasExtension">hasExtension</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:-60-.-62-">(<.>)</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></li><li class="src short"><a href="#v:splitExtensions">splitExtensions</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> (<a href="System-FilePath-Windows.html#t:FilePath">FilePath</a>, <a href="../base-4.5.1.0/Data-String.html#t:String">String</a>)</li><li class="src short"><a href="#v:dropExtensions">dropExtensions</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></li><li class="src short"><a href="#v:takeExtensions">takeExtensions</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></li><li class="src short"><a href="#v:splitDrive">splitDrive</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> (<a href="System-FilePath-Windows.html#t:FilePath">FilePath</a>, <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a>)</li><li class="src short"><a href="#v:joinDrive">joinDrive</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></li><li class="src short"><a href="#v:takeDrive">takeDrive</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></li><li class="src short"><a href="#v:hasDrive">hasDrive</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:dropDrive">dropDrive</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></li><li class="src short"><a href="#v:isDrive">isDrive</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:splitFileName">splitFileName</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> (<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>, <a href="../base-4.5.1.0/Data-String.html#t:String">String</a>)</li><li class="src short"><a href="#v:takeFileName">takeFileName</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></li><li class="src short"><a href="#v:replaceFileName">replaceFileName</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></li><li class="src short"><a href="#v:dropFileName">dropFileName</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></li><li class="src short"><a href="#v:takeBaseName">takeBaseName</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></li><li class="src short"><a href="#v:replaceBaseName">replaceBaseName</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></li><li class="src short"><a href="#v:takeDirectory">takeDirectory</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></li><li class="src short"><a href="#v:replaceDirectory">replaceDirectory</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></li><li class="src short"><a href="#v:combine">combine</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></li><li class="src short"><a href="#v:-60--47--62-">(</>)</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></li><li class="src short"><a href="#v:splitPath">splitPath</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> [<a href="System-FilePath-Windows.html#t:FilePath">FilePath</a>]</li><li class="src short"><a href="#v:joinPath">joinPath</a> :: [<a href="System-FilePath-Windows.html#t:FilePath">FilePath</a>] -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></li><li class="src short"><a href="#v:splitDirectories">splitDirectories</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> [<a href="System-FilePath-Windows.html#t:FilePath">FilePath</a>]</li><li class="src short"><a href="#v:hasTrailingPathSeparator">hasTrailingPathSeparator</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:addTrailingPathSeparator">addTrailingPathSeparator</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></li><li class="src short"><a href="#v:dropTrailingPathSeparator">dropTrailingPathSeparator</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></li><li class="src short"><a href="#v:normalise">normalise</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></li><li class="src short"><a href="#v:equalFilePath">equalFilePath</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:makeRelative">makeRelative</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></li><li class="src short"><a href="#v:isRelative">isRelative</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:isAbsolute">isAbsolute</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:isValid">isValid</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:makeValid">makeValid</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></li></ul></div><div id="interface"><h1 id="g:1">Separator predicates </h1><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:FilePath" class="def">FilePath</a> = <a href="../base-4.5.1.0/Data-String.html#t:String">String</a><a href="../base-4.5.1.0/src/GHC-IO.html#FilePath" class="link">Source</a></p><div class="doc"><p>File and directory names are values of type <code><a href="../base-4.5.1.0/Data-String.html#t:String">String</a></code>, whose precise meaning is operating system dependent. Files can be opened, yielding a handle which can then be used to operate on the contents of that file. </p></div></div><div class="top"><p class="src"><a name="v:pathSeparator" class="def">pathSeparator</a> :: <a href="../base-4.5.1.0/Data-Char.html#t:Char">Char</a></p><div class="doc"><p>The character that separates directories. In the case where more than one character is possible, <code><a href="System-FilePath-Windows.html#v:pathSeparator">pathSeparator</a></code> is the 'ideal' one. </p><pre> Windows: pathSeparator == '\\' Posix: pathSeparator == '/' isPathSeparator pathSeparator </pre></div></div><div class="top"><p class="src"><a name="v:pathSeparators" class="def">pathSeparators</a> :: [<a href="../base-4.5.1.0/Data-Char.html#t:Char">Char</a>]</p><div class="doc"><p>The list of all possible separators. </p><pre> Windows: pathSeparators == ['\\', '/'] Posix: pathSeparators == ['/'] pathSeparator `elem` pathSeparators </pre></div></div><div class="top"><p class="src"><a name="v:isPathSeparator" class="def">isPathSeparator</a> :: <a href="../base-4.5.1.0/Data-Char.html#t:Char">Char</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>Rather than using <code>(== <code><a href="System-FilePath-Windows.html#v:pathSeparator">pathSeparator</a></code>)</code>, use this. Test if something is a path separator. </p><pre> isPathSeparator a == (a `elem` pathSeparators) </pre></div></div><div class="top"><p class="src"><a name="v:searchPathSeparator" class="def">searchPathSeparator</a> :: <a href="../base-4.5.1.0/Data-Char.html#t:Char">Char</a></p><div class="doc"><p>The character that is used to separate the entries in the $PATH environment variable. </p><pre> Windows: searchPathSeparator == ';' Posix: searchPathSeparator == ':' </pre></div></div><div class="top"><p class="src"><a name="v:isSearchPathSeparator" class="def">isSearchPathSeparator</a> :: <a href="../base-4.5.1.0/Data-Char.html#t:Char">Char</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>Is the character a file separator? </p><pre> isSearchPathSeparator a == (a == searchPathSeparator) </pre></div></div><div class="top"><p class="src"><a name="v:extSeparator" class="def">extSeparator</a> :: <a href="../base-4.5.1.0/Data-Char.html#t:Char">Char</a></p><div class="doc"><p>File extension character </p><pre> extSeparator == '.' </pre></div></div><div class="top"><p class="src"><a name="v:isExtSeparator" class="def">isExtSeparator</a> :: <a href="../base-4.5.1.0/Data-Char.html#t:Char">Char</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>Is the character an extension character? </p><pre> isExtSeparator a == (a == extSeparator) </pre></div></div><h1 id="g:2">Path methods (environment $PATH) </h1><div class="top"><p class="src"><a name="v:splitSearchPath" class="def">splitSearchPath</a> :: <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> [<a href="System-FilePath-Windows.html#t:FilePath">FilePath</a>]</p><div class="doc"><p>Take a string, split it on the <code><a href="System-FilePath-Windows.html#v:searchPathSeparator">searchPathSeparator</a></code> character. </p><p>Follows the recommendations in <a href="http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html">http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html</a> </p><pre> Posix: splitSearchPath "File1:File2:File3" == ["File1","File2","File3"] Posix: splitSearchPath "File1::File2:File3" == ["File1",".","File2","File3"] Windows: splitSearchPath "File1;File2;File3" == ["File1","File2","File3"] Windows: splitSearchPath "File1;;File2;File3" == ["File1","File2","File3"] </pre></div></div><div class="top"><p class="src"><a name="v:getSearchPath" class="def">getSearchPath</a> :: <a href="../base-4.5.1.0/System-IO.html#t:IO">IO</a> [<a href="System-FilePath-Windows.html#t:FilePath">FilePath</a>]</p><div class="doc"><p>Get a list of filepaths in the $PATH. </p></div></div><h1 id="g:3">Extension methods </h1><div class="top"><p class="src"><a name="v:splitExtension" class="def">splitExtension</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> (<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>, <a href="../base-4.5.1.0/Data-String.html#t:String">String</a>)</p><div class="doc"><p>Split on the extension. <code><a href="System-FilePath-Windows.html#v:addExtension">addExtension</a></code> is the inverse. </p><pre> uncurry (++) (splitExtension x) == x uncurry addExtension (splitExtension x) == x splitExtension "file.txt" == ("file",".txt") splitExtension "file" == ("file","") splitExtension "file/file.txt" == ("file/file",".txt") splitExtension "file.txt/boris" == ("file.txt/boris","") splitExtension "file.txt/boris.ext" == ("file.txt/boris",".ext") splitExtension "file/path.txt.bob.fred" == ("file/path.txt.bob",".fred") splitExtension "file/path.txt/" == ("file/path.txt/","") </pre></div></div><div class="top"><p class="src"><a name="v:takeExtension" class="def">takeExtension</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></p><div class="doc"><p>Get the extension of a file, returns <code>""</code> for no extension, <code>.ext</code> otherwise. </p><pre> takeExtension x == snd (splitExtension x) Valid x => takeExtension (addExtension x "ext") == ".ext" Valid x => takeExtension (replaceExtension x "ext") == ".ext" </pre></div></div><div class="top"><p class="src"><a name="v:replaceExtension" class="def">replaceExtension</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></p><div class="doc"><p>Set the extension of a file, overwriting one if already present. </p><pre> replaceExtension "file.txt" ".bob" == "file.bob" replaceExtension "file.txt" "bob" == "file.bob" replaceExtension "file" ".bob" == "file.bob" replaceExtension "file.txt" "" == "file" replaceExtension "file.fred.bob" "txt" == "file.fred.txt" </pre></div></div><div class="top"><p class="src"><a name="v:dropExtension" class="def">dropExtension</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></p><div class="doc"><p>Remove last extension, and the "." preceding it. </p><pre> dropExtension x == fst (splitExtension x) </pre></div></div><div class="top"><p class="src"><a name="v:addExtension" class="def">addExtension</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></p><div class="doc"><p>Add an extension, even if there is already one there. E.g. <code>addExtension "foo.txt" "bat" -> "foo.txt.bat"</code>. </p><pre> addExtension "file.txt" "bib" == "file.txt.bib" addExtension "file." ".bib" == "file..bib" addExtension "file" ".bib" == "file.bib" addExtension "/" "x" == "/.x" Valid x => takeFileName (addExtension (addTrailingPathSeparator x) "ext") == ".ext" Windows: addExtension "\\\\share" ".txt" == "\\\\share\\.txt" </pre></div></div><div class="top"><p class="src"><a name="v:hasExtension" class="def">hasExtension</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>Does the given filename have an extension? </p><pre> null (takeExtension x) == not (hasExtension x) </pre></div></div><div class="top"><p class="src"><a name="v:-60-.-62-" class="def">(<.>)</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></p><div class="doc"><p>Alias to <code><a href="System-FilePath-Windows.html#v:addExtension">addExtension</a></code>, for people who like that sort of thing. </p></div></div><div class="top"><p class="src"><a name="v:splitExtensions" class="def">splitExtensions</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> (<a href="System-FilePath-Windows.html#t:FilePath">FilePath</a>, <a href="../base-4.5.1.0/Data-String.html#t:String">String</a>)</p><div class="doc"><p>Split on all extensions </p><pre> uncurry (++) (splitExtensions x) == x uncurry addExtension (splitExtensions x) == x splitExtensions "file.tar.gz" == ("file",".tar.gz") </pre></div></div><div class="top"><p class="src"><a name="v:dropExtensions" class="def">dropExtensions</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></p><div class="doc"><p>Drop all extensions </p><pre> not $ hasExtension (dropExtensions x) </pre></div></div><div class="top"><p class="src"><a name="v:takeExtensions" class="def">takeExtensions</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></p><div class="doc"><p>Get all extensions </p><pre> takeExtensions "file.tar.gz" == ".tar.gz" </pre></div></div><h1 id="g:4">Drive methods </h1><div class="top"><p class="src"><a name="v:splitDrive" class="def">splitDrive</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> (<a href="System-FilePath-Windows.html#t:FilePath">FilePath</a>, <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a>)</p><div class="doc"><p>Split a path into a drive and a path. On Unix, / is a Drive. </p><pre> uncurry (++) (splitDrive x) == x Windows: splitDrive "file" == ("","file") Windows: splitDrive "c:/file" == ("c:/","file") Windows: splitDrive "c:\\file" == ("c:\\","file") Windows: splitDrive "\\\\shared\\test" == ("\\\\shared\\","test") Windows: splitDrive "\\\\shared" == ("\\\\shared","") Windows: splitDrive "\\\\?\\UNC\\shared\\file" == ("\\\\?\\UNC\\shared\\","file") Windows: splitDrive "\\\\?\\UNCshared\\file" == ("\\\\?\\","UNCshared\\file") Windows: splitDrive "\\\\?\\d:\\file" == ("\\\\?\\d:\\","file") Windows: splitDrive "/d" == ("","/d") Posix: splitDrive "/test" == ("/","test") Posix: splitDrive "//test" == ("//","test") Posix: splitDrive "test/file" == ("","test/file") Posix: splitDrive "file" == ("","file") </pre></div></div><div class="top"><p class="src"><a name="v:joinDrive" class="def">joinDrive</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></p><div class="doc"><p>Join a drive and the rest of the path. </p><pre> uncurry joinDrive (splitDrive x) == x Windows: joinDrive "C:" "foo" == "C:foo" Windows: joinDrive "C:\\" "bar" == "C:\\bar" Windows: joinDrive "\\\\share" "foo" == "\\\\share\\foo" Windows: joinDrive "/:" "foo" == "/:\\foo" </pre></div></div><div class="top"><p class="src"><a name="v:takeDrive" class="def">takeDrive</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></p><div class="doc"><p>Get the drive from a filepath. </p><pre> takeDrive x == fst (splitDrive x) </pre></div></div><div class="top"><p class="src"><a name="v:hasDrive" class="def">hasDrive</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>Does a path have a drive. </p><pre> not (hasDrive x) == null (takeDrive x) </pre></div></div><div class="top"><p class="src"><a name="v:dropDrive" class="def">dropDrive</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></p><div class="doc"><p>Delete the drive, if it exists. </p><pre> dropDrive x == snd (splitDrive x) </pre></div></div><div class="top"><p class="src"><a name="v:isDrive" class="def">isDrive</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>Is an element a drive </p></div></div><h1 id="g:5">Operations on a FilePath, as a list of directories </h1><div class="top"><p class="src"><a name="v:splitFileName" class="def">splitFileName</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> (<a href="../base-4.5.1.0/Data-String.html#t:String">String</a>, <a href="../base-4.5.1.0/Data-String.html#t:String">String</a>)</p><div class="doc"><p>Split a filename into directory and file. <code><a href="System-FilePath-Windows.html#v:combine">combine</a></code> is the inverse. </p><pre> Valid x => uncurry (</>) (splitFileName x) == x || fst (splitFileName x) == "./" Valid x => isValid (fst (splitFileName x)) splitFileName "file/bob.txt" == ("file/", "bob.txt") splitFileName "file/" == ("file/", "") splitFileName "bob" == ("./", "bob") Posix: splitFileName "/" == ("/","") Windows: splitFileName "c:" == ("c:","") </pre></div></div><div class="top"><p class="src"><a name="v:takeFileName" class="def">takeFileName</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></p><div class="doc"><p>Get the file name. </p><pre> takeFileName "test/" == "" takeFileName x `isSuffixOf` x takeFileName x == snd (splitFileName x) Valid x => takeFileName (replaceFileName x "fred") == "fred" Valid x => takeFileName (x </> "fred") == "fred" Valid x => isRelative (takeFileName x) </pre></div></div><div class="top"><p class="src"><a name="v:replaceFileName" class="def">replaceFileName</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></p><div class="doc"><p>Set the filename. </p><pre> Valid x => replaceFileName x (takeFileName x) == x </pre></div></div><div class="top"><p class="src"><a name="v:dropFileName" class="def">dropFileName</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></p><div class="doc"><p>Drop the filename. </p><pre> dropFileName x == fst (splitFileName x) </pre></div></div><div class="top"><p class="src"><a name="v:takeBaseName" class="def">takeBaseName</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></p><div class="doc"><p>Get the base name, without an extension or path. </p><pre> takeBaseName "file/test.txt" == "test" takeBaseName "dave.ext" == "dave" takeBaseName "" == "" takeBaseName "test" == "test" takeBaseName (addTrailingPathSeparator x) == "" takeBaseName "file/file.tar.gz" == "file.tar" </pre></div></div><div class="top"><p class="src"><a name="v:replaceBaseName" class="def">replaceBaseName</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></p><div class="doc"><p>Set the base name. </p><pre> replaceBaseName "file/test.txt" "bob" == "file/bob.txt" replaceBaseName "fred" "bill" == "bill" replaceBaseName "/dave/fred/bob.gz.tar" "new" == "/dave/fred/new.tar" Valid x => replaceBaseName x (takeBaseName x) == x </pre></div></div><div class="top"><p class="src"><a name="v:takeDirectory" class="def">takeDirectory</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></p><div class="doc"><p>Get the directory name, move up one level. </p><pre> takeDirectory x `isPrefixOf` x || takeDirectory x == "." takeDirectory "foo" == "." takeDirectory "/foo/bar/baz" == "/foo/bar" takeDirectory "/foo/bar/baz/" == "/foo/bar/baz" takeDirectory "foo/bar/baz" == "foo/bar" Windows: takeDirectory "foo\\bar" == "foo" Windows: takeDirectory "foo\\bar\\\\" == "foo\\bar" Windows: takeDirectory "C:\\" == "C:\\" </pre></div></div><div class="top"><p class="src"><a name="v:replaceDirectory" class="def">replaceDirectory</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></p><div class="doc"><p>Set the directory, keeping the filename the same. </p><pre> Valid x => replaceDirectory x (takeDirectory x) `equalFilePath` x </pre></div></div><div class="top"><p class="src"><a name="v:combine" class="def">combine</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></p><div class="doc"><p>Combine two paths, if the second path <code><a href="System-FilePath-Windows.html#v:isAbsolute">isAbsolute</a></code>, then it returns the second. </p><pre> Valid x => combine (takeDirectory x) (takeFileName x) `equalFilePath` x Posix: combine "/" "test" == "/test" Posix: combine "home" "bob" == "home/bob" Windows: combine "home" "bob" == "home\\bob" Windows: combine "home" "/bob" == "/bob" </pre></div></div><div class="top"><p class="src"><a name="v:-60--47--62-" class="def">(</>)</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></p><div class="doc"><p>A nice alias for <code><a href="System-FilePath-Windows.html#v:combine">combine</a></code>. </p></div></div><div class="top"><p class="src"><a name="v:splitPath" class="def">splitPath</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> [<a href="System-FilePath-Windows.html#t:FilePath">FilePath</a>]</p><div class="doc"><p>Split a path by the directory separator. </p><pre> concat (splitPath x) == x splitPath "test//item/" == ["test//","item/"] splitPath "test/item/file" == ["test/","item/","file"] splitPath "" == [] Windows: splitPath "c:\\test\\path" == ["c:\\","test\\","path"] Posix: splitPath "/file/test" == ["/","file/","test"] </pre></div></div><div class="top"><p class="src"><a name="v:joinPath" class="def">joinPath</a> :: [<a href="System-FilePath-Windows.html#t:FilePath">FilePath</a>] -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></p><div class="doc"><p>Join path elements back together. </p><pre> Valid x => joinPath (splitPath x) == x joinPath [] == "" Posix: joinPath ["test","file","path"] == "test/file/path" </pre></div></div><div class="top"><p class="src"><a name="v:splitDirectories" class="def">splitDirectories</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> [<a href="System-FilePath-Windows.html#t:FilePath">FilePath</a>]</p><div class="doc"><p>Just as <code><a href="System-FilePath-Windows.html#v:splitPath">splitPath</a></code>, but don't add the trailing slashes to each element. </p><pre> splitDirectories "test/file" == ["test","file"] splitDirectories "/test/file" == ["/","test","file"] Valid x => joinPath (splitDirectories x) `equalFilePath` x splitDirectories "" == [] </pre></div></div><h1 id="g:6">Low level FilePath operators </h1><div class="top"><p class="src"><a name="v:hasTrailingPathSeparator" class="def">hasTrailingPathSeparator</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>Is an item either a directory or the last character a path separator? </p><pre> hasTrailingPathSeparator "test" == False hasTrailingPathSeparator "test/" == True </pre></div></div><div class="top"><p class="src"><a name="v:addTrailingPathSeparator" class="def">addTrailingPathSeparator</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></p><div class="doc"><p>Add a trailing file path separator if one is not already present. </p><pre> hasTrailingPathSeparator (addTrailingPathSeparator x) hasTrailingPathSeparator x ==> addTrailingPathSeparator x == x Posix: addTrailingPathSeparator "test/rest" == "test/rest/" </pre></div></div><div class="top"><p class="src"><a name="v:dropTrailingPathSeparator" class="def">dropTrailingPathSeparator</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></p><div class="doc"><p>Remove any trailing path separators </p><pre> dropTrailingPathSeparator "file/test/" == "file/test" Posix: not (hasTrailingPathSeparator (dropTrailingPathSeparator x)) || isDrive x Posix: dropTrailingPathSeparator "/" == "/" Windows: dropTrailingPathSeparator "\\" == "\\" </pre></div></div><h1 id="g:7">File name manipulators </h1><div class="top"><p class="src"><a name="v:normalise" class="def">normalise</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></p><div class="doc"><p>Normalise a file </p><ul><li> // outside of the drive can be made blank </li><li> / -> <code><a href="System-FilePath-Windows.html#v:pathSeparator">pathSeparator</a></code> </li><li> ./ -> "" </li></ul><pre> Posix: normalise "/file/\\test////" == "/file/\\test/" Posix: normalise "/file/./test" == "/file/test" Posix: normalise "/test/file/../bob/fred/" == "/test/file/../bob/fred/" Posix: normalise "../bob/fred/" == "../bob/fred/" Posix: normalise "./bob/fred/" == "bob/fred/" Windows: normalise "c:\\file/bob\\" == "C:\\file\\bob\\" Windows: normalise "c:\\" == "C:\\" Windows: normalise "\\\\server\\test" == "\\\\server\\test" Windows: normalise "c:/file" == "C:\\file" normalise "." == "." Posix: normalise "./" == "./" Posix: normalise "./." == "./" Posix: normalise "/" == "/" Posix: normalise "bob/fred/." == "bob/fred/" </pre></div></div><div class="top"><p class="src"><a name="v:equalFilePath" class="def">equalFilePath</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>Equality of two <code><a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></code>s. If you call <code>System.Directory.canonicalizePath</code> first this has a much better chance of working. Note that this doesn't follow symlinks or DOSNAM~1s. </p><pre> x == y ==> equalFilePath x y normalise x == normalise y ==> equalFilePath x y Posix: equalFilePath "foo" "foo/" Posix: not (equalFilePath "foo" "/foo") Posix: not (equalFilePath "foo" "FOO") Windows: equalFilePath "foo" "FOO" </pre></div></div><div class="top"><p class="src"><a name="v:makeRelative" class="def">makeRelative</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></p><div class="doc"><p>Contract a filename, based on a relative path. </p><p>There is no corresponding <code>makeAbsolute</code> function, instead use <code>System.Directory.canonicalizePath</code> which has the same effect. </p><pre> Valid y => equalFilePath x y || (isRelative x && makeRelative y x == x) || equalFilePath (y </> makeRelative y x) x makeRelative x x == "." null y || equalFilePath (makeRelative x (x </> y)) y || null (takeFileName x) Windows: makeRelative "C:\\Home" "c:\\home\\bob" == "bob" Windows: makeRelative "C:\\Home" "c:/home/bob" == "bob" Windows: makeRelative "C:\\Home" "D:\\Home\\Bob" == "D:\\Home\\Bob" Windows: makeRelative "C:\\Home" "C:Home\\Bob" == "C:Home\\Bob" Windows: makeRelative "/Home" "/home/bob" == "bob" Posix: makeRelative "/Home" "/home/bob" == "/home/bob" Posix: makeRelative "/home/" "/home/bob/foo/bar" == "bob/foo/bar" Posix: makeRelative "/fred" "bob" == "bob" Posix: makeRelative "/file/test" "/file/test/fred" == "fred" Posix: makeRelative "/file/test" "/file/test/fred/" == "fred/" Posix: makeRelative "some/path" "some/path/a/b/c" == "a/b/c" </pre></div></div><div class="top"><p class="src"><a name="v:isRelative" class="def">isRelative</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>Is a path relative, or is it fixed to the root? </p><pre> Windows: isRelative "path\\test" == True Windows: isRelative "c:\\test" == False Windows: isRelative "c:test" == True Windows: isRelative "c:" == True Windows: isRelative "\\\\foo" == False Windows: isRelative "/foo" == True Posix: isRelative "test/path" == True Posix: isRelative "/test" == False </pre></div></div><div class="top"><p class="src"><a name="v:isAbsolute" class="def">isAbsolute</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><pre>not . <code><a href="System-FilePath-Windows.html#v:isRelative">isRelative</a></code></pre><pre> isAbsolute x == not (isRelative x) </pre></div></div><div class="top"><p class="src"><a name="v:isValid" class="def">isValid</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>Is a FilePath valid, i.e. could you create a file like it? </p><pre> isValid "" == False Posix: isValid "/random_ path:*" == True Posix: isValid x == not (null x) Windows: isValid "c:\\test" == True Windows: isValid "c:\\test:of_test" == False Windows: isValid "test*" == False Windows: isValid "c:\\test\\nul" == False Windows: isValid "c:\\test\\prn.txt" == False Windows: isValid "c:\\nul\\file" == False Windows: isValid "\\\\" == False </pre></div></div><div class="top"><p class="src"><a name="v:makeValid" class="def">makeValid</a> :: <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a> -> <a href="System-FilePath-Windows.html#t:FilePath">FilePath</a></p><div class="doc"><p>Take a FilePath and make it valid; does not change already valid FilePaths. </p><pre> isValid (makeValid x) isValid x ==> makeValid x == x makeValid "" == "_" Windows: makeValid "c:\\test:of_test" == "c:\\test_of_test" Windows: makeValid "test*" == "test_" Windows: makeValid "c:\\test\\nul" == "c:\\test\\nul_" Windows: makeValid "c:\\test\\prn.txt" == "c:\\test\\prn_.txt" Windows: makeValid "c:\\test/prn.txt" == "c:\\test/prn_.txt" Windows: makeValid "c:\\nul\\file" == "c:\\nul_\\file" </pre></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.11.0</p></div></body></html>