54c047fcf4
travis build: 56 commit: e54f407ec21f014d266d4996e661106a5356c09c auto-pushed to gh-pages
243 lines
64 KiB
HTML
243 lines
64 KiB
HTML
<!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.Posix.FilePath</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-Posix-FilePath.html");};
|
|
//]]>
|
|
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/System-Posix-FilePath.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.3: Support for well-typed paths</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Copyright</th><td>© 2016 Julian Ospald</td></tr><tr><th>License</th><td>BSD3</td></tr><tr><th>Maintainer</th><td>Julian Ospald <hasufell@posteo.de></td></tr><tr><th>Stability</th><td>experimental</td></tr><tr><th>Portability</th><td>portable</td></tr><tr><th>Safe Haskell</th><td>Safe-Inferred</td></tr><tr><th>Language</th><td>Haskell2010</td></tr></table><p class="caption">System.Posix.FilePath</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</a></li><li><a href="#g:3">Extension functions</a></li><li><a href="#g:4">Filename/directory functions</a></li><li><a href="#g:5">Trailing slash functions</a></li><li><a href="#g:6">File name manipulations</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>The equivalent of <a href="https://hackage.haskell.org/package/filepath-1.3.0.2/docs/System-FilePath.html">System.FilePath</a> on raw (byte string) file paths.</p><p>Not all functions of <a href="https://hackage.haskell.org/package/filepath-1.3.0.2/docs/System-FilePath.html">System.FilePath</a> are implemented yet. Feel free to contribute!</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"><a href="#v:pathSeparator">pathSeparator</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Word.html#t:Word8">Word8</a></li><li class="src short"><a href="#v:isPathSeparator">isPathSeparator</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Word.html#t:Word8">Word8</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:searchPathSeparator">searchPathSeparator</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Word.html#t:Word8">Word8</a></li><li class="src short"><a href="#v:isSearchPathSeparator">isSearchPathSeparator</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Word.html#t:Word8">Word8</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:extSeparator">extSeparator</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Word.html#t:Word8">Word8</a></li><li class="src short"><a href="#v:isExtSeparator">isExtSeparator</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Word.html#t:Word8">Word8</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:splitSearchPath">splitSearchPath</a> :: <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> -> [<a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a>]</li><li class="src short"><a href="#v:getSearchPath">getSearchPath</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/System-IO.html#t:IO">IO</a> [<a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a>]</li><li class="src short"><a href="#v:splitExtension">splitExtension</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> (<a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a>, <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a>)</li><li class="src short"><a href="#v:takeExtension">takeExtension</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a></li><li class="src short"><a href="#v:replaceExtension">replaceExtension</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></li><li class="src short"><a href="#v:dropExtension">dropExtension</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></li><li class="src short"><a href="#v:addExtension">addExtension</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></li><li class="src short"><a href="#v:hasExtension">hasExtension</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:-60-.-62-">(<.>)</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></li><li class="src short"><a href="#v:splitExtensions">splitExtensions</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> (<a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a>, <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a>)</li><li class="src short"><a href="#v:dropExtensions">dropExtensions</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></li><li class="src short"><a href="#v:takeExtensions">takeExtensions</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a></li><li class="src short"><a href="#v:stripExtension">stripExtension</a> :: <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Maybe.html#t:Maybe">Maybe</a> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></li><li class="src short"><a href="#v:splitFileName">splitFileName</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> (<a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a>, <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a>)</li><li class="src short"><a href="#v:takeFileName">takeFileName</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></li><li class="src short"><a href="#v:replaceFileName">replaceFileName</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></li><li class="src short"><a href="#v:dropFileName">dropFileName</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></li><li class="src short"><a href="#v:takeBaseName">takeBaseName</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a></li><li class="src short"><a href="#v:replaceBaseName">replaceBaseName</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></li><li class="src short"><a href="#v:takeDirectory">takeDirectory</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></li><li class="src short"><a href="#v:replaceDirectory">replaceDirectory</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></li><li class="src short"><a href="#v:combine">combine</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></li><li class="src short"><a href="#v:-60--47--62-">(</>)</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></li><li class="src short"><a href="#v:splitPath">splitPath</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> [<a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a>]</li><li class="src short"><a href="#v:joinPath">joinPath</a> :: [<a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a>] -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></li><li class="src short"><a href="#v:splitDirectories">splitDirectories</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> [<a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a>]</li><li class="src short"><a href="#v:hasTrailingPathSeparator">hasTrailingPathSeparator</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:addTrailingPathSeparator">addTrailingPathSeparator</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></li><li class="src short"><a href="#v:dropTrailingPathSeparator">dropTrailingPathSeparator</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></li><li class="src short"><a href="#v:normalise">normalise</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></li><li class="src short"><a href="#v:makeRelative">makeRelative</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></li><li class="src short"><a href="#v:equalFilePath">equalFilePath</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:isRelative">isRelative</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:isAbsolute">isAbsolute</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:isValid">isValid</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:makeValid">makeValid</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></li><li class="src short"><a href="#v:isFileName">isFileName</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:hasParentDir">hasParentDir</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:hiddenFile">hiddenFile</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a></li><li class="src short">module <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html">System.Posix.ByteString.FilePath</a></li></ul></div><div id="interface"><h1 id="g:1">Separator predicates</h1><div class="top"><p class="src"><a name="v:pathSeparator" class="def">pathSeparator</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Word.html#t:Word8">Word8</a> <a href="src/System-Posix-FilePath.html#pathSeparator" class="link">Source</a></p><div class="doc"><p>Path separator character</p></div></div><div class="top"><p class="src"><a name="v:isPathSeparator" class="def">isPathSeparator</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Word.html#t:Word8">Word8</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a> <a href="src/System-Posix-FilePath.html#isPathSeparator" class="link">Source</a></p><div class="doc"><p>Check if a character is the path separator</p><pre>\n -> (_chr n == '/') == isPathSeparator n</pre></div></div><div class="top"><p class="src"><a name="v:searchPathSeparator" class="def">searchPathSeparator</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Word.html#t:Word8">Word8</a> <a href="src/System-Posix-FilePath.html#searchPathSeparator" class="link">Source</a></p><div class="doc"><p>Search path separator</p></div></div><div class="top"><p class="src"><a name="v:isSearchPathSeparator" class="def">isSearchPathSeparator</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Word.html#t:Word8">Word8</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a> <a href="src/System-Posix-FilePath.html#isSearchPathSeparator" class="link">Source</a></p><div class="doc"><p>Check if a character is the search path separator</p><pre>\n -> (_chr n == ':') == isSearchPathSeparator n</pre></div></div><div class="top"><p class="src"><a name="v:extSeparator" class="def">extSeparator</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Word.html#t:Word8">Word8</a> <a href="src/System-Posix-FilePath.html#extSeparator" class="link">Source</a></p><div class="doc"><p>File extension separator</p></div></div><div class="top"><p class="src"><a name="v:isExtSeparator" class="def">isExtSeparator</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Word.html#t:Word8">Word8</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a> <a href="src/System-Posix-FilePath.html#isExtSeparator" class="link">Source</a></p><div class="doc"><p>Check if a character is the file extension separator</p><pre>\n -> (_chr n == '.') == isExtSeparator n</pre></div></div><h1 id="g:2">$PATH methods</h1><div class="top"><p class="src"><a name="v:splitSearchPath" class="def">splitSearchPath</a> :: <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> -> [<a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a>] <a href="src/System-Posix-FilePath.html#splitSearchPath" class="link">Source</a></p><div class="doc"><p>Take a ByteString, split it on the <code><a href="System-Posix-FilePath.html#v:searchPathSeparator">searchPathSeparator</a></code>.
|
|
Blank items are converted to <code>.</code>.</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 class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>splitSearchPath "File1:File2:File3"
|
|
</code></strong>["File1","File2","File3"]
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>splitSearchPath "File1::File2:File3"
|
|
</code></strong>["File1",".","File2","File3"]
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>splitSearchPath ""
|
|
</code></strong>["."]
|
|
</pre></div></div><div class="top"><p class="src"><a name="v:getSearchPath" class="def">getSearchPath</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/System-IO.html#t:IO">IO</a> [<a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a>] <a href="src/System-Posix-FilePath.html#getSearchPath" class="link">Source</a></p><div class="doc"><p>Get a list of <code><a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></code>s in the $PATH variable.</p></div></div><h1 id="g:3">Extension functions</h1><div class="top"><p class="src"><a name="v:splitExtension" class="def">splitExtension</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> (<a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a>, <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a>) <a href="src/System-Posix-FilePath.html#splitExtension" class="link">Source</a></p><div class="doc"><p>Split a <code><a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></code> into a path+filename and extension</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>splitExtension "file.exe"
|
|
</code></strong>("file",".exe")
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>splitExtension "file"
|
|
</code></strong>("file","")
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>splitExtension "/path/file.tar.gz"
|
|
</code></strong>("/path/file.tar",".gz")
|
|
</pre><pre>\path -> uncurry (BS.append) (splitExtension path) == path</pre></div></div><div class="top"><p class="src"><a name="v:takeExtension" class="def">takeExtension</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> <a href="src/System-Posix-FilePath.html#takeExtension" class="link">Source</a></p><div class="doc"><p>Get the final extension from a <code><a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></code></p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>takeExtension "file.exe"
|
|
</code></strong>".exe"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>takeExtension "file"
|
|
</code></strong>""
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>takeExtension "/path/file.tar.gz"
|
|
</code></strong>".gz"
|
|
</pre></div></div><div class="top"><p class="src"><a name="v:replaceExtension" class="def">replaceExtension</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> <a href="src/System-Posix-FilePath.html#replaceExtension" class="link">Source</a></p><div class="doc"><p>Change a file's extension</p><pre>\path -> let ext = takeExtension path in replaceExtension path ext == path</pre></div></div><div class="top"><p class="src"><a name="v:dropExtension" class="def">dropExtension</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> <a href="src/System-Posix-FilePath.html#dropExtension" class="link">Source</a></p><div class="doc"><p>Drop the final extension from a <code><a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></code></p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>dropExtension "file.exe"
|
|
</code></strong>"file"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>dropExtension "file"
|
|
</code></strong>"file"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>dropExtension "/path/file.tar.gz"
|
|
</code></strong>"/path/file.tar"
|
|
</pre></div></div><div class="top"><p class="src"><a name="v:addExtension" class="def">addExtension</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> <a href="src/System-Posix-FilePath.html#addExtension" class="link">Source</a></p><div class="doc"><p>Add an extension to a <code><a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></code></p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>addExtension "file" ".exe"
|
|
</code></strong>"file.exe"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>addExtension "file.tar" ".gz"
|
|
</code></strong>"file.tar.gz"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>addExtension "/path/" ".ext"
|
|
</code></strong>"/path/.ext"
|
|
</pre></div></div><div class="top"><p class="src"><a name="v:hasExtension" class="def">hasExtension</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a> <a href="src/System-Posix-FilePath.html#hasExtension" class="link">Source</a></p><div class="doc"><p>Check if a <code><a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></code> has an extension</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>hasExtension "file"
|
|
</code></strong>False
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>hasExtension "file.tar"
|
|
</code></strong>True
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>hasExtension "/path.part1/"
|
|
</code></strong>False
|
|
</pre></div></div><div class="top"><p class="src"><a name="v:-60-.-62-" class="def">(<.>)</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> <a href="src/System-Posix-FilePath.html#%3C.%3E" class="link">Source</a></p><div class="doc"><p>Operator version of <code><a href="System-Posix-FilePath.html#v:addExtension">addExtension</a></code></p></div></div><div class="top"><p class="src"><a name="v:splitExtensions" class="def">splitExtensions</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> (<a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a>, <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a>) <a href="src/System-Posix-FilePath.html#splitExtensions" class="link">Source</a></p><div class="doc"><p>Split a <code><a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></code> on the first extension.</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>splitExtensions "/path/file.tar.gz"
|
|
</code></strong>("/path/file",".tar.gz")
|
|
</pre><pre>\path -> uncurry addExtension (splitExtensions path) == path</pre></div></div><div class="top"><p class="src"><a name="v:dropExtensions" class="def">dropExtensions</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> <a href="src/System-Posix-FilePath.html#dropExtensions" class="link">Source</a></p><div class="doc"><p>Remove all extensions from a <code><a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></code></p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>dropExtensions "/path/file.tar.gz"
|
|
</code></strong>"/path/file"
|
|
</pre></div></div><div class="top"><p class="src"><a name="v:takeExtensions" class="def">takeExtensions</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> <a href="src/System-Posix-FilePath.html#takeExtensions" class="link">Source</a></p><div class="doc"><p>Take all extensions from a <code><a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></code></p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>takeExtensions "/path/file.tar.gz"
|
|
</code></strong>".tar.gz"
|
|
</pre></div></div><div class="top"><p class="src"><a name="v:stripExtension" class="def">stripExtension</a> :: <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Maybe.html#t:Maybe">Maybe</a> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> <a href="src/System-Posix-FilePath.html#stripExtension" class="link">Source</a></p><div class="doc"><p>Drop the given extension from a FilePath, and the <code>"."</code> preceding it.
|
|
Returns <code><a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Maybe.html#v:Nothing">Nothing</a></code> if the FilePath does not have the given extension, or
|
|
<code><a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Maybe.html#v:Just">Just</a></code> and the part before the extension if it does.</p><p>This function can be more predictable than <code><a href="System-Posix-FilePath.html#v:dropExtensions">dropExtensions</a></code>,
|
|
especially if the filename might itself contain <code>.</code> characters.</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>stripExtension "hs.o" "foo.x.hs.o"
|
|
</code></strong>Just "foo.x"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>stripExtension "hi.o" "foo.x.hs.o"
|
|
</code></strong>Nothing
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>stripExtension ".c.d" "a.b.c.d"
|
|
</code></strong>Just "a.b"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>stripExtension ".c.d" "a.b..c.d"
|
|
</code></strong>Just "a.b."
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>stripExtension "baz" "foo.bar"
|
|
</code></strong>Nothing
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>stripExtension "bar" "foobar"
|
|
</code></strong>Nothing
|
|
</pre><pre>\path -> stripExtension "" path == Just path</pre><pre>\path -> dropExtension path == fromJust (stripExtension (takeExtension path) path)</pre><pre>\path -> dropExtensions path == fromJust (stripExtension (takeExtensions path) path)</pre></div></div><h1 id="g:4">Filename/directory functions</h1><div class="top"><p class="src"><a name="v:splitFileName" class="def">splitFileName</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> (<a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a>, <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a>) <a href="src/System-Posix-FilePath.html#splitFileName" class="link">Source</a></p><div class="doc"><p>Split a <code><a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></code> into (path,file). <code><a href="System-Posix-FilePath.html#v:combine">combine</a></code> is the inverse</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>splitFileName "path/file.txt"
|
|
</code></strong>("path/","file.txt")
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>splitFileName "path/"
|
|
</code></strong>("path/","")
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>splitFileName "file.txt"
|
|
</code></strong>("./","file.txt")
|
|
</pre><pre>\path -> uncurry combine (splitFileName path) == path || fst (splitFileName path) == "./"</pre></div></div><div class="top"><p class="src"><a name="v:takeFileName" class="def">takeFileName</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> <a href="src/System-Posix-FilePath.html#takeFileName" class="link">Source</a></p><div class="doc"><p>Get the file name</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>takeFileName "path/file.txt"
|
|
</code></strong>"file.txt"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>takeFileName "path/"
|
|
</code></strong>""
|
|
</pre></div></div><div class="top"><p class="src"><a name="v:replaceFileName" class="def">replaceFileName</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> <a href="src/System-Posix-FilePath.html#replaceFileName" class="link">Source</a></p><div class="doc"><p>Change the file name</p><pre>\path -> replaceFileName path (takeFileName path) == path</pre></div></div><div class="top"><p class="src"><a name="v:dropFileName" class="def">dropFileName</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> <a href="src/System-Posix-FilePath.html#dropFileName" class="link">Source</a></p><div class="doc"><p>Drop the file name</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>dropFileName "path/file.txt"
|
|
</code></strong>"path/"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>dropFileName "file.txt"
|
|
</code></strong>"./"
|
|
</pre></div></div><div class="top"><p class="src"><a name="v:takeBaseName" class="def">takeBaseName</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> <a href="src/System-Posix-FilePath.html#takeBaseName" class="link">Source</a></p><div class="doc"><p>Get the file name, without a trailing extension</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>takeBaseName "path/file.tar.gz"
|
|
</code></strong>"file.tar"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>takeBaseName ""
|
|
</code></strong>""
|
|
</pre></div></div><div class="top"><p class="src"><a name="v:replaceBaseName" class="def">replaceBaseName</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> <a href="src/System-Posix-FilePath.html#replaceBaseName" class="link">Source</a></p><div class="doc"><p>Change the base name</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>replaceBaseName "path/file.tar.gz" "bob"
|
|
</code></strong>"path/bob.gz"
|
|
</pre><pre>\path -> replaceBaseName path (takeBaseName path) == path</pre></div></div><div class="top"><p class="src"><a name="v:takeDirectory" class="def">takeDirectory</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> <a href="src/System-Posix-FilePath.html#takeDirectory" class="link">Source</a></p><div class="doc"><p>Get the directory, moving up one level if it's already a directory</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>takeDirectory "path/file.txt"
|
|
</code></strong>"path"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>takeDirectory "file"
|
|
</code></strong>"."
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>takeDirectory "/path/to/"
|
|
</code></strong>"/path/to"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>takeDirectory "/path/to"
|
|
</code></strong>"/path"
|
|
</pre></div></div><div class="top"><p class="src"><a name="v:replaceDirectory" class="def">replaceDirectory</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/bytestring-0.10.4.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> <a href="src/System-Posix-FilePath.html#replaceDirectory" class="link">Source</a></p><div class="doc"><p>Change the directory component of a <code><a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></code></p><pre>\path -> replaceDirectory path (takeDirectory path) `equalFilePath` path || takeDirectory path == "."</pre></div></div><div class="top"><p class="src"><a name="v:combine" class="def">combine</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> <a href="src/System-Posix-FilePath.html#combine" class="link">Source</a></p><div class="doc"><p>Join two paths together</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>combine "/" "file"
|
|
</code></strong>"/file"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>combine "/path/to" "file"
|
|
</code></strong>"/path/to/file"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>combine "file" "/absolute/path"
|
|
</code></strong>"/absolute/path"
|
|
</pre></div></div><div class="top"><p class="src"><a name="v:-60--47--62-" class="def">(</>)</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> <a href="src/System-Posix-FilePath.html#%3C%2F%3E" class="link">Source</a></p><div class="doc"><p>Operator version of combine</p></div></div><div class="top"><p class="src"><a name="v:splitPath" class="def">splitPath</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> [<a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a>] <a href="src/System-Posix-FilePath.html#splitPath" class="link">Source</a></p><div class="doc"><p>Split a path into a list of components:</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>splitPath "/path/to/file.txt"
|
|
</code></strong>["/","path/","to/","file.txt"]
|
|
</pre><pre>\path -> BS.concat (splitPath path) == path</pre></div></div><div class="top"><p class="src"><a name="v:joinPath" class="def">joinPath</a> :: [<a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a>] -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> <a href="src/System-Posix-FilePath.html#joinPath" class="link">Source</a></p><div class="doc"><p>Join a split path back together</p><pre>\path -> joinPath (splitPath path) == path</pre><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>joinPath ["path","to","file.txt"]
|
|
</code></strong>"path/to/file.txt"
|
|
</pre></div></div><div class="top"><p class="src"><a name="v:splitDirectories" class="def">splitDirectories</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> [<a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a>] <a href="src/System-Posix-FilePath.html#splitDirectories" class="link">Source</a></p><div class="doc"><p>Like <code><a href="System-Posix-FilePath.html#v:splitPath">splitPath</a></code>, but without trailing slashes</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>splitDirectories "/path/to/file.txt"
|
|
</code></strong>["/","path","to","file.txt"]
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>splitDirectories ""
|
|
</code></strong>[]
|
|
</pre></div></div><h1 id="g:5">Trailing slash functions</h1><div class="top"><p class="src"><a name="v:hasTrailingPathSeparator" class="def">hasTrailingPathSeparator</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a> <a href="src/System-Posix-FilePath.html#hasTrailingPathSeparator" class="link">Source</a></p><div class="doc"><p>Check if the last character of a <code><a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a></code> is <code><a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Prelude.html#v:-47-">/</a></code>.</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>hasTrailingPathSeparator "/path/"
|
|
</code></strong>True
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>hasTrailingPathSeparator "/"
|
|
</code></strong>True
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>hasTrailingPathSeparator "/path"
|
|
</code></strong>False
|
|
</pre></div></div><div class="top"><p class="src"><a name="v:addTrailingPathSeparator" class="def">addTrailingPathSeparator</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> <a href="src/System-Posix-FilePath.html#addTrailingPathSeparator" class="link">Source</a></p><div class="doc"><p>Add a trailing path separator.</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>addTrailingPathSeparator "/path"
|
|
</code></strong>"/path/"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>addTrailingPathSeparator "/path/"
|
|
</code></strong>"/path/"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>addTrailingPathSeparator "/"
|
|
</code></strong>"/"
|
|
</pre></div></div><div class="top"><p class="src"><a name="v:dropTrailingPathSeparator" class="def">dropTrailingPathSeparator</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> <a href="src/System-Posix-FilePath.html#dropTrailingPathSeparator" class="link">Source</a></p><div class="doc"><p>Remove a trailing path separator</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>dropTrailingPathSeparator "/path/"
|
|
</code></strong>"/path"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>dropTrailingPathSeparator "/path////"
|
|
</code></strong>"/path"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>dropTrailingPathSeparator "/"
|
|
</code></strong>"/"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>dropTrailingPathSeparator "//"
|
|
</code></strong>"/"
|
|
</pre></div></div><h1 id="g:6">File name manipulations</h1><div class="top"><p class="src"><a name="v:normalise" class="def">normalise</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> <a href="src/System-Posix-FilePath.html#normalise" class="link">Source</a></p><div class="doc"><p>Normalise a file.</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>normalise "/file/\\test////"
|
|
</code></strong>"/file/\\test/"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>normalise "/file/./test"
|
|
</code></strong>"/file/test"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>normalise "/test/file/../bob/fred/"
|
|
</code></strong>"/test/file/../bob/fred/"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>normalise "../bob/fred/"
|
|
</code></strong>"../bob/fred/"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>normalise "./bob/fred/"
|
|
</code></strong>"bob/fred/"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>normalise "./bob////.fred/./...///./..///#."
|
|
</code></strong>"bob/.fred/.../../#."
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>normalise "."
|
|
</code></strong>"."
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>normalise "./"
|
|
</code></strong>"./"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>normalise "./."
|
|
</code></strong>"./"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>normalise "/./"
|
|
</code></strong>"/"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>normalise "/"
|
|
</code></strong>"/"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>normalise "bob/fred/."
|
|
</code></strong>"bob/fred/"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>normalise "//home"
|
|
</code></strong>"/home"
|
|
</pre></div></div><div class="top"><p class="src"><a name="v:makeRelative" class="def">makeRelative</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> <a href="src/System-Posix-FilePath.html#makeRelative" class="link">Source</a></p><div class="doc"><p>Contract a filename, based on a relative path. Note that the resulting
|
|
path will never introduce <code>..</code> paths, as the presence of symlinks
|
|
means <code>../b</code> may not reach <code>a/b</code> if it starts from <code>a/c</code>. For a
|
|
worked example see
|
|
<a href="http://neilmitchell.blogspot.co.uk/2015/10/filepaths-are-subtle-symlinks-are-hard.html">this blog post</a>.</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>makeRelative "/directory" "/directory/file.ext"
|
|
</code></strong>"file.ext"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>makeRelative "/Home" "/home/bob"
|
|
</code></strong>"/home/bob"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>makeRelative "/home/" "/home/bob/foo/bar"
|
|
</code></strong>"bob/foo/bar"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>makeRelative "/fred" "bob"
|
|
</code></strong>"bob"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>makeRelative "/file/test" "/file/test/fred"
|
|
</code></strong>"fred"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>makeRelative "/file/test" "/file/test/fred/"
|
|
</code></strong>"fred/"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>makeRelative "some/path" "some/path/a/b/c"
|
|
</code></strong>"a/b/c"
|
|
</pre><pre>\p -> makeRelative p p == "."</pre><pre>\p -> makeRelative (takeDirectory p) p `equalFilePath` takeFileName p</pre><p>prop x y -> equalFilePath x y || (isRelative x && makeRelative y x == x) || equalFilePath (y <a href="/">/</a> makeRelative y x) x</p></div></div><div class="top"><p class="src"><a name="v:equalFilePath" class="def">equalFilePath</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a> <a href="src/System-Posix-FilePath.html#equalFilePath" class="link">Source</a></p><div class="doc"><p>Equality of two filepaths. The filepaths are normalised
|
|
and trailing path separators are dropped.</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>equalFilePath "foo" "foo"
|
|
</code></strong>True
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>equalFilePath "foo" "foo/"
|
|
</code></strong>True
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>equalFilePath "foo" "./foo"
|
|
</code></strong>True
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>equalFilePath "" ""
|
|
</code></strong>True
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>equalFilePath "foo" "/foo"
|
|
</code></strong>False
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>equalFilePath "foo" "FOO"
|
|
</code></strong>False
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>equalFilePath "foo" "../foo"
|
|
</code></strong>False
|
|
</pre><pre>\p -> equalFilePath p p</pre></div></div><div class="top"><p class="src"><a name="v:isRelative" class="def">isRelative</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a> <a href="src/System-Posix-FilePath.html#isRelative" class="link">Source</a></p><div class="doc"><p>Check if a path is relative</p><pre>\path -> isRelative path /= isAbsolute path</pre></div></div><div class="top"><p class="src"><a name="v:isAbsolute" class="def">isAbsolute</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a> <a href="src/System-Posix-FilePath.html#isAbsolute" class="link">Source</a></p><div class="doc"><p>Check if a path is absolute</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>isAbsolute "/path"
|
|
</code></strong>True
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>isAbsolute "path"
|
|
</code></strong>False
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>isAbsolute ""
|
|
</code></strong>False
|
|
</pre></div></div><div class="top"><p class="src"><a name="v:isValid" class="def">isValid</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a> <a href="src/System-Posix-FilePath.html#isValid" class="link">Source</a></p><div class="doc"><p>Is a FilePath valid, i.e. could you create a file like it?</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>isValid ""
|
|
</code></strong>False
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>isValid "\0"
|
|
</code></strong>False
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>isValid "/random_ path:*"
|
|
</code></strong>True
|
|
</pre></div></div><div class="top"><p class="src"><a name="v:makeValid" class="def">makeValid</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> <a href="src/System-Posix-FilePath.html#makeValid" class="link">Source</a></p><div class="doc"><p>Take a FilePath and make it valid; does not change already valid FilePaths.</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>makeValid ""
|
|
</code></strong>"_"
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>makeValid "file\0name"
|
|
</code></strong>"file_name"
|
|
</pre><pre>\p -> if isValid p then makeValid p == p else makeValid p /= p</pre><pre>\p -> isValid (makeValid p)</pre></div></div><div class="top"><p class="src"><a name="v:isFileName" class="def">isFileName</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a> <a href="src/System-Posix-FilePath.html#isFileName" class="link">Source</a></p><div class="doc"><p>Is the given path a valid filename? This includes
|
|
"." and "..".</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>isFileName "lal"
|
|
</code></strong>True
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>isFileName "."
|
|
</code></strong>True
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>isFileName ".."
|
|
</code></strong>True
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>isFileName ""
|
|
</code></strong>False
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>isFileName "\0"
|
|
</code></strong>False
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>isFileName "/random_ path:*"
|
|
</code></strong>False
|
|
</pre></div></div><div class="top"><p class="src"><a name="v:hasParentDir" class="def">hasParentDir</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a> <a href="src/System-Posix-FilePath.html#hasParentDir" class="link">Source</a></p><div class="doc"><p>Check if the filepath has any parent directories in it.</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>hasParentDir "/.."
|
|
</code></strong>True
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>hasParentDir "foo/bar/.."
|
|
</code></strong>True
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>hasParentDir "foo/../bar/."
|
|
</code></strong>True
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>hasParentDir "foo/bar"
|
|
</code></strong>False
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>hasParentDir "foo"
|
|
</code></strong>False
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>hasParentDir ""
|
|
</code></strong>False
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>hasParentDir ".."
|
|
</code></strong>False
|
|
</pre></div></div><div class="top"><p class="src"><a name="v:hiddenFile" class="def">hiddenFile</a> :: <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html#t:RawFilePath">RawFilePath</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Bool.html#t:Bool">Bool</a> <a href="src/System-Posix-FilePath.html#hiddenFile" class="link">Source</a></p><div class="doc"><p>Whether the file is a hidden file.</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>hiddenFile ".foo"
|
|
</code></strong>True
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>hiddenFile "..foo.bar"
|
|
</code></strong>True
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>hiddenFile "some/path/.bar"
|
|
</code></strong>True
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>hiddenFile "..."
|
|
</code></strong>True
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>hiddenFile "dod.bar"
|
|
</code></strong>False
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>hiddenFile "."
|
|
</code></strong>False
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>hiddenFile ".."
|
|
</code></strong>False
|
|
<code class="prompt">>>> </code><strong class="userinput"><code>hiddenFile ""
|
|
</code></strong>False
|
|
</pre></div></div><div class="top"><p class="src">module <a href="https://hackage.haskell.org/package/unix-2.7.0.1/docs/System-Posix-ByteString-FilePath.html">System.Posix.ByteString.FilePath</a></p></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.14.3</p></div></body></html> |