<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--Rendered using the Haskell Html Library v0.2--> <HTML ><HEAD ><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8" ><TITLE >System.FilePath.Windows</TITLE ><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css" ><SCRIPT SRC="haddock-util.js" TYPE="text/javascript" ></SCRIPT ><SCRIPT TYPE="text/javascript" >window.onload = function () {setSynopsis("mini_System-FilePath-Windows.html")};</SCRIPT ></HEAD ><BODY ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="topbar" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD ><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" " ></TD ><TD CLASS="title" >filepath-1.1.0.2: Library for manipulating FilePath's in a cross platform way.</TD ><TD CLASS="topbut" ><A HREF="index.html" >Contents</A ></TD ><TD CLASS="topbut" ><A HREF="doc-index.html" >Index</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="modulebar" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD ><FONT SIZE="6" >System.FilePath.Windows</FONT ></TD ><TD ALIGN="right" ><TABLE CLASS="narrow" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="infohead" >Portability</TD ><TD CLASS="infoval" >portable</TD ></TR ><TR ><TD CLASS="infohead" >Stability</TD ><TD CLASS="infoval" >stable</TD ></TR ><TR ><TD CLASS="infohead" >Maintainer</TD ><TD CLASS="infoval" >libraries@haskell.org</TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="section4" ><B >Contents</B ></TD ></TR ><TR ><TD ><DL ><DT ><A HREF="#1" >Separator predicates </A ></DT ><DT ><A HREF="#2" >Path methods (environment $PATH) </A ></DT ><DT ><A HREF="#3" >Extension methods </A ></DT ><DT ><A HREF="#4" >Drive methods </A ></DT ><DT ><A HREF="#5" >Operations on a FilePath, as a list of directories </A ></DT ><DT ><A HREF="#6" >Low level FilePath operators </A ></DT ><DT ><A HREF="#7" >File name manipulators </A ></DT ></DL ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" >Description</TD ></TR ><TR ><TD CLASS="doc" >A library for FilePath manipulations, using Windows style paths on all platforms. Importing <A HREF="System-FilePath.html" >System.FilePath</A > is usually better. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" >Synopsis</TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3ApathSeparator" >pathSeparator</A > :: <A HREF="../ghc-prim/GHC-Types.html#t%3AChar" >Char</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3ApathSeparators" >pathSeparators</A > :: [<A HREF="../ghc-prim/GHC-Types.html#t%3AChar" >Char</A >]</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AisPathSeparator" >isPathSeparator</A > :: <A HREF="../ghc-prim/GHC-Types.html#t%3AChar" >Char</A > -> <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AsearchPathSeparator" >searchPathSeparator</A > :: <A HREF="../ghc-prim/GHC-Types.html#t%3AChar" >Char</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AisSearchPathSeparator" >isSearchPathSeparator</A > :: <A HREF="../ghc-prim/GHC-Types.html#t%3AChar" >Char</A > -> <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AextSeparator" >extSeparator</A > :: <A HREF="../ghc-prim/GHC-Types.html#t%3AChar" >Char</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AisExtSeparator" >isExtSeparator</A > :: <A HREF="../ghc-prim/GHC-Types.html#t%3AChar" >Char</A > -> <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AsplitSearchPath" >splitSearchPath</A > :: <A HREF="../base/Data-Char.html#t%3AString" >String</A > -> [<A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A >]</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AgetSearchPath" >getSearchPath</A > :: <A HREF="../base/System-IO.html#t%3AIO" >IO</A > [<A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A >]</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AsplitExtension" >splitExtension</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> (<A HREF="../base/Data-Char.html#t%3AString" >String</A >, <A HREF="../base/Data-Char.html#t%3AString" >String</A >)</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AtakeExtension" >takeExtension</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/Data-Char.html#t%3AString" >String</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AreplaceExtension" >replaceExtension</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/Data-Char.html#t%3AString" >String</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AdropExtension" >dropExtension</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AaddExtension" >addExtension</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/Data-Char.html#t%3AString" >String</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhasExtension" >hasExtension</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3A%3C.%3E" >(<.>)</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/Data-Char.html#t%3AString" >String</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AsplitExtensions" >splitExtensions</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> (<A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A >, <A HREF="../base/Data-Char.html#t%3AString" >String</A >)</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AdropExtensions" >dropExtensions</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AtakeExtensions" >takeExtensions</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/Data-Char.html#t%3AString" >String</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AsplitDrive" >splitDrive</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> (<A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A >, <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A >)</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AjoinDrive" >joinDrive</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AtakeDrive" >takeDrive</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhasDrive" >hasDrive</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AdropDrive" >dropDrive</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AisDrive" >isDrive</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AsplitFileName" >splitFileName</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> (<A HREF="../base/Data-Char.html#t%3AString" >String</A >, <A HREF="../base/Data-Char.html#t%3AString" >String</A >)</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AtakeFileName" >takeFileName</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AreplaceFileName" >replaceFileName</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/Data-Char.html#t%3AString" >String</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AdropFileName" >dropFileName</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AtakeBaseName" >takeBaseName</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/Data-Char.html#t%3AString" >String</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AreplaceBaseName" >replaceBaseName</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/Data-Char.html#t%3AString" >String</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AtakeDirectory" >takeDirectory</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AreplaceDirectory" >replaceDirectory</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/Data-Char.html#t%3AString" >String</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Acombine" >combine</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3A%3C%2F%3E" >(</>)</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AsplitPath" >splitPath</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> [<A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A >]</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AjoinPath" >joinPath</A > :: [<A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A >] -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AsplitDirectories" >splitDirectories</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> [<A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A >]</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AhasTrailingPathSeparator" >hasTrailingPathSeparator</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AaddTrailingPathSeparator" >addTrailingPathSeparator</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AdropTrailingPathSeparator" >dropTrailingPathSeparator</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Anormalise" >normalise</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AequalFilePath" >equalFilePath</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AmakeRelative" >makeRelative</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AisRelative" >isRelative</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AisAbsolute" >isAbsolute</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AisValid" >isValid</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AmakeValid" >makeValid</A > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" ><A NAME="1" ><A NAME="1" >Separator predicates </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:pathSeparator" ><A NAME="v%3ApathSeparator" ></A ></A ><B >pathSeparator</B > :: <A HREF="../ghc-prim/GHC-Types.html#t%3AChar" >Char</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >The character that separates directories. In the case where more than one character is possible, <TT ><A HREF="System-FilePath-Windows.html#v%3ApathSeparator" >pathSeparator</A ></TT > is the 'ideal' one. </P ><PRE > Windows: pathSeparator == '\\' Posix: pathSeparator == '/' isPathSeparator pathSeparator </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:pathSeparators" ><A NAME="v%3ApathSeparators" ></A ></A ><B >pathSeparators</B > :: [<A HREF="../ghc-prim/GHC-Types.html#t%3AChar" >Char</A >]</TD ></TR ><TR ><TD CLASS="doc" ><P >The list of all possible separators. </P ><PRE > Windows: pathSeparators == ['\\', '/'] Posix: pathSeparators == ['/'] pathSeparator `elem` pathSeparators </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:isPathSeparator" ><A NAME="v%3AisPathSeparator" ></A ></A ><B >isPathSeparator</B > :: <A HREF="../ghc-prim/GHC-Types.html#t%3AChar" >Char</A > -> <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Rather than using <TT >(== <TT ><A HREF="System-FilePath-Windows.html#v%3ApathSeparator" >pathSeparator</A ></TT >)</TT >, use this. Test if something is a path separator. </P ><PRE > isPathSeparator a == (a `elem` pathSeparators) </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:searchPathSeparator" ><A NAME="v%3AsearchPathSeparator" ></A ></A ><B >searchPathSeparator</B > :: <A HREF="../ghc-prim/GHC-Types.html#t%3AChar" >Char</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >The character that is used to separate the entries in the $PATH environment variable. </P ><PRE > Windows: searchPathSeparator == ';' Posix: searchPathSeparator == ':' </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:isSearchPathSeparator" ><A NAME="v%3AisSearchPathSeparator" ></A ></A ><B >isSearchPathSeparator</B > :: <A HREF="../ghc-prim/GHC-Types.html#t%3AChar" >Char</A > -> <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Is the character a file separator? </P ><PRE > isSearchPathSeparator a == (a == searchPathSeparator) </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:extSeparator" ><A NAME="v%3AextSeparator" ></A ></A ><B >extSeparator</B > :: <A HREF="../ghc-prim/GHC-Types.html#t%3AChar" >Char</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >File extension character </P ><PRE > extSeparator == '.' </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:isExtSeparator" ><A NAME="v%3AisExtSeparator" ></A ></A ><B >isExtSeparator</B > :: <A HREF="../ghc-prim/GHC-Types.html#t%3AChar" >Char</A > -> <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Is the character an extension character? </P ><PRE > isExtSeparator a == (a == extSeparator) </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" ><A NAME="2" ><A NAME="2" >Path methods (environment $PATH) </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:splitSearchPath" ><A NAME="v%3AsplitSearchPath" ></A ></A ><B >splitSearchPath</B > :: <A HREF="../base/Data-Char.html#t%3AString" >String</A > -> [<A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A >]</TD ></TR ><TR ><TD CLASS="doc" ><P >Take a string, split it on the <TT ><A HREF="System-FilePath-Windows.html#v%3AsearchPathSeparator" >searchPathSeparator</A ></TT > 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 ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:getSearchPath" ><A NAME="v%3AgetSearchPath" ></A ></A ><B >getSearchPath</B > :: <A HREF="../base/System-IO.html#t%3AIO" >IO</A > [<A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A >]</TD ></TR ><TR ><TD CLASS="doc" >Get a list of filepaths in the $PATH. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" ><A NAME="3" ><A NAME="3" >Extension methods </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:splitExtension" ><A NAME="v%3AsplitExtension" ></A ></A ><B >splitExtension</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> (<A HREF="../base/Data-Char.html#t%3AString" >String</A >, <A HREF="../base/Data-Char.html#t%3AString" >String</A >)</TD ></TR ><TR ><TD CLASS="doc" ><P >Split on the extension. <TT ><A HREF="System-FilePath-Windows.html#v%3AaddExtension" >addExtension</A ></TT > 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 ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:takeExtension" ><A NAME="v%3AtakeExtension" ></A ></A ><B >takeExtension</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/Data-Char.html#t%3AString" >String</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Get the extension of a file, returns <TT >""</TT > for no extension, <TT >.ext</TT > otherwise. </P ><PRE > takeExtension x == snd (splitExtension x) Valid x => takeExtension (addExtension x "ext") == ".ext" Valid x => takeExtension (replaceExtension x "ext") == ".ext" </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:replaceExtension" ><A NAME="v%3AreplaceExtension" ></A ></A ><B >replaceExtension</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/Data-Char.html#t%3AString" >String</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD 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 ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:dropExtension" ><A NAME="v%3AdropExtension" ></A ></A ><B >dropExtension</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Remove last extension, and the "." preceding it. </P ><PRE > dropExtension x == fst (splitExtension x) </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:addExtension" ><A NAME="v%3AaddExtension" ></A ></A ><B >addExtension</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/Data-Char.html#t%3AString" >String</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Add an extension, even if there is already one there. E.g. <TT >addExtension "foo.txt" "bat" -> "foo.txt.bat"</TT >. </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 ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hasExtension" ><A NAME="v%3AhasExtension" ></A ></A ><B >hasExtension</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Does the given filename have an extension? </P ><PRE > null (takeExtension x) == not (hasExtension x) </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:<.>" ><A NAME="v%3A%3C.%3E" ></A ></A ><B >(<.>)</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/Data-Char.html#t%3AString" >String</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="doc" >Alias to <TT ><A HREF="System-FilePath-Windows.html#v%3AaddExtension" >addExtension</A ></TT >, for people who like that sort of thing. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:splitExtensions" ><A NAME="v%3AsplitExtensions" ></A ></A ><B >splitExtensions</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> (<A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A >, <A HREF="../base/Data-Char.html#t%3AString" >String</A >)</TD ></TR ><TR ><TD CLASS="doc" ><P >Split on all extensions </P ><PRE > splitExtensions "file.tar.gz" == ("file",".tar.gz") </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:dropExtensions" ><A NAME="v%3AdropExtensions" ></A ></A ><B >dropExtensions</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Drop all extensions </P ><PRE > not $ hasExtension (dropExtensions x) </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:takeExtensions" ><A NAME="v%3AtakeExtensions" ></A ></A ><B >takeExtensions</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/Data-Char.html#t%3AString" >String</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Get all extensions </P ><PRE > takeExtensions "file.tar.gz" == ".tar.gz" </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" ><A NAME="4" ><A NAME="4" >Drive methods </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:splitDrive" ><A NAME="v%3AsplitDrive" ></A ></A ><B >splitDrive</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> (<A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A >, <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A >)</TD ></TR ><TR ><TD 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 ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:joinDrive" ><A NAME="v%3AjoinDrive" ></A ></A ><B >joinDrive</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD 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 ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:takeDrive" ><A NAME="v%3AtakeDrive" ></A ></A ><B >takeDrive</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Get the drive from a filepath. </P ><PRE > takeDrive x == fst (splitDrive x) </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hasDrive" ><A NAME="v%3AhasDrive" ></A ></A ><B >hasDrive</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Does a path have a drive. </P ><PRE > not (hasDrive x) == null (takeDrive x) </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:dropDrive" ><A NAME="v%3AdropDrive" ></A ></A ><B >dropDrive</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Delete the drive, if it exists. </P ><PRE > dropDrive x == snd (splitDrive x) </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:isDrive" ><A NAME="v%3AisDrive" ></A ></A ><B >isDrive</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="doc" >Is an element a drive </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" ><A NAME="5" ><A NAME="5" >Operations on a FilePath, as a list of directories </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:splitFileName" ><A NAME="v%3AsplitFileName" ></A ></A ><B >splitFileName</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> (<A HREF="../base/Data-Char.html#t%3AString" >String</A >, <A HREF="../base/Data-Char.html#t%3AString" >String</A >)</TD ></TR ><TR ><TD CLASS="doc" ><P >Split a filename into directory and file. <TT ><A HREF="System-FilePath-Windows.html#v%3Acombine" >combine</A ></TT > is the inverse. </P ><PRE > uncurry (++) (splitFileName x) == x Valid x => uncurry combine (splitFileName x) == x splitFileName "file/bob.txt" == ("file/", "bob.txt") splitFileName "file/" == ("file/", "") splitFileName "bob" == ("", "bob") Posix: splitFileName "/" == ("/","") Windows: splitFileName "c:" == ("c:","") </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:takeFileName" ><A NAME="v%3AtakeFileName" ></A ></A ><B >takeFileName</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD 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 ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:replaceFileName" ><A NAME="v%3AreplaceFileName" ></A ></A ><B >replaceFileName</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/Data-Char.html#t%3AString" >String</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Set the filename. </P ><PRE > Valid x => replaceFileName x (takeFileName x) == x </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:dropFileName" ><A NAME="v%3AdropFileName" ></A ></A ><B >dropFileName</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Drop the filename. </P ><PRE > dropFileName x == fst (splitFileName x) </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:takeBaseName" ><A NAME="v%3AtakeBaseName" ></A ></A ><B >takeBaseName</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/Data-Char.html#t%3AString" >String</A ></TD ></TR ><TR ><TD 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 ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:replaceBaseName" ><A NAME="v%3AreplaceBaseName" ></A ></A ><B >replaceBaseName</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/Data-Char.html#t%3AString" >String</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD 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" replaceBaseName x (takeBaseName x) == x </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:takeDirectory" ><A NAME="v%3AtakeDirectory" ></A ></A ><B >takeDirectory</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Get the directory name, move up one level. </P ><PRE > takeDirectory x `isPrefixOf` 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 ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:replaceDirectory" ><A NAME="v%3AreplaceDirectory" ></A ></A ><B >replaceDirectory</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/Data-Char.html#t%3AString" >String</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Set the directory, keeping the filename the same. </P ><PRE > replaceDirectory x (takeDirectory x) `equalFilePath` x </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:combine" ><A NAME="v%3Acombine" ></A ></A ><B >combine</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Combine two paths, if the second path <TT ><A HREF="System-FilePath-Windows.html#v%3AisAbsolute" >isAbsolute</A ></TT >, 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 ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:</>" ><A NAME="v%3A%3C%2F%3E" ></A ></A ><B >(</>)</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="doc" >A nice alias for <TT ><A HREF="System-FilePath-Windows.html#v%3Acombine" >combine</A ></TT >. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:splitPath" ><A NAME="v%3AsplitPath" ></A ></A ><B >splitPath</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> [<A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A >]</TD ></TR ><TR ><TD 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 ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:joinPath" ><A NAME="v%3AjoinPath" ></A ></A ><B >joinPath</B > :: [<A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A >] -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD 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 ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:splitDirectories" ><A NAME="v%3AsplitDirectories" ></A ></A ><B >splitDirectories</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> [<A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A >]</TD ></TR ><TR ><TD CLASS="doc" ><P >Just as <TT ><A HREF="System-FilePath-Windows.html#v%3AsplitPath" >splitPath</A ></TT >, 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 ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" ><A NAME="6" ><A NAME="6" >Low level FilePath operators </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:hasTrailingPathSeparator" ><A NAME="v%3AhasTrailingPathSeparator" ></A ></A ><B >hasTrailingPathSeparator</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD 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 ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:addTrailingPathSeparator" ><A NAME="v%3AaddTrailingPathSeparator" ></A ></A ><B >addTrailingPathSeparator</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD 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 ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:dropTrailingPathSeparator" ><A NAME="v%3AdropTrailingPathSeparator" ></A ></A ><B >dropTrailingPathSeparator</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Remove any trailing path separators </P ><PRE > dropTrailingPathSeparator "file/test/" == "file/test" not (hasTrailingPathSeparator (dropTrailingPathSeparator x)) || isDrive x Posix: dropTrailingPathSeparator "/" == "/" Windows: dropTrailingPathSeparator "\\" == "\\" </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" ><A NAME="7" ><A NAME="7" >File name manipulators </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:normalise" ><A NAME="v%3Anormalise" ></A ></A ><B >normalise</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Normalise a file </P ><UL ><LI > // outside of the drive can be made blank </LI ><LI > / -> <TT ><A HREF="System-FilePath-Windows.html#v%3ApathSeparator" >pathSeparator</A ></TT > </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 "./" == "./" </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:equalFilePath" ><A NAME="v%3AequalFilePath" ></A ></A ><B >equalFilePath</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Equality of two <TT ><A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TT >s. If you call <TT >System.Directory.canonicalizePath</TT > 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 ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:makeRelative" ><A NAME="v%3AmakeRelative" ></A ></A ><B >makeRelative</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Contract a filename, based on a relative path. </P ><P >There is no corresponding <TT >makeAbsolute</TT > function, instead use <TT >System.Directory.canonicalizePath</TT > 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 ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:isRelative" ><A NAME="v%3AisRelative" ></A ></A ><B >isRelative</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD 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 ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:isAbsolute" ><A NAME="v%3AisAbsolute" ></A ></A ><B >isAbsolute</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="doc" ><PRE >not . <TT ><A HREF="System-FilePath-Windows.html#v%3AisRelative" >isRelative</A ></TT ></PRE ><PRE > isAbsolute x == not (isRelative x) </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:isValid" ><A NAME="v%3AisValid" ></A ></A ><B >isValid</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../ghc-prim/GHC-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD 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 ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:makeValid" ><A NAME="v%3AmakeValid" ></A ></A ><B >makeValid</B > :: <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="../base/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD 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 ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="botbar" >Produced by <A HREF="http://www.haskell.org/haddock/" >Haddock</A > version 2.4.2</TD ></TR ></TABLE ></BODY ></HTML >