Initial commit
This commit is contained in:
commit
1fd1427532
22
HPath-IO-Errors.html
Normal file
22
HPath-IO-Errors.html
Normal file
File diff suppressed because one or more lines are too long
6
HPath-IO-Utils.html
Normal file
6
HPath-IO-Utils.html
Normal file
@ -0,0 +1,6 @@
|
||||
<!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>HPath.IO.Utils</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();setSynopsis("mini_HPath-IO-Utils.html");};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/HPath-IO-Utils.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>GPL-2</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</td></tr><tr><th>Language</th><td>Haskell2010</td></tr></table><p class="caption">HPath.IO.Utils</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Random and general IO/monad utilities.</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:whenM">whenM</a> :: Monad m => m Bool -> m () -> m ()</li><li class="src short"><a href="#v:unlessM">unlessM</a> :: Monad m => m Bool -> m () -> m ()</li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><a id="v:whenM" class="def">whenM</a> :: Monad m => m Bool -> m () -> m () <a href="src/HPath-IO-Utils.html#whenM" class="link">Source</a> <a href="#v:whenM" class="selflink">#</a></p><div class="doc"><p>If the value of the first argument is True, then execute the action
|
||||
provided in the second argument, otherwise do nothing.</p></div></div><div class="top"><p class="src"><a id="v:unlessM" class="def">unlessM</a> :: Monad m => m Bool -> m () -> m () <a href="src/HPath-IO-Utils.html#unlessM" class="link">Source</a> <a href="#v:unlessM" class="selflink">#</a></p><div class="doc"><p>If the value of the first argument is False, then execute the action
|
||||
provided in the second argument, otherwise do nothing.</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
59
HPath-IO.html
Normal file
59
HPath-IO.html
Normal file
File diff suppressed because one or more lines are too long
105
HPath.html
Normal file
105
HPath.html
Normal file
File diff suppressed because one or more lines are too long
9
System-Posix-Directory-Foreign.html
Normal file
9
System-Posix-Directory-Foreign.html
Normal file
File diff suppressed because one or more lines are too long
11
System-Posix-Directory-Traversals.html
Normal file
11
System-Posix-Directory-Traversals.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!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.Directory.Traversals</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();setSynopsis("mini_System-Posix-Directory-Traversals.html");};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/System-Posix-Directory-Traversals.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>None</td></tr><tr><th>Language</th><td>Haskell2010</td></tr></table><p class="caption">System.Posix.Directory.Traversals</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Traversal and read operations on directories.</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:getDirectoryContents">getDirectoryContents</a> :: RawFilePath -> IO [(<a href="System-Posix-Directory-Foreign.html#t:DirType">DirType</a>, RawFilePath)]</li><li class="src short"><a href="#v:getDirectoryContents-39-">getDirectoryContents'</a> :: Fd -> IO [(<a href="System-Posix-Directory-Foreign.html#t:DirType">DirType</a>, RawFilePath)]</li><li class="src short"><a href="#v:allDirectoryContents">allDirectoryContents</a> :: RawFilePath -> IO [RawFilePath]</li><li class="src short"><a href="#v:allDirectoryContents-39-">allDirectoryContents'</a> :: RawFilePath -> IO [RawFilePath]</li><li class="src short"><a href="#v:traverseDirectory">traverseDirectory</a> :: (s -> RawFilePath -> IO s) -> s -> RawFilePath -> IO s</li><li class="src short"><a href="#v:readDirEnt">readDirEnt</a> :: DirStream -> IO (<a href="System-Posix-Directory-Foreign.html#t:DirType">DirType</a>, RawFilePath)</li><li class="src short"><a href="#v:packDirStream">packDirStream</a> :: Ptr CDir -> DirStream</li><li class="src short"><a href="#v:unpackDirStream">unpackDirStream</a> :: DirStream -> Ptr CDir</li><li class="src short"><a href="#v:fdOpendir">fdOpendir</a> :: Fd -> IO DirStream</li><li class="src short"><a href="#v:realpath">realpath</a> :: RawFilePath -> IO RawFilePath</li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><a id="v:getDirectoryContents" class="def">getDirectoryContents</a> :: RawFilePath -> IO [(<a href="System-Posix-Directory-Foreign.html#t:DirType">DirType</a>, RawFilePath)] <a href="src/System-Posix-Directory-Traversals.html#getDirectoryContents" class="link">Source</a> <a href="#v:getDirectoryContents" class="selflink">#</a></p><div class="doc"><p>Gets all directory contents (not recursively).</p></div></div><div class="top"><p class="src"><a id="v:getDirectoryContents-39-" class="def">getDirectoryContents'</a> :: Fd -> IO [(<a href="System-Posix-Directory-Foreign.html#t:DirType">DirType</a>, RawFilePath)] <a href="src/System-Posix-Directory-Traversals.html#getDirectoryContents%27" class="link">Source</a> <a href="#v:getDirectoryContents-39-" class="selflink">#</a></p><div class="doc"><p>Like <code><a href="System-Posix-Directory-Traversals.html#v:getDirectoryContents">getDirectoryContents</a></code> except for a file descriptor.</p><p>To avoid complicated error checks, the file descriptor is
|
||||
<strong>always</strong> closed, even if <code><a href="System-Posix-Directory-Traversals.html#v:fdOpendir">fdOpendir</a></code> fails. Usually, this
|
||||
only happens on successful <code><a href="System-Posix-Directory-Traversals.html#v:fdOpendir">fdOpendir</a></code> and after the directory
|
||||
stream is closed. Also see the manpage of <code>fdopendir(3)</code> for
|
||||
more details.</p></div></div><div class="top"><p class="src"><a id="v:allDirectoryContents" class="def">allDirectoryContents</a> :: RawFilePath -> IO [RawFilePath] <a href="src/System-Posix-Directory-Traversals.html#allDirectoryContents" class="link">Source</a> <a href="#v:allDirectoryContents" class="selflink">#</a></p><div class="doc"><p>Get all files from a directory and its subdirectories.</p><p>Upon entering a directory, <code><a href="System-Posix-Directory-Traversals.html#v:allDirectoryContents">allDirectoryContents</a></code> will get all entries
|
||||
strictly. However the returned list is lazy in that directories will only
|
||||
be accessed on demand.</p><p>Follows symbolic links for the input dir.</p></div></div><div class="top"><p class="src"><a id="v:allDirectoryContents-39-" class="def">allDirectoryContents'</a> :: RawFilePath -> IO [RawFilePath] <a href="src/System-Posix-Directory-Traversals.html#allDirectoryContents%27" class="link">Source</a> <a href="#v:allDirectoryContents-39-" class="selflink">#</a></p><div class="doc"><p>Get all files from a directory and its subdirectories strictly.</p><p>Follows symbolic links for the input dir.</p></div></div><div class="top"><p class="src"><a id="v:traverseDirectory" class="def">traverseDirectory</a> :: (s -> RawFilePath -> IO s) -> s -> RawFilePath -> IO s <a href="src/System-Posix-Directory-Traversals.html#traverseDirectory" class="link">Source</a> <a href="#v:traverseDirectory" class="selflink">#</a></p><div class="doc"><p>Recursively apply the <code>action</code> to the parent directory and all
|
||||
files/subdirectories.</p><p>This function allows for memory-efficient traversals.</p><p>Follows symbolic links for the input dir.</p></div></div><div class="top"><p class="src"><a id="v:readDirEnt" class="def">readDirEnt</a> :: DirStream -> IO (<a href="System-Posix-Directory-Foreign.html#t:DirType">DirType</a>, RawFilePath) <a href="src/System-Posix-Directory-Traversals.html#readDirEnt" class="link">Source</a> <a href="#v:readDirEnt" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:packDirStream" class="def">packDirStream</a> :: Ptr CDir -> DirStream <a href="src/System-Posix-Directory-Traversals.html#packDirStream" class="link">Source</a> <a href="#v:packDirStream" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:unpackDirStream" class="def">unpackDirStream</a> :: DirStream -> Ptr CDir <a href="src/System-Posix-Directory-Traversals.html#unpackDirStream" class="link">Source</a> <a href="#v:unpackDirStream" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:fdOpendir" class="def">fdOpendir</a> :: Fd -> IO DirStream <a href="src/System-Posix-Directory-Traversals.html#fdOpendir" class="link">Source</a> <a href="#v:fdOpendir" class="selflink">#</a></p><div class="doc"><p>Binding to <code>fdopendir(3)</code>.</p></div></div><div class="top"><p class="src"><a id="v:realpath" class="def">realpath</a> :: RawFilePath -> IO RawFilePath <a href="src/System-Posix-Directory-Traversals.html#realpath" class="link">Source</a> <a href="#v:realpath" class="selflink">#</a></p><div class="doc"><p>return the canonicalized absolute pathname</p><p>like canonicalizePath, but uses <code>realpath(3)</code></p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
9
System-Posix-FD.html
Normal file
9
System-Posix-FD.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!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.FD</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();setSynopsis("mini_System-Posix-FD.html");};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/System-Posix-FD.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</td></tr><tr><th>Language</th><td>Haskell2010</td></tr></table><p class="caption">System.Posix.FD</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Provides an alternative for <code><a href="System-Posix-IO-ByteString.html#v:openFd">openFd</a></code>
|
||||
which gives us more control on what status flags to pass to the
|
||||
low-level <code>open(2)</code> call, in contrast to the unix package.</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:openFd">openFd</a> :: RawFilePath -> OpenMode -> [<a href="System-Posix-Directory-Foreign.html#t:Flags">Flags</a>] -> Maybe FileMode -> IO Fd</li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><a id="v:openFd" class="def">openFd</a> <a href="src/System-Posix-FD.html#openFd" class="link">Source</a> <a href="#v:openFd" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: RawFilePath</td><td class="doc empty"> </td></tr><tr><td class="src">-> OpenMode</td><td class="doc empty"> </td></tr><tr><td class="src">-> [<a href="System-Posix-Directory-Foreign.html#t:Flags">Flags</a>]</td><td class="doc"><p>status flags of <code>open(2)</code></p></td></tr><tr><td class="src">-> Maybe FileMode</td><td class="doc"><p><code>Just x</code> => creates the file with the given modes, Nothing => the file must exist.</p></td></tr><tr><td class="src">-> IO Fd</td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Open and optionally create this file. See <code><a href="System-Posix.html#v:Files">Files</a></code>
|
||||
for information on how to use the <code>FileMode</code> type.</p><p>Note that passing <code>Just x</code> as the 4th argument triggers the
|
||||
<code><a href="System-Posix-Directory-Foreign.html#v:oCreat">oCreat</a></code> status flag, which must be set when you pass in <code><a href="System-Posix-Directory-Foreign.html#v:oExcl">oExcl</a></code>
|
||||
to the status flags. Also see the manpage for <code>open(2)</code>.</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
243
System-Posix-FilePath.html
Normal file
243
System-Posix-FilePath.html
Normal file
File diff suppressed because one or more lines are too long
4
doc-index-60.html
Normal file
4
doc-index-60.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>hpath-0.7.3: Support for well-typed paths (Index - <)</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.3: Support for well-typed paths</p></div><div id="content"><div id="alphabet"><ul><li><a href="doc-index-A.html">A</a></li><li><a href="doc-index-B.html">B</a></li><li><a href="doc-index-C.html">C</a></li><li><a href="doc-index-D.html">D</a></li><li><a href="doc-index-E.html">E</a></li><li><a href="doc-index-F.html">F</a></li><li><a href="doc-index-G.html">G</a></li><li><a href="doc-index-H.html">H</a></li><li><a href="doc-index-I.html">I</a></li><li><a href="doc-index-J.html">J</a></li><li><a href="doc-index-M.html">M</a></li><li><a href="doc-index-N.html">N</a></li><li><a href="doc-index-O.html">O</a></li><li><a href="doc-index-P.html">P</a></li><li><a href="doc-index-R.html">R</a></li><li><a href="doc-index-S.html">S</a></li><li><a href="doc-index-T.html">T</a></li><li><a href="doc-index-U.html">U</a></li><li><a href="doc-index-W.html">W</a></li><li><a href="doc-index-60.html"><</a></li><li><a href="doc-index-All.html">All</a></li></ul></div><div id="index"><p class="caption">Index - <</p><table><tr><td class="src"><.></td><td class="module"><a href="System-Posix-FilePath.html#v:-60-.-62-">System.Posix.FilePath</a></td></tr><tr><td class="src"></></td><td> </td></tr><tr><td class="alt">1 (Function)</td><td class="module"><a href="System-Posix-FilePath.html#v:-60--47--62-">System.Posix.FilePath</a></td></tr><tr><td class="alt">2 (Function)</td><td class="module"><a href="HPath.html#v:-60--47--62-">HPath</a></td></tr></table></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
4
doc-index-A.html
Normal file
4
doc-index-A.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>hpath-0.7.3: Support for well-typed paths (Index - A)</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.3: Support for well-typed paths</p></div><div id="content"><div id="alphabet"><ul><li><a href="doc-index-A.html">A</a></li><li><a href="doc-index-B.html">B</a></li><li><a href="doc-index-C.html">C</a></li><li><a href="doc-index-D.html">D</a></li><li><a href="doc-index-E.html">E</a></li><li><a href="doc-index-F.html">F</a></li><li><a href="doc-index-G.html">G</a></li><li><a href="doc-index-H.html">H</a></li><li><a href="doc-index-I.html">I</a></li><li><a href="doc-index-J.html">J</a></li><li><a href="doc-index-M.html">M</a></li><li><a href="doc-index-N.html">N</a></li><li><a href="doc-index-O.html">O</a></li><li><a href="doc-index-P.html">P</a></li><li><a href="doc-index-R.html">R</a></li><li><a href="doc-index-S.html">S</a></li><li><a href="doc-index-T.html">T</a></li><li><a href="doc-index-U.html">U</a></li><li><a href="doc-index-W.html">W</a></li><li><a href="doc-index-60.html"><</a></li><li><a href="doc-index-All.html">All</a></li></ul></div><div id="index"><p class="caption">Index - A</p><table><tr><td class="src">Abs</td><td class="module"><a href="HPath.html#t:Abs">HPath</a></td></tr><tr><td class="src">addExtension</td><td class="module"><a href="System-Posix-FilePath.html#v:addExtension">System.Posix.FilePath</a></td></tr><tr><td class="src">addTrailingPathSeparator</td><td class="module"><a href="System-Posix-FilePath.html#v:addTrailingPathSeparator">System.Posix.FilePath</a></td></tr><tr><td class="src">allDirectoryContents</td><td class="module"><a href="System-Posix-Directory-Traversals.html#v:allDirectoryContents">System.Posix.Directory.Traversals</a></td></tr><tr><td class="src">allDirectoryContents'</td><td class="module"><a href="System-Posix-Directory-Traversals.html#v:allDirectoryContents-39-">System.Posix.Directory.Traversals</a></td></tr></table></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
4
doc-index-All.html
Normal file
4
doc-index-All.html
Normal file
File diff suppressed because one or more lines are too long
4
doc-index-B.html
Normal file
4
doc-index-B.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>hpath-0.7.3: Support for well-typed paths (Index - B)</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.3: Support for well-typed paths</p></div><div id="content"><div id="alphabet"><ul><li><a href="doc-index-A.html">A</a></li><li><a href="doc-index-B.html">B</a></li><li><a href="doc-index-C.html">C</a></li><li><a href="doc-index-D.html">D</a></li><li><a href="doc-index-E.html">E</a></li><li><a href="doc-index-F.html">F</a></li><li><a href="doc-index-G.html">G</a></li><li><a href="doc-index-H.html">H</a></li><li><a href="doc-index-I.html">I</a></li><li><a href="doc-index-J.html">J</a></li><li><a href="doc-index-M.html">M</a></li><li><a href="doc-index-N.html">N</a></li><li><a href="doc-index-O.html">O</a></li><li><a href="doc-index-P.html">P</a></li><li><a href="doc-index-R.html">R</a></li><li><a href="doc-index-S.html">S</a></li><li><a href="doc-index-T.html">T</a></li><li><a href="doc-index-U.html">U</a></li><li><a href="doc-index-W.html">W</a></li><li><a href="doc-index-60.html"><</a></li><li><a href="doc-index-All.html">All</a></li></ul></div><div id="index"><p class="caption">Index - B</p><table><tr><td class="src">basename</td><td class="module"><a href="HPath.html#v:basename">HPath</a></td></tr><tr><td class="src">BlockDevice</td><td class="module"><a href="HPath-IO.html#v:BlockDevice">HPath.IO</a></td></tr><tr><td class="src">bracketeer</td><td class="module"><a href="HPath-IO-Errors.html#v:bracketeer">HPath.IO.Errors</a></td></tr></table></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
4
doc-index-C.html
Normal file
4
doc-index-C.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>hpath-0.7.3: Support for well-typed paths (Index - C)</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.3: Support for well-typed paths</p></div><div id="content"><div id="alphabet"><ul><li><a href="doc-index-A.html">A</a></li><li><a href="doc-index-B.html">B</a></li><li><a href="doc-index-C.html">C</a></li><li><a href="doc-index-D.html">D</a></li><li><a href="doc-index-E.html">E</a></li><li><a href="doc-index-F.html">F</a></li><li><a href="doc-index-G.html">G</a></li><li><a href="doc-index-H.html">H</a></li><li><a href="doc-index-I.html">I</a></li><li><a href="doc-index-J.html">J</a></li><li><a href="doc-index-M.html">M</a></li><li><a href="doc-index-N.html">N</a></li><li><a href="doc-index-O.html">O</a></li><li><a href="doc-index-P.html">P</a></li><li><a href="doc-index-R.html">R</a></li><li><a href="doc-index-S.html">S</a></li><li><a href="doc-index-T.html">T</a></li><li><a href="doc-index-U.html">U</a></li><li><a href="doc-index-W.html">W</a></li><li><a href="doc-index-60.html"><</a></li><li><a href="doc-index-All.html">All</a></li></ul></div><div id="index"><p class="caption">Index - C</p><table><tr><td class="src">Can'tOpenDirectory</td><td class="module"><a href="HPath-IO-Errors.html#v:Can-39-tOpenDirectory">HPath.IO.Errors</a></td></tr><tr><td class="src">canonicalizePath</td><td class="module"><a href="HPath-IO.html#v:canonicalizePath">HPath.IO</a></td></tr><tr><td class="src">canOpenDirectory</td><td class="module"><a href="HPath-IO-Errors.html#v:canOpenDirectory">HPath.IO.Errors</a></td></tr><tr><td class="src">catchErrno</td><td class="module"><a href="HPath-IO-Errors.html#v:catchErrno">HPath.IO.Errors</a></td></tr><tr><td class="src">CharacterDevice</td><td class="module"><a href="HPath-IO.html#v:CharacterDevice">HPath.IO</a></td></tr><tr><td class="src">combine</td><td class="module"><a href="System-Posix-FilePath.html#v:combine">System.Posix.FilePath</a></td></tr><tr><td class="src">copyDirRecursive</td><td class="module"><a href="HPath-IO.html#v:copyDirRecursive">HPath.IO</a></td></tr><tr><td class="src">copyDirRecursiveOverwrite</td><td class="module"><a href="HPath-IO.html#v:copyDirRecursiveOverwrite">HPath.IO</a></td></tr><tr><td class="src">CopyFailed</td><td class="module"><a href="HPath-IO-Errors.html#v:CopyFailed">HPath.IO.Errors</a></td></tr><tr><td class="src">copyFile</td><td class="module"><a href="HPath-IO.html#v:copyFile">HPath.IO</a></td></tr><tr><td class="src">copyFileOverwrite</td><td class="module"><a href="HPath-IO.html#v:copyFileOverwrite">HPath.IO</a></td></tr><tr><td class="src">createDir</td><td class="module"><a href="HPath-IO.html#v:createDir">HPath.IO</a></td></tr><tr><td class="src">createRegularFile</td><td class="module"><a href="HPath-IO.html#v:createRegularFile">HPath.IO</a></td></tr><tr><td class="src">createSymlink</td><td class="module"><a href="HPath-IO.html#v:createSymlink">HPath.IO</a></td></tr></table></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
4
doc-index-D.html
Normal file
4
doc-index-D.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>hpath-0.7.3: Support for well-typed paths (Index - D)</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.3: Support for well-typed paths</p></div><div id="content"><div id="alphabet"><ul><li><a href="doc-index-A.html">A</a></li><li><a href="doc-index-B.html">B</a></li><li><a href="doc-index-C.html">C</a></li><li><a href="doc-index-D.html">D</a></li><li><a href="doc-index-E.html">E</a></li><li><a href="doc-index-F.html">F</a></li><li><a href="doc-index-G.html">G</a></li><li><a href="doc-index-H.html">H</a></li><li><a href="doc-index-I.html">I</a></li><li><a href="doc-index-J.html">J</a></li><li><a href="doc-index-M.html">M</a></li><li><a href="doc-index-N.html">N</a></li><li><a href="doc-index-O.html">O</a></li><li><a href="doc-index-P.html">P</a></li><li><a href="doc-index-R.html">R</a></li><li><a href="doc-index-S.html">S</a></li><li><a href="doc-index-T.html">T</a></li><li><a href="doc-index-U.html">U</a></li><li><a href="doc-index-W.html">W</a></li><li><a href="doc-index-60.html"><</a></li><li><a href="doc-index-All.html">All</a></li></ul></div><div id="index"><p class="caption">Index - D</p><table><tr><td class="src">deleteDir</td><td class="module"><a href="HPath-IO.html#v:deleteDir">HPath.IO</a></td></tr><tr><td class="src">deleteDirRecursive</td><td class="module"><a href="HPath-IO.html#v:deleteDirRecursive">HPath.IO</a></td></tr><tr><td class="src">deleteFile</td><td class="module"><a href="HPath-IO.html#v:deleteFile">HPath.IO</a></td></tr><tr><td class="src">DestinationInSource</td><td class="module"><a href="HPath-IO-Errors.html#v:DestinationInSource">HPath.IO.Errors</a></td></tr><tr><td class="src">DirDoesExist</td><td class="module"><a href="HPath-IO-Errors.html#v:DirDoesExist">HPath.IO.Errors</a></td></tr><tr><td class="src">DirDoesNotExist</td><td class="module"><a href="HPath-IO-Errors.html#v:DirDoesNotExist">HPath.IO.Errors</a></td></tr><tr><td class="src">Directory</td><td class="module"><a href="HPath-IO.html#v:Directory">HPath.IO</a></td></tr><tr><td class="src">dirname</td><td class="module"><a href="HPath.html#v:dirname">HPath</a></td></tr><tr><td class="src">DirType</td><td> </td></tr><tr><td class="alt">1 (Type/Class)</td><td class="module"><a href="System-Posix-Directory-Foreign.html#t:DirType">System.Posix.Directory.Foreign</a></td></tr><tr><td class="alt">2 (Data Constructor)</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:DirType">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">doesDirectoryExist</td><td class="module"><a href="HPath-IO-Errors.html#v:doesDirectoryExist">HPath.IO.Errors</a></td></tr><tr><td class="src">doesFileExist</td><td class="module"><a href="HPath-IO-Errors.html#v:doesFileExist">HPath.IO.Errors</a></td></tr><tr><td class="src">dropExtension</td><td class="module"><a href="System-Posix-FilePath.html#v:dropExtension">System.Posix.FilePath</a></td></tr><tr><td class="src">dropExtensions</td><td class="module"><a href="System-Posix-FilePath.html#v:dropExtensions">System.Posix.FilePath</a></td></tr><tr><td class="src">dropFileName</td><td class="module"><a href="System-Posix-FilePath.html#v:dropFileName">System.Posix.FilePath</a></td></tr><tr><td class="src">dropTrailingPathSeparator</td><td class="module"><a href="System-Posix-FilePath.html#v:dropTrailingPathSeparator">System.Posix.FilePath</a></td></tr><tr><td class="src">dtBlk</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:dtBlk">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">dtChr</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:dtChr">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">dtDir</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:dtDir">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">dtFifo</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:dtFifo">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">dtLnk</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:dtLnk">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">dtReg</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:dtReg">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">dtSock</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:dtSock">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">dtUnknown</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:dtUnknown">System.Posix.Directory.Foreign</a></td></tr></table></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
4
doc-index-E.html
Normal file
4
doc-index-E.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>hpath-0.7.3: Support for well-typed paths (Index - E)</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.3: Support for well-typed paths</p></div><div id="content"><div id="alphabet"><ul><li><a href="doc-index-A.html">A</a></li><li><a href="doc-index-B.html">B</a></li><li><a href="doc-index-C.html">C</a></li><li><a href="doc-index-D.html">D</a></li><li><a href="doc-index-E.html">E</a></li><li><a href="doc-index-F.html">F</a></li><li><a href="doc-index-G.html">G</a></li><li><a href="doc-index-H.html">H</a></li><li><a href="doc-index-I.html">I</a></li><li><a href="doc-index-J.html">J</a></li><li><a href="doc-index-M.html">M</a></li><li><a href="doc-index-N.html">N</a></li><li><a href="doc-index-O.html">O</a></li><li><a href="doc-index-P.html">P</a></li><li><a href="doc-index-R.html">R</a></li><li><a href="doc-index-S.html">S</a></li><li><a href="doc-index-T.html">T</a></li><li><a href="doc-index-U.html">U</a></li><li><a href="doc-index-W.html">W</a></li><li><a href="doc-index-60.html"><</a></li><li><a href="doc-index-All.html">All</a></li></ul></div><div id="index"><p class="caption">Index - E</p><table><tr><td class="src">easyCopy</td><td class="module"><a href="HPath-IO.html#v:easyCopy">HPath.IO</a></td></tr><tr><td class="src">easyCopyOverwrite</td><td class="module"><a href="HPath-IO.html#v:easyCopyOverwrite">HPath.IO</a></td></tr><tr><td class="src">easyDelete</td><td class="module"><a href="HPath-IO.html#v:easyDelete">HPath.IO</a></td></tr><tr><td class="src">equalFilePath</td><td class="module"><a href="System-Posix-FilePath.html#v:equalFilePath">System.Posix.FilePath</a></td></tr><tr><td class="src">executeFile</td><td class="module"><a href="HPath-IO.html#v:executeFile">HPath.IO</a></td></tr><tr><td class="src">extSeparator</td><td class="module"><a href="System-Posix-FilePath.html#v:extSeparator">System.Posix.FilePath</a></td></tr></table></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
4
doc-index-F.html
Normal file
4
doc-index-F.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>hpath-0.7.3: Support for well-typed paths (Index - F)</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.3: Support for well-typed paths</p></div><div id="content"><div id="alphabet"><ul><li><a href="doc-index-A.html">A</a></li><li><a href="doc-index-B.html">B</a></li><li><a href="doc-index-C.html">C</a></li><li><a href="doc-index-D.html">D</a></li><li><a href="doc-index-E.html">E</a></li><li><a href="doc-index-F.html">F</a></li><li><a href="doc-index-G.html">G</a></li><li><a href="doc-index-H.html">H</a></li><li><a href="doc-index-I.html">I</a></li><li><a href="doc-index-J.html">J</a></li><li><a href="doc-index-M.html">M</a></li><li><a href="doc-index-N.html">N</a></li><li><a href="doc-index-O.html">O</a></li><li><a href="doc-index-P.html">P</a></li><li><a href="doc-index-R.html">R</a></li><li><a href="doc-index-S.html">S</a></li><li><a href="doc-index-T.html">T</a></li><li><a href="doc-index-U.html">U</a></li><li><a href="doc-index-W.html">W</a></li><li><a href="doc-index-60.html"><</a></li><li><a href="doc-index-All.html">All</a></li></ul></div><div id="index"><p class="caption">Index - F</p><table><tr><td class="src">fdOpendir</td><td class="module"><a href="System-Posix-Directory-Traversals.html#v:fdOpendir">System.Posix.Directory.Traversals</a></td></tr><tr><td class="src">FileDoesExist</td><td class="module"><a href="HPath-IO-Errors.html#v:FileDoesExist">HPath.IO.Errors</a></td></tr><tr><td class="src">FileDoesNotExist</td><td class="module"><a href="HPath-IO-Errors.html#v:FileDoesNotExist">HPath.IO.Errors</a></td></tr><tr><td class="src">FileType</td><td class="module"><a href="HPath-IO.html#t:FileType">HPath.IO</a></td></tr><tr><td class="src">Flags</td><td> </td></tr><tr><td class="alt">1 (Type/Class)</td><td class="module"><a href="System-Posix-Directory-Foreign.html#t:Flags">System.Posix.Directory.Foreign</a></td></tr><tr><td class="alt">2 (Data Constructor)</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:Flags">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">Fn</td><td class="module"><a href="HPath.html#t:Fn">HPath</a></td></tr><tr><td class="src">fromAbs</td><td class="module"><a href="HPath.html#v:fromAbs">HPath</a></td></tr><tr><td class="src">fromRel</td><td class="module"><a href="HPath.html#v:fromRel">HPath</a></td></tr></table></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
4
doc-index-G.html
Normal file
4
doc-index-G.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>hpath-0.7.3: Support for well-typed paths (Index - G)</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.3: Support for well-typed paths</p></div><div id="content"><div id="alphabet"><ul><li><a href="doc-index-A.html">A</a></li><li><a href="doc-index-B.html">B</a></li><li><a href="doc-index-C.html">C</a></li><li><a href="doc-index-D.html">D</a></li><li><a href="doc-index-E.html">E</a></li><li><a href="doc-index-F.html">F</a></li><li><a href="doc-index-G.html">G</a></li><li><a href="doc-index-H.html">H</a></li><li><a href="doc-index-I.html">I</a></li><li><a href="doc-index-J.html">J</a></li><li><a href="doc-index-M.html">M</a></li><li><a href="doc-index-N.html">N</a></li><li><a href="doc-index-O.html">O</a></li><li><a href="doc-index-P.html">P</a></li><li><a href="doc-index-R.html">R</a></li><li><a href="doc-index-S.html">S</a></li><li><a href="doc-index-T.html">T</a></li><li><a href="doc-index-U.html">U</a></li><li><a href="doc-index-W.html">W</a></li><li><a href="doc-index-60.html"><</a></li><li><a href="doc-index-All.html">All</a></li></ul></div><div id="index"><p class="caption">Index - G</p><table><tr><td class="src">getAllParents</td><td class="module"><a href="HPath.html#v:getAllParents">HPath</a></td></tr><tr><td class="src">getDirectoryContents</td><td class="module"><a href="System-Posix-Directory-Traversals.html#v:getDirectoryContents">System.Posix.Directory.Traversals</a></td></tr><tr><td class="src">getDirectoryContents'</td><td class="module"><a href="System-Posix-Directory-Traversals.html#v:getDirectoryContents-39-">System.Posix.Directory.Traversals</a></td></tr><tr><td class="src">getDirsFiles</td><td class="module"><a href="HPath-IO.html#v:getDirsFiles">HPath.IO</a></td></tr><tr><td class="src">getFileType</td><td class="module"><a href="HPath-IO.html#v:getFileType">HPath.IO</a></td></tr><tr><td class="src">getSearchPath</td><td class="module"><a href="System-Posix-FilePath.html#v:getSearchPath">System.Posix.FilePath</a></td></tr></table></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
4
doc-index-H.html
Normal file
4
doc-index-H.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>hpath-0.7.3: Support for well-typed paths (Index - H)</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.3: Support for well-typed paths</p></div><div id="content"><div id="alphabet"><ul><li><a href="doc-index-A.html">A</a></li><li><a href="doc-index-B.html">B</a></li><li><a href="doc-index-C.html">C</a></li><li><a href="doc-index-D.html">D</a></li><li><a href="doc-index-E.html">E</a></li><li><a href="doc-index-F.html">F</a></li><li><a href="doc-index-G.html">G</a></li><li><a href="doc-index-H.html">H</a></li><li><a href="doc-index-I.html">I</a></li><li><a href="doc-index-J.html">J</a></li><li><a href="doc-index-M.html">M</a></li><li><a href="doc-index-N.html">N</a></li><li><a href="doc-index-O.html">O</a></li><li><a href="doc-index-P.html">P</a></li><li><a href="doc-index-R.html">R</a></li><li><a href="doc-index-S.html">S</a></li><li><a href="doc-index-T.html">T</a></li><li><a href="doc-index-U.html">U</a></li><li><a href="doc-index-W.html">W</a></li><li><a href="doc-index-60.html"><</a></li><li><a href="doc-index-All.html">All</a></li></ul></div><div id="index"><p class="caption">Index - H</p><table><tr><td class="src">handleIOError</td><td class="module"><a href="HPath-IO-Errors.html#v:handleIOError">HPath.IO.Errors</a></td></tr><tr><td class="src">hasExtension</td><td class="module"><a href="System-Posix-FilePath.html#v:hasExtension">System.Posix.FilePath</a></td></tr><tr><td class="src">hasParentDir</td><td class="module"><a href="System-Posix-FilePath.html#v:hasParentDir">System.Posix.FilePath</a></td></tr><tr><td class="src">hasTrailingPathSeparator</td><td class="module"><a href="System-Posix-FilePath.html#v:hasTrailingPathSeparator">System.Posix.FilePath</a></td></tr><tr><td class="src">hiddenFile</td><td class="module"><a href="System-Posix-FilePath.html#v:hiddenFile">System.Posix.FilePath</a></td></tr><tr><td class="src">HPathIOException</td><td class="module"><a href="HPath-IO-Errors.html#t:HPathIOException">HPath.IO.Errors</a></td></tr></table></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
4
doc-index-I.html
Normal file
4
doc-index-I.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>hpath-0.7.3: Support for well-typed paths (Index - I)</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.3: Support for well-typed paths</p></div><div id="content"><div id="alphabet"><ul><li><a href="doc-index-A.html">A</a></li><li><a href="doc-index-B.html">B</a></li><li><a href="doc-index-C.html">C</a></li><li><a href="doc-index-D.html">D</a></li><li><a href="doc-index-E.html">E</a></li><li><a href="doc-index-F.html">F</a></li><li><a href="doc-index-G.html">G</a></li><li><a href="doc-index-H.html">H</a></li><li><a href="doc-index-I.html">I</a></li><li><a href="doc-index-J.html">J</a></li><li><a href="doc-index-M.html">M</a></li><li><a href="doc-index-N.html">N</a></li><li><a href="doc-index-O.html">O</a></li><li><a href="doc-index-P.html">P</a></li><li><a href="doc-index-R.html">R</a></li><li><a href="doc-index-S.html">S</a></li><li><a href="doc-index-T.html">T</a></li><li><a href="doc-index-U.html">U</a></li><li><a href="doc-index-W.html">W</a></li><li><a href="doc-index-60.html"><</a></li><li><a href="doc-index-All.html">All</a></li></ul></div><div id="index"><p class="caption">Index - I</p><table><tr><td class="src">InvalidOperation</td><td class="module"><a href="HPath-IO-Errors.html#v:InvalidOperation">HPath.IO.Errors</a></td></tr><tr><td class="src">isAbsolute</td><td class="module"><a href="System-Posix-FilePath.html#v:isAbsolute">System.Posix.FilePath</a></td></tr><tr><td class="src">isCan'tOpenDirectory</td><td class="module"><a href="HPath-IO-Errors.html#v:isCan-39-tOpenDirectory">HPath.IO.Errors</a></td></tr><tr><td class="src">isCopyFailed</td><td class="module"><a href="HPath-IO-Errors.html#v:isCopyFailed">HPath.IO.Errors</a></td></tr><tr><td class="src">isDestinationInSource</td><td class="module"><a href="HPath-IO-Errors.html#v:isDestinationInSource">HPath.IO.Errors</a></td></tr><tr><td class="src">isDirDoesExist</td><td class="module"><a href="HPath-IO-Errors.html#v:isDirDoesExist">HPath.IO.Errors</a></td></tr><tr><td class="src">isDirDoesNotExist</td><td class="module"><a href="HPath-IO-Errors.html#v:isDirDoesNotExist">HPath.IO.Errors</a></td></tr><tr><td class="src">isExtSeparator</td><td class="module"><a href="System-Posix-FilePath.html#v:isExtSeparator">System.Posix.FilePath</a></td></tr><tr><td class="src">isFileDoesExist</td><td class="module"><a href="HPath-IO-Errors.html#v:isFileDoesExist">HPath.IO.Errors</a></td></tr><tr><td class="src">isFileDoesNotExist</td><td class="module"><a href="HPath-IO-Errors.html#v:isFileDoesNotExist">HPath.IO.Errors</a></td></tr><tr><td class="src">isFileName</td><td class="module"><a href="System-Posix-FilePath.html#v:isFileName">System.Posix.FilePath</a></td></tr><tr><td class="src">isInvalidOperation</td><td class="module"><a href="HPath-IO-Errors.html#v:isInvalidOperation">HPath.IO.Errors</a></td></tr><tr><td class="src">isParentOf</td><td class="module"><a href="HPath.html#v:isParentOf">HPath</a></td></tr><tr><td class="src">isPathSeparator</td><td class="module"><a href="System-Posix-FilePath.html#v:isPathSeparator">System.Posix.FilePath</a></td></tr><tr><td class="src">isRelative</td><td class="module"><a href="System-Posix-FilePath.html#v:isRelative">System.Posix.FilePath</a></td></tr><tr><td class="src">isSameFile</td><td class="module"><a href="HPath-IO-Errors.html#v:isSameFile">HPath.IO.Errors</a></td></tr><tr><td class="src">isSearchPathSeparator</td><td class="module"><a href="System-Posix-FilePath.html#v:isSearchPathSeparator">System.Posix.FilePath</a></td></tr><tr><td class="src">isSupported</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:isSupported">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">isValid</td><td class="module"><a href="System-Posix-FilePath.html#v:isValid">System.Posix.FilePath</a></td></tr><tr><td class="src">isWritable</td><td class="module"><a href="HPath-IO-Errors.html#v:isWritable">HPath.IO.Errors</a></td></tr></table></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
4
doc-index-J.html
Normal file
4
doc-index-J.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>hpath-0.7.3: Support for well-typed paths (Index - J)</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.3: Support for well-typed paths</p></div><div id="content"><div id="alphabet"><ul><li><a href="doc-index-A.html">A</a></li><li><a href="doc-index-B.html">B</a></li><li><a href="doc-index-C.html">C</a></li><li><a href="doc-index-D.html">D</a></li><li><a href="doc-index-E.html">E</a></li><li><a href="doc-index-F.html">F</a></li><li><a href="doc-index-G.html">G</a></li><li><a href="doc-index-H.html">H</a></li><li><a href="doc-index-I.html">I</a></li><li><a href="doc-index-J.html">J</a></li><li><a href="doc-index-M.html">M</a></li><li><a href="doc-index-N.html">N</a></li><li><a href="doc-index-O.html">O</a></li><li><a href="doc-index-P.html">P</a></li><li><a href="doc-index-R.html">R</a></li><li><a href="doc-index-S.html">S</a></li><li><a href="doc-index-T.html">T</a></li><li><a href="doc-index-U.html">U</a></li><li><a href="doc-index-W.html">W</a></li><li><a href="doc-index-60.html"><</a></li><li><a href="doc-index-All.html">All</a></li></ul></div><div id="index"><p class="caption">Index - J</p><table><tr><td class="src">joinPath</td><td class="module"><a href="System-Posix-FilePath.html#v:joinPath">System.Posix.FilePath</a></td></tr></table></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
4
doc-index-M.html
Normal file
4
doc-index-M.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>hpath-0.7.3: Support for well-typed paths (Index - M)</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.3: Support for well-typed paths</p></div><div id="content"><div id="alphabet"><ul><li><a href="doc-index-A.html">A</a></li><li><a href="doc-index-B.html">B</a></li><li><a href="doc-index-C.html">C</a></li><li><a href="doc-index-D.html">D</a></li><li><a href="doc-index-E.html">E</a></li><li><a href="doc-index-F.html">F</a></li><li><a href="doc-index-G.html">G</a></li><li><a href="doc-index-H.html">H</a></li><li><a href="doc-index-I.html">I</a></li><li><a href="doc-index-J.html">J</a></li><li><a href="doc-index-M.html">M</a></li><li><a href="doc-index-N.html">N</a></li><li><a href="doc-index-O.html">O</a></li><li><a href="doc-index-P.html">P</a></li><li><a href="doc-index-R.html">R</a></li><li><a href="doc-index-S.html">S</a></li><li><a href="doc-index-T.html">T</a></li><li><a href="doc-index-U.html">U</a></li><li><a href="doc-index-W.html">W</a></li><li><a href="doc-index-60.html"><</a></li><li><a href="doc-index-All.html">All</a></li></ul></div><div id="index"><p class="caption">Index - M</p><table><tr><td class="src">makeRelative</td><td class="module"><a href="System-Posix-FilePath.html#v:makeRelative">System.Posix.FilePath</a></td></tr><tr><td class="src">makeValid</td><td class="module"><a href="System-Posix-FilePath.html#v:makeValid">System.Posix.FilePath</a></td></tr><tr><td class="src">moveFile</td><td class="module"><a href="HPath-IO.html#v:moveFile">HPath.IO</a></td></tr><tr><td class="src">moveFileOverwrite</td><td class="module"><a href="HPath-IO.html#v:moveFileOverwrite">HPath.IO</a></td></tr></table></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
4
doc-index-N.html
Normal file
4
doc-index-N.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>hpath-0.7.3: Support for well-typed paths (Index - N)</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.3: Support for well-typed paths</p></div><div id="content"><div id="alphabet"><ul><li><a href="doc-index-A.html">A</a></li><li><a href="doc-index-B.html">B</a></li><li><a href="doc-index-C.html">C</a></li><li><a href="doc-index-D.html">D</a></li><li><a href="doc-index-E.html">E</a></li><li><a href="doc-index-F.html">F</a></li><li><a href="doc-index-G.html">G</a></li><li><a href="doc-index-H.html">H</a></li><li><a href="doc-index-I.html">I</a></li><li><a href="doc-index-J.html">J</a></li><li><a href="doc-index-M.html">M</a></li><li><a href="doc-index-N.html">N</a></li><li><a href="doc-index-O.html">O</a></li><li><a href="doc-index-P.html">P</a></li><li><a href="doc-index-R.html">R</a></li><li><a href="doc-index-S.html">S</a></li><li><a href="doc-index-T.html">T</a></li><li><a href="doc-index-U.html">U</a></li><li><a href="doc-index-W.html">W</a></li><li><a href="doc-index-60.html"><</a></li><li><a href="doc-index-All.html">All</a></li></ul></div><div id="index"><p class="caption">Index - N</p><table><tr><td class="src">NamedPipe</td><td class="module"><a href="HPath-IO.html#v:NamedPipe">HPath.IO</a></td></tr><tr><td class="src">newDirPerms</td><td class="module"><a href="HPath-IO.html#v:newDirPerms">HPath.IO</a></td></tr><tr><td class="src">newFilePerms</td><td class="module"><a href="HPath-IO.html#v:newFilePerms">HPath.IO</a></td></tr><tr><td class="src">normalise</td><td class="module"><a href="System-Posix-FilePath.html#v:normalise">System.Posix.FilePath</a></td></tr></table></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
4
doc-index-O.html
Normal file
4
doc-index-O.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>hpath-0.7.3: Support for well-typed paths (Index - O)</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.3: Support for well-typed paths</p></div><div id="content"><div id="alphabet"><ul><li><a href="doc-index-A.html">A</a></li><li><a href="doc-index-B.html">B</a></li><li><a href="doc-index-C.html">C</a></li><li><a href="doc-index-D.html">D</a></li><li><a href="doc-index-E.html">E</a></li><li><a href="doc-index-F.html">F</a></li><li><a href="doc-index-G.html">G</a></li><li><a href="doc-index-H.html">H</a></li><li><a href="doc-index-I.html">I</a></li><li><a href="doc-index-J.html">J</a></li><li><a href="doc-index-M.html">M</a></li><li><a href="doc-index-N.html">N</a></li><li><a href="doc-index-O.html">O</a></li><li><a href="doc-index-P.html">P</a></li><li><a href="doc-index-R.html">R</a></li><li><a href="doc-index-S.html">S</a></li><li><a href="doc-index-T.html">T</a></li><li><a href="doc-index-U.html">U</a></li><li><a href="doc-index-W.html">W</a></li><li><a href="doc-index-60.html"><</a></li><li><a href="doc-index-All.html">All</a></li></ul></div><div id="index"><p class="caption">Index - O</p><table><tr><td class="src">oAppend</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:oAppend">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">oAsync</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:oAsync">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">oCloexec</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:oCloexec">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">oCreat</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:oCreat">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">oDirectory</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:oDirectory">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">oExcl</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:oExcl">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">oNoctty</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:oNoctty">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">oNofollow</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:oNofollow">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">oNonblock</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:oNonblock">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">openFd</td><td class="module"><a href="System-Posix-FD.html#v:openFd">System.Posix.FD</a></td></tr><tr><td class="src">openFile</td><td class="module"><a href="HPath-IO.html#v:openFile">HPath.IO</a></td></tr><tr><td class="src">oRdonly</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:oRdonly">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">oRdwr</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:oRdwr">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">oSync</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:oSync">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">oTrunc</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:oTrunc">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">oWronly</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:oWronly">System.Posix.Directory.Foreign</a></td></tr></table></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
4
doc-index-P.html
Normal file
4
doc-index-P.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>hpath-0.7.3: Support for well-typed paths (Index - P)</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.3: Support for well-typed paths</p></div><div id="content"><div id="alphabet"><ul><li><a href="doc-index-A.html">A</a></li><li><a href="doc-index-B.html">B</a></li><li><a href="doc-index-C.html">C</a></li><li><a href="doc-index-D.html">D</a></li><li><a href="doc-index-E.html">E</a></li><li><a href="doc-index-F.html">F</a></li><li><a href="doc-index-G.html">G</a></li><li><a href="doc-index-H.html">H</a></li><li><a href="doc-index-I.html">I</a></li><li><a href="doc-index-J.html">J</a></li><li><a href="doc-index-M.html">M</a></li><li><a href="doc-index-N.html">N</a></li><li><a href="doc-index-O.html">O</a></li><li><a href="doc-index-P.html">P</a></li><li><a href="doc-index-R.html">R</a></li><li><a href="doc-index-S.html">S</a></li><li><a href="doc-index-T.html">T</a></li><li><a href="doc-index-U.html">U</a></li><li><a href="doc-index-W.html">W</a></li><li><a href="doc-index-60.html"><</a></li><li><a href="doc-index-All.html">All</a></li></ul></div><div id="index"><p class="caption">Index - P</p><table><tr><td class="src">packDirStream</td><td class="module"><a href="System-Posix-Directory-Traversals.html#v:packDirStream">System.Posix.Directory.Traversals</a></td></tr><tr><td class="src">parseAbs</td><td class="module"><a href="HPath.html#v:parseAbs">HPath</a></td></tr><tr><td class="src">parseFn</td><td class="module"><a href="HPath.html#v:parseFn">HPath</a></td></tr><tr><td class="src">parseRel</td><td class="module"><a href="HPath.html#v:parseRel">HPath</a></td></tr><tr><td class="src">Path</td><td> </td></tr><tr><td class="alt">1 (Type/Class)</td><td class="module"><a href="HPath.html#t:Path">HPath</a></td></tr><tr><td class="alt">2 (Data Constructor)</td><td class="module"><a href="HPath.html#v:Path">HPath</a></td></tr><tr><td class="src">PathException</td><td class="module"><a href="HPath.html#t:PathException">HPath</a></td></tr><tr><td class="src">pathMax</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:pathMax">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">PathParseException</td><td class="module"><a href="HPath.html#t:PathParseException">HPath</a></td></tr><tr><td class="src">pathSeparator</td><td class="module"><a href="System-Posix-FilePath.html#v:pathSeparator">System.Posix.FilePath</a></td></tr><tr><td class="src">peekFilePath</td><td class="module">System.Posix.FilePath</td></tr><tr><td class="src">peekFilePathLen</td><td class="module">System.Posix.FilePath</td></tr></table></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
4
doc-index-R.html
Normal file
4
doc-index-R.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>hpath-0.7.3: Support for well-typed paths (Index - R)</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.3: Support for well-typed paths</p></div><div id="content"><div id="alphabet"><ul><li><a href="doc-index-A.html">A</a></li><li><a href="doc-index-B.html">B</a></li><li><a href="doc-index-C.html">C</a></li><li><a href="doc-index-D.html">D</a></li><li><a href="doc-index-E.html">E</a></li><li><a href="doc-index-F.html">F</a></li><li><a href="doc-index-G.html">G</a></li><li><a href="doc-index-H.html">H</a></li><li><a href="doc-index-I.html">I</a></li><li><a href="doc-index-J.html">J</a></li><li><a href="doc-index-M.html">M</a></li><li><a href="doc-index-N.html">N</a></li><li><a href="doc-index-O.html">O</a></li><li><a href="doc-index-P.html">P</a></li><li><a href="doc-index-R.html">R</a></li><li><a href="doc-index-S.html">S</a></li><li><a href="doc-index-T.html">T</a></li><li><a href="doc-index-U.html">U</a></li><li><a href="doc-index-W.html">W</a></li><li><a href="doc-index-60.html"><</a></li><li><a href="doc-index-All.html">All</a></li></ul></div><div id="index"><p class="caption">Index - R</p><table><tr><td class="src">RawFilePath</td><td class="module">System.Posix.FilePath</td></tr><tr><td class="src">reactOnError</td><td class="module"><a href="HPath-IO-Errors.html#v:reactOnError">HPath.IO.Errors</a></td></tr><tr><td class="src">readDirEnt</td><td class="module"><a href="System-Posix-Directory-Traversals.html#v:readDirEnt">System.Posix.Directory.Traversals</a></td></tr><tr><td class="src">realpath</td><td class="module"><a href="System-Posix-Directory-Traversals.html#v:realpath">System.Posix.Directory.Traversals</a></td></tr><tr><td class="src">recreateSymlink</td><td class="module"><a href="HPath-IO.html#v:recreateSymlink">HPath.IO</a></td></tr><tr><td class="src">RegularFile</td><td class="module"><a href="HPath-IO.html#v:RegularFile">HPath.IO</a></td></tr><tr><td class="src">Rel</td><td class="module"><a href="HPath.html#t:Rel">HPath</a></td></tr><tr><td class="src">RelC</td><td class="module"><a href="HPath.html#t:RelC">HPath</a></td></tr><tr><td class="src">renameFile</td><td class="module"><a href="HPath-IO.html#v:renameFile">HPath.IO</a></td></tr><tr><td class="src">replaceBaseName</td><td class="module"><a href="System-Posix-FilePath.html#v:replaceBaseName">System.Posix.FilePath</a></td></tr><tr><td class="src">replaceDirectory</td><td class="module"><a href="System-Posix-FilePath.html#v:replaceDirectory">System.Posix.FilePath</a></td></tr><tr><td class="src">replaceExtension</td><td class="module"><a href="System-Posix-FilePath.html#v:replaceExtension">System.Posix.FilePath</a></td></tr><tr><td class="src">replaceFileName</td><td class="module"><a href="System-Posix-FilePath.html#v:replaceFileName">System.Posix.FilePath</a></td></tr><tr><td class="src">rethrowErrnoAs</td><td class="module"><a href="HPath-IO-Errors.html#v:rethrowErrnoAs">HPath.IO.Errors</a></td></tr></table></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
4
doc-index-S.html
Normal file
4
doc-index-S.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>hpath-0.7.3: Support for well-typed paths (Index - S)</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.3: Support for well-typed paths</p></div><div id="content"><div id="alphabet"><ul><li><a href="doc-index-A.html">A</a></li><li><a href="doc-index-B.html">B</a></li><li><a href="doc-index-C.html">C</a></li><li><a href="doc-index-D.html">D</a></li><li><a href="doc-index-E.html">E</a></li><li><a href="doc-index-F.html">F</a></li><li><a href="doc-index-G.html">G</a></li><li><a href="doc-index-H.html">H</a></li><li><a href="doc-index-I.html">I</a></li><li><a href="doc-index-J.html">J</a></li><li><a href="doc-index-M.html">M</a></li><li><a href="doc-index-N.html">N</a></li><li><a href="doc-index-O.html">O</a></li><li><a href="doc-index-P.html">P</a></li><li><a href="doc-index-R.html">R</a></li><li><a href="doc-index-S.html">S</a></li><li><a href="doc-index-T.html">T</a></li><li><a href="doc-index-U.html">U</a></li><li><a href="doc-index-W.html">W</a></li><li><a href="doc-index-60.html"><</a></li><li><a href="doc-index-All.html">All</a></li></ul></div><div id="index"><p class="caption">Index - S</p><table><tr><td class="src">SameFile</td><td class="module"><a href="HPath-IO-Errors.html#v:SameFile">HPath.IO.Errors</a></td></tr><tr><td class="src">sameFile</td><td class="module"><a href="HPath-IO-Errors.html#v:sameFile">HPath.IO.Errors</a></td></tr><tr><td class="src">searchPathSeparator</td><td class="module"><a href="System-Posix-FilePath.html#v:searchPathSeparator">System.Posix.FilePath</a></td></tr><tr><td class="src">Socket</td><td class="module"><a href="HPath-IO.html#v:Socket">HPath.IO</a></td></tr><tr><td class="src">splitDirectories</td><td class="module"><a href="System-Posix-FilePath.html#v:splitDirectories">System.Posix.FilePath</a></td></tr><tr><td class="src">splitExtension</td><td class="module"><a href="System-Posix-FilePath.html#v:splitExtension">System.Posix.FilePath</a></td></tr><tr><td class="src">splitExtensions</td><td class="module"><a href="System-Posix-FilePath.html#v:splitExtensions">System.Posix.FilePath</a></td></tr><tr><td class="src">splitFileName</td><td class="module"><a href="System-Posix-FilePath.html#v:splitFileName">System.Posix.FilePath</a></td></tr><tr><td class="src">splitPath</td><td class="module"><a href="System-Posix-FilePath.html#v:splitPath">System.Posix.FilePath</a></td></tr><tr><td class="src">splitSearchPath</td><td class="module"><a href="System-Posix-FilePath.html#v:splitSearchPath">System.Posix.FilePath</a></td></tr><tr><td class="src">stripDir</td><td class="module"><a href="HPath.html#v:stripDir">HPath</a></td></tr><tr><td class="src">stripExtension</td><td class="module"><a href="System-Posix-FilePath.html#v:stripExtension">System.Posix.FilePath</a></td></tr><tr><td class="src">SymbolicLink</td><td class="module"><a href="HPath-IO.html#v:SymbolicLink">HPath.IO</a></td></tr></table></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
4
doc-index-T.html
Normal file
4
doc-index-T.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>hpath-0.7.3: Support for well-typed paths (Index - T)</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.3: Support for well-typed paths</p></div><div id="content"><div id="alphabet"><ul><li><a href="doc-index-A.html">A</a></li><li><a href="doc-index-B.html">B</a></li><li><a href="doc-index-C.html">C</a></li><li><a href="doc-index-D.html">D</a></li><li><a href="doc-index-E.html">E</a></li><li><a href="doc-index-F.html">F</a></li><li><a href="doc-index-G.html">G</a></li><li><a href="doc-index-H.html">H</a></li><li><a href="doc-index-I.html">I</a></li><li><a href="doc-index-J.html">J</a></li><li><a href="doc-index-M.html">M</a></li><li><a href="doc-index-N.html">N</a></li><li><a href="doc-index-O.html">O</a></li><li><a href="doc-index-P.html">P</a></li><li><a href="doc-index-R.html">R</a></li><li><a href="doc-index-S.html">S</a></li><li><a href="doc-index-T.html">T</a></li><li><a href="doc-index-U.html">U</a></li><li><a href="doc-index-W.html">W</a></li><li><a href="doc-index-60.html"><</a></li><li><a href="doc-index-All.html">All</a></li></ul></div><div id="index"><p class="caption">Index - T</p><table><tr><td class="src">takeBaseName</td><td class="module"><a href="System-Posix-FilePath.html#v:takeBaseName">System.Posix.FilePath</a></td></tr><tr><td class="src">takeDirectory</td><td class="module"><a href="System-Posix-FilePath.html#v:takeDirectory">System.Posix.FilePath</a></td></tr><tr><td class="src">takeExtension</td><td class="module"><a href="System-Posix-FilePath.html#v:takeExtension">System.Posix.FilePath</a></td></tr><tr><td class="src">takeExtensions</td><td class="module"><a href="System-Posix-FilePath.html#v:takeExtensions">System.Posix.FilePath</a></td></tr><tr><td class="src">takeFileName</td><td class="module"><a href="System-Posix-FilePath.html#v:takeFileName">System.Posix.FilePath</a></td></tr><tr><td class="src">throwCantOpenDirectory</td><td class="module"><a href="HPath-IO-Errors.html#v:throwCantOpenDirectory">HPath.IO.Errors</a></td></tr><tr><td class="src">throwDestinationInSource</td><td class="module"><a href="HPath-IO-Errors.html#v:throwDestinationInSource">HPath.IO.Errors</a></td></tr><tr><td class="src">throwDirDoesExist</td><td class="module"><a href="HPath-IO-Errors.html#v:throwDirDoesExist">HPath.IO.Errors</a></td></tr><tr><td class="src">throwDirDoesNotExist</td><td class="module"><a href="HPath-IO-Errors.html#v:throwDirDoesNotExist">HPath.IO.Errors</a></td></tr><tr><td class="src">throwErrnoPath</td><td class="module">System.Posix.FilePath</td></tr><tr><td class="src">throwErrnoPathIf</td><td class="module">System.Posix.FilePath</td></tr><tr><td class="src">throwErrnoPathIfMinus1</td><td class="module">System.Posix.FilePath</td></tr><tr><td class="src">throwErrnoPathIfMinus1Retry</td><td class="module">System.Posix.FilePath</td></tr><tr><td class="src">throwErrnoPathIfMinus1Retry_</td><td class="module">System.Posix.FilePath</td></tr><tr><td class="src">throwErrnoPathIfMinus1_</td><td class="module">System.Posix.FilePath</td></tr><tr><td class="src">throwErrnoPathIfNull</td><td class="module">System.Posix.FilePath</td></tr><tr><td class="src">throwErrnoPathIfNullRetry</td><td class="module">System.Posix.FilePath</td></tr><tr><td class="src">throwErrnoPathIfRetry</td><td class="module">System.Posix.FilePath</td></tr><tr><td class="src">throwErrnoPathIf_</td><td class="module">System.Posix.FilePath</td></tr><tr><td class="src">throwFileDoesExist</td><td class="module"><a href="HPath-IO-Errors.html#v:throwFileDoesExist">HPath.IO.Errors</a></td></tr><tr><td class="src">throwFileDoesNotExist</td><td class="module"><a href="HPath-IO-Errors.html#v:throwFileDoesNotExist">HPath.IO.Errors</a></td></tr><tr><td class="src">throwSameFile</td><td class="module"><a href="HPath-IO-Errors.html#v:throwSameFile">HPath.IO.Errors</a></td></tr><tr><td class="src">toFilePath</td><td class="module"><a href="HPath.html#v:toFilePath">HPath</a></td></tr><tr><td class="src">traverseDirectory</td><td class="module"><a href="System-Posix-Directory-Traversals.html#v:traverseDirectory">System.Posix.Directory.Traversals</a></td></tr></table></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
4
doc-index-U.html
Normal file
4
doc-index-U.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>hpath-0.7.3: Support for well-typed paths (Index - U)</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.3: Support for well-typed paths</p></div><div id="content"><div id="alphabet"><ul><li><a href="doc-index-A.html">A</a></li><li><a href="doc-index-B.html">B</a></li><li><a href="doc-index-C.html">C</a></li><li><a href="doc-index-D.html">D</a></li><li><a href="doc-index-E.html">E</a></li><li><a href="doc-index-F.html">F</a></li><li><a href="doc-index-G.html">G</a></li><li><a href="doc-index-H.html">H</a></li><li><a href="doc-index-I.html">I</a></li><li><a href="doc-index-J.html">J</a></li><li><a href="doc-index-M.html">M</a></li><li><a href="doc-index-N.html">N</a></li><li><a href="doc-index-O.html">O</a></li><li><a href="doc-index-P.html">P</a></li><li><a href="doc-index-R.html">R</a></li><li><a href="doc-index-S.html">S</a></li><li><a href="doc-index-T.html">T</a></li><li><a href="doc-index-U.html">U</a></li><li><a href="doc-index-W.html">W</a></li><li><a href="doc-index-60.html"><</a></li><li><a href="doc-index-All.html">All</a></li></ul></div><div id="index"><p class="caption">Index - U</p><table><tr><td class="src">unFlags</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:unFlags">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">unionFlags</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:unionFlags">System.Posix.Directory.Foreign</a></td></tr><tr><td class="src">unlessM</td><td class="module"><a href="HPath-IO-Utils.html#v:unlessM">HPath.IO.Utils</a></td></tr><tr><td class="src">unpackDirStream</td><td class="module"><a href="System-Posix-Directory-Traversals.html#v:unpackDirStream">System.Posix.Directory.Traversals</a></td></tr><tr><td class="src">UnsupportedFlag</td><td class="module"><a href="System-Posix-Directory-Foreign.html#v:UnsupportedFlag">System.Posix.Directory.Foreign</a></td></tr></table></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
4
doc-index-W.html
Normal file
4
doc-index-W.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>hpath-0.7.3: Support for well-typed paths (Index - W)</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.3: Support for well-typed paths</p></div><div id="content"><div id="alphabet"><ul><li><a href="doc-index-A.html">A</a></li><li><a href="doc-index-B.html">B</a></li><li><a href="doc-index-C.html">C</a></li><li><a href="doc-index-D.html">D</a></li><li><a href="doc-index-E.html">E</a></li><li><a href="doc-index-F.html">F</a></li><li><a href="doc-index-G.html">G</a></li><li><a href="doc-index-H.html">H</a></li><li><a href="doc-index-I.html">I</a></li><li><a href="doc-index-J.html">J</a></li><li><a href="doc-index-M.html">M</a></li><li><a href="doc-index-N.html">N</a></li><li><a href="doc-index-O.html">O</a></li><li><a href="doc-index-P.html">P</a></li><li><a href="doc-index-R.html">R</a></li><li><a href="doc-index-S.html">S</a></li><li><a href="doc-index-T.html">T</a></li><li><a href="doc-index-U.html">U</a></li><li><a href="doc-index-W.html">W</a></li><li><a href="doc-index-60.html"><</a></li><li><a href="doc-index-All.html">All</a></li></ul></div><div id="index"><p class="caption">Index - W</p><table><tr><td class="src">whenM</td><td class="module"><a href="HPath-IO-Utils.html#v:whenM">HPath.IO.Utils</a></td></tr><tr><td class="src">withAbsPath</td><td class="module"><a href="HPath.html#v:withAbsPath">HPath</a></td></tr><tr><td class="src">withFilePath</td><td class="module">System.Posix.FilePath</td></tr><tr><td class="src">withFnPath</td><td class="module"><a href="HPath.html#v:withFnPath">HPath</a></td></tr><tr><td class="src">withRelPath</td><td class="module"><a href="HPath.html#v:withRelPath">HPath</a></td></tr></table></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
4
doc-index.html
Normal file
4
doc-index.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>hpath-0.7.3: Support for well-typed paths (Index)</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.3: Support for well-typed paths</p></div><div id="content"><div id="alphabet"><ul><li><a href="doc-index-A.html">A</a></li><li><a href="doc-index-B.html">B</a></li><li><a href="doc-index-C.html">C</a></li><li><a href="doc-index-D.html">D</a></li><li><a href="doc-index-E.html">E</a></li><li><a href="doc-index-F.html">F</a></li><li><a href="doc-index-G.html">G</a></li><li><a href="doc-index-H.html">H</a></li><li><a href="doc-index-I.html">I</a></li><li><a href="doc-index-J.html">J</a></li><li><a href="doc-index-M.html">M</a></li><li><a href="doc-index-N.html">N</a></li><li><a href="doc-index-O.html">O</a></li><li><a href="doc-index-P.html">P</a></li><li><a href="doc-index-R.html">R</a></li><li><a href="doc-index-S.html">S</a></li><li><a href="doc-index-T.html">T</a></li><li><a href="doc-index-U.html">U</a></li><li><a href="doc-index-W.html">W</a></li><li><a href="doc-index-60.html"><</a></li><li><a href="doc-index-All.html">All</a></li></ul></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
30
frames.html
Normal file
30
frames.html
Normal file
@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title></title>
|
||||
<script src="haddock-util.js" type="text/javascript"></script>
|
||||
<script type="text/javascript"><!--
|
||||
/*
|
||||
|
||||
The synopsis frame needs to be updated using javascript, so we hide
|
||||
it by default and only show it if javascript is enabled.
|
||||
|
||||
TODO: provide some means to disable it.
|
||||
*/
|
||||
function load() {
|
||||
var d = document.getElementById("inner-fs");
|
||||
d.rows = "50%,50%";
|
||||
postReframe();
|
||||
}
|
||||
--></script>
|
||||
</head>
|
||||
<frameset id="outer-fs" cols="25%,75%" onload="load()">
|
||||
<frameset id="inner-fs" rows="100%,0%">
|
||||
<frame src="index-frames.html" name="modules" />
|
||||
<frame src="" name="synopsis" />
|
||||
</frameset>
|
||||
<frame src="index.html" name="main" />
|
||||
</frameset>
|
||||
</html>
|
344
haddock-util.js
Normal file
344
haddock-util.js
Normal file
@ -0,0 +1,344 @@
|
||||
// Haddock JavaScript utilities
|
||||
|
||||
var rspace = /\s\s+/g,
|
||||
rtrim = /^\s+|\s+$/g;
|
||||
|
||||
function spaced(s) { return (" " + s + " ").replace(rspace, " "); }
|
||||
function trim(s) { return s.replace(rtrim, ""); }
|
||||
|
||||
function hasClass(elem, value) {
|
||||
var className = spaced(elem.className || "");
|
||||
return className.indexOf( " " + value + " " ) >= 0;
|
||||
}
|
||||
|
||||
function addClass(elem, value) {
|
||||
var className = spaced(elem.className || "");
|
||||
if ( className.indexOf( " " + value + " " ) < 0 ) {
|
||||
elem.className = trim(className + " " + value);
|
||||
}
|
||||
}
|
||||
|
||||
function removeClass(elem, value) {
|
||||
var className = spaced(elem.className || "");
|
||||
className = className.replace(" " + value + " ", " ");
|
||||
elem.className = trim(className);
|
||||
}
|
||||
|
||||
function toggleClass(elem, valueOn, valueOff, bool) {
|
||||
if (bool == null) { bool = ! hasClass(elem, valueOn); }
|
||||
if (bool) {
|
||||
removeClass(elem, valueOff);
|
||||
addClass(elem, valueOn);
|
||||
}
|
||||
else {
|
||||
removeClass(elem, valueOn);
|
||||
addClass(elem, valueOff);
|
||||
}
|
||||
return bool;
|
||||
}
|
||||
|
||||
|
||||
function makeClassToggle(valueOn, valueOff)
|
||||
{
|
||||
return function(elem, bool) {
|
||||
return toggleClass(elem, valueOn, valueOff, bool);
|
||||
}
|
||||
}
|
||||
|
||||
toggleShow = makeClassToggle("show", "hide");
|
||||
toggleCollapser = makeClassToggle("collapser", "expander");
|
||||
|
||||
function toggleSection(id)
|
||||
{
|
||||
var b = toggleShow(document.getElementById("section." + id));
|
||||
toggleCollapser(document.getElementById("control." + id), b);
|
||||
rememberCollapsed(id, b);
|
||||
return b;
|
||||
}
|
||||
|
||||
var collapsed = {};
|
||||
function rememberCollapsed(id, b)
|
||||
{
|
||||
if(b)
|
||||
delete collapsed[id]
|
||||
else
|
||||
collapsed[id] = null;
|
||||
|
||||
var sections = [];
|
||||
for(var i in collapsed)
|
||||
{
|
||||
if(collapsed.hasOwnProperty(i))
|
||||
sections.push(i);
|
||||
}
|
||||
// cookie specific to this page; don't use setCookie which sets path=/
|
||||
document.cookie = "collapsed=" + escape(sections.join('+'));
|
||||
}
|
||||
|
||||
function restoreCollapsed()
|
||||
{
|
||||
var cookie = getCookie("collapsed");
|
||||
if(!cookie)
|
||||
return;
|
||||
|
||||
var ids = cookie.split('+');
|
||||
for(var i in ids)
|
||||
{
|
||||
if(document.getElementById("section." + ids[i]))
|
||||
toggleSection(ids[i]);
|
||||
}
|
||||
}
|
||||
|
||||
function setCookie(name, value) {
|
||||
document.cookie = name + "=" + escape(value) + ";path=/;";
|
||||
}
|
||||
|
||||
function clearCookie(name) {
|
||||
document.cookie = name + "=;path=/;expires=Thu, 01-Jan-1970 00:00:01 GMT;";
|
||||
}
|
||||
|
||||
function getCookie(name) {
|
||||
var nameEQ = name + "=";
|
||||
var ca = document.cookie.split(';');
|
||||
for(var i=0;i < ca.length;i++) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0)==' ') c = c.substring(1,c.length);
|
||||
if (c.indexOf(nameEQ) == 0) {
|
||||
return unescape(c.substring(nameEQ.length,c.length));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
var max_results = 75; // 50 is not enough to search for map in the base libraries
|
||||
var shown_range = null;
|
||||
var last_search = null;
|
||||
|
||||
function quick_search()
|
||||
{
|
||||
perform_search(false);
|
||||
}
|
||||
|
||||
function full_search()
|
||||
{
|
||||
perform_search(true);
|
||||
}
|
||||
|
||||
|
||||
function perform_search(full)
|
||||
{
|
||||
var text = document.getElementById("searchbox").value.toLowerCase();
|
||||
if (text == last_search && !full) return;
|
||||
last_search = text;
|
||||
|
||||
var table = document.getElementById("indexlist");
|
||||
var status = document.getElementById("searchmsg");
|
||||
var children = table.firstChild.childNodes;
|
||||
|
||||
// first figure out the first node with the prefix
|
||||
var first = bisect(-1);
|
||||
var last = (first == -1 ? -1 : bisect(1));
|
||||
|
||||
if (first == -1)
|
||||
{
|
||||
table.className = "";
|
||||
status.innerHTML = "No results found, displaying all";
|
||||
}
|
||||
else if (first == 0 && last == children.length - 1)
|
||||
{
|
||||
table.className = "";
|
||||
status.innerHTML = "";
|
||||
}
|
||||
else if (last - first >= max_results && !full)
|
||||
{
|
||||
table.className = "";
|
||||
status.innerHTML = "More than " + max_results + ", press Search to display";
|
||||
}
|
||||
else
|
||||
{
|
||||
// decide what you need to clear/show
|
||||
if (shown_range)
|
||||
setclass(shown_range[0], shown_range[1], "indexrow");
|
||||
setclass(first, last, "indexshow");
|
||||
shown_range = [first, last];
|
||||
table.className = "indexsearch";
|
||||
status.innerHTML = "";
|
||||
}
|
||||
|
||||
|
||||
function setclass(first, last, status)
|
||||
{
|
||||
for (var i = first; i <= last; i++)
|
||||
{
|
||||
children[i].className = status;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// do a binary search, treating 0 as ...
|
||||
// return either -1 (no 0's found) or location of most far match
|
||||
function bisect(dir)
|
||||
{
|
||||
var first = 0, finish = children.length - 1;
|
||||
var mid, success = false;
|
||||
|
||||
while (finish - first > 3)
|
||||
{
|
||||
mid = Math.floor((finish + first) / 2);
|
||||
|
||||
var i = checkitem(mid);
|
||||
if (i == 0) i = dir;
|
||||
if (i == -1)
|
||||
finish = mid;
|
||||
else
|
||||
first = mid;
|
||||
}
|
||||
var a = (dir == 1 ? first : finish);
|
||||
var b = (dir == 1 ? finish : first);
|
||||
for (var i = b; i != a - dir; i -= dir)
|
||||
{
|
||||
if (checkitem(i) == 0) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// from an index, decide what the result is
|
||||
// 0 = match, -1 is lower, 1 is higher
|
||||
function checkitem(i)
|
||||
{
|
||||
var s = getitem(i).toLowerCase().substr(0, text.length);
|
||||
if (s == text) return 0;
|
||||
else return (s > text ? -1 : 1);
|
||||
}
|
||||
|
||||
|
||||
// from an index, get its string
|
||||
// this abstracts over alternates
|
||||
function getitem(i)
|
||||
{
|
||||
for ( ; i >= 0; i--)
|
||||
{
|
||||
var s = children[i].firstChild.firstChild.data;
|
||||
if (s.indexOf(' ') == -1)
|
||||
return s;
|
||||
}
|
||||
return ""; // should never be reached
|
||||
}
|
||||
}
|
||||
|
||||
function setSynopsis(filename) {
|
||||
if (parent.window.synopsis && parent.window.synopsis.location) {
|
||||
if (parent.window.synopsis.location.replace) {
|
||||
// In Firefox this avoids adding the change to the history.
|
||||
parent.window.synopsis.location.replace(filename);
|
||||
} else {
|
||||
parent.window.synopsis.location = filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addMenuItem(html) {
|
||||
var menu = document.getElementById("page-menu");
|
||||
if (menu) {
|
||||
var btn = menu.firstChild.cloneNode(false);
|
||||
btn.innerHTML = html;
|
||||
menu.appendChild(btn);
|
||||
}
|
||||
}
|
||||
|
||||
function adjustForFrames() {
|
||||
var bodyCls;
|
||||
|
||||
if (parent.location.href == window.location.href) {
|
||||
// not in frames, so add Frames button
|
||||
addMenuItem("<a href='#' onclick='reframe();return true;'>Frames</a>");
|
||||
bodyCls = "no-frame";
|
||||
}
|
||||
else {
|
||||
bodyCls = "in-frame";
|
||||
}
|
||||
addClass(document.body, bodyCls);
|
||||
}
|
||||
|
||||
function reframe() {
|
||||
setCookie("haddock-reframe", document.URL);
|
||||
window.location = "frames.html";
|
||||
}
|
||||
|
||||
function postReframe() {
|
||||
var s = getCookie("haddock-reframe");
|
||||
if (s) {
|
||||
parent.window.main.location = s;
|
||||
clearCookie("haddock-reframe");
|
||||
}
|
||||
}
|
||||
|
||||
function styles() {
|
||||
var i, a, es = document.getElementsByTagName("link"), rs = [];
|
||||
for (i = 0; a = es[i]; i++) {
|
||||
if(a.rel.indexOf("style") != -1 && a.title) {
|
||||
rs.push(a);
|
||||
}
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
function addStyleMenu() {
|
||||
var as = styles();
|
||||
var i, a, btns = "";
|
||||
for(i=0; a = as[i]; i++) {
|
||||
btns += "<li><a href='#' onclick=\"setActiveStyleSheet('"
|
||||
+ a.title + "'); return false;\">"
|
||||
+ a.title + "</a></li>"
|
||||
}
|
||||
if (as.length > 1) {
|
||||
var h = "<div id='style-menu-holder'>"
|
||||
+ "<a href='#' onclick='styleMenu(); return false;'>Style ▾</a>"
|
||||
+ "<ul id='style-menu' class='hide'>" + btns + "</ul>"
|
||||
+ "</div>";
|
||||
addMenuItem(h);
|
||||
}
|
||||
}
|
||||
|
||||
function setActiveStyleSheet(title) {
|
||||
var as = styles();
|
||||
var i, a, found;
|
||||
for(i=0; a = as[i]; i++) {
|
||||
a.disabled = true;
|
||||
// need to do this always, some browsers are edge triggered
|
||||
if(a.title == title) {
|
||||
found = a;
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
found.disabled = false;
|
||||
setCookie("haddock-style", title);
|
||||
}
|
||||
else {
|
||||
as[0].disabled = false;
|
||||
clearCookie("haddock-style");
|
||||
}
|
||||
styleMenu(false);
|
||||
}
|
||||
|
||||
function resetStyle() {
|
||||
var s = getCookie("haddock-style");
|
||||
if (s) setActiveStyleSheet(s);
|
||||
}
|
||||
|
||||
|
||||
function styleMenu(show) {
|
||||
var m = document.getElementById('style-menu');
|
||||
if (m) toggleShow(m, show);
|
||||
}
|
||||
|
||||
|
||||
function pageLoad() {
|
||||
addStyleMenu();
|
||||
adjustForFrames();
|
||||
resetStyle();
|
||||
restoreCollapsed();
|
||||
}
|
||||
|
BIN
hpath.haddock
Normal file
BIN
hpath.haddock
Normal file
Binary file not shown.
BIN
hslogo-16.png
Normal file
BIN
hslogo-16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
4
index-frames.html
Normal file
4
index-frames.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>hpath-0.7.3: Support for well-typed paths</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body id="mini"><div id="module-list"><p class="caption">Modules</p><ul><li class="module"><a href="HPath.html" target="main">HPath</a></li><li class="module"><a href="HPath-IO.html" target="main">HPath.IO</a></li><li class="module"><a href="HPath-IO-Errors.html" target="main">HPath.IO.Errors</a></li><li class="module"><a href="HPath-IO-Utils.html" target="main">HPath.IO.Utils</a></li><li class="module"><a href="System-Posix-Directory-Foreign.html" target="main">System.Posix.Directory.Foreign</a></li><li class="module"><a href="System-Posix-Directory-Traversals.html" target="main">System.Posix.Directory.Traversals</a></li><li class="module"><a href="System-Posix-FD.html" target="main">System.Posix.FD</a></li><li class="module"><a href="System-Posix-FilePath.html" target="main">System.Posix.FilePath</a></li></ul></div></body></html>
|
4
index.html
Normal file
4
index.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>hpath-0.7.3: Support for well-typed paths</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.3: Support for well-typed paths</p></div><div id="content"><div id="description"><h1>hpath-0.7.3: Support for well-typed paths</h1><div class="doc"><p>Support for well-typed paths, utilizing ByteString under the hood.</p></div></div><div id="module-list"><p class="caption">Modules</p><ul><li><span class="module"><span id="control.n.1" class="collapser" onclick="toggleSection('n.1')"> </span><a href="HPath.html">HPath</a></span><ul id="section.n.1" class="show"><li><span class="module"><span id="control.n.1.1" class="collapser" onclick="toggleSection('n.1.1')"> </span><a href="HPath-IO.html">HPath.IO</a></span><ul id="section.n.1.1" class="show"><li><span class="module"><a href="HPath-IO-Errors.html">HPath.IO.Errors</a></span></li><li><span class="module"><a href="HPath-IO-Utils.html">HPath.IO.Utils</a></span></li></ul></li></ul></li><li><span id="control.n.2" class="module collapser" onclick="toggleSection('n.2')">System</span><ul id="section.n.2" class="show"><li><span id="control.n.2.1" class="module collapser" onclick="toggleSection('n.2.1')">Posix</span><ul id="section.n.2.1" class="show"><li><span id="control.n.2.1.1" class="module collapser" onclick="toggleSection('n.2.1.1')">Directory</span><ul id="section.n.2.1.1" class="show"><li><span class="module"><a href="System-Posix-Directory-Foreign.html">System.Posix.Directory.Foreign</a></span></li><li><span class="module"><a href="System-Posix-Directory-Traversals.html">System.Posix.Directory.Traversals</a></span></li></ul></li><li><span class="module"><a href="System-Posix-FD.html">System.Posix.FD</a></span></li><li><span class="module"><a href="System-Posix-FilePath.html">System.Posix.FilePath</a></span></li></ul></li></ul></li></ul></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|
4
mini_HPath-IO-Errors.html
Normal file
4
mini_HPath-IO-Errors.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>HPath.IO.Errors</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body id="mini"><div id="module-header"><p class="caption">HPath.IO.Errors</p></div><div id="interface"><h1>Types</h1><div class="top"><p class="src"><span class="keyword">data</span> <a href="HPath-IO-Errors.html#t:HPathIOException" target="main">HPathIOException</a></p></div><h1>Exception identifiers</h1><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:isFileDoesNotExist" target="main">isFileDoesNotExist</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:isDirDoesNotExist" target="main">isDirDoesNotExist</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:isSameFile" target="main">isSameFile</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:isDestinationInSource" target="main">isDestinationInSource</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:isFileDoesExist" target="main">isFileDoesExist</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:isDirDoesExist" target="main">isDirDoesExist</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:isInvalidOperation" target="main">isInvalidOperation</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:isCan-39-tOpenDirectory" target="main">isCan'tOpenDirectory</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:isCopyFailed" target="main">isCopyFailed</a></p></div><h1>Path based functions</h1><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:throwFileDoesExist" target="main">throwFileDoesExist</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:throwDirDoesExist" target="main">throwDirDoesExist</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:throwFileDoesNotExist" target="main">throwFileDoesNotExist</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:throwDirDoesNotExist" target="main">throwDirDoesNotExist</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:throwSameFile" target="main">throwSameFile</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:sameFile" target="main">sameFile</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:throwDestinationInSource" target="main">throwDestinationInSource</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:doesFileExist" target="main">doesFileExist</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:doesDirectoryExist" target="main">doesDirectoryExist</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:isWritable" target="main">isWritable</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:canOpenDirectory" target="main">canOpenDirectory</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:throwCantOpenDirectory" target="main">throwCantOpenDirectory</a></p></div><h1>Error handling functions</h1><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:catchErrno" target="main">catchErrno</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:rethrowErrnoAs" target="main">rethrowErrnoAs</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:handleIOError" target="main">handleIOError</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:bracketeer" target="main">bracketeer</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Errors.html#v:reactOnError" target="main">reactOnError</a></p></div></div></body></html>
|
4
mini_HPath-IO-Utils.html
Normal file
4
mini_HPath-IO-Utils.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>HPath.IO.Utils</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body id="mini"><div id="module-header"><p class="caption">HPath.IO.Utils</p></div><div id="interface"><div class="top"><p class="src"><a href="HPath-IO-Utils.html#v:whenM" target="main">whenM</a></p></div><div class="top"><p class="src"><a href="HPath-IO-Utils.html#v:unlessM" target="main">unlessM</a></p></div></div></body></html>
|
4
mini_HPath-IO.html
Normal file
4
mini_HPath-IO.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>HPath.IO</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body id="mini"><div id="module-header"><p class="caption">HPath.IO</p></div><div id="interface"><h1>Types</h1><div class="top"><p class="src"><span class="keyword">data</span> <a href="HPath-IO.html#t:FileType" target="main">FileType</a></p></div><h1>File copying</h1><div class="top"><p class="src"><a href="HPath-IO.html#v:copyDirRecursive" target="main">copyDirRecursive</a></p></div><div class="top"><p class="src"><a href="HPath-IO.html#v:copyDirRecursiveOverwrite" target="main">copyDirRecursiveOverwrite</a></p></div><div class="top"><p class="src"><a href="HPath-IO.html#v:recreateSymlink" target="main">recreateSymlink</a></p></div><div class="top"><p class="src"><a href="HPath-IO.html#v:copyFile" target="main">copyFile</a></p></div><div class="top"><p class="src"><a href="HPath-IO.html#v:copyFileOverwrite" target="main">copyFileOverwrite</a></p></div><div class="top"><p class="src"><a href="HPath-IO.html#v:easyCopy" target="main">easyCopy</a></p></div><div class="top"><p class="src"><a href="HPath-IO.html#v:easyCopyOverwrite" target="main">easyCopyOverwrite</a></p></div><h1>File deletion</h1><div class="top"><p class="src"><a href="HPath-IO.html#v:deleteFile" target="main">deleteFile</a></p></div><div class="top"><p class="src"><a href="HPath-IO.html#v:deleteDir" target="main">deleteDir</a></p></div><div class="top"><p class="src"><a href="HPath-IO.html#v:deleteDirRecursive" target="main">deleteDirRecursive</a></p></div><div class="top"><p class="src"><a href="HPath-IO.html#v:easyDelete" target="main">easyDelete</a></p></div><h1>File opening</h1><div class="top"><p class="src"><a href="HPath-IO.html#v:openFile" target="main">openFile</a></p></div><div class="top"><p class="src"><a href="HPath-IO.html#v:executeFile" target="main">executeFile</a></p></div><h1>File creation</h1><div class="top"><p class="src"><a href="HPath-IO.html#v:createRegularFile" target="main">createRegularFile</a></p></div><div class="top"><p class="src"><a href="HPath-IO.html#v:createDir" target="main">createDir</a></p></div><div class="top"><p class="src"><a href="HPath-IO.html#v:createSymlink" target="main">createSymlink</a></p></div><h1>File renaming/moving</h1><div class="top"><p class="src"><a href="HPath-IO.html#v:renameFile" target="main">renameFile</a></p></div><div class="top"><p class="src"><a href="HPath-IO.html#v:moveFile" target="main">moveFile</a></p></div><div class="top"><p class="src"><a href="HPath-IO.html#v:moveFileOverwrite" target="main">moveFileOverwrite</a></p></div><h1>File permissions</h1><div class="top"><p class="src"><a href="HPath-IO.html#v:newFilePerms" target="main">newFilePerms</a></p></div><div class="top"><p class="src"><a href="HPath-IO.html#v:newDirPerms" target="main">newDirPerms</a></p></div><h1>Directory reading</h1><div class="top"><p class="src"><a href="HPath-IO.html#v:getDirsFiles" target="main">getDirsFiles</a></p></div><h1>Filetype operations</h1><div class="top"><p class="src"><a href="HPath-IO.html#v:getFileType" target="main">getFileType</a></p></div><h1>Others</h1><div class="top"><p class="src"><a href="HPath-IO.html#v:canonicalizePath" target="main">canonicalizePath</a></p></div></div></body></html>
|
4
mini_HPath.html
Normal file
4
mini_HPath.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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>HPath</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body id="mini"><div id="module-header"><p class="caption">HPath</p></div><div id="interface"><h1>Types</h1><div class="top"><p class="src"><span class="keyword">data</span> <a href="HPath.html#t:Abs" target="main">Abs</a></p></div><div class="top"><p class="src"><span class="keyword">data</span> <a href="HPath.html#t:Path" target="main">Path</a> b</p></div><div class="top"><p class="src"><span class="keyword">data</span> <a href="HPath.html#t:Rel" target="main">Rel</a></p></div><div class="top"><p class="src"><span class="keyword">data</span> <a href="HPath.html#t:Fn" target="main">Fn</a></p></div><div class="top"><p class="src"><span class="keyword">data</span> <a href="HPath.html#t:PathParseException" target="main">PathParseException</a></p></div><div class="top"><p class="src"><span class="keyword">data</span> <a href="HPath.html#t:PathException" target="main">PathException</a></p></div><div class="top"><p class="src"><span class="keyword">class</span> <a href="HPath.html#t:RelC" target="main">RelC</a> m</p></div><h1>PatternSynonyms/ViewPatterns</h1><h1>Path Parsing</h1><div class="top"><p class="src"><a href="HPath.html#v:parseAbs" target="main">parseAbs</a></p></div><div class="top"><p class="src"><a href="HPath.html#v:parseFn" target="main">parseFn</a></p></div><div class="top"><p class="src"><a href="HPath.html#v:parseRel" target="main">parseRel</a></p></div><h1>Path Conversion</h1><div class="top"><p class="src"><a href="HPath.html#v:fromAbs" target="main">fromAbs</a></p></div><div class="top"><p class="src"><a href="HPath.html#v:fromRel" target="main">fromRel</a></p></div><div class="top"><p class="src"><a href="HPath.html#v:toFilePath" target="main">toFilePath</a></p></div><h1>Path Operations</h1><div class="top"><p class="src"><a href="HPath.html#v:-60--47--62-" target="main">(</>)</a></p></div><div class="top"><p class="src"><a href="HPath.html#v:basename" target="main">basename</a></p></div><div class="top"><p class="src"><a href="HPath.html#v:dirname" target="main">dirname</a></p></div><div class="top"><p class="src"><a href="HPath.html#v:isParentOf" target="main">isParentOf</a></p></div><div class="top"><p class="src"><a href="HPath.html#v:getAllParents" target="main">getAllParents</a></p></div><div class="top"><p class="src"><a href="HPath.html#v:stripDir" target="main">stripDir</a></p></div><h1>Path IO helpers</h1><div class="top"><p class="src"><a href="HPath.html#v:withAbsPath" target="main">withAbsPath</a></p></div><div class="top"><p class="src"><a href="HPath.html#v:withRelPath" target="main">withRelPath</a></p></div><div class="top"><p class="src"><a href="HPath.html#v:withFnPath" target="main">withFnPath</a></p></div></div></body></html>
|
4
mini_System-Posix-Directory-Foreign.html
Normal file
4
mini_System-Posix-Directory-Foreign.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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.Directory.Foreign</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body id="mini"><div id="module-header"><p class="caption">System.Posix.Directory.Foreign</p></div><div id="interface"><div class="top"><p class="src"><span class="keyword">data</span> <a href="System-Posix-Directory-Foreign.html#t:DirType" target="main">DirType</a></p></div><div class="top"><p class="src"><span class="keyword">data</span> <a href="System-Posix-Directory-Foreign.html#t:Flags" target="main">Flags</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:unFlags" target="main">unFlags</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:isSupported" target="main">isSupported</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:oCloexec" target="main">oCloexec</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:dtBlk" target="main">dtBlk</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:oAppend" target="main">oAppend</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:dtChr" target="main">dtChr</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:pathMax" target="main">pathMax</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:oAsync" target="main">oAsync</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:dtDir" target="main">dtDir</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:oCreat" target="main">oCreat</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:dtFifo" target="main">dtFifo</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:unionFlags" target="main">unionFlags</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:dtLnk" target="main">dtLnk</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:oDirectory" target="main">oDirectory</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:oExcl" target="main">oExcl</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:dtReg" target="main">dtReg</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:oNoctty" target="main">oNoctty</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:dtSock" target="main">dtSock</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:oNofollow" target="main">oNofollow</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:dtUnknown" target="main">dtUnknown</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:oNonblock" target="main">oNonblock</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:oRdonly" target="main">oRdonly</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:oWronly" target="main">oWronly</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:oRdwr" target="main">oRdwr</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:oSync" target="main">oSync</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Foreign.html#v:oTrunc" target="main">oTrunc</a></p></div></div></body></html>
|
4
mini_System-Posix-Directory-Traversals.html
Normal file
4
mini_System-Posix-Directory-Traversals.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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.Directory.Traversals</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body id="mini"><div id="module-header"><p class="caption">System.Posix.Directory.Traversals</p></div><div id="interface"><div class="top"><p class="src"><a href="System-Posix-Directory-Traversals.html#v:getDirectoryContents" target="main">getDirectoryContents</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Traversals.html#v:getDirectoryContents-39-" target="main">getDirectoryContents'</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Traversals.html#v:allDirectoryContents" target="main">allDirectoryContents</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Traversals.html#v:allDirectoryContents-39-" target="main">allDirectoryContents'</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Traversals.html#v:traverseDirectory" target="main">traverseDirectory</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Traversals.html#v:readDirEnt" target="main">readDirEnt</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Traversals.html#v:packDirStream" target="main">packDirStream</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Traversals.html#v:unpackDirStream" target="main">unpackDirStream</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Traversals.html#v:fdOpendir" target="main">fdOpendir</a></p></div><div class="top"><p class="src"><a href="System-Posix-Directory-Traversals.html#v:realpath" target="main">realpath</a></p></div></div></body></html>
|
4
mini_System-Posix-FD.html
Normal file
4
mini_System-Posix-FD.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!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.FD</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
||||
window.onload = function () {pageLoad();};
|
||||
//]]>
|
||||
</script></head><body id="mini"><div id="module-header"><p class="caption">System.Posix.FD</p></div><div id="interface"><div class="top"><p class="src"><a href="System-Posix-FD.html#v:openFd" target="main">openFd</a></p></div></div></body></html>
|
4
mini_System-Posix-FilePath.html
Normal file
4
mini_System-Posix-FilePath.html
Normal file
File diff suppressed because one or more lines are too long
610
ocean.css
Normal file
610
ocean.css
Normal file
@ -0,0 +1,610 @@
|
||||
/* @group Fundamentals */
|
||||
|
||||
* { margin: 0; padding: 0 }
|
||||
|
||||
/* Is this portable? */
|
||||
html {
|
||||
background-color: white;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
background: white;
|
||||
color: black;
|
||||
text-align: left;
|
||||
min-height: 100%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0.8em 0;
|
||||
}
|
||||
|
||||
ul, ol {
|
||||
margin: 0.8em 0 0.8em 2em;
|
||||
}
|
||||
|
||||
dl {
|
||||
margin: 0.8em 0;
|
||||
}
|
||||
|
||||
dt {
|
||||
font-weight: bold;
|
||||
}
|
||||
dd {
|
||||
margin-left: 2em;
|
||||
}
|
||||
|
||||
a { text-decoration: none; }
|
||||
a[href]:link { color: rgb(196,69,29); }
|
||||
a[href]:visited { color: rgb(171,105,84); }
|
||||
a[href]:hover { text-decoration:underline; }
|
||||
|
||||
a[href].def:link, a[href].def:visited { color: black; }
|
||||
a[href].def:hover { color: rgb(78, 98, 114); }
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Fonts & Sizes */
|
||||
|
||||
/* Basic technique & IE workarounds from YUI 3
|
||||
For reasons, see:
|
||||
http://yui.yahooapis.com/3.1.1/build/cssfonts/fonts.css
|
||||
*/
|
||||
|
||||
body {
|
||||
font:13px/1.4 sans-serif;
|
||||
*font-size:small; /* for IE */
|
||||
*font:x-small; /* for IE in quirks mode */
|
||||
}
|
||||
|
||||
h1 { font-size: 146.5%; /* 19pt */ }
|
||||
h2 { font-size: 131%; /* 17pt */ }
|
||||
h3 { font-size: 116%; /* 15pt */ }
|
||||
h4 { font-size: 100%; /* 13pt */ }
|
||||
h5 { font-size: 100%; /* 13pt */ }
|
||||
|
||||
select, input, button, textarea {
|
||||
font:99% sans-serif;
|
||||
}
|
||||
|
||||
table {
|
||||
font-size:inherit;
|
||||
font:100%;
|
||||
}
|
||||
|
||||
pre, code, kbd, samp, tt, .src {
|
||||
font-family:monospace;
|
||||
*font-size:108%;
|
||||
line-height: 124%;
|
||||
}
|
||||
|
||||
.links, .link {
|
||||
font-size: 85%; /* 11pt */
|
||||
}
|
||||
|
||||
#module-header .caption {
|
||||
font-size: 182%; /* 24pt */
|
||||
}
|
||||
|
||||
.info {
|
||||
font-size: 85%; /* 11pt */
|
||||
}
|
||||
|
||||
#table-of-contents, #synopsis {
|
||||
/* font-size: 85%; /* 11pt */
|
||||
}
|
||||
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Common */
|
||||
|
||||
.caption, h1, h2, h3, h4, h5, h6 {
|
||||
font-weight: bold;
|
||||
color: rgb(78,98,114);
|
||||
margin: 0.8em 0 0.4em;
|
||||
}
|
||||
|
||||
* + h1, * + h2, * + h3, * + h4, * + h5, * + h6 {
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
h1 + h2, h2 + h3, h3 + h4, h4 + h5, h5 + h6 {
|
||||
margin-top: inherit;
|
||||
}
|
||||
|
||||
ul.links {
|
||||
list-style: none;
|
||||
text-align: left;
|
||||
float: right;
|
||||
display: inline-table;
|
||||
margin: 0 0 0 1em;
|
||||
}
|
||||
|
||||
ul.links li {
|
||||
display: inline;
|
||||
border-left: 1px solid #d5d5d5;
|
||||
white-space: nowrap;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
ul.links li a {
|
||||
padding: 0.2em 0.5em;
|
||||
}
|
||||
|
||||
.hide { display: none; }
|
||||
.show { display: inherit; }
|
||||
.clear { clear: both; }
|
||||
|
||||
.collapser {
|
||||
background-image: url(minus.gif);
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.expander {
|
||||
background-image: url(plus.gif);
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.collapser, .expander {
|
||||
padding-left: 14px;
|
||||
margin-left: -14px;
|
||||
cursor: pointer;
|
||||
}
|
||||
p.caption.collapser,
|
||||
p.caption.expander {
|
||||
background-position: 0 0.4em;
|
||||
}
|
||||
|
||||
.instance.collapser, .instance.expander {
|
||||
margin-left: 0px;
|
||||
background-position: left center;
|
||||
min-width: 9px;
|
||||
min-height: 9px;
|
||||
}
|
||||
|
||||
|
||||
pre {
|
||||
padding: 0.25em;
|
||||
margin: 0.8em 0;
|
||||
background: rgb(229,237,244);
|
||||
overflow: auto;
|
||||
border-bottom: 0.25em solid white;
|
||||
/* white border adds some space below the box to compensate
|
||||
for visual extra space that paragraphs have between baseline
|
||||
and the bounding box */
|
||||
}
|
||||
|
||||
.src {
|
||||
background: #f0f0f0;
|
||||
padding: 0.2em 0.5em;
|
||||
}
|
||||
|
||||
.keyword { font-weight: normal; }
|
||||
.def { font-weight: bold; }
|
||||
|
||||
@media print {
|
||||
#footer { display: none; }
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Page Structure */
|
||||
|
||||
#content {
|
||||
margin: 0 auto;
|
||||
padding: 0 2em 6em;
|
||||
}
|
||||
|
||||
#package-header {
|
||||
background: rgb(41,56,69);
|
||||
border-top: 5px solid rgb(78,98,114);
|
||||
color: #ddd;
|
||||
padding: 0.2em;
|
||||
position: relative;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#package-header .caption {
|
||||
background: url(hslogo-16.png) no-repeat 0em;
|
||||
color: white;
|
||||
margin: 0 2em;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
#package-header a:link, #package-header a:visited { color: white; }
|
||||
#package-header a:hover { background: rgb(78,98,114); }
|
||||
|
||||
#module-header .caption {
|
||||
color: rgb(78,98,114);
|
||||
font-weight: bold;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
table.info {
|
||||
float: right;
|
||||
padding: 0.5em 1em;
|
||||
border: 1px solid #ddd;
|
||||
color: rgb(78,98,114);
|
||||
background-color: #fff;
|
||||
max-width: 40%;
|
||||
border-spacing: 0;
|
||||
position: relative;
|
||||
top: -0.5em;
|
||||
margin: 0 0 0 2em;
|
||||
}
|
||||
|
||||
.info th {
|
||||
padding: 0 1em 0 0;
|
||||
}
|
||||
|
||||
div#style-menu-holder {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#style-menu {
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
overflow: visible;
|
||||
background: #374c5e;
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
right: 0;
|
||||
padding: 0;
|
||||
top: 1.25em;
|
||||
}
|
||||
|
||||
#style-menu li {
|
||||
display: list-item;
|
||||
border-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color: #000;
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
#style-menu li + li {
|
||||
border-top: 1px solid #919191;
|
||||
}
|
||||
|
||||
#style-menu a {
|
||||
width: 6em;
|
||||
padding: 3px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
#footer {
|
||||
background: #ddd;
|
||||
border-top: 1px solid #aaa;
|
||||
padding: 0.5em 0;
|
||||
color: #666;
|
||||
text-align: center;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 3em;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Front Matter */
|
||||
|
||||
#table-of-contents {
|
||||
float: right;
|
||||
clear: right;
|
||||
background: #faf9dc;
|
||||
border: 1px solid #d8d7ad;
|
||||
padding: 0.5em 1em;
|
||||
max-width: 20em;
|
||||
margin: 0.5em 0 1em 1em;
|
||||
}
|
||||
|
||||
#table-of-contents .caption {
|
||||
text-align: center;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#table-of-contents ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#table-of-contents ul ul {
|
||||
margin-left: 2em;
|
||||
}
|
||||
|
||||
#description .caption {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#synopsis {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.no-frame #synopsis {
|
||||
display: block;
|
||||
position: fixed;
|
||||
right: 0;
|
||||
height: 80%;
|
||||
top: 10%;
|
||||
padding: 0;
|
||||
max-width: 75%;
|
||||
}
|
||||
|
||||
#synopsis .caption {
|
||||
float: left;
|
||||
width: 29px;
|
||||
color: rgba(255,255,255,0);
|
||||
height: 110px;
|
||||
margin: 0;
|
||||
font-size: 1px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#synopsis p.caption.collapser {
|
||||
background: url(synopsis.png) no-repeat -64px -8px;
|
||||
}
|
||||
|
||||
#synopsis p.caption.expander {
|
||||
background: url(synopsis.png) no-repeat 0px -8px;
|
||||
}
|
||||
|
||||
#synopsis ul {
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
padding: 0.5em;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#synopsis ul ul {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#synopsis ul,
|
||||
#synopsis ul li.src {
|
||||
background-color: #faf9dc;
|
||||
white-space: nowrap;
|
||||
list-style: none;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Main Content */
|
||||
|
||||
#interface div.top { margin: 2em 0; }
|
||||
#interface h1 + div.top,
|
||||
#interface h2 + div.top,
|
||||
#interface h3 + div.top,
|
||||
#interface h4 + div.top,
|
||||
#interface h5 + div.top {
|
||||
margin-top: 1em;
|
||||
}
|
||||
#interface .src .selflink,
|
||||
#interface .src .link {
|
||||
float: right;
|
||||
color: #919191;
|
||||
background: #f0f0f0;
|
||||
padding: 0 0.5em 0.2em;
|
||||
margin: 0 -0.5em 0 0;
|
||||
}
|
||||
#interface .src .selflink {
|
||||
border-left: 1px solid #919191;
|
||||
margin: 0 -0.5em 0 0.5em;
|
||||
}
|
||||
|
||||
#interface span.fixity {
|
||||
color: #919191;
|
||||
border-left: 1px solid #919191;
|
||||
padding: 0.2em 0.5em 0.2em 0.5em;
|
||||
margin: 0 -1em 0 1em;
|
||||
}
|
||||
|
||||
#interface span.rightedge {
|
||||
border-left: 1px solid #919191;
|
||||
padding: 0.2em 0 0.2em 0;
|
||||
margin: 0 0 0 1em;
|
||||
}
|
||||
|
||||
#interface table { border-spacing: 2px; }
|
||||
#interface td {
|
||||
vertical-align: top;
|
||||
padding-left: 0.5em;
|
||||
}
|
||||
#interface td.src {
|
||||
white-space: nowrap;
|
||||
}
|
||||
#interface td.doc p {
|
||||
margin: 0;
|
||||
}
|
||||
#interface td.doc p + p {
|
||||
margin-top: 0.8em;
|
||||
}
|
||||
|
||||
.clearfix:after {
|
||||
clear: both;
|
||||
content: " ";
|
||||
display: block;
|
||||
height: 0;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.subs ul {
|
||||
list-style: none;
|
||||
display: table;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.subs ul li {
|
||||
display: table-row;
|
||||
}
|
||||
|
||||
.subs ul li dfn {
|
||||
display: table-cell;
|
||||
font-style: normal;
|
||||
font-weight: bold;
|
||||
margin: 1px 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.subs ul li > .doc {
|
||||
display: table-cell;
|
||||
padding-left: 0.5em;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.subs ul li > .doc p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Render short-style data instances */
|
||||
.inst ul {
|
||||
height: 100%;
|
||||
padding: 0.5em;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.inst, .inst li {
|
||||
list-style: none;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
/* Workaround for bug in Firefox (issue #384) */
|
||||
.inst-left {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.top p.src {
|
||||
border-top: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.subs, .doc {
|
||||
/* use this selector for one level of indent */
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
.warning {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.arguments {
|
||||
margin-top: -0.4em;
|
||||
}
|
||||
.arguments .caption {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.fields { padding-left: 1em; }
|
||||
|
||||
.fields .caption { display: none; }
|
||||
|
||||
.fields p { margin: 0 0; }
|
||||
|
||||
/* this seems bulky to me
|
||||
.methods, .constructors {
|
||||
background: #f8f8f8;
|
||||
border: 1px solid #eee;
|
||||
}
|
||||
*/
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Auxillary Pages */
|
||||
|
||||
|
||||
.extension-list {
|
||||
list-style-type: none;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
#mini {
|
||||
margin: 0 auto;
|
||||
padding: 0 1em 1em;
|
||||
}
|
||||
|
||||
#mini > * {
|
||||
font-size: 93%; /* 12pt */
|
||||
}
|
||||
|
||||
#mini #module-list .caption,
|
||||
#mini #module-header .caption {
|
||||
font-size: 125%; /* 15pt */
|
||||
}
|
||||
|
||||
#mini #interface h1,
|
||||
#mini #interface h2,
|
||||
#mini #interface h3,
|
||||
#mini #interface h4 {
|
||||
font-size: 109%; /* 13pt */
|
||||
margin: 1em 0 0;
|
||||
}
|
||||
|
||||
#mini #interface .top,
|
||||
#mini #interface .src {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#mini #module-list ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#alphabet ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0.5em 0 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#alphabet li {
|
||||
display: inline;
|
||||
margin: 0 0.25em;
|
||||
}
|
||||
|
||||
#alphabet a {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#index .caption,
|
||||
#module-list .caption { font-size: 131%; /* 17pt */ }
|
||||
|
||||
#index table {
|
||||
margin-left: 2em;
|
||||
}
|
||||
|
||||
#index .src {
|
||||
font-weight: bold;
|
||||
}
|
||||
#index .alt {
|
||||
font-size: 77%; /* 10pt */
|
||||
font-style: italic;
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
#index td + td {
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
#module-list ul {
|
||||
list-style: none;
|
||||
margin: 0 0 0 2em;
|
||||
}
|
||||
|
||||
#module-list li {
|
||||
clear: right;
|
||||
}
|
||||
|
||||
#module-list span.collapser,
|
||||
#module-list span.expander {
|
||||
background-position: 0 0.3em;
|
||||
}
|
||||
|
||||
#module-list .package {
|
||||
float: right;
|
||||
}
|
||||
|
||||
/* @end */
|
370
src/HPath-IO-Errors.html
Normal file
370
src/HPath-IO-Errors.html
Normal file
@ -0,0 +1,370 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
|
||||
<title>src/HPath/IO/Errors.hs</title>
|
||||
<link type='text/css' rel='stylesheet' href='hscolour.css' />
|
||||
</head>
|
||||
<body>
|
||||
<pre><a name="line-1"></a><span class='hs-comment'>-- |</span>
|
||||
<a name="line-2"></a><span class='hs-comment'>-- Module : HPath.IO.Errors</span>
|
||||
<a name="line-3"></a><span class='hs-comment'>-- Copyright : © 2016 Julian Ospald</span>
|
||||
<a name="line-4"></a><span class='hs-comment'>-- License : GPL-2</span>
|
||||
<a name="line-5"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-6"></a><span class='hs-comment'>-- Maintainer : Julian Ospald <hasufell@posteo.de></span>
|
||||
<a name="line-7"></a><span class='hs-comment'>-- Stability : experimental</span>
|
||||
<a name="line-8"></a><span class='hs-comment'>-- Portability : portable</span>
|
||||
<a name="line-9"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-10"></a><span class='hs-comment'>-- Provides error handling.</span>
|
||||
<a name="line-11"></a>
|
||||
<a name="line-12"></a><span class='hs-comment'>{-# LANGUAGE DeriveDataTypeable #-}</span>
|
||||
<a name="line-13"></a><span class='hs-comment'>{-# LANGUAGE ScopedTypeVariables #-}</span>
|
||||
<a name="line-14"></a>
|
||||
<a name="line-15"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>HPath</span><span class='hs-varop'>.</span><span class='hs-conid'>IO</span><span class='hs-varop'>.</span><span class='hs-conid'>Errors</span>
|
||||
<a name="line-16"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-17"></a> <span class='hs-comment'>-- * Types</span>
|
||||
<a name="line-18"></a> <span class='hs-conid'>HPathIOException</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span>
|
||||
<a name="line-19"></a>
|
||||
<a name="line-20"></a> <span class='hs-comment'>-- * Exception identifiers</span>
|
||||
<a name="line-21"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>isFileDoesNotExist</span>
|
||||
<a name="line-22"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>isDirDoesNotExist</span>
|
||||
<a name="line-23"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>isSameFile</span>
|
||||
<a name="line-24"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>isDestinationInSource</span>
|
||||
<a name="line-25"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>isFileDoesExist</span>
|
||||
<a name="line-26"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>isDirDoesExist</span>
|
||||
<a name="line-27"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>isInvalidOperation</span>
|
||||
<a name="line-28"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>isCan'tOpenDirectory</span>
|
||||
<a name="line-29"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>isCopyFailed</span>
|
||||
<a name="line-30"></a>
|
||||
<a name="line-31"></a> <span class='hs-comment'>-- * Path based functions</span>
|
||||
<a name="line-32"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>throwFileDoesExist</span>
|
||||
<a name="line-33"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>throwDirDoesExist</span>
|
||||
<a name="line-34"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>throwFileDoesNotExist</span>
|
||||
<a name="line-35"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>throwDirDoesNotExist</span>
|
||||
<a name="line-36"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>throwSameFile</span>
|
||||
<a name="line-37"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>sameFile</span>
|
||||
<a name="line-38"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>throwDestinationInSource</span>
|
||||
<a name="line-39"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>doesFileExist</span>
|
||||
<a name="line-40"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>doesDirectoryExist</span>
|
||||
<a name="line-41"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>isWritable</span>
|
||||
<a name="line-42"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>canOpenDirectory</span>
|
||||
<a name="line-43"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>throwCantOpenDirectory</span>
|
||||
<a name="line-44"></a>
|
||||
<a name="line-45"></a> <span class='hs-comment'>-- * Error handling functions</span>
|
||||
<a name="line-46"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>catchErrno</span>
|
||||
<a name="line-47"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>rethrowErrnoAs</span>
|
||||
<a name="line-48"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>handleIOError</span>
|
||||
<a name="line-49"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>bracketeer</span>
|
||||
<a name="line-50"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>reactOnError</span>
|
||||
<a name="line-51"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-52"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-53"></a>
|
||||
<a name="line-54"></a>
|
||||
<a name="line-55"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Applicative</span>
|
||||
<a name="line-56"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-57"></a> <span class='hs-layout'>(</span><span class='hs-varop'><$></span><span class='hs-layout'>)</span>
|
||||
<a name="line-58"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-59"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Exception</span>
|
||||
<a name="line-60"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Monad</span>
|
||||
<a name="line-61"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-62"></a> <span class='hs-varid'>forM</span>
|
||||
<a name="line-63"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>when</span>
|
||||
<a name="line-64"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-65"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span>
|
||||
<a name="line-66"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-67"></a> <span class='hs-conid'>ByteString</span>
|
||||
<a name="line-68"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-69"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span><span class='hs-varop'>.</span><span class='hs-conid'>UTF8</span>
|
||||
<a name="line-70"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-71"></a> <span class='hs-varid'>toString</span>
|
||||
<a name="line-72"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-73"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Data</span>
|
||||
<a name="line-74"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-75"></a> <span class='hs-conid'>Data</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span>
|
||||
<a name="line-76"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-77"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Typeable</span>
|
||||
<a name="line-78"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>C</span><span class='hs-varop'>.</span><span class='hs-conid'>Error</span>
|
||||
<a name="line-79"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-80"></a> <span class='hs-varid'>getErrno</span>
|
||||
<a name="line-81"></a> <span class='hs-layout'>,</span> <span class='hs-conid'>Errno</span>
|
||||
<a name="line-82"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-83"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>GHC</span><span class='hs-varop'>.</span><span class='hs-conid'>IO</span><span class='hs-varop'>.</span><span class='hs-conid'>Exception</span>
|
||||
<a name="line-84"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-85"></a> <span class='hs-conid'>IOErrorType</span>
|
||||
<a name="line-86"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-87"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>HPath</span>
|
||||
<a name="line-88"></a><span class='hs-keyword'>import</span> <span class='hs-comment'>{-# SOURCE #-}</span> <span class='hs-conid'>HPath</span><span class='hs-varop'>.</span><span class='hs-conid'>IO</span>
|
||||
<a name="line-89"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-90"></a> <span class='hs-varid'>canonicalizePath</span>
|
||||
<a name="line-91"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-92"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>HPath</span><span class='hs-varop'>.</span><span class='hs-conid'>IO</span><span class='hs-varop'>.</span><span class='hs-conid'>Utils</span>
|
||||
<a name="line-93"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>IO</span><span class='hs-varop'>.</span><span class='hs-conid'>Error</span>
|
||||
<a name="line-94"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-95"></a> <span class='hs-varid'>catchIOError</span>
|
||||
<a name="line-96"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>ioeGetErrorType</span>
|
||||
<a name="line-97"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-98"></a>
|
||||
<a name="line-99"></a><span class='hs-keyword'>import</span> <span class='hs-keyword'>qualified</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Directory</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span> <span class='hs-keyword'>as</span> <span class='hs-conid'>PFD</span>
|
||||
<a name="line-100"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Files</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span>
|
||||
<a name="line-101"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-102"></a> <span class='hs-varid'>fileAccess</span>
|
||||
<a name="line-103"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>getFileStatus</span>
|
||||
<a name="line-104"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-105"></a><span class='hs-keyword'>import</span> <span class='hs-keyword'>qualified</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Files</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span> <span class='hs-keyword'>as</span> <span class='hs-conid'>PF</span>
|
||||
<a name="line-106"></a>
|
||||
<a name="line-107"></a>
|
||||
<a name="line-108"></a><a name="HPathIOException"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>HPathIOException</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>FileDoesNotExist</span> <span class='hs-conid'>ByteString</span>
|
||||
<a name="line-109"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>DirDoesNotExist</span> <span class='hs-conid'>ByteString</span>
|
||||
<a name="line-110"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>SameFile</span> <span class='hs-conid'>ByteString</span> <span class='hs-conid'>ByteString</span>
|
||||
<a name="line-111"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>DestinationInSource</span> <span class='hs-conid'>ByteString</span> <span class='hs-conid'>ByteString</span>
|
||||
<a name="line-112"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>FileDoesExist</span> <span class='hs-conid'>ByteString</span>
|
||||
<a name="line-113"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>DirDoesExist</span> <span class='hs-conid'>ByteString</span>
|
||||
<a name="line-114"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>InvalidOperation</span> <span class='hs-conid'>String</span>
|
||||
<a name="line-115"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>Can'tOpenDirectory</span> <span class='hs-conid'>ByteString</span>
|
||||
<a name="line-116"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>CopyFailed</span> <span class='hs-conid'>String</span>
|
||||
<a name="line-117"></a> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span><span class='hs-conid'>Typeable</span><span class='hs-layout'>,</span> <span class='hs-conid'>Eq</span><span class='hs-layout'>,</span> <span class='hs-conid'>Data</span><span class='hs-layout'>)</span>
|
||||
<a name="line-118"></a>
|
||||
<a name="line-119"></a>
|
||||
<a name="line-120"></a><a name="instance%20Show%20HPathIOException"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>Show</span> <span class='hs-conid'>HPathIOException</span> <span class='hs-keyword'>where</span>
|
||||
<a name="line-121"></a> <span class='hs-varid'>show</span> <span class='hs-layout'>(</span><span class='hs-conid'>FileDoesNotExist</span> <span class='hs-varid'>fp</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-str'>"File does not exist:"</span> <span class='hs-varop'>++</span> <span class='hs-varid'>toString</span> <span class='hs-varid'>fp</span>
|
||||
<a name="line-122"></a> <span class='hs-varid'>show</span> <span class='hs-layout'>(</span><span class='hs-conid'>DirDoesNotExist</span> <span class='hs-varid'>fp</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-str'>"Directory does not exist: "</span>
|
||||
<a name="line-123"></a> <span class='hs-varop'>++</span> <span class='hs-varid'>toString</span> <span class='hs-varid'>fp</span>
|
||||
<a name="line-124"></a> <span class='hs-varid'>show</span> <span class='hs-layout'>(</span><span class='hs-conid'>SameFile</span> <span class='hs-varid'>fp1</span> <span class='hs-varid'>fp2</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>toString</span> <span class='hs-varid'>fp1</span>
|
||||
<a name="line-125"></a> <span class='hs-varop'>++</span> <span class='hs-str'>" and "</span> <span class='hs-varop'>++</span> <span class='hs-varid'>toString</span> <span class='hs-varid'>fp2</span>
|
||||
<a name="line-126"></a> <span class='hs-varop'>++</span> <span class='hs-str'>" are the same file!"</span>
|
||||
<a name="line-127"></a> <span class='hs-varid'>show</span> <span class='hs-layout'>(</span><span class='hs-conid'>DestinationInSource</span> <span class='hs-varid'>fp1</span> <span class='hs-varid'>fp2</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>toString</span> <span class='hs-varid'>fp1</span>
|
||||
<a name="line-128"></a> <span class='hs-varop'>++</span> <span class='hs-str'>" is contained in "</span>
|
||||
<a name="line-129"></a> <span class='hs-varop'>++</span> <span class='hs-varid'>toString</span> <span class='hs-varid'>fp2</span>
|
||||
<a name="line-130"></a> <span class='hs-varid'>show</span> <span class='hs-layout'>(</span><span class='hs-conid'>FileDoesExist</span> <span class='hs-varid'>fp</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-str'>"File does exist: "</span> <span class='hs-varop'>++</span> <span class='hs-varid'>toString</span> <span class='hs-varid'>fp</span>
|
||||
<a name="line-131"></a> <span class='hs-varid'>show</span> <span class='hs-layout'>(</span><span class='hs-conid'>DirDoesExist</span> <span class='hs-varid'>fp</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-str'>"Directory does exist: "</span> <span class='hs-varop'>++</span> <span class='hs-varid'>toString</span> <span class='hs-varid'>fp</span>
|
||||
<a name="line-132"></a> <span class='hs-varid'>show</span> <span class='hs-layout'>(</span><span class='hs-conid'>InvalidOperation</span> <span class='hs-varid'>str</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-str'>"Invalid operation: "</span> <span class='hs-varop'>++</span> <span class='hs-varid'>str</span>
|
||||
<a name="line-133"></a> <span class='hs-varid'>show</span> <span class='hs-layout'>(</span><span class='hs-conid'>Can'tOpenDirectory</span> <span class='hs-varid'>fp</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-str'>"Can't open directory: "</span>
|
||||
<a name="line-134"></a> <span class='hs-varop'>++</span> <span class='hs-varid'>toString</span> <span class='hs-varid'>fp</span>
|
||||
<a name="line-135"></a> <span class='hs-varid'>show</span> <span class='hs-layout'>(</span><span class='hs-conid'>CopyFailed</span> <span class='hs-varid'>str</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-str'>"Copying failed: "</span> <span class='hs-varop'>++</span> <span class='hs-varid'>str</span>
|
||||
<a name="line-136"></a>
|
||||
<a name="line-137"></a>
|
||||
<a name="line-138"></a>
|
||||
<a name="line-139"></a><a name="instance%20Exception%20HPathIOException"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>Exception</span> <span class='hs-conid'>HPathIOException</span>
|
||||
<a name="line-140"></a>
|
||||
<a name="line-141"></a>
|
||||
<a name="line-142"></a>
|
||||
<a name="line-143"></a>
|
||||
<a name="line-144"></a>
|
||||
<a name="line-145"></a> <span class='hs-comment'>-----------------------------</span>
|
||||
<a name="line-146"></a> <span class='hs-comment'>--[ Exception identifiers ]--</span>
|
||||
<a name="line-147"></a> <span class='hs-comment'>-----------------------------</span>
|
||||
<a name="line-148"></a>
|
||||
<a name="line-149"></a><a name="isFileDoesNotExist"></a><span class='hs-definition'>isFileDoesNotExist</span><span class='hs-layout'>,</span> <span class='hs-varid'>isDirDoesNotExist</span><span class='hs-layout'>,</span> <span class='hs-varid'>isSameFile</span><span class='hs-layout'>,</span> <span class='hs-varid'>isDestinationInSource</span><span class='hs-layout'>,</span> <span class='hs-varid'>isFileDoesExist</span><span class='hs-layout'>,</span> <span class='hs-varid'>isDirDoesExist</span><span class='hs-layout'>,</span> <span class='hs-varid'>isInvalidOperation</span><span class='hs-layout'>,</span> <span class='hs-varid'>isCan'tOpenDirectory</span><span class='hs-layout'>,</span> <span class='hs-varid'>isCopyFailed</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>HPathIOException</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Bool</span>
|
||||
<a name="line-150"></a><span class='hs-definition'>isFileDoesNotExist</span> <span class='hs-varid'>ex</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>toConstr</span> <span class='hs-layout'>(</span><span class='hs-varid'>ex</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>HPathIOException</span><span class='hs-layout'>)</span> <span class='hs-varop'>==</span> <span class='hs-varid'>toConstr</span> <span class='hs-conid'>FileDoesNotExist</span><span class='hs-layout'>{</span><span class='hs-layout'>}</span>
|
||||
<a name="line-151"></a><a name="isDirDoesNotExist"></a><span class='hs-definition'>isDirDoesNotExist</span> <span class='hs-varid'>ex</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>toConstr</span> <span class='hs-layout'>(</span><span class='hs-varid'>ex</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>HPathIOException</span><span class='hs-layout'>)</span> <span class='hs-varop'>==</span> <span class='hs-varid'>toConstr</span> <span class='hs-conid'>DirDoesNotExist</span><span class='hs-layout'>{</span><span class='hs-layout'>}</span>
|
||||
<a name="line-152"></a><a name="isSameFile"></a><span class='hs-definition'>isSameFile</span> <span class='hs-varid'>ex</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>toConstr</span> <span class='hs-layout'>(</span><span class='hs-varid'>ex</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>HPathIOException</span><span class='hs-layout'>)</span> <span class='hs-varop'>==</span> <span class='hs-varid'>toConstr</span> <span class='hs-conid'>SameFile</span><span class='hs-layout'>{</span><span class='hs-layout'>}</span>
|
||||
<a name="line-153"></a><a name="isDestinationInSource"></a><span class='hs-definition'>isDestinationInSource</span> <span class='hs-varid'>ex</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>toConstr</span> <span class='hs-layout'>(</span><span class='hs-varid'>ex</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>HPathIOException</span><span class='hs-layout'>)</span> <span class='hs-varop'>==</span> <span class='hs-varid'>toConstr</span> <span class='hs-conid'>DestinationInSource</span><span class='hs-layout'>{</span><span class='hs-layout'>}</span>
|
||||
<a name="line-154"></a><a name="isFileDoesExist"></a><span class='hs-definition'>isFileDoesExist</span> <span class='hs-varid'>ex</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>toConstr</span> <span class='hs-layout'>(</span><span class='hs-varid'>ex</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>HPathIOException</span><span class='hs-layout'>)</span> <span class='hs-varop'>==</span> <span class='hs-varid'>toConstr</span> <span class='hs-conid'>FileDoesExist</span><span class='hs-layout'>{</span><span class='hs-layout'>}</span>
|
||||
<a name="line-155"></a><a name="isDirDoesExist"></a><span class='hs-definition'>isDirDoesExist</span> <span class='hs-varid'>ex</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>toConstr</span> <span class='hs-layout'>(</span><span class='hs-varid'>ex</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>HPathIOException</span><span class='hs-layout'>)</span> <span class='hs-varop'>==</span> <span class='hs-varid'>toConstr</span> <span class='hs-conid'>DirDoesExist</span><span class='hs-layout'>{</span><span class='hs-layout'>}</span>
|
||||
<a name="line-156"></a><a name="isInvalidOperation"></a><span class='hs-definition'>isInvalidOperation</span> <span class='hs-varid'>ex</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>toConstr</span> <span class='hs-layout'>(</span><span class='hs-varid'>ex</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>HPathIOException</span><span class='hs-layout'>)</span> <span class='hs-varop'>==</span> <span class='hs-varid'>toConstr</span> <span class='hs-conid'>InvalidOperation</span><span class='hs-layout'>{</span><span class='hs-layout'>}</span>
|
||||
<a name="line-157"></a><a name="isCan'tOpenDirectory"></a><span class='hs-definition'>isCan'tOpenDirectory</span> <span class='hs-varid'>ex</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>toConstr</span> <span class='hs-layout'>(</span><span class='hs-varid'>ex</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>HPathIOException</span><span class='hs-layout'>)</span> <span class='hs-varop'>==</span> <span class='hs-varid'>toConstr</span> <span class='hs-conid'>Can'tOpenDirectory</span><span class='hs-layout'>{</span><span class='hs-layout'>}</span>
|
||||
<a name="line-158"></a><a name="isCopyFailed"></a><span class='hs-definition'>isCopyFailed</span> <span class='hs-varid'>ex</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>toConstr</span> <span class='hs-layout'>(</span><span class='hs-varid'>ex</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>HPathIOException</span><span class='hs-layout'>)</span> <span class='hs-varop'>==</span> <span class='hs-varid'>toConstr</span> <span class='hs-conid'>CopyFailed</span><span class='hs-layout'>{</span><span class='hs-layout'>}</span>
|
||||
<a name="line-159"></a>
|
||||
<a name="line-160"></a>
|
||||
<a name="line-161"></a>
|
||||
<a name="line-162"></a>
|
||||
<a name="line-163"></a> <span class='hs-comment'>----------------------------</span>
|
||||
<a name="line-164"></a> <span class='hs-comment'>--[ Path based functions ]--</span>
|
||||
<a name="line-165"></a> <span class='hs-comment'>----------------------------</span>
|
||||
<a name="line-166"></a>
|
||||
<a name="line-167"></a>
|
||||
<a name="line-168"></a><a name="throwFileDoesExist"></a><span class='hs-definition'>throwFileDoesExist</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-169"></a><span class='hs-definition'>throwFileDoesExist</span> <span class='hs-varid'>fp</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-170"></a> <span class='hs-varid'>whenM</span> <span class='hs-layout'>(</span><span class='hs-varid'>doesFileExist</span> <span class='hs-varid'>fp</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>throwIO</span> <span class='hs-varop'>.</span> <span class='hs-conid'>FileDoesExist</span>
|
||||
<a name="line-171"></a> <span class='hs-varop'>.</span> <span class='hs-varid'>fromAbs</span> <span class='hs-varop'>$</span> <span class='hs-varid'>fp</span><span class='hs-layout'>)</span>
|
||||
<a name="line-172"></a>
|
||||
<a name="line-173"></a>
|
||||
<a name="line-174"></a><a name="throwDirDoesExist"></a><span class='hs-definition'>throwDirDoesExist</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-175"></a><span class='hs-definition'>throwDirDoesExist</span> <span class='hs-varid'>fp</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-176"></a> <span class='hs-varid'>whenM</span> <span class='hs-layout'>(</span><span class='hs-varid'>doesDirectoryExist</span> <span class='hs-varid'>fp</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>throwIO</span> <span class='hs-varop'>.</span> <span class='hs-conid'>DirDoesExist</span>
|
||||
<a name="line-177"></a> <span class='hs-varop'>.</span> <span class='hs-varid'>fromAbs</span> <span class='hs-varop'>$</span> <span class='hs-varid'>fp</span><span class='hs-layout'>)</span>
|
||||
<a name="line-178"></a>
|
||||
<a name="line-179"></a>
|
||||
<a name="line-180"></a><a name="throwFileDoesNotExist"></a><span class='hs-definition'>throwFileDoesNotExist</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-181"></a><span class='hs-definition'>throwFileDoesNotExist</span> <span class='hs-varid'>fp</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-182"></a> <span class='hs-varid'>unlessM</span> <span class='hs-layout'>(</span><span class='hs-varid'>doesFileExist</span> <span class='hs-varid'>fp</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>throwIO</span> <span class='hs-varop'>.</span> <span class='hs-conid'>FileDoesNotExist</span>
|
||||
<a name="line-183"></a> <span class='hs-varop'>.</span> <span class='hs-varid'>fromAbs</span> <span class='hs-varop'>$</span> <span class='hs-varid'>fp</span><span class='hs-layout'>)</span>
|
||||
<a name="line-184"></a>
|
||||
<a name="line-185"></a>
|
||||
<a name="line-186"></a><a name="throwDirDoesNotExist"></a><span class='hs-definition'>throwDirDoesNotExist</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-187"></a><span class='hs-definition'>throwDirDoesNotExist</span> <span class='hs-varid'>fp</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-188"></a> <span class='hs-varid'>unlessM</span> <span class='hs-layout'>(</span><span class='hs-varid'>doesDirectoryExist</span> <span class='hs-varid'>fp</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>throwIO</span> <span class='hs-varop'>.</span> <span class='hs-conid'>DirDoesNotExist</span>
|
||||
<a name="line-189"></a> <span class='hs-varop'>.</span> <span class='hs-varid'>fromAbs</span> <span class='hs-varop'>$</span> <span class='hs-varid'>fp</span><span class='hs-layout'>)</span>
|
||||
<a name="line-190"></a>
|
||||
<a name="line-191"></a>
|
||||
<a name="line-192"></a><a name="throwSameFile"></a><span class='hs-comment'>-- |Uses `isSameFile` and throws `SameFile` if it returns True.</span>
|
||||
<a name="line-193"></a><span class='hs-definition'>throwSameFile</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span>
|
||||
<a name="line-194"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span>
|
||||
<a name="line-195"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-196"></a><span class='hs-definition'>throwSameFile</span> <span class='hs-varid'>fp1</span> <span class='hs-varid'>fp2</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-197"></a> <span class='hs-varid'>whenM</span> <span class='hs-layout'>(</span><span class='hs-varid'>sameFile</span> <span class='hs-varid'>fp1</span> <span class='hs-varid'>fp2</span><span class='hs-layout'>)</span>
|
||||
<a name="line-198"></a> <span class='hs-layout'>(</span><span class='hs-varid'>throwIO</span> <span class='hs-varop'>$</span> <span class='hs-conid'>SameFile</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromAbs</span> <span class='hs-varid'>fp1</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromAbs</span> <span class='hs-varid'>fp2</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
|
||||
<a name="line-199"></a>
|
||||
<a name="line-200"></a>
|
||||
<a name="line-201"></a><a name="sameFile"></a><span class='hs-comment'>-- |Check if the files are the same by examining device and file id.</span>
|
||||
<a name="line-202"></a><span class='hs-comment'>-- This follows symbolic links.</span>
|
||||
<a name="line-203"></a><span class='hs-definition'>sameFile</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
|
||||
<a name="line-204"></a><span class='hs-definition'>sameFile</span> <span class='hs-varid'>fp1</span> <span class='hs-varid'>fp2</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-205"></a> <span class='hs-varid'>withAbsPath</span> <span class='hs-varid'>fp1</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>fp1'</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>withAbsPath</span> <span class='hs-varid'>fp2</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>fp2'</span> <span class='hs-keyglyph'>-></span>
|
||||
<a name="line-206"></a> <span class='hs-varid'>handleIOError</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-keyword'>_</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>return</span> <span class='hs-conid'>False</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-207"></a> <span class='hs-varid'>fs1</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>getFileStatus</span> <span class='hs-varid'>fp1'</span>
|
||||
<a name="line-208"></a> <span class='hs-varid'>fs2</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>getFileStatus</span> <span class='hs-varid'>fp2'</span>
|
||||
<a name="line-209"></a>
|
||||
<a name="line-210"></a> <span class='hs-keyword'>if</span> <span class='hs-layout'>(</span><span class='hs-layout'>(</span><span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>deviceID</span> <span class='hs-varid'>fs1</span><span class='hs-layout'>,</span> <span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>fileID</span> <span class='hs-varid'>fs1</span><span class='hs-layout'>)</span> <span class='hs-varop'>==</span>
|
||||
<a name="line-211"></a> <span class='hs-layout'>(</span><span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>deviceID</span> <span class='hs-varid'>fs2</span><span class='hs-layout'>,</span> <span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>fileID</span> <span class='hs-varid'>fs2</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
|
||||
<a name="line-212"></a> <span class='hs-keyword'>then</span> <span class='hs-varid'>return</span> <span class='hs-conid'>True</span>
|
||||
<a name="line-213"></a> <span class='hs-keyword'>else</span> <span class='hs-varid'>return</span> <span class='hs-conid'>False</span>
|
||||
<a name="line-214"></a>
|
||||
<a name="line-215"></a>
|
||||
<a name="line-216"></a><a name="throwDestinationInSource"></a><span class='hs-comment'>-- TODO: make this more robust when destination does not exist</span>
|
||||
<a name="line-217"></a><span class='hs-comment'>-- |Checks whether the destination directory is contained</span>
|
||||
<a name="line-218"></a><span class='hs-comment'>-- within the source directory by comparing the device+file ID of the</span>
|
||||
<a name="line-219"></a><span class='hs-comment'>-- source directory with all device+file IDs of the parent directories</span>
|
||||
<a name="line-220"></a><span class='hs-comment'>-- of the destination.</span>
|
||||
<a name="line-221"></a><span class='hs-definition'>throwDestinationInSource</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-comment'>-- ^ source dir</span>
|
||||
<a name="line-222"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-comment'>-- ^ full destination, @dirname dest@</span>
|
||||
<a name="line-223"></a> <span class='hs-comment'>-- must exist</span>
|
||||
<a name="line-224"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-225"></a><span class='hs-definition'>throwDestinationInSource</span> <span class='hs-varid'>source</span> <span class='hs-varid'>dest</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-226"></a> <span class='hs-varid'>dest'</span> <span class='hs-keyglyph'><-</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>x</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>maybe</span> <span class='hs-varid'>x</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>y</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>x</span> <span class='hs-varop'></></span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-varid'>basename</span> <span class='hs-varid'>dest</span><span class='hs-layout'>)</span>
|
||||
<a name="line-227"></a> <span class='hs-varop'><$></span> <span class='hs-layout'>(</span><span class='hs-varid'>canonicalizePath</span> <span class='hs-varop'>$</span> <span class='hs-varid'>dirname</span> <span class='hs-varid'>dest</span><span class='hs-layout'>)</span>
|
||||
<a name="line-228"></a> <span class='hs-varid'>dids</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>forM</span> <span class='hs-layout'>(</span><span class='hs-varid'>getAllParents</span> <span class='hs-varid'>dest'</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>p</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-229"></a> <span class='hs-varid'>fs</span> <span class='hs-keyglyph'><-</span> <span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>getSymbolicLinkStatus</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromAbs</span> <span class='hs-varid'>p</span><span class='hs-layout'>)</span>
|
||||
<a name="line-230"></a> <span class='hs-varid'>return</span> <span class='hs-layout'>(</span><span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>deviceID</span> <span class='hs-varid'>fs</span><span class='hs-layout'>,</span> <span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>fileID</span> <span class='hs-varid'>fs</span><span class='hs-layout'>)</span>
|
||||
<a name="line-231"></a> <span class='hs-varid'>sid</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>fmap</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>x</span> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>deviceID</span> <span class='hs-varid'>x</span><span class='hs-layout'>,</span> <span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>fileID</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
|
||||
<a name="line-232"></a> <span class='hs-varop'>$</span> <span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>getFileStatus</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromAbs</span> <span class='hs-varid'>source</span><span class='hs-layout'>)</span>
|
||||
<a name="line-233"></a> <span class='hs-varid'>when</span> <span class='hs-layout'>(</span><span class='hs-varid'>elem</span> <span class='hs-varid'>sid</span> <span class='hs-varid'>dids</span><span class='hs-layout'>)</span>
|
||||
<a name="line-234"></a> <span class='hs-layout'>(</span><span class='hs-varid'>throwIO</span> <span class='hs-varop'>$</span> <span class='hs-conid'>DestinationInSource</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromAbs</span> <span class='hs-varid'>dest</span><span class='hs-layout'>)</span>
|
||||
<a name="line-235"></a> <span class='hs-layout'>(</span><span class='hs-varid'>fromAbs</span> <span class='hs-varid'>source</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
|
||||
<a name="line-236"></a>
|
||||
<a name="line-237"></a>
|
||||
<a name="line-238"></a><a name="doesFileExist"></a><span class='hs-comment'>-- |Checks if the given file exists and is not a directory.</span>
|
||||
<a name="line-239"></a><span class='hs-comment'>-- Does not follow symlinks.</span>
|
||||
<a name="line-240"></a><span class='hs-definition'>doesFileExist</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
|
||||
<a name="line-241"></a><span class='hs-definition'>doesFileExist</span> <span class='hs-varid'>fp</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-242"></a> <span class='hs-varid'>handleIOError</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-keyword'>_</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>return</span> <span class='hs-conid'>False</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-243"></a> <span class='hs-varid'>fs</span> <span class='hs-keyglyph'><-</span> <span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>getSymbolicLinkStatus</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromAbs</span> <span class='hs-varid'>fp</span><span class='hs-layout'>)</span>
|
||||
<a name="line-244"></a> <span class='hs-varid'>return</span> <span class='hs-varop'>$</span> <span class='hs-varid'>not</span> <span class='hs-varop'>.</span> <span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>isDirectory</span> <span class='hs-varop'>$</span> <span class='hs-varid'>fs</span>
|
||||
<a name="line-245"></a>
|
||||
<a name="line-246"></a>
|
||||
<a name="line-247"></a><a name="doesDirectoryExist"></a><span class='hs-comment'>-- |Checks if the given file exists and is a directory.</span>
|
||||
<a name="line-248"></a><span class='hs-comment'>-- Does not follow symlinks.</span>
|
||||
<a name="line-249"></a><span class='hs-definition'>doesDirectoryExist</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
|
||||
<a name="line-250"></a><span class='hs-definition'>doesDirectoryExist</span> <span class='hs-varid'>fp</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-251"></a> <span class='hs-varid'>handleIOError</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-keyword'>_</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>return</span> <span class='hs-conid'>False</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-252"></a> <span class='hs-varid'>fs</span> <span class='hs-keyglyph'><-</span> <span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>getSymbolicLinkStatus</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromAbs</span> <span class='hs-varid'>fp</span><span class='hs-layout'>)</span>
|
||||
<a name="line-253"></a> <span class='hs-varid'>return</span> <span class='hs-varop'>$</span> <span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>isDirectory</span> <span class='hs-varid'>fs</span>
|
||||
<a name="line-254"></a>
|
||||
<a name="line-255"></a>
|
||||
<a name="line-256"></a><a name="isWritable"></a><span class='hs-comment'>-- |Checks whether a file or folder is writable.</span>
|
||||
<a name="line-257"></a><span class='hs-definition'>isWritable</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
|
||||
<a name="line-258"></a><span class='hs-definition'>isWritable</span> <span class='hs-varid'>fp</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-259"></a> <span class='hs-varid'>handleIOError</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-keyword'>_</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>return</span> <span class='hs-conid'>False</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span>
|
||||
<a name="line-260"></a> <span class='hs-varid'>fileAccess</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromAbs</span> <span class='hs-varid'>fp</span><span class='hs-layout'>)</span> <span class='hs-conid'>False</span> <span class='hs-conid'>True</span> <span class='hs-conid'>False</span>
|
||||
<a name="line-261"></a>
|
||||
<a name="line-262"></a>
|
||||
<a name="line-263"></a><a name="canOpenDirectory"></a><span class='hs-comment'>-- |Checks whether the directory at the given path exists and can be</span>
|
||||
<a name="line-264"></a><span class='hs-comment'>-- opened. This invokes `openDirStream` which follows symlinks.</span>
|
||||
<a name="line-265"></a><span class='hs-definition'>canOpenDirectory</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
|
||||
<a name="line-266"></a><span class='hs-definition'>canOpenDirectory</span> <span class='hs-varid'>fp</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-267"></a> <span class='hs-varid'>handleIOError</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-keyword'>_</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>return</span> <span class='hs-conid'>False</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-268"></a> <span class='hs-varid'>bracket</span> <span class='hs-layout'>(</span><span class='hs-conid'>PFD</span><span class='hs-varop'>.</span><span class='hs-varid'>openDirStream</span> <span class='hs-varop'>.</span> <span class='hs-varid'>fromAbs</span> <span class='hs-varop'>$</span> <span class='hs-varid'>fp</span><span class='hs-layout'>)</span>
|
||||
<a name="line-269"></a> <span class='hs-conid'>PFD</span><span class='hs-varop'>.</span><span class='hs-varid'>closeDirStream</span>
|
||||
<a name="line-270"></a> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-keyword'>_</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>return</span> <span class='hs-conid'>()</span><span class='hs-layout'>)</span>
|
||||
<a name="line-271"></a> <span class='hs-varid'>return</span> <span class='hs-conid'>True</span>
|
||||
<a name="line-272"></a>
|
||||
<a name="line-273"></a>
|
||||
<a name="line-274"></a><a name="throwCantOpenDirectory"></a><span class='hs-comment'>-- |Throws a `Can'tOpenDirectory` HPathIOException if the directory at the given</span>
|
||||
<a name="line-275"></a><span class='hs-comment'>-- path cannot be opened.</span>
|
||||
<a name="line-276"></a><span class='hs-definition'>throwCantOpenDirectory</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-277"></a><span class='hs-definition'>throwCantOpenDirectory</span> <span class='hs-varid'>fp</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-278"></a> <span class='hs-varid'>unlessM</span> <span class='hs-layout'>(</span><span class='hs-varid'>canOpenDirectory</span> <span class='hs-varid'>fp</span><span class='hs-layout'>)</span>
|
||||
<a name="line-279"></a> <span class='hs-layout'>(</span><span class='hs-varid'>throwIO</span> <span class='hs-varop'>.</span> <span class='hs-conid'>Can'tOpenDirectory</span> <span class='hs-varop'>.</span> <span class='hs-varid'>fromAbs</span> <span class='hs-varop'>$</span> <span class='hs-varid'>fp</span><span class='hs-layout'>)</span>
|
||||
<a name="line-280"></a>
|
||||
<a name="line-281"></a>
|
||||
<a name="line-282"></a>
|
||||
<a name="line-283"></a> <span class='hs-comment'>--------------------------------</span>
|
||||
<a name="line-284"></a> <span class='hs-comment'>--[ Error handling functions ]--</span>
|
||||
<a name="line-285"></a> <span class='hs-comment'>--------------------------------</span>
|
||||
<a name="line-286"></a>
|
||||
<a name="line-287"></a>
|
||||
<a name="line-288"></a><a name="catchErrno"></a><span class='hs-comment'>-- |Carries out an action, then checks if there is an IOException and</span>
|
||||
<a name="line-289"></a><span class='hs-comment'>-- a specific errno. If so, then it carries out another action, otherwise</span>
|
||||
<a name="line-290"></a><span class='hs-comment'>-- it rethrows the error.</span>
|
||||
<a name="line-291"></a><span class='hs-definition'>catchErrno</span> <span class='hs-keyglyph'>::</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>Errno</span><span class='hs-keyglyph'>]</span> <span class='hs-comment'>-- ^ errno to catch</span>
|
||||
<a name="line-292"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>a</span> <span class='hs-comment'>-- ^ action to try, which can raise an IOException</span>
|
||||
<a name="line-293"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>a</span> <span class='hs-comment'>-- ^ action to carry out in case of an IOException and</span>
|
||||
<a name="line-294"></a> <span class='hs-comment'>-- if errno matches</span>
|
||||
<a name="line-295"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>a</span>
|
||||
<a name="line-296"></a><span class='hs-definition'>catchErrno</span> <span class='hs-varid'>en</span> <span class='hs-varid'>a1</span> <span class='hs-varid'>a2</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-297"></a> <span class='hs-varid'>catchIOError</span> <span class='hs-varid'>a1</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>e</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-298"></a> <span class='hs-varid'>errno</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>getErrno</span>
|
||||
<a name="line-299"></a> <span class='hs-keyword'>if</span> <span class='hs-varid'>errno</span> <span class='hs-varop'>`elem`</span> <span class='hs-varid'>en</span>
|
||||
<a name="line-300"></a> <span class='hs-keyword'>then</span> <span class='hs-varid'>a2</span>
|
||||
<a name="line-301"></a> <span class='hs-keyword'>else</span> <span class='hs-varid'>ioError</span> <span class='hs-varid'>e</span>
|
||||
<a name="line-302"></a>
|
||||
<a name="line-303"></a>
|
||||
<a name="line-304"></a><a name="rethrowErrnoAs"></a><span class='hs-comment'>-- |Execute the given action and retrow IO exceptions as a new Exception</span>
|
||||
<a name="line-305"></a><span class='hs-comment'>-- that have the given errno. If errno does not match the exception is rethrown</span>
|
||||
<a name="line-306"></a><span class='hs-comment'>-- as is.</span>
|
||||
<a name="line-307"></a><span class='hs-definition'>rethrowErrnoAs</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Exception</span> <span class='hs-varid'>e</span>
|
||||
<a name="line-308"></a> <span class='hs-keyglyph'>=></span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>Errno</span><span class='hs-keyglyph'>]</span> <span class='hs-comment'>-- ^ errno to catch</span>
|
||||
<a name="line-309"></a> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>e</span> <span class='hs-comment'>-- ^ rethrow as if errno matches</span>
|
||||
<a name="line-310"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>a</span> <span class='hs-comment'>-- ^ action to try</span>
|
||||
<a name="line-311"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>a</span>
|
||||
<a name="line-312"></a><span class='hs-definition'>rethrowErrnoAs</span> <span class='hs-varid'>en</span> <span class='hs-varid'>fmex</span> <span class='hs-varid'>action</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>catchErrno</span> <span class='hs-varid'>en</span> <span class='hs-varid'>action</span> <span class='hs-layout'>(</span><span class='hs-varid'>throwIO</span> <span class='hs-varid'>fmex</span><span class='hs-layout'>)</span>
|
||||
<a name="line-313"></a>
|
||||
<a name="line-314"></a>
|
||||
<a name="line-315"></a>
|
||||
<a name="line-316"></a><a name="handleIOError"></a><span class='hs-comment'>-- |Like `catchIOError`, with arguments swapped.</span>
|
||||
<a name="line-317"></a><span class='hs-definition'>handleIOError</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>IOError</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>a</span>
|
||||
<a name="line-318"></a><span class='hs-definition'>handleIOError</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>flip</span> <span class='hs-varid'>catchIOError</span>
|
||||
<a name="line-319"></a>
|
||||
<a name="line-320"></a>
|
||||
<a name="line-321"></a><a name="bracketeer"></a><span class='hs-comment'>-- |Like `bracket`, but allows to have different clean-up</span>
|
||||
<a name="line-322"></a><span class='hs-comment'>-- actions depending on whether the in-between computation</span>
|
||||
<a name="line-323"></a><span class='hs-comment'>-- has raised an exception or not. </span>
|
||||
<a name="line-324"></a><span class='hs-definition'>bracketeer</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>IO</span> <span class='hs-varid'>a</span> <span class='hs-comment'>-- ^ computation to run first</span>
|
||||
<a name="line-325"></a> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span> <span class='hs-comment'>-- ^ computation to run last, when</span>
|
||||
<a name="line-326"></a> <span class='hs-comment'>-- no exception was raised</span>
|
||||
<a name="line-327"></a> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span> <span class='hs-comment'>-- ^ computation to run last,</span>
|
||||
<a name="line-328"></a> <span class='hs-comment'>-- when an exception was raised</span>
|
||||
<a name="line-329"></a> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-varid'>a</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>c</span><span class='hs-layout'>)</span> <span class='hs-comment'>-- ^ computation to run in-between</span>
|
||||
<a name="line-330"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>c</span>
|
||||
<a name="line-331"></a><span class='hs-definition'>bracketeer</span> <span class='hs-varid'>before</span> <span class='hs-varid'>after</span> <span class='hs-varid'>afterEx</span> <span class='hs-varid'>thing</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-332"></a> <span class='hs-varid'>mask</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>restore</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-333"></a> <span class='hs-varid'>a</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>before</span>
|
||||
<a name="line-334"></a> <span class='hs-varid'>r</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>restore</span> <span class='hs-layout'>(</span><span class='hs-varid'>thing</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-varop'>`onException`</span> <span class='hs-varid'>afterEx</span> <span class='hs-varid'>a</span>
|
||||
<a name="line-335"></a> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>after</span> <span class='hs-varid'>a</span>
|
||||
<a name="line-336"></a> <span class='hs-varid'>return</span> <span class='hs-varid'>r</span>
|
||||
<a name="line-337"></a>
|
||||
<a name="line-338"></a>
|
||||
<a name="line-339"></a><a name="reactOnError"></a><span class='hs-definition'>reactOnError</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>IO</span> <span class='hs-varid'>a</span>
|
||||
<a name="line-340"></a> <span class='hs-keyglyph'>-></span> <span class='hs-keyglyph'>[</span><span class='hs-layout'>(</span><span class='hs-conid'>IOErrorType</span><span class='hs-layout'>,</span> <span class='hs-conid'>IO</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span><span class='hs-keyglyph'>]</span> <span class='hs-comment'>-- ^ reaction on IO errors</span>
|
||||
<a name="line-341"></a> <span class='hs-keyglyph'>-></span> <span class='hs-keyglyph'>[</span><span class='hs-layout'>(</span><span class='hs-conid'>HPathIOException</span><span class='hs-layout'>,</span> <span class='hs-conid'>IO</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span><span class='hs-keyglyph'>]</span> <span class='hs-comment'>-- ^ reaction on HPathIOException</span>
|
||||
<a name="line-342"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>a</span>
|
||||
<a name="line-343"></a><span class='hs-definition'>reactOnError</span> <span class='hs-varid'>a</span> <span class='hs-varid'>ios</span> <span class='hs-varid'>fmios</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-344"></a> <span class='hs-varid'>a</span> <span class='hs-varop'>`catches`</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>iohandler</span><span class='hs-layout'>,</span> <span class='hs-varid'>fmiohandler</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-345"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-346"></a> <span class='hs-varid'>iohandler</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Handler</span> <span class='hs-varop'>$</span>
|
||||
<a name="line-347"></a> <span class='hs-keyglyph'>\</span><span class='hs-layout'>(</span><span class='hs-varid'>ex</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>IOException</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span>
|
||||
<a name="line-348"></a> <span class='hs-varid'>foldr</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-layout'>(</span><span class='hs-varid'>t</span><span class='hs-layout'>,</span> <span class='hs-varid'>a'</span><span class='hs-layout'>)</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>if</span> <span class='hs-varid'>ioeGetErrorType</span> <span class='hs-varid'>ex</span> <span class='hs-varop'>==</span> <span class='hs-varid'>t</span>
|
||||
<a name="line-349"></a> <span class='hs-keyword'>then</span> <span class='hs-varid'>a'</span>
|
||||
<a name="line-350"></a> <span class='hs-keyword'>else</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span>
|
||||
<a name="line-351"></a> <span class='hs-layout'>(</span><span class='hs-varid'>throwIO</span> <span class='hs-varid'>ex</span><span class='hs-layout'>)</span>
|
||||
<a name="line-352"></a> <span class='hs-varid'>ios</span>
|
||||
<a name="line-353"></a> <span class='hs-varid'>fmiohandler</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Handler</span> <span class='hs-varop'>$</span>
|
||||
<a name="line-354"></a> <span class='hs-keyglyph'>\</span><span class='hs-layout'>(</span><span class='hs-varid'>ex</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>HPathIOException</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span>
|
||||
<a name="line-355"></a> <span class='hs-varid'>foldr</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-layout'>(</span><span class='hs-varid'>t</span><span class='hs-layout'>,</span> <span class='hs-varid'>a'</span><span class='hs-layout'>)</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>if</span> <span class='hs-varid'>toConstr</span> <span class='hs-varid'>ex</span> <span class='hs-varop'>==</span> <span class='hs-varid'>toConstr</span> <span class='hs-varid'>t</span>
|
||||
<a name="line-356"></a> <span class='hs-keyword'>then</span> <span class='hs-varid'>a'</span>
|
||||
<a name="line-357"></a> <span class='hs-keyword'>else</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span>
|
||||
<a name="line-358"></a> <span class='hs-layout'>(</span><span class='hs-varid'>throwIO</span> <span class='hs-varid'>ex</span><span class='hs-layout'>)</span>
|
||||
<a name="line-359"></a> <span class='hs-varid'>fmios</span>
|
||||
</pre></body>
|
||||
</html>
|
43
src/HPath-IO-Utils.html
Normal file
43
src/HPath-IO-Utils.html
Normal file
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
|
||||
<title>src/HPath/IO/Utils.hs</title>
|
||||
<link type='text/css' rel='stylesheet' href='hscolour.css' />
|
||||
</head>
|
||||
<body>
|
||||
<pre><a name="line-1"></a><span class='hs-comment'>-- |</span>
|
||||
<a name="line-2"></a><span class='hs-comment'>-- Module : HPath.IO.Utils</span>
|
||||
<a name="line-3"></a><span class='hs-comment'>-- Copyright : © 2016 Julian Ospald</span>
|
||||
<a name="line-4"></a><span class='hs-comment'>-- License : GPL-2</span>
|
||||
<a name="line-5"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-6"></a><span class='hs-comment'>-- Maintainer : Julian Ospald <hasufell@posteo.de></span>
|
||||
<a name="line-7"></a><span class='hs-comment'>-- Stability : experimental</span>
|
||||
<a name="line-8"></a><span class='hs-comment'>-- Portability : portable</span>
|
||||
<a name="line-9"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-10"></a><span class='hs-comment'>-- Random and general IO/monad utilities.</span>
|
||||
<a name="line-11"></a>
|
||||
<a name="line-12"></a>
|
||||
<a name="line-13"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>HPath</span><span class='hs-varop'>.</span><span class='hs-conid'>IO</span><span class='hs-varop'>.</span><span class='hs-conid'>Utils</span> <span class='hs-keyword'>where</span>
|
||||
<a name="line-14"></a>
|
||||
<a name="line-15"></a>
|
||||
<a name="line-16"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Monad</span>
|
||||
<a name="line-17"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-18"></a> <span class='hs-varid'>when</span>
|
||||
<a name="line-19"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>unless</span>
|
||||
<a name="line-20"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-21"></a>
|
||||
<a name="line-22"></a>
|
||||
<a name="line-23"></a><a name="whenM"></a><span class='hs-comment'>-- |If the value of the first argument is True, then execute the action</span>
|
||||
<a name="line-24"></a><span class='hs-comment'>-- provided in the second argument, otherwise do nothing.</span>
|
||||
<a name="line-25"></a><span class='hs-definition'>whenM</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Monad</span> <span class='hs-varid'>m</span> <span class='hs-keyglyph'>=></span> <span class='hs-varid'>m</span> <span class='hs-conid'>Bool</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-conid'>()</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-26"></a><span class='hs-definition'>whenM</span> <span class='hs-varid'>mb</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>mb</span> <span class='hs-varop'>>>=</span> <span class='hs-layout'>(</span><span class='hs-varop'>`when`</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span>
|
||||
<a name="line-27"></a>
|
||||
<a name="line-28"></a>
|
||||
<a name="line-29"></a><a name="unlessM"></a><span class='hs-comment'>-- |If the value of the first argument is False, then execute the action</span>
|
||||
<a name="line-30"></a><span class='hs-comment'>-- provided in the second argument, otherwise do nothing.</span>
|
||||
<a name="line-31"></a><span class='hs-definition'>unlessM</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Monad</span> <span class='hs-varid'>m</span> <span class='hs-keyglyph'>=></span> <span class='hs-varid'>m</span> <span class='hs-conid'>Bool</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-conid'>()</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-32"></a><span class='hs-definition'>unlessM</span> <span class='hs-varid'>mb</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>mb</span> <span class='hs-varop'>>>=</span> <span class='hs-layout'>(</span><span class='hs-varop'>`unless`</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span>
|
||||
</pre></body>
|
||||
</html>
|
909
src/HPath-IO.html
Normal file
909
src/HPath-IO.html
Normal file
@ -0,0 +1,909 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
|
||||
<title>src/HPath/IO.hs</title>
|
||||
<link type='text/css' rel='stylesheet' href='hscolour.css' />
|
||||
</head>
|
||||
<body>
|
||||
<pre><a name="line-1"></a><span class='hs-comment'>-- |</span>
|
||||
<a name="line-2"></a><span class='hs-comment'>-- Module : HPath.IO</span>
|
||||
<a name="line-3"></a><span class='hs-comment'>-- Copyright : © 2016 Julian Ospald</span>
|
||||
<a name="line-4"></a><span class='hs-comment'>-- License : GPL-2</span>
|
||||
<a name="line-5"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-6"></a><span class='hs-comment'>-- Maintainer : Julian Ospald <hasufell@posteo.de></span>
|
||||
<a name="line-7"></a><span class='hs-comment'>-- Stability : experimental</span>
|
||||
<a name="line-8"></a><span class='hs-comment'>-- Portability : portable</span>
|
||||
<a name="line-9"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-10"></a><span class='hs-comment'>-- This module provides high-level IO related file operations like</span>
|
||||
<a name="line-11"></a><span class='hs-comment'>-- copy, delete, move and so on. It only operates on /Path Abs/ which</span>
|
||||
<a name="line-12"></a><span class='hs-comment'>-- guarantees us well-typed paths which are absolute.</span>
|
||||
<a name="line-13"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-14"></a><span class='hs-comment'>-- Some functions are just path-safe wrappers around</span>
|
||||
<a name="line-15"></a><span class='hs-comment'>-- unix functions, others have stricter exception handling</span>
|
||||
<a name="line-16"></a><span class='hs-comment'>-- and some implement functionality that doesn't have a unix</span>
|
||||
<a name="line-17"></a><span class='hs-comment'>-- counterpart (like `copyDirRecursive`).</span>
|
||||
<a name="line-18"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-19"></a><span class='hs-comment'>-- Some of these operations are due to their nature __not atomic__, which</span>
|
||||
<a name="line-20"></a><span class='hs-comment'>-- means they may do multiple syscalls which form one context. Some</span>
|
||||
<a name="line-21"></a><span class='hs-comment'>-- of them also have to examine the filetypes explicitly before the</span>
|
||||
<a name="line-22"></a><span class='hs-comment'>-- syscalls, so a reasonable decision can be made. That means</span>
|
||||
<a name="line-23"></a><span class='hs-comment'>-- the result is undefined if another process changes that context</span>
|
||||
<a name="line-24"></a><span class='hs-comment'>-- while the non-atomic operation is still happening. However, where</span>
|
||||
<a name="line-25"></a><span class='hs-comment'>-- possible, as few syscalls as possible are used and the underlying</span>
|
||||
<a name="line-26"></a><span class='hs-comment'>-- exception handling is kept.</span>
|
||||
<a name="line-27"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-28"></a><span class='hs-comment'>-- Note: `BlockDevice`, `CharacterDevice`, `NamedPipe` and `Socket`</span>
|
||||
<a name="line-29"></a><span class='hs-comment'>-- are ignored by some of the more high-level functions (like `easyCopy`).</span>
|
||||
<a name="line-30"></a><span class='hs-comment'>-- For other functions (like `copyFile`), the behavior on these file types is</span>
|
||||
<a name="line-31"></a><span class='hs-comment'>-- unreliable/unsafe. Check the documentation of those functions for details.</span>
|
||||
<a name="line-32"></a>
|
||||
<a name="line-33"></a><span class='hs-comment'>{-# LANGUAGE PackageImports #-}</span>
|
||||
<a name="line-34"></a><span class='hs-comment'>{-# LANGUAGE OverloadedStrings #-}</span>
|
||||
<a name="line-35"></a>
|
||||
<a name="line-36"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>HPath</span><span class='hs-varop'>.</span><span class='hs-conid'>IO</span>
|
||||
<a name="line-37"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-38"></a> <span class='hs-comment'>-- * Types</span>
|
||||
<a name="line-39"></a> <span class='hs-conid'>FileType</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span>
|
||||
<a name="line-40"></a> <span class='hs-comment'>-- * File copying</span>
|
||||
<a name="line-41"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>copyDirRecursive</span>
|
||||
<a name="line-42"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>copyDirRecursiveOverwrite</span>
|
||||
<a name="line-43"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>recreateSymlink</span>
|
||||
<a name="line-44"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>copyFile</span>
|
||||
<a name="line-45"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>copyFileOverwrite</span>
|
||||
<a name="line-46"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>easyCopy</span>
|
||||
<a name="line-47"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>easyCopyOverwrite</span>
|
||||
<a name="line-48"></a> <span class='hs-comment'>-- * File deletion</span>
|
||||
<a name="line-49"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>deleteFile</span>
|
||||
<a name="line-50"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>deleteDir</span>
|
||||
<a name="line-51"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>deleteDirRecursive</span>
|
||||
<a name="line-52"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>easyDelete</span>
|
||||
<a name="line-53"></a> <span class='hs-comment'>-- * File opening</span>
|
||||
<a name="line-54"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>openFile</span>
|
||||
<a name="line-55"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>executeFile</span>
|
||||
<a name="line-56"></a> <span class='hs-comment'>-- * File creation</span>
|
||||
<a name="line-57"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>createRegularFile</span>
|
||||
<a name="line-58"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>createDir</span>
|
||||
<a name="line-59"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>createSymlink</span>
|
||||
<a name="line-60"></a> <span class='hs-comment'>-- * File renaming/moving</span>
|
||||
<a name="line-61"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>renameFile</span>
|
||||
<a name="line-62"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>moveFile</span>
|
||||
<a name="line-63"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>moveFileOverwrite</span>
|
||||
<a name="line-64"></a> <span class='hs-comment'>-- * File permissions</span>
|
||||
<a name="line-65"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>newFilePerms</span>
|
||||
<a name="line-66"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>newDirPerms</span>
|
||||
<a name="line-67"></a> <span class='hs-comment'>-- * Directory reading</span>
|
||||
<a name="line-68"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>getDirsFiles</span>
|
||||
<a name="line-69"></a> <span class='hs-comment'>-- * Filetype operations</span>
|
||||
<a name="line-70"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>getFileType</span>
|
||||
<a name="line-71"></a> <span class='hs-comment'>-- * Others</span>
|
||||
<a name="line-72"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>canonicalizePath</span>
|
||||
<a name="line-73"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-74"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-75"></a>
|
||||
<a name="line-76"></a>
|
||||
<a name="line-77"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Applicative</span>
|
||||
<a name="line-78"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-79"></a> <span class='hs-layout'>(</span><span class='hs-varop'><$></span><span class='hs-layout'>)</span>
|
||||
<a name="line-80"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-81"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Exception</span>
|
||||
<a name="line-82"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-83"></a> <span class='hs-varid'>bracket</span>
|
||||
<a name="line-84"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>throwIO</span>
|
||||
<a name="line-85"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-86"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Monad</span>
|
||||
<a name="line-87"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-88"></a> <span class='hs-varid'>void</span>
|
||||
<a name="line-89"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>when</span>
|
||||
<a name="line-90"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-91"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span>
|
||||
<a name="line-92"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-93"></a> <span class='hs-conid'>ByteString</span>
|
||||
<a name="line-94"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-95"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Foldable</span>
|
||||
<a name="line-96"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-97"></a> <span class='hs-varid'>for_</span>
|
||||
<a name="line-98"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-99"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Maybe</span>
|
||||
<a name="line-100"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-101"></a> <span class='hs-varid'>catMaybes</span>
|
||||
<a name="line-102"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-103"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Word</span>
|
||||
<a name="line-104"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-105"></a> <span class='hs-conid'>Word8</span>
|
||||
<a name="line-106"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-107"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>C</span><span class='hs-varop'>.</span><span class='hs-conid'>Error</span>
|
||||
<a name="line-108"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-109"></a> <span class='hs-varid'>eEXIST</span>
|
||||
<a name="line-110"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>eINVAL</span>
|
||||
<a name="line-111"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>eNOSYS</span>
|
||||
<a name="line-112"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>eNOTEMPTY</span>
|
||||
<a name="line-113"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>eXDEV</span>
|
||||
<a name="line-114"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-115"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>C</span><span class='hs-varop'>.</span><span class='hs-conid'>Types</span>
|
||||
<a name="line-116"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-117"></a> <span class='hs-conid'>CSize</span>
|
||||
<a name="line-118"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-119"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>Marshal</span><span class='hs-varop'>.</span><span class='hs-conid'>Alloc</span>
|
||||
<a name="line-120"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-121"></a> <span class='hs-varid'>allocaBytes</span>
|
||||
<a name="line-122"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-123"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>Ptr</span>
|
||||
<a name="line-124"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-125"></a> <span class='hs-conid'>Ptr</span>
|
||||
<a name="line-126"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-127"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>GHC</span><span class='hs-varop'>.</span><span class='hs-conid'>IO</span><span class='hs-varop'>.</span><span class='hs-conid'>Exception</span>
|
||||
<a name="line-128"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-129"></a> <span class='hs-conid'>IOErrorType</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span>
|
||||
<a name="line-130"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-131"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>HPath</span>
|
||||
<a name="line-132"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>HPath</span><span class='hs-varop'>.</span><span class='hs-conid'>Internal</span>
|
||||
<a name="line-133"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>HPath</span><span class='hs-varop'>.</span><span class='hs-conid'>IO</span><span class='hs-varop'>.</span><span class='hs-conid'>Errors</span>
|
||||
<a name="line-134"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>HPath</span><span class='hs-varop'>.</span><span class='hs-conid'>IO</span><span class='hs-varop'>.</span><span class='hs-conid'>Utils</span>
|
||||
<a name="line-135"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Prelude</span> <span class='hs-varid'>hiding</span> <span class='hs-layout'>(</span><span class='hs-varid'>readFile</span><span class='hs-layout'>)</span>
|
||||
<a name="line-136"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>IO</span><span class='hs-varop'>.</span><span class='hs-conid'>Error</span>
|
||||
<a name="line-137"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-138"></a> <span class='hs-varid'>catchIOError</span>
|
||||
<a name="line-139"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>ioeGetErrorType</span>
|
||||
<a name="line-140"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-141"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Linux</span><span class='hs-varop'>.</span><span class='hs-conid'>Sendfile</span>
|
||||
<a name="line-142"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-143"></a> <span class='hs-varid'>sendfileFd</span>
|
||||
<a name="line-144"></a> <span class='hs-layout'>,</span> <span class='hs-conid'>FileRange</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span>
|
||||
<a name="line-145"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-146"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span>
|
||||
<a name="line-147"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-148"></a> <span class='hs-varid'>exclusive</span>
|
||||
<a name="line-149"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-150"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Directory</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span>
|
||||
<a name="line-151"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-152"></a> <span class='hs-varid'>createDirectory</span>
|
||||
<a name="line-153"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>removeDirectory</span>
|
||||
<a name="line-154"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-155"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Directory</span><span class='hs-varop'>.</span><span class='hs-conid'>Traversals</span>
|
||||
<a name="line-156"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-157"></a> <span class='hs-varid'>getDirectoryContents'</span>
|
||||
<a name="line-158"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-159"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Files</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span>
|
||||
<a name="line-160"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-161"></a> <span class='hs-varid'>createSymbolicLink</span>
|
||||
<a name="line-162"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>fileMode</span>
|
||||
<a name="line-163"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>getFdStatus</span>
|
||||
<a name="line-164"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>groupExecuteMode</span>
|
||||
<a name="line-165"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>groupReadMode</span>
|
||||
<a name="line-166"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>groupWriteMode</span>
|
||||
<a name="line-167"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>otherExecuteMode</span>
|
||||
<a name="line-168"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>otherReadMode</span>
|
||||
<a name="line-169"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>otherWriteMode</span>
|
||||
<a name="line-170"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>ownerModes</span>
|
||||
<a name="line-171"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>ownerReadMode</span>
|
||||
<a name="line-172"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>ownerWriteMode</span>
|
||||
<a name="line-173"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>readSymbolicLink</span>
|
||||
<a name="line-174"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>removeLink</span>
|
||||
<a name="line-175"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>rename</span>
|
||||
<a name="line-176"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>setFileMode</span>
|
||||
<a name="line-177"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>unionFileModes</span>
|
||||
<a name="line-178"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-179"></a><span class='hs-keyword'>import</span> <span class='hs-keyword'>qualified</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Files</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span> <span class='hs-keyword'>as</span> <span class='hs-conid'>PF</span>
|
||||
<a name="line-180"></a><span class='hs-keyword'>import</span> <span class='hs-keyword'>qualified</span> <span class='hs-str'>"unix"</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>IO</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span> <span class='hs-keyword'>as</span> <span class='hs-conid'>SPI</span>
|
||||
<a name="line-181"></a><span class='hs-keyword'>import</span> <span class='hs-keyword'>qualified</span> <span class='hs-str'>"unix-bytestring"</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>IO</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span> <span class='hs-keyword'>as</span> <span class='hs-conid'>SPB</span>
|
||||
<a name="line-182"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>FD</span>
|
||||
<a name="line-183"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-184"></a> <span class='hs-varid'>openFd</span>
|
||||
<a name="line-185"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-186"></a><span class='hs-keyword'>import</span> <span class='hs-keyword'>qualified</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Directory</span><span class='hs-varop'>.</span><span class='hs-conid'>Traversals</span> <span class='hs-keyword'>as</span> <span class='hs-conid'>SPDT</span>
|
||||
<a name="line-187"></a><span class='hs-keyword'>import</span> <span class='hs-keyword'>qualified</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Directory</span><span class='hs-varop'>.</span><span class='hs-conid'>Foreign</span> <span class='hs-keyword'>as</span> <span class='hs-conid'>SPDF</span>
|
||||
<a name="line-188"></a><span class='hs-keyword'>import</span> <span class='hs-keyword'>qualified</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Process</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span> <span class='hs-keyword'>as</span> <span class='hs-conid'>SPP</span>
|
||||
<a name="line-189"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Types</span>
|
||||
<a name="line-190"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-191"></a> <span class='hs-conid'>FileMode</span>
|
||||
<a name="line-192"></a> <span class='hs-layout'>,</span> <span class='hs-conid'>ProcessID</span>
|
||||
<a name="line-193"></a> <span class='hs-layout'>,</span> <span class='hs-conid'>Fd</span>
|
||||
<a name="line-194"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-195"></a>
|
||||
<a name="line-196"></a>
|
||||
<a name="line-197"></a>
|
||||
<a name="line-198"></a>
|
||||
<a name="line-199"></a>
|
||||
<a name="line-200"></a> <span class='hs-comment'>-------------</span>
|
||||
<a name="line-201"></a> <span class='hs-comment'>--[ Types ]--</span>
|
||||
<a name="line-202"></a> <span class='hs-comment'>-------------</span>
|
||||
<a name="line-203"></a>
|
||||
<a name="line-204"></a>
|
||||
<a name="line-205"></a><a name="FileType"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>FileType</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Directory</span>
|
||||
<a name="line-206"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>RegularFile</span>
|
||||
<a name="line-207"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>SymbolicLink</span>
|
||||
<a name="line-208"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>BlockDevice</span>
|
||||
<a name="line-209"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>CharacterDevice</span>
|
||||
<a name="line-210"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>NamedPipe</span>
|
||||
<a name="line-211"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>Socket</span>
|
||||
<a name="line-212"></a> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span><span class='hs-conid'>Eq</span><span class='hs-layout'>,</span> <span class='hs-conid'>Show</span><span class='hs-layout'>)</span>
|
||||
<a name="line-213"></a>
|
||||
<a name="line-214"></a>
|
||||
<a name="line-215"></a>
|
||||
<a name="line-216"></a>
|
||||
<a name="line-217"></a>
|
||||
<a name="line-218"></a> <span class='hs-comment'>--------------------</span>
|
||||
<a name="line-219"></a> <span class='hs-comment'>--[ File Copying ]--</span>
|
||||
<a name="line-220"></a> <span class='hs-comment'>--------------------</span>
|
||||
<a name="line-221"></a>
|
||||
<a name="line-222"></a>
|
||||
<a name="line-223"></a>
|
||||
<a name="line-224"></a><a name="copyDirRecursive"></a><span class='hs-comment'>-- |Copies a directory recursively to the given destination.</span>
|
||||
<a name="line-225"></a><span class='hs-comment'>-- Does not follow symbolic links.</span>
|
||||
<a name="line-226"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-227"></a><span class='hs-comment'>-- For directory contents, this has the same behavior as `easyCopy`</span>
|
||||
<a name="line-228"></a><span class='hs-comment'>-- and thus will ignore any file type that is not `RegularFile`,</span>
|
||||
<a name="line-229"></a><span class='hs-comment'>-- `SymbolicLink` or `Directory`.</span>
|
||||
<a name="line-230"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-231"></a><span class='hs-comment'>-- Safety/reliability concerns:</span>
|
||||
<a name="line-232"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-233"></a><span class='hs-comment'>-- * not atomic</span>
|
||||
<a name="line-234"></a><span class='hs-comment'>-- * examines filetypes explicitly</span>
|
||||
<a name="line-235"></a><span class='hs-comment'>-- * an explicit check `throwDestinationInSource` is carried out for the</span>
|
||||
<a name="line-236"></a><span class='hs-comment'>-- top directory for basic sanity, because otherwise we might end up</span>
|
||||
<a name="line-237"></a><span class='hs-comment'>-- with an infinite copy loop... however, this operation is not</span>
|
||||
<a name="line-238"></a><span class='hs-comment'>-- carried out recursively (because it's slow)</span>
|
||||
<a name="line-239"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-240"></a><span class='hs-comment'>-- Throws:</span>
|
||||
<a name="line-241"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-242"></a><span class='hs-comment'>-- - `NoSuchThing` if source directory does not exist</span>
|
||||
<a name="line-243"></a><span class='hs-comment'>-- - `PermissionDenied` if output directory is not writable</span>
|
||||
<a name="line-244"></a><span class='hs-comment'>-- - `PermissionDenied` if source directory can't be opened</span>
|
||||
<a name="line-245"></a><span class='hs-comment'>-- - `InvalidArgument` if source directory is wrong type (symlink)</span>
|
||||
<a name="line-246"></a><span class='hs-comment'>-- - `InvalidArgument` if source directory is wrong type (regular file)</span>
|
||||
<a name="line-247"></a><span class='hs-comment'>-- - `AlreadyExists` if destination already exists</span>
|
||||
<a name="line-248"></a><span class='hs-comment'>-- - `SameFile` if source and destination are the same file (`HPathIOException`)</span>
|
||||
<a name="line-249"></a><span class='hs-comment'>-- - `DestinationInSource` if destination is contained in source (`HPathIOException`)</span>
|
||||
<a name="line-250"></a><span class='hs-definition'>copyDirRecursive</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-comment'>-- ^ source dir</span>
|
||||
<a name="line-251"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-comment'>-- ^ full destination</span>
|
||||
<a name="line-252"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-253"></a><span class='hs-definition'>copyDirRecursive</span> <span class='hs-varid'>fromp</span> <span class='hs-varid'>destdirp</span>
|
||||
<a name="line-254"></a> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-255"></a> <span class='hs-comment'>-- for performance, sanity checks are only done for the top dir</span>
|
||||
<a name="line-256"></a> <span class='hs-varid'>throwSameFile</span> <span class='hs-varid'>fromp</span> <span class='hs-varid'>destdirp</span>
|
||||
<a name="line-257"></a> <span class='hs-varid'>throwDestinationInSource</span> <span class='hs-varid'>fromp</span> <span class='hs-varid'>destdirp</span>
|
||||
<a name="line-258"></a> <span class='hs-varid'>go</span> <span class='hs-varid'>fromp</span> <span class='hs-varid'>destdirp</span>
|
||||
<a name="line-259"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-260"></a> <span class='hs-varid'>go</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-261"></a> <span class='hs-varid'>go</span> <span class='hs-varid'>fromp'</span> <span class='hs-varid'>destdirp'</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-262"></a> <span class='hs-comment'>-- order is important here, so we don't get empty directories</span>
|
||||
<a name="line-263"></a> <span class='hs-comment'>-- on failure</span>
|
||||
<a name="line-264"></a> <span class='hs-varid'>contents</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>getDirsFiles</span> <span class='hs-varid'>fromp'</span>
|
||||
<a name="line-265"></a>
|
||||
<a name="line-266"></a> <span class='hs-varid'>fmode'</span> <span class='hs-keyglyph'><-</span> <span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>fileMode</span> <span class='hs-varop'><$></span> <span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>getSymbolicLinkStatus</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromAbs</span> <span class='hs-varid'>fromp'</span><span class='hs-layout'>)</span>
|
||||
<a name="line-267"></a> <span class='hs-varid'>createDirectory</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromAbs</span> <span class='hs-varid'>destdirp'</span><span class='hs-layout'>)</span> <span class='hs-varid'>fmode'</span>
|
||||
<a name="line-268"></a>
|
||||
<a name="line-269"></a> <span class='hs-comment'>-- we can't use `easyCopy` here, because we want to call `go`</span>
|
||||
<a name="line-270"></a> <span class='hs-comment'>-- recursively to skip the top-level sanity checks</span>
|
||||
<a name="line-271"></a> <span class='hs-varid'>for_</span> <span class='hs-varid'>contents</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>f</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-272"></a> <span class='hs-varid'>ftype</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>getFileType</span> <span class='hs-varid'>f</span>
|
||||
<a name="line-273"></a> <span class='hs-varid'>newdest</span> <span class='hs-keyglyph'><-</span> <span class='hs-layout'>(</span><span class='hs-varid'>destdirp'</span> <span class='hs-varop'></></span><span class='hs-layout'>)</span> <span class='hs-varop'><$></span> <span class='hs-varid'>basename</span> <span class='hs-varid'>f</span>
|
||||
<a name="line-274"></a> <span class='hs-keyword'>case</span> <span class='hs-varid'>ftype</span> <span class='hs-keyword'>of</span>
|
||||
<a name="line-275"></a> <span class='hs-conid'>SymbolicLink</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>recreateSymlink</span> <span class='hs-varid'>f</span> <span class='hs-varid'>newdest</span>
|
||||
<a name="line-276"></a> <span class='hs-conid'>Directory</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>go</span> <span class='hs-varid'>f</span> <span class='hs-varid'>newdest</span>
|
||||
<a name="line-277"></a> <span class='hs-conid'>RegularFile</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>copyFile</span> <span class='hs-varid'>f</span> <span class='hs-varid'>newdest</span>
|
||||
<a name="line-278"></a> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>return</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-279"></a>
|
||||
<a name="line-280"></a>
|
||||
<a name="line-281"></a><a name="copyDirRecursiveOverwrite"></a><span class='hs-comment'>-- |Like `copyDirRecursive` except it overwrites contents of directories</span>
|
||||
<a name="line-282"></a><span class='hs-comment'>-- if any.</span>
|
||||
<a name="line-283"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-284"></a><span class='hs-comment'>-- For directory contents, this has the same behavior as `easyCopyOverwrite`</span>
|
||||
<a name="line-285"></a><span class='hs-comment'>-- and thus will ignore any file type that is not `RegularFile`,</span>
|
||||
<a name="line-286"></a><span class='hs-comment'>-- `SymbolicLink` or `Directory`.</span>
|
||||
<a name="line-287"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-288"></a><span class='hs-comment'>-- Throws:</span>
|
||||
<a name="line-289"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-290"></a><span class='hs-comment'>-- - `NoSuchThing` if source directory does not exist</span>
|
||||
<a name="line-291"></a><span class='hs-comment'>-- - `PermissionDenied` if output directory is not writable</span>
|
||||
<a name="line-292"></a><span class='hs-comment'>-- - `PermissionDenied` if source directory can't be opened</span>
|
||||
<a name="line-293"></a><span class='hs-comment'>-- - `InvalidArgument` if source directory is wrong type (symlink)</span>
|
||||
<a name="line-294"></a><span class='hs-comment'>-- - `InvalidArgument` if source directory is wrong type (regular file)</span>
|
||||
<a name="line-295"></a><span class='hs-comment'>-- - `SameFile` if source and destination are the same file (`HPathIOException`)</span>
|
||||
<a name="line-296"></a><span class='hs-comment'>-- - `DestinationInSource` if destination is contained in source (`HPathIOException`)</span>
|
||||
<a name="line-297"></a><span class='hs-definition'>copyDirRecursiveOverwrite</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-comment'>-- ^ source dir</span>
|
||||
<a name="line-298"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-comment'>-- ^ full destination</span>
|
||||
<a name="line-299"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-300"></a><span class='hs-definition'>copyDirRecursiveOverwrite</span> <span class='hs-varid'>fromp</span> <span class='hs-varid'>destdirp</span>
|
||||
<a name="line-301"></a> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-302"></a> <span class='hs-comment'>-- for performance, sanity checks are only done for the top dir</span>
|
||||
<a name="line-303"></a> <span class='hs-varid'>throwSameFile</span> <span class='hs-varid'>fromp</span> <span class='hs-varid'>destdirp</span>
|
||||
<a name="line-304"></a> <span class='hs-varid'>throwDestinationInSource</span> <span class='hs-varid'>fromp</span> <span class='hs-varid'>destdirp</span>
|
||||
<a name="line-305"></a> <span class='hs-varid'>go</span> <span class='hs-varid'>fromp</span> <span class='hs-varid'>destdirp</span>
|
||||
<a name="line-306"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-307"></a> <span class='hs-varid'>go</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-308"></a> <span class='hs-varid'>go</span> <span class='hs-varid'>fromp'</span> <span class='hs-varid'>destdirp'</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-309"></a> <span class='hs-comment'>-- order is important here, so we don't get empty directories</span>
|
||||
<a name="line-310"></a> <span class='hs-comment'>-- on failure</span>
|
||||
<a name="line-311"></a> <span class='hs-varid'>contents</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>getDirsFiles</span> <span class='hs-varid'>fromp'</span>
|
||||
<a name="line-312"></a>
|
||||
<a name="line-313"></a> <span class='hs-varid'>fmode'</span> <span class='hs-keyglyph'><-</span> <span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>fileMode</span> <span class='hs-varop'><$></span> <span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>getSymbolicLinkStatus</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromAbs</span> <span class='hs-varid'>fromp'</span><span class='hs-layout'>)</span>
|
||||
<a name="line-314"></a> <span class='hs-varid'>catchIOError</span> <span class='hs-layout'>(</span><span class='hs-varid'>createDirectory</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromAbs</span> <span class='hs-varid'>destdirp'</span><span class='hs-layout'>)</span> <span class='hs-varid'>fmode'</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>e</span> <span class='hs-keyglyph'>-></span>
|
||||
<a name="line-315"></a> <span class='hs-keyword'>case</span> <span class='hs-varid'>ioeGetErrorType</span> <span class='hs-varid'>e</span> <span class='hs-keyword'>of</span>
|
||||
<a name="line-316"></a> <span class='hs-conid'>AlreadyExists</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>setFileMode</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromAbs</span> <span class='hs-varid'>destdirp'</span><span class='hs-layout'>)</span> <span class='hs-varid'>fmode'</span>
|
||||
<a name="line-317"></a> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>ioError</span> <span class='hs-varid'>e</span>
|
||||
<a name="line-318"></a>
|
||||
<a name="line-319"></a> <span class='hs-comment'>-- we can't use `easyCopyOverwrite` here, because we want to call `go`</span>
|
||||
<a name="line-320"></a> <span class='hs-comment'>-- recursively to skip the top-level sanity checks</span>
|
||||
<a name="line-321"></a> <span class='hs-varid'>for_</span> <span class='hs-varid'>contents</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>f</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-322"></a> <span class='hs-varid'>ftype</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>getFileType</span> <span class='hs-varid'>f</span>
|
||||
<a name="line-323"></a> <span class='hs-varid'>newdest</span> <span class='hs-keyglyph'><-</span> <span class='hs-layout'>(</span><span class='hs-varid'>destdirp'</span> <span class='hs-varop'></></span><span class='hs-layout'>)</span> <span class='hs-varop'><$></span> <span class='hs-varid'>basename</span> <span class='hs-varid'>f</span>
|
||||
<a name="line-324"></a> <span class='hs-keyword'>case</span> <span class='hs-varid'>ftype</span> <span class='hs-keyword'>of</span>
|
||||
<a name="line-325"></a> <span class='hs-conid'>SymbolicLink</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>whenM</span> <span class='hs-layout'>(</span><span class='hs-varid'>doesFileExist</span> <span class='hs-varid'>newdest</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>deleteFile</span> <span class='hs-varid'>newdest</span><span class='hs-layout'>)</span>
|
||||
<a name="line-326"></a> <span class='hs-varop'>>></span> <span class='hs-varid'>recreateSymlink</span> <span class='hs-varid'>f</span> <span class='hs-varid'>newdest</span>
|
||||
<a name="line-327"></a> <span class='hs-conid'>Directory</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>go</span> <span class='hs-varid'>f</span> <span class='hs-varid'>newdest</span>
|
||||
<a name="line-328"></a> <span class='hs-conid'>RegularFile</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>copyFileOverwrite</span> <span class='hs-varid'>f</span> <span class='hs-varid'>newdest</span>
|
||||
<a name="line-329"></a> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>return</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-330"></a>
|
||||
<a name="line-331"></a>
|
||||
<a name="line-332"></a><a name="recreateSymlink"></a><span class='hs-comment'>-- |Recreate a symlink.</span>
|
||||
<a name="line-333"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-334"></a><span class='hs-comment'>-- Throws:</span>
|
||||
<a name="line-335"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-336"></a><span class='hs-comment'>-- - `InvalidArgument` if source file is wrong type (not a symlink)</span>
|
||||
<a name="line-337"></a><span class='hs-comment'>-- - `PermissionDenied` if output directory cannot be written to</span>
|
||||
<a name="line-338"></a><span class='hs-comment'>-- - `PermissionDenied` if source directory cannot be opened</span>
|
||||
<a name="line-339"></a><span class='hs-comment'>-- - `AlreadyExists` if destination file already exists</span>
|
||||
<a name="line-340"></a><span class='hs-comment'>-- - `SameFile` if source and destination are the same file (`HPathIOException`)</span>
|
||||
<a name="line-341"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-342"></a><span class='hs-comment'>-- Note: calls `symlink`</span>
|
||||
<a name="line-343"></a><span class='hs-definition'>recreateSymlink</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-comment'>-- ^ the old symlink file</span>
|
||||
<a name="line-344"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-comment'>-- ^ destination file</span>
|
||||
<a name="line-345"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-346"></a><span class='hs-definition'>recreateSymlink</span> <span class='hs-varid'>symsource</span> <span class='hs-varid'>newsym</span>
|
||||
<a name="line-347"></a> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-348"></a> <span class='hs-varid'>throwSameFile</span> <span class='hs-varid'>symsource</span> <span class='hs-varid'>newsym</span>
|
||||
<a name="line-349"></a> <span class='hs-varid'>sympoint</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>readSymbolicLink</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromAbs</span> <span class='hs-varid'>symsource</span><span class='hs-layout'>)</span>
|
||||
<a name="line-350"></a> <span class='hs-varid'>createSymbolicLink</span> <span class='hs-varid'>sympoint</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromAbs</span> <span class='hs-varid'>newsym</span><span class='hs-layout'>)</span>
|
||||
<a name="line-351"></a>
|
||||
<a name="line-352"></a>
|
||||
<a name="line-353"></a><a name="copyFile"></a><span class='hs-comment'>-- |Copies the given regular file to the given destination.</span>
|
||||
<a name="line-354"></a><span class='hs-comment'>-- Neither follows symbolic links, nor accepts them.</span>
|
||||
<a name="line-355"></a><span class='hs-comment'>-- For "copying" symbolic links, use `recreateSymlink` instead.</span>
|
||||
<a name="line-356"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-357"></a><span class='hs-comment'>-- Note that this is still sort of a low-level function and doesn't</span>
|
||||
<a name="line-358"></a><span class='hs-comment'>-- examine file types. For a more high-level version, use `easyCopy`</span>
|
||||
<a name="line-359"></a><span class='hs-comment'>-- instead.</span>
|
||||
<a name="line-360"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-361"></a><span class='hs-comment'>-- Safety/reliability concerns:</span>
|
||||
<a name="line-362"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-363"></a><span class='hs-comment'>-- * when used on `CharacterDevice`, reads the "contents" and copies</span>
|
||||
<a name="line-364"></a><span class='hs-comment'>-- them to a regular file, which might take indefinitely</span>
|
||||
<a name="line-365"></a><span class='hs-comment'>-- * when used on `BlockDevice`, may either read the "contents"</span>
|
||||
<a name="line-366"></a><span class='hs-comment'>-- and copy them to a regular file (potentially hanging indefinitely)</span>
|
||||
<a name="line-367"></a><span class='hs-comment'>-- or may create a regular empty destination file</span>
|
||||
<a name="line-368"></a><span class='hs-comment'>-- * when used on `NamedPipe`, will hang indefinitely</span>
|
||||
<a name="line-369"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-370"></a><span class='hs-comment'>-- Throws:</span>
|
||||
<a name="line-371"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-372"></a><span class='hs-comment'>-- - `NoSuchThing` if source file does not exist</span>
|
||||
<a name="line-373"></a><span class='hs-comment'>-- - `NoSuchThing` if source file is a a `Socket`</span>
|
||||
<a name="line-374"></a><span class='hs-comment'>-- - `PermissionDenied` if output directory is not writable</span>
|
||||
<a name="line-375"></a><span class='hs-comment'>-- - `PermissionDenied` if source directory can't be opened</span>
|
||||
<a name="line-376"></a><span class='hs-comment'>-- - `InvalidArgument` if source file is wrong type (symlink or directory)</span>
|
||||
<a name="line-377"></a><span class='hs-comment'>-- - `AlreadyExists` if destination already exists</span>
|
||||
<a name="line-378"></a><span class='hs-comment'>-- - `SameFile` if source and destination are the same file (`HPathIOException`)</span>
|
||||
<a name="line-379"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-380"></a><span class='hs-comment'>-- Note: calls `sendfile` and possibly `read`/`write` as fallback</span>
|
||||
<a name="line-381"></a><span class='hs-definition'>copyFile</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-comment'>-- ^ source file</span>
|
||||
<a name="line-382"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-comment'>-- ^ destination file</span>
|
||||
<a name="line-383"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-384"></a><span class='hs-definition'>copyFile</span> <span class='hs-varid'>from</span> <span class='hs-varid'>to</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-385"></a> <span class='hs-varid'>throwSameFile</span> <span class='hs-varid'>from</span> <span class='hs-varid'>to</span>
|
||||
<a name="line-386"></a> <span class='hs-sel'>_copyFile</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>SPDF</span><span class='hs-varop'>.</span><span class='hs-varid'>oNofollow</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-387"></a> <span class='hs-keyglyph'>[</span><span class='hs-conid'>SPDF</span><span class='hs-varop'>.</span><span class='hs-varid'>oNofollow</span><span class='hs-layout'>,</span> <span class='hs-conid'>SPDF</span><span class='hs-varop'>.</span><span class='hs-varid'>oExcl</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-388"></a> <span class='hs-varid'>from</span> <span class='hs-varid'>to</span>
|
||||
<a name="line-389"></a>
|
||||
<a name="line-390"></a>
|
||||
<a name="line-391"></a><a name="copyFileOverwrite"></a><span class='hs-comment'>-- |Like `copyFile` except it overwrites the destination if it already</span>
|
||||
<a name="line-392"></a><span class='hs-comment'>-- exists.</span>
|
||||
<a name="line-393"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-394"></a><span class='hs-comment'>-- Safety/reliability concerns:</span>
|
||||
<a name="line-395"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-396"></a><span class='hs-comment'>-- * when used on `CharacterDevice`, reads the "contents" and copies</span>
|
||||
<a name="line-397"></a><span class='hs-comment'>-- them to a regular file, which might take indefinitely</span>
|
||||
<a name="line-398"></a><span class='hs-comment'>-- * when used on `BlockDevice`, may either read the "contents"</span>
|
||||
<a name="line-399"></a><span class='hs-comment'>-- and copy them to a regular file (potentially hanging indefinitely)</span>
|
||||
<a name="line-400"></a><span class='hs-comment'>-- or may create a regular empty destination file</span>
|
||||
<a name="line-401"></a><span class='hs-comment'>-- * when used on `NamedPipe`, will hang indefinitely</span>
|
||||
<a name="line-402"></a><span class='hs-comment'>-- * not atomic, since it uses read/write</span>
|
||||
<a name="line-403"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-404"></a><span class='hs-comment'>-- Throws:</span>
|
||||
<a name="line-405"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-406"></a><span class='hs-comment'>-- - `NoSuchThing` if source file does not exist</span>
|
||||
<a name="line-407"></a><span class='hs-comment'>-- - `NoSuchThing` if source file is a `Socket`</span>
|
||||
<a name="line-408"></a><span class='hs-comment'>-- - `PermissionDenied` if output directory is not writable</span>
|
||||
<a name="line-409"></a><span class='hs-comment'>-- - `PermissionDenied` if source directory can't be opened</span>
|
||||
<a name="line-410"></a><span class='hs-comment'>-- - `InvalidArgument` if source file is wrong type (symlink or directory)</span>
|
||||
<a name="line-411"></a><span class='hs-comment'>-- - `SameFile` if source and destination are the same file (`HPathIOException`)</span>
|
||||
<a name="line-412"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-413"></a><span class='hs-comment'>-- Note: calls `sendfile` and possibly `read`/`write` as fallback</span>
|
||||
<a name="line-414"></a><span class='hs-definition'>copyFileOverwrite</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-comment'>-- ^ source file</span>
|
||||
<a name="line-415"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-comment'>-- ^ destination file</span>
|
||||
<a name="line-416"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-417"></a><span class='hs-definition'>copyFileOverwrite</span> <span class='hs-varid'>from</span> <span class='hs-varid'>to</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-418"></a> <span class='hs-varid'>throwSameFile</span> <span class='hs-varid'>from</span> <span class='hs-varid'>to</span>
|
||||
<a name="line-419"></a> <span class='hs-varid'>catchIOError</span> <span class='hs-layout'>(</span><span class='hs-sel'>_copyFile</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>SPDF</span><span class='hs-varop'>.</span><span class='hs-varid'>oNofollow</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-420"></a> <span class='hs-keyglyph'>[</span><span class='hs-conid'>SPDF</span><span class='hs-varop'>.</span><span class='hs-varid'>oNofollow</span><span class='hs-layout'>,</span> <span class='hs-conid'>SPDF</span><span class='hs-varop'>.</span><span class='hs-varid'>oTrunc</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-421"></a> <span class='hs-varid'>from</span> <span class='hs-varid'>to</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>e</span> <span class='hs-keyglyph'>-></span>
|
||||
<a name="line-422"></a> <span class='hs-keyword'>case</span> <span class='hs-varid'>ioeGetErrorType</span> <span class='hs-varid'>e</span> <span class='hs-keyword'>of</span>
|
||||
<a name="line-423"></a> <span class='hs-comment'>-- if the destination file is not writable, we need to</span>
|
||||
<a name="line-424"></a> <span class='hs-comment'>-- figure out if we can still copy by deleting it first</span>
|
||||
<a name="line-425"></a> <span class='hs-conid'>PermissionDenied</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-426"></a> <span class='hs-varid'>exists</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>doesFileExist</span> <span class='hs-varid'>to</span>
|
||||
<a name="line-427"></a> <span class='hs-varid'>writable</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>isWritable</span> <span class='hs-layout'>(</span><span class='hs-varid'>dirname</span> <span class='hs-varid'>to</span><span class='hs-layout'>)</span>
|
||||
<a name="line-428"></a> <span class='hs-keyword'>if</span> <span class='hs-varid'>exists</span> <span class='hs-varop'>&&</span> <span class='hs-varid'>writable</span>
|
||||
<a name="line-429"></a> <span class='hs-keyword'>then</span> <span class='hs-varid'>deleteFile</span> <span class='hs-varid'>to</span> <span class='hs-varop'>>></span> <span class='hs-varid'>copyFile</span> <span class='hs-varid'>from</span> <span class='hs-varid'>to</span>
|
||||
<a name="line-430"></a> <span class='hs-keyword'>else</span> <span class='hs-varid'>ioError</span> <span class='hs-varid'>e</span>
|
||||
<a name="line-431"></a> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>ioError</span> <span class='hs-varid'>e</span>
|
||||
<a name="line-432"></a>
|
||||
<a name="line-433"></a>
|
||||
<a name="line-434"></a><span class='hs-sel'>_copyFile</span> <span class='hs-keyglyph'>::</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>SPDF</span><span class='hs-varop'>.</span><span class='hs-conid'>Flags</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-435"></a> <span class='hs-keyglyph'>-></span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>SPDF</span><span class='hs-varop'>.</span><span class='hs-conid'>Flags</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-436"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-comment'>-- ^ source file</span>
|
||||
<a name="line-437"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-comment'>-- ^ destination file</span>
|
||||
<a name="line-438"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-439"></a><span class='hs-sel'>_copyFile</span> <span class='hs-varid'>sflags</span> <span class='hs-varid'>dflags</span> <span class='hs-varid'>from</span> <span class='hs-varid'>to</span>
|
||||
<a name="line-440"></a> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-441"></a> <span class='hs-comment'>-- from sendfile(2) manpage:</span>
|
||||
<a name="line-442"></a> <span class='hs-comment'>-- Applications may wish to fall back to read(2)/write(2) in the case</span>
|
||||
<a name="line-443"></a> <span class='hs-comment'>-- where sendfile() fails with EINVAL or ENOSYS.</span>
|
||||
<a name="line-444"></a> <span class='hs-varid'>withAbsPath</span> <span class='hs-varid'>to</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>to'</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>withAbsPath</span> <span class='hs-varid'>from</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>from'</span> <span class='hs-keyglyph'>-></span>
|
||||
<a name="line-445"></a> <span class='hs-varid'>catchErrno</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>eINVAL</span><span class='hs-layout'>,</span> <span class='hs-varid'>eNOSYS</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-446"></a> <span class='hs-layout'>(</span><span class='hs-varid'>sendFileCopy</span> <span class='hs-varid'>from'</span> <span class='hs-varid'>to'</span><span class='hs-layout'>)</span>
|
||||
<a name="line-447"></a> <span class='hs-layout'>(</span><span class='hs-varid'>void</span> <span class='hs-varop'>$</span> <span class='hs-varid'>readWriteCopy</span> <span class='hs-varid'>from'</span> <span class='hs-varid'>to'</span><span class='hs-layout'>)</span>
|
||||
<a name="line-448"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-449"></a> <span class='hs-varid'>copyWith</span> <span class='hs-varid'>copyAction</span> <span class='hs-varid'>source</span> <span class='hs-varid'>dest</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-450"></a> <span class='hs-varid'>bracket</span> <span class='hs-layout'>(</span><span class='hs-varid'>openFd</span> <span class='hs-varid'>source</span> <span class='hs-conid'>SPI</span><span class='hs-varop'>.</span><span class='hs-conid'>ReadOnly</span> <span class='hs-varid'>sflags</span> <span class='hs-conid'>Nothing</span><span class='hs-layout'>)</span>
|
||||
<a name="line-451"></a> <span class='hs-conid'>SPI</span><span class='hs-varop'>.</span><span class='hs-varid'>closeFd</span>
|
||||
<a name="line-452"></a> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>sfd</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-453"></a> <span class='hs-varid'>fileM</span> <span class='hs-keyglyph'><-</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Files</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span><span class='hs-varop'>.</span><span class='hs-varid'>fileMode</span>
|
||||
<a name="line-454"></a> <span class='hs-varop'><$></span> <span class='hs-varid'>getFdStatus</span> <span class='hs-varid'>sfd</span>
|
||||
<a name="line-455"></a> <span class='hs-varid'>bracketeer</span> <span class='hs-layout'>(</span><span class='hs-varid'>openFd</span> <span class='hs-varid'>dest</span> <span class='hs-conid'>SPI</span><span class='hs-varop'>.</span><span class='hs-conid'>WriteOnly</span>
|
||||
<a name="line-456"></a> <span class='hs-varid'>dflags</span> <span class='hs-varop'>$</span> <span class='hs-conid'>Just</span> <span class='hs-varid'>fileM</span><span class='hs-layout'>)</span>
|
||||
<a name="line-457"></a> <span class='hs-conid'>SPI</span><span class='hs-varop'>.</span><span class='hs-varid'>closeFd</span>
|
||||
<a name="line-458"></a> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>fd</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>SPI</span><span class='hs-varop'>.</span><span class='hs-varid'>closeFd</span> <span class='hs-varid'>fd</span> <span class='hs-varop'>>></span> <span class='hs-varid'>deleteFile</span> <span class='hs-varid'>to</span><span class='hs-layout'>)</span>
|
||||
<a name="line-459"></a> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>dfd</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>copyAction</span> <span class='hs-varid'>sfd</span> <span class='hs-varid'>dfd</span>
|
||||
<a name="line-460"></a> <span class='hs-comment'>-- this is low-level stuff utilizing sendfile(2) for speed</span>
|
||||
<a name="line-461"></a> <span class='hs-varid'>sendFileCopy</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>ByteString</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>ByteString</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-462"></a> <span class='hs-varid'>sendFileCopy</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>copyWith</span>
|
||||
<a name="line-463"></a> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>sfd</span> <span class='hs-varid'>dfd</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>sendfileFd</span> <span class='hs-varid'>dfd</span> <span class='hs-varid'>sfd</span> <span class='hs-conid'>EntireFile</span> <span class='hs-varop'>$</span> <span class='hs-varid'>return</span> <span class='hs-conid'>()</span><span class='hs-layout'>)</span>
|
||||
<a name="line-464"></a> <span class='hs-comment'>-- low-level copy operation utilizing read(2)/write(2)</span>
|
||||
<a name="line-465"></a> <span class='hs-comment'>-- in case `sendFileCopy` fails/is unsupported</span>
|
||||
<a name="line-466"></a> <span class='hs-varid'>readWriteCopy</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>ByteString</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>ByteString</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Int</span>
|
||||
<a name="line-467"></a> <span class='hs-varid'>readWriteCopy</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>copyWith</span>
|
||||
<a name="line-468"></a> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>sfd</span> <span class='hs-varid'>dfd</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>allocaBytes</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>bufSize</span><span class='hs-layout'>)</span>
|
||||
<a name="line-469"></a> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>buf</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>write'</span> <span class='hs-varid'>sfd</span> <span class='hs-varid'>dfd</span> <span class='hs-varid'>buf</span> <span class='hs-num'>0</span><span class='hs-layout'>)</span>
|
||||
<a name="line-470"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-471"></a> <span class='hs-varid'>bufSize</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>CSize</span>
|
||||
<a name="line-472"></a> <span class='hs-varid'>bufSize</span> <span class='hs-keyglyph'>=</span> <span class='hs-num'>8192</span>
|
||||
<a name="line-473"></a> <span class='hs-varid'>write'</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Fd</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Fd</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Ptr</span> <span class='hs-conid'>Word8</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Int</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Int</span>
|
||||
<a name="line-474"></a> <span class='hs-varid'>write'</span> <span class='hs-varid'>sfd</span> <span class='hs-varid'>dfd</span> <span class='hs-varid'>buf</span> <span class='hs-varid'>totalsize</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-475"></a> <span class='hs-varid'>size</span> <span class='hs-keyglyph'><-</span> <span class='hs-conid'>SPB</span><span class='hs-varop'>.</span><span class='hs-varid'>fdReadBuf</span> <span class='hs-varid'>sfd</span> <span class='hs-varid'>buf</span> <span class='hs-varid'>bufSize</span>
|
||||
<a name="line-476"></a> <span class='hs-keyword'>if</span> <span class='hs-varid'>size</span> <span class='hs-varop'>==</span> <span class='hs-num'>0</span>
|
||||
<a name="line-477"></a> <span class='hs-keyword'>then</span> <span class='hs-varid'>return</span> <span class='hs-varop'>$</span> <span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>totalsize</span>
|
||||
<a name="line-478"></a> <span class='hs-keyword'>else</span> <span class='hs-keyword'>do</span> <span class='hs-varid'>rsize</span> <span class='hs-keyglyph'><-</span> <span class='hs-conid'>SPB</span><span class='hs-varop'>.</span><span class='hs-varid'>fdWriteBuf</span> <span class='hs-varid'>dfd</span> <span class='hs-varid'>buf</span> <span class='hs-varid'>size</span>
|
||||
<a name="line-479"></a> <span class='hs-varid'>when</span> <span class='hs-layout'>(</span><span class='hs-varid'>rsize</span> <span class='hs-varop'>/=</span> <span class='hs-varid'>size</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>throwIO</span> <span class='hs-varop'>.</span> <span class='hs-conid'>CopyFailed</span> <span class='hs-varop'>$</span> <span class='hs-str'>"wrong size!"</span><span class='hs-layout'>)</span>
|
||||
<a name="line-480"></a> <span class='hs-varid'>write'</span> <span class='hs-varid'>sfd</span> <span class='hs-varid'>dfd</span> <span class='hs-varid'>buf</span> <span class='hs-layout'>(</span><span class='hs-varid'>totalsize</span> <span class='hs-varop'>+</span> <span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>size</span><span class='hs-layout'>)</span>
|
||||
<a name="line-481"></a>
|
||||
<a name="line-482"></a>
|
||||
<a name="line-483"></a><a name="easyCopy"></a><span class='hs-comment'>-- |Copies a regular file, directory or symbolic link. In case of a</span>
|
||||
<a name="line-484"></a><span class='hs-comment'>-- symbolic link it is just recreated, even if it points to a directory.</span>
|
||||
<a name="line-485"></a><span class='hs-comment'>-- Any other file type is ignored.</span>
|
||||
<a name="line-486"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-487"></a><span class='hs-comment'>-- Safety/reliability concerns:</span>
|
||||
<a name="line-488"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-489"></a><span class='hs-comment'>-- * examines filetypes explicitly</span>
|
||||
<a name="line-490"></a><span class='hs-comment'>-- * calls `copyDirRecursive` for directories</span>
|
||||
<a name="line-491"></a><span class='hs-definition'>easyCopy</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span>
|
||||
<a name="line-492"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span>
|
||||
<a name="line-493"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-494"></a><span class='hs-definition'>easyCopy</span> <span class='hs-varid'>from</span> <span class='hs-varid'>to</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-495"></a> <span class='hs-varid'>ftype</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>getFileType</span> <span class='hs-varid'>from</span>
|
||||
<a name="line-496"></a> <span class='hs-keyword'>case</span> <span class='hs-varid'>ftype</span> <span class='hs-keyword'>of</span>
|
||||
<a name="line-497"></a> <span class='hs-conid'>SymbolicLink</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>recreateSymlink</span> <span class='hs-varid'>from</span> <span class='hs-varid'>to</span>
|
||||
<a name="line-498"></a> <span class='hs-conid'>RegularFile</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>copyFile</span> <span class='hs-varid'>from</span> <span class='hs-varid'>to</span>
|
||||
<a name="line-499"></a> <span class='hs-conid'>Directory</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>copyDirRecursive</span> <span class='hs-varid'>from</span> <span class='hs-varid'>to</span>
|
||||
<a name="line-500"></a> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>return</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-501"></a>
|
||||
<a name="line-502"></a>
|
||||
<a name="line-503"></a><a name="easyCopyOverwrite"></a><span class='hs-comment'>-- |Like `easyCopy` except it overwrites the destination if it already exists.</span>
|
||||
<a name="line-504"></a><span class='hs-comment'>-- For directories, this overwrites contents without pruning them, so the resulting</span>
|
||||
<a name="line-505"></a><span class='hs-comment'>-- directory may have more files than have been copied.</span>
|
||||
<a name="line-506"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-507"></a><span class='hs-comment'>-- Safety/reliability concerns:</span>
|
||||
<a name="line-508"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-509"></a><span class='hs-comment'>-- * examines filetypes explicitly</span>
|
||||
<a name="line-510"></a><span class='hs-comment'>-- * calls `copyDirRecursive` for directories</span>
|
||||
<a name="line-511"></a><span class='hs-definition'>easyCopyOverwrite</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span>
|
||||
<a name="line-512"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span>
|
||||
<a name="line-513"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-514"></a><span class='hs-definition'>easyCopyOverwrite</span> <span class='hs-varid'>from</span> <span class='hs-varid'>to</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-515"></a> <span class='hs-varid'>ftype</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>getFileType</span> <span class='hs-varid'>from</span>
|
||||
<a name="line-516"></a> <span class='hs-keyword'>case</span> <span class='hs-varid'>ftype</span> <span class='hs-keyword'>of</span>
|
||||
<a name="line-517"></a> <span class='hs-conid'>SymbolicLink</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>whenM</span> <span class='hs-layout'>(</span><span class='hs-varid'>doesFileExist</span> <span class='hs-varid'>to</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>deleteFile</span> <span class='hs-varid'>to</span><span class='hs-layout'>)</span>
|
||||
<a name="line-518"></a> <span class='hs-varop'>>></span> <span class='hs-varid'>recreateSymlink</span> <span class='hs-varid'>from</span> <span class='hs-varid'>to</span>
|
||||
<a name="line-519"></a> <span class='hs-conid'>RegularFile</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>copyFileOverwrite</span> <span class='hs-varid'>from</span> <span class='hs-varid'>to</span>
|
||||
<a name="line-520"></a> <span class='hs-conid'>Directory</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>copyDirRecursiveOverwrite</span> <span class='hs-varid'>from</span> <span class='hs-varid'>to</span>
|
||||
<a name="line-521"></a> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>return</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-522"></a>
|
||||
<a name="line-523"></a>
|
||||
<a name="line-524"></a>
|
||||
<a name="line-525"></a>
|
||||
<a name="line-526"></a>
|
||||
<a name="line-527"></a>
|
||||
<a name="line-528"></a> <span class='hs-comment'>---------------------</span>
|
||||
<a name="line-529"></a> <span class='hs-comment'>--[ File Deletion ]--</span>
|
||||
<a name="line-530"></a> <span class='hs-comment'>---------------------</span>
|
||||
<a name="line-531"></a>
|
||||
<a name="line-532"></a>
|
||||
<a name="line-533"></a><a name="deleteFile"></a><span class='hs-comment'>-- |Deletes the given file. Raises `eISDIR`</span>
|
||||
<a name="line-534"></a><span class='hs-comment'>-- if run on a directory. Does not follow symbolic links.</span>
|
||||
<a name="line-535"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-536"></a><span class='hs-comment'>-- Throws:</span>
|
||||
<a name="line-537"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-538"></a><span class='hs-comment'>-- - `InappropriateType` for wrong file type (directory)</span>
|
||||
<a name="line-539"></a><span class='hs-comment'>-- - `NoSuchThing` if the file does not exist</span>
|
||||
<a name="line-540"></a><span class='hs-comment'>-- - `PermissionDenied` if the directory cannot be read</span>
|
||||
<a name="line-541"></a><span class='hs-definition'>deleteFile</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-542"></a><span class='hs-definition'>deleteFile</span> <span class='hs-varid'>p</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>withAbsPath</span> <span class='hs-varid'>p</span> <span class='hs-varid'>removeLink</span>
|
||||
<a name="line-543"></a>
|
||||
<a name="line-544"></a>
|
||||
<a name="line-545"></a><a name="deleteDir"></a><span class='hs-comment'>-- |Deletes the given directory, which must be empty, never symlinks.</span>
|
||||
<a name="line-546"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-547"></a><span class='hs-comment'>-- Throws:</span>
|
||||
<a name="line-548"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-549"></a><span class='hs-comment'>-- - `InappropriateType` for wrong file type (symlink to directory)</span>
|
||||
<a name="line-550"></a><span class='hs-comment'>-- - `InappropriateType` for wrong file type (regular file)</span>
|
||||
<a name="line-551"></a><span class='hs-comment'>-- - `NoSuchThing` if directory does not exist</span>
|
||||
<a name="line-552"></a><span class='hs-comment'>-- - `UnsatisfiedConstraints` if directory is not empty</span>
|
||||
<a name="line-553"></a><span class='hs-comment'>-- - `PermissionDenied` if we can't open or write to parent directory</span>
|
||||
<a name="line-554"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-555"></a><span class='hs-comment'>-- Notes: calls `rmdir`</span>
|
||||
<a name="line-556"></a><span class='hs-definition'>deleteDir</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-557"></a><span class='hs-definition'>deleteDir</span> <span class='hs-varid'>p</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>withAbsPath</span> <span class='hs-varid'>p</span> <span class='hs-varid'>removeDirectory</span>
|
||||
<a name="line-558"></a>
|
||||
<a name="line-559"></a>
|
||||
<a name="line-560"></a><a name="deleteDirRecursive"></a><span class='hs-comment'>-- |Deletes the given directory recursively. Does not follow symbolic</span>
|
||||
<a name="line-561"></a><span class='hs-comment'>-- links. Tries `deleteDir` first before attemtping a recursive</span>
|
||||
<a name="line-562"></a><span class='hs-comment'>-- deletion.</span>
|
||||
<a name="line-563"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-564"></a><span class='hs-comment'>-- On directory contents this behaves like `easyDelete`</span>
|
||||
<a name="line-565"></a><span class='hs-comment'>-- and thus will ignore any file type that is not `RegularFile`,</span>
|
||||
<a name="line-566"></a><span class='hs-comment'>-- `SymbolicLink` or `Directory`.</span>
|
||||
<a name="line-567"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-568"></a><span class='hs-comment'>-- Safety/reliability concerns:</span>
|
||||
<a name="line-569"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-570"></a><span class='hs-comment'>-- * not atomic</span>
|
||||
<a name="line-571"></a><span class='hs-comment'>-- * examines filetypes explicitly</span>
|
||||
<a name="line-572"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-573"></a><span class='hs-comment'>-- Throws:</span>
|
||||
<a name="line-574"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-575"></a><span class='hs-comment'>-- - `InappropriateType` for wrong file type (symlink to directory)</span>
|
||||
<a name="line-576"></a><span class='hs-comment'>-- - `InappropriateType` for wrong file type (regular file)</span>
|
||||
<a name="line-577"></a><span class='hs-comment'>-- - `NoSuchThing` if directory does not exist</span>
|
||||
<a name="line-578"></a><span class='hs-comment'>-- - `PermissionDenied` if we can't open or write to parent directory</span>
|
||||
<a name="line-579"></a><span class='hs-definition'>deleteDirRecursive</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-580"></a><span class='hs-definition'>deleteDirRecursive</span> <span class='hs-varid'>p</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-581"></a> <span class='hs-varid'>catchErrno</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>eNOTEMPTY</span><span class='hs-layout'>,</span> <span class='hs-varid'>eEXIST</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-582"></a> <span class='hs-layout'>(</span><span class='hs-varid'>deleteDir</span> <span class='hs-varid'>p</span><span class='hs-layout'>)</span>
|
||||
<a name="line-583"></a> <span class='hs-varop'>$</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-584"></a> <span class='hs-varid'>files</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>getDirsFiles</span> <span class='hs-varid'>p</span>
|
||||
<a name="line-585"></a> <span class='hs-varid'>for_</span> <span class='hs-varid'>files</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>file</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-586"></a> <span class='hs-varid'>ftype</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>getFileType</span> <span class='hs-varid'>file</span>
|
||||
<a name="line-587"></a> <span class='hs-keyword'>case</span> <span class='hs-varid'>ftype</span> <span class='hs-keyword'>of</span>
|
||||
<a name="line-588"></a> <span class='hs-conid'>SymbolicLink</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>deleteFile</span> <span class='hs-varid'>file</span>
|
||||
<a name="line-589"></a> <span class='hs-conid'>Directory</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>deleteDirRecursive</span> <span class='hs-varid'>file</span>
|
||||
<a name="line-590"></a> <span class='hs-conid'>RegularFile</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>deleteFile</span> <span class='hs-varid'>file</span>
|
||||
<a name="line-591"></a> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>return</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-592"></a> <span class='hs-varid'>removeDirectory</span> <span class='hs-varop'>.</span> <span class='hs-varid'>toFilePath</span> <span class='hs-varop'>$</span> <span class='hs-varid'>p</span>
|
||||
<a name="line-593"></a>
|
||||
<a name="line-594"></a>
|
||||
<a name="line-595"></a><a name="easyDelete"></a><span class='hs-comment'>-- |Deletes a file, directory or symlink.</span>
|
||||
<a name="line-596"></a><span class='hs-comment'>-- In case of directory, performs recursive deletion. In case of</span>
|
||||
<a name="line-597"></a><span class='hs-comment'>-- a symlink, the symlink file is deleted.</span>
|
||||
<a name="line-598"></a><span class='hs-comment'>-- Any other file type is ignored.</span>
|
||||
<a name="line-599"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-600"></a><span class='hs-comment'>-- Safety/reliability concerns:</span>
|
||||
<a name="line-601"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-602"></a><span class='hs-comment'>-- * examines filetypes explicitly</span>
|
||||
<a name="line-603"></a><span class='hs-comment'>-- * calls `deleteDirRecursive` for directories</span>
|
||||
<a name="line-604"></a><span class='hs-definition'>easyDelete</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-605"></a><span class='hs-definition'>easyDelete</span> <span class='hs-varid'>p</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-606"></a> <span class='hs-varid'>ftype</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>getFileType</span> <span class='hs-varid'>p</span>
|
||||
<a name="line-607"></a> <span class='hs-keyword'>case</span> <span class='hs-varid'>ftype</span> <span class='hs-keyword'>of</span>
|
||||
<a name="line-608"></a> <span class='hs-conid'>SymbolicLink</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>deleteFile</span> <span class='hs-varid'>p</span>
|
||||
<a name="line-609"></a> <span class='hs-conid'>Directory</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>deleteDirRecursive</span> <span class='hs-varid'>p</span>
|
||||
<a name="line-610"></a> <span class='hs-conid'>RegularFile</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>deleteFile</span> <span class='hs-varid'>p</span>
|
||||
<a name="line-611"></a> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>return</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-612"></a>
|
||||
<a name="line-613"></a>
|
||||
<a name="line-614"></a>
|
||||
<a name="line-615"></a>
|
||||
<a name="line-616"></a> <span class='hs-comment'>--------------------</span>
|
||||
<a name="line-617"></a> <span class='hs-comment'>--[ File Opening ]--</span>
|
||||
<a name="line-618"></a> <span class='hs-comment'>--------------------</span>
|
||||
<a name="line-619"></a>
|
||||
<a name="line-620"></a>
|
||||
<a name="line-621"></a><a name="openFile"></a><span class='hs-comment'>-- |Opens a file appropriately by invoking xdg-open. The file type</span>
|
||||
<a name="line-622"></a><span class='hs-comment'>-- is not checked. This forks a process.</span>
|
||||
<a name="line-623"></a><span class='hs-definition'>openFile</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span>
|
||||
<a name="line-624"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>ProcessID</span>
|
||||
<a name="line-625"></a><span class='hs-definition'>openFile</span> <span class='hs-varid'>p</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-626"></a> <span class='hs-varid'>withAbsPath</span> <span class='hs-varid'>p</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>fp</span> <span class='hs-keyglyph'>-></span>
|
||||
<a name="line-627"></a> <span class='hs-conid'>SPP</span><span class='hs-varop'>.</span><span class='hs-varid'>forkProcess</span> <span class='hs-varop'>$</span> <span class='hs-conid'>SPP</span><span class='hs-varop'>.</span><span class='hs-varid'>executeFile</span> <span class='hs-str'>"xdg-open"</span> <span class='hs-conid'>True</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>fp</span><span class='hs-keyglyph'>]</span> <span class='hs-conid'>Nothing</span>
|
||||
<a name="line-628"></a>
|
||||
<a name="line-629"></a>
|
||||
<a name="line-630"></a><a name="executeFile"></a><span class='hs-comment'>-- |Executes a program with the given arguments. This forks a process.</span>
|
||||
<a name="line-631"></a><span class='hs-definition'>executeFile</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-comment'>-- ^ program</span>
|
||||
<a name="line-632"></a> <span class='hs-keyglyph'>-></span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>ByteString</span><span class='hs-keyglyph'>]</span> <span class='hs-comment'>-- ^ arguments</span>
|
||||
<a name="line-633"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>ProcessID</span>
|
||||
<a name="line-634"></a><span class='hs-definition'>executeFile</span> <span class='hs-varid'>fp</span> <span class='hs-varid'>args</span>
|
||||
<a name="line-635"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>withAbsPath</span> <span class='hs-varid'>fp</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>fpb</span> <span class='hs-keyglyph'>-></span>
|
||||
<a name="line-636"></a> <span class='hs-conid'>SPP</span><span class='hs-varop'>.</span><span class='hs-varid'>forkProcess</span>
|
||||
<a name="line-637"></a> <span class='hs-varop'>$</span> <span class='hs-conid'>SPP</span><span class='hs-varop'>.</span><span class='hs-varid'>executeFile</span> <span class='hs-varid'>fpb</span> <span class='hs-conid'>True</span> <span class='hs-varid'>args</span> <span class='hs-conid'>Nothing</span>
|
||||
<a name="line-638"></a>
|
||||
<a name="line-639"></a>
|
||||
<a name="line-640"></a>
|
||||
<a name="line-641"></a>
|
||||
<a name="line-642"></a> <span class='hs-comment'>---------------------</span>
|
||||
<a name="line-643"></a> <span class='hs-comment'>--[ File Creation ]--</span>
|
||||
<a name="line-644"></a> <span class='hs-comment'>---------------------</span>
|
||||
<a name="line-645"></a>
|
||||
<a name="line-646"></a>
|
||||
<a name="line-647"></a><a name="createRegularFile"></a><span class='hs-comment'>-- |Create an empty regular file at the given directory with the given filename.</span>
|
||||
<a name="line-648"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-649"></a><span class='hs-comment'>-- Throws:</span>
|
||||
<a name="line-650"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-651"></a><span class='hs-comment'>-- - `PermissionDenied` if output directory cannot be written to</span>
|
||||
<a name="line-652"></a><span class='hs-comment'>-- - `AlreadyExists` if destination file already exists</span>
|
||||
<a name="line-653"></a><span class='hs-definition'>createRegularFile</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-654"></a><span class='hs-definition'>createRegularFile</span> <span class='hs-varid'>dest</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-655"></a> <span class='hs-varid'>bracket</span> <span class='hs-layout'>(</span><span class='hs-conid'>SPI</span><span class='hs-varop'>.</span><span class='hs-varid'>openFd</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromAbs</span> <span class='hs-varid'>dest</span><span class='hs-layout'>)</span> <span class='hs-conid'>SPI</span><span class='hs-varop'>.</span><span class='hs-conid'>WriteOnly</span> <span class='hs-layout'>(</span><span class='hs-conid'>Just</span> <span class='hs-varid'>newFilePerms</span><span class='hs-layout'>)</span>
|
||||
<a name="line-656"></a> <span class='hs-layout'>(</span><span class='hs-conid'>SPI</span><span class='hs-varop'>.</span><span class='hs-varid'>defaultFileFlags</span> <span class='hs-layout'>{</span> <span class='hs-varid'>exclusive</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>True</span> <span class='hs-layout'>}</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
|
||||
<a name="line-657"></a> <span class='hs-conid'>SPI</span><span class='hs-varop'>.</span><span class='hs-varid'>closeFd</span>
|
||||
<a name="line-658"></a> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-keyword'>_</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>return</span> <span class='hs-conid'>()</span><span class='hs-layout'>)</span>
|
||||
<a name="line-659"></a>
|
||||
<a name="line-660"></a>
|
||||
<a name="line-661"></a><a name="createDir"></a><span class='hs-comment'>-- |Create an empty directory at the given directory with the given filename.</span>
|
||||
<a name="line-662"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-663"></a><span class='hs-comment'>-- Throws:</span>
|
||||
<a name="line-664"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-665"></a><span class='hs-comment'>-- - `PermissionDenied` if output directory cannot be written to</span>
|
||||
<a name="line-666"></a><span class='hs-comment'>-- - `AlreadyExists` if destination directory already exists</span>
|
||||
<a name="line-667"></a><span class='hs-definition'>createDir</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-668"></a><span class='hs-definition'>createDir</span> <span class='hs-varid'>dest</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>createDirectory</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromAbs</span> <span class='hs-varid'>dest</span><span class='hs-layout'>)</span> <span class='hs-varid'>newDirPerms</span>
|
||||
<a name="line-669"></a>
|
||||
<a name="line-670"></a>
|
||||
<a name="line-671"></a><a name="createSymlink"></a><span class='hs-comment'>-- |Create a symlink.</span>
|
||||
<a name="line-672"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-673"></a><span class='hs-comment'>-- Throws:</span>
|
||||
<a name="line-674"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-675"></a><span class='hs-comment'>-- - `PermissionDenied` if output directory cannot be written to</span>
|
||||
<a name="line-676"></a><span class='hs-comment'>-- - `AlreadyExists` if destination file already exists</span>
|
||||
<a name="line-677"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-678"></a><span class='hs-comment'>-- Note: calls `symlink`</span>
|
||||
<a name="line-679"></a><span class='hs-definition'>createSymlink</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-comment'>-- ^ destination file</span>
|
||||
<a name="line-680"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>ByteString</span> <span class='hs-comment'>-- ^ path the symlink points to</span>
|
||||
<a name="line-681"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-682"></a><span class='hs-definition'>createSymlink</span> <span class='hs-varid'>dest</span> <span class='hs-varid'>sympoint</span>
|
||||
<a name="line-683"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>createSymbolicLink</span> <span class='hs-varid'>sympoint</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromAbs</span> <span class='hs-varid'>dest</span><span class='hs-layout'>)</span>
|
||||
<a name="line-684"></a>
|
||||
<a name="line-685"></a>
|
||||
<a name="line-686"></a>
|
||||
<a name="line-687"></a> <span class='hs-comment'>----------------------------</span>
|
||||
<a name="line-688"></a> <span class='hs-comment'>--[ File Renaming/Moving ]--</span>
|
||||
<a name="line-689"></a> <span class='hs-comment'>----------------------------</span>
|
||||
<a name="line-690"></a>
|
||||
<a name="line-691"></a>
|
||||
<a name="line-692"></a><a name="renameFile"></a><span class='hs-comment'>-- |Rename a given file with the provided filename. Destination and source</span>
|
||||
<a name="line-693"></a><span class='hs-comment'>-- must be on the same device, otherwise `eXDEV` will be raised.</span>
|
||||
<a name="line-694"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-695"></a><span class='hs-comment'>-- Does not follow symbolic links, but renames the symbolic link file.</span>
|
||||
<a name="line-696"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-697"></a><span class='hs-comment'>-- Safety/reliability concerns:</span>
|
||||
<a name="line-698"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-699"></a><span class='hs-comment'>-- * has a separate set of exception handling, apart from the syscall</span>
|
||||
<a name="line-700"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-701"></a><span class='hs-comment'>-- Throws:</span>
|
||||
<a name="line-702"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-703"></a><span class='hs-comment'>-- - `NoSuchThing` if source file does not exist</span>
|
||||
<a name="line-704"></a><span class='hs-comment'>-- - `PermissionDenied` if output directory cannot be written to</span>
|
||||
<a name="line-705"></a><span class='hs-comment'>-- - `PermissionDenied` if source directory cannot be opened</span>
|
||||
<a name="line-706"></a><span class='hs-comment'>-- - `UnsupportedOperation` if source and destination are on different devices</span>
|
||||
<a name="line-707"></a><span class='hs-comment'>-- - `FileDoesExist` if destination file already exists (`HPathIOException`)</span>
|
||||
<a name="line-708"></a><span class='hs-comment'>-- - `DirDoesExist` if destination directory already exists (`HPathIOException`)</span>
|
||||
<a name="line-709"></a><span class='hs-comment'>-- - `SameFile` if destination and source are the same file (`HPathIOException`)</span>
|
||||
<a name="line-710"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-711"></a><span class='hs-comment'>-- Note: calls `rename` (but does not allow to rename over existing files)</span>
|
||||
<a name="line-712"></a><span class='hs-definition'>renameFile</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-713"></a><span class='hs-definition'>renameFile</span> <span class='hs-varid'>fromf</span> <span class='hs-varid'>tof</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-714"></a> <span class='hs-varid'>throwSameFile</span> <span class='hs-varid'>fromf</span> <span class='hs-varid'>tof</span>
|
||||
<a name="line-715"></a> <span class='hs-varid'>throwFileDoesExist</span> <span class='hs-varid'>tof</span>
|
||||
<a name="line-716"></a> <span class='hs-varid'>throwDirDoesExist</span> <span class='hs-varid'>tof</span>
|
||||
<a name="line-717"></a> <span class='hs-varid'>rename</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromAbs</span> <span class='hs-varid'>fromf</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromAbs</span> <span class='hs-varid'>tof</span><span class='hs-layout'>)</span>
|
||||
<a name="line-718"></a>
|
||||
<a name="line-719"></a>
|
||||
<a name="line-720"></a><a name="moveFile"></a><span class='hs-comment'>-- |Move a file. This also works across devices by copy-delete fallback.</span>
|
||||
<a name="line-721"></a><span class='hs-comment'>-- And also works on directories.</span>
|
||||
<a name="line-722"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-723"></a><span class='hs-comment'>-- Does not follow symbolic links, but renames the symbolic link file.</span>
|
||||
<a name="line-724"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-725"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-726"></a><span class='hs-comment'>-- Safety/reliability concerns:</span>
|
||||
<a name="line-727"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-728"></a><span class='hs-comment'>-- * copy-delete fallback is inherently non-atomic</span>
|
||||
<a name="line-729"></a><span class='hs-comment'>-- * since this function calls `easyCopy` and `easyDelete` as a fallback</span>
|
||||
<a name="line-730"></a><span class='hs-comment'>-- to `renameFile`, file types that are not `RegularFile`, `SymbolicLink`</span>
|
||||
<a name="line-731"></a><span class='hs-comment'>-- or `Directory` may be ignored</span>
|
||||
<a name="line-732"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-733"></a><span class='hs-comment'>-- Throws:</span>
|
||||
<a name="line-734"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-735"></a><span class='hs-comment'>-- - `NoSuchThing` if source file does not exist</span>
|
||||
<a name="line-736"></a><span class='hs-comment'>-- - `PermissionDenied` if output directory cannot be written to</span>
|
||||
<a name="line-737"></a><span class='hs-comment'>-- - `PermissionDenied` if source directory cannot be opened</span>
|
||||
<a name="line-738"></a><span class='hs-comment'>-- - `FileDoesExist` if destination file already exists (`HPathIOException`)</span>
|
||||
<a name="line-739"></a><span class='hs-comment'>-- - `DirDoesExist` if destination directory already exists (`HPathIOException`)</span>
|
||||
<a name="line-740"></a><span class='hs-comment'>-- - `SameFile` if destination and source are the same file (`HPathIOException`)</span>
|
||||
<a name="line-741"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-742"></a><span class='hs-comment'>-- Note: calls `rename` (but does not allow to rename over existing files)</span>
|
||||
<a name="line-743"></a><span class='hs-definition'>moveFile</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-comment'>-- ^ file to move</span>
|
||||
<a name="line-744"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-comment'>-- ^ destination</span>
|
||||
<a name="line-745"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-746"></a><span class='hs-definition'>moveFile</span> <span class='hs-varid'>from</span> <span class='hs-varid'>to</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-747"></a> <span class='hs-varid'>throwSameFile</span> <span class='hs-varid'>from</span> <span class='hs-varid'>to</span>
|
||||
<a name="line-748"></a> <span class='hs-varid'>catchErrno</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>eXDEV</span><span class='hs-keyglyph'>]</span> <span class='hs-layout'>(</span><span class='hs-varid'>renameFile</span> <span class='hs-varid'>from</span> <span class='hs-varid'>to</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-749"></a> <span class='hs-varid'>easyCopy</span> <span class='hs-varid'>from</span> <span class='hs-varid'>to</span>
|
||||
<a name="line-750"></a> <span class='hs-varid'>easyDelete</span> <span class='hs-varid'>from</span>
|
||||
<a name="line-751"></a>
|
||||
<a name="line-752"></a>
|
||||
<a name="line-753"></a><a name="moveFileOverwrite"></a><span class='hs-comment'>-- |Like `moveFile`, but overwrites the destination if it exists.</span>
|
||||
<a name="line-754"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-755"></a><span class='hs-comment'>-- Does not follow symbolic links, but renames the symbolic link file.</span>
|
||||
<a name="line-756"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-757"></a><span class='hs-comment'>-- Ignores any file type that is not `RegularFile`, `SymbolicLink` or</span>
|
||||
<a name="line-758"></a><span class='hs-comment'>-- `Directory`.</span>
|
||||
<a name="line-759"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-760"></a><span class='hs-comment'>-- Safety/reliability concerns:</span>
|
||||
<a name="line-761"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-762"></a><span class='hs-comment'>-- * copy-delete fallback is inherently non-atomic</span>
|
||||
<a name="line-763"></a><span class='hs-comment'>-- * checks for file types and destination file existence explicitly</span>
|
||||
<a name="line-764"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-765"></a><span class='hs-comment'>-- Throws:</span>
|
||||
<a name="line-766"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-767"></a><span class='hs-comment'>-- - `NoSuchThing` if source file does not exist</span>
|
||||
<a name="line-768"></a><span class='hs-comment'>-- - `PermissionDenied` if output directory cannot be written to</span>
|
||||
<a name="line-769"></a><span class='hs-comment'>-- - `PermissionDenied` if source directory cannot be opened</span>
|
||||
<a name="line-770"></a><span class='hs-comment'>-- - `SameFile` if destination and source are the same file (`HPathIOException`)</span>
|
||||
<a name="line-771"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-772"></a><span class='hs-comment'>-- Note: calls `rename` (but does not allow to rename over existing files)</span>
|
||||
<a name="line-773"></a><span class='hs-definition'>moveFileOverwrite</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-comment'>-- ^ file to move</span>
|
||||
<a name="line-774"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-comment'>-- ^ destination</span>
|
||||
<a name="line-775"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-776"></a><span class='hs-definition'>moveFileOverwrite</span> <span class='hs-varid'>from</span> <span class='hs-varid'>to</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-777"></a> <span class='hs-varid'>throwSameFile</span> <span class='hs-varid'>from</span> <span class='hs-varid'>to</span>
|
||||
<a name="line-778"></a> <span class='hs-varid'>ft</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>getFileType</span> <span class='hs-varid'>from</span>
|
||||
<a name="line-779"></a> <span class='hs-varid'>writable</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>isWritable</span> <span class='hs-varop'>$</span> <span class='hs-varid'>dirname</span> <span class='hs-varid'>to</span>
|
||||
<a name="line-780"></a> <span class='hs-keyword'>case</span> <span class='hs-varid'>ft</span> <span class='hs-keyword'>of</span>
|
||||
<a name="line-781"></a> <span class='hs-conid'>RegularFile</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-782"></a> <span class='hs-varid'>exists</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>doesFileExist</span> <span class='hs-varid'>to</span>
|
||||
<a name="line-783"></a> <span class='hs-varid'>when</span> <span class='hs-layout'>(</span><span class='hs-varid'>exists</span> <span class='hs-varop'>&&</span> <span class='hs-varid'>writable</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>deleteFile</span> <span class='hs-varid'>to</span><span class='hs-layout'>)</span>
|
||||
<a name="line-784"></a> <span class='hs-conid'>SymbolicLink</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-785"></a> <span class='hs-varid'>exists</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>doesFileExist</span> <span class='hs-varid'>to</span>
|
||||
<a name="line-786"></a> <span class='hs-varid'>when</span> <span class='hs-layout'>(</span><span class='hs-varid'>exists</span> <span class='hs-varop'>&&</span> <span class='hs-varid'>writable</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>deleteFile</span> <span class='hs-varid'>to</span><span class='hs-layout'>)</span>
|
||||
<a name="line-787"></a> <span class='hs-conid'>Directory</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-788"></a> <span class='hs-varid'>exists</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>doesDirectoryExist</span> <span class='hs-varid'>to</span>
|
||||
<a name="line-789"></a> <span class='hs-varid'>when</span> <span class='hs-layout'>(</span><span class='hs-varid'>exists</span> <span class='hs-varop'>&&</span> <span class='hs-varid'>writable</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>deleteDir</span> <span class='hs-varid'>to</span><span class='hs-layout'>)</span>
|
||||
<a name="line-790"></a> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>return</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-791"></a> <span class='hs-varid'>moveFile</span> <span class='hs-varid'>from</span> <span class='hs-varid'>to</span>
|
||||
<a name="line-792"></a>
|
||||
<a name="line-793"></a>
|
||||
<a name="line-794"></a>
|
||||
<a name="line-795"></a>
|
||||
<a name="line-796"></a> <span class='hs-comment'>-----------------------</span>
|
||||
<a name="line-797"></a> <span class='hs-comment'>--[ File Permissions]--</span>
|
||||
<a name="line-798"></a> <span class='hs-comment'>-----------------------</span>
|
||||
<a name="line-799"></a>
|
||||
<a name="line-800"></a>
|
||||
<a name="line-801"></a><a name="newFilePerms"></a><span class='hs-comment'>-- |Default permissions for a new file.</span>
|
||||
<a name="line-802"></a><span class='hs-definition'>newFilePerms</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>FileMode</span>
|
||||
<a name="line-803"></a><span class='hs-definition'>newFilePerms</span>
|
||||
<a name="line-804"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>ownerWriteMode</span>
|
||||
<a name="line-805"></a> <span class='hs-varop'>`unionFileModes`</span> <span class='hs-varid'>ownerReadMode</span>
|
||||
<a name="line-806"></a> <span class='hs-varop'>`unionFileModes`</span> <span class='hs-varid'>groupWriteMode</span>
|
||||
<a name="line-807"></a> <span class='hs-varop'>`unionFileModes`</span> <span class='hs-varid'>groupReadMode</span>
|
||||
<a name="line-808"></a> <span class='hs-varop'>`unionFileModes`</span> <span class='hs-varid'>otherWriteMode</span>
|
||||
<a name="line-809"></a> <span class='hs-varop'>`unionFileModes`</span> <span class='hs-varid'>otherReadMode</span>
|
||||
<a name="line-810"></a>
|
||||
<a name="line-811"></a>
|
||||
<a name="line-812"></a><a name="newDirPerms"></a><span class='hs-comment'>-- |Default permissions for a new directory.</span>
|
||||
<a name="line-813"></a><span class='hs-definition'>newDirPerms</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>FileMode</span>
|
||||
<a name="line-814"></a><span class='hs-definition'>newDirPerms</span>
|
||||
<a name="line-815"></a> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>ownerModes</span>
|
||||
<a name="line-816"></a> <span class='hs-varop'>`unionFileModes`</span> <span class='hs-varid'>groupExecuteMode</span>
|
||||
<a name="line-817"></a> <span class='hs-varop'>`unionFileModes`</span> <span class='hs-varid'>groupReadMode</span>
|
||||
<a name="line-818"></a> <span class='hs-varop'>`unionFileModes`</span> <span class='hs-varid'>otherExecuteMode</span>
|
||||
<a name="line-819"></a> <span class='hs-varop'>`unionFileModes`</span> <span class='hs-varid'>otherReadMode</span>
|
||||
<a name="line-820"></a>
|
||||
<a name="line-821"></a>
|
||||
<a name="line-822"></a>
|
||||
<a name="line-823"></a> <span class='hs-comment'>-------------------------</span>
|
||||
<a name="line-824"></a> <span class='hs-comment'>--[ Directory reading ]--</span>
|
||||
<a name="line-825"></a> <span class='hs-comment'>-------------------------</span>
|
||||
<a name="line-826"></a>
|
||||
<a name="line-827"></a>
|
||||
<a name="line-828"></a><a name="getDirsFiles"></a><span class='hs-comment'>-- |Gets all filenames of the given directory. This excludes "." and "..".</span>
|
||||
<a name="line-829"></a><span class='hs-comment'>-- This version does not follow symbolic links.</span>
|
||||
<a name="line-830"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-831"></a><span class='hs-comment'>-- Throws:</span>
|
||||
<a name="line-832"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-833"></a><span class='hs-comment'>-- - `NoSuchThing` if directory does not exist</span>
|
||||
<a name="line-834"></a><span class='hs-comment'>-- - `InappropriateType` if file type is wrong (file)</span>
|
||||
<a name="line-835"></a><span class='hs-comment'>-- - `InappropriateType` if file type is wrong (symlink to file)</span>
|
||||
<a name="line-836"></a><span class='hs-comment'>-- - `InappropriateType` if file type is wrong (symlink to dir)</span>
|
||||
<a name="line-837"></a><span class='hs-comment'>-- - `PermissionDenied` if directory cannot be opened</span>
|
||||
<a name="line-838"></a><span class='hs-definition'>getDirsFiles</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-comment'>-- ^ dir to read</span>
|
||||
<a name="line-839"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-840"></a><span class='hs-definition'>getDirsFiles</span> <span class='hs-varid'>p</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-841"></a> <span class='hs-varid'>withAbsPath</span> <span class='hs-varid'>p</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>fp</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-842"></a> <span class='hs-varid'>fd</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>openFd</span> <span class='hs-varid'>fp</span> <span class='hs-conid'>SPI</span><span class='hs-varop'>.</span><span class='hs-conid'>ReadOnly</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>SPDF</span><span class='hs-varop'>.</span><span class='hs-varid'>oNofollow</span><span class='hs-keyglyph'>]</span> <span class='hs-conid'>Nothing</span>
|
||||
<a name="line-843"></a> <span class='hs-varid'>return</span>
|
||||
<a name="line-844"></a> <span class='hs-varop'>.</span> <span class='hs-varid'>catMaybes</span>
|
||||
<a name="line-845"></a> <span class='hs-varop'>.</span> <span class='hs-varid'>fmap</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>x</span> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-varop'></></span><span class='hs-layout'>)</span> <span class='hs-varid'>p</span> <span class='hs-varop'><$></span> <span class='hs-layout'>(</span><span class='hs-varid'>parseMaybe</span> <span class='hs-varop'>.</span> <span class='hs-varid'>snd</span> <span class='hs-varop'>$</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
|
||||
<a name="line-846"></a> <span class='hs-varop'>=<<</span> <span class='hs-varid'>getDirectoryContents'</span> <span class='hs-varid'>fd</span>
|
||||
<a name="line-847"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-848"></a> <span class='hs-varid'>parseMaybe</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>ByteString</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Maybe</span> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span> <span class='hs-conid'>Fn</span><span class='hs-layout'>)</span>
|
||||
<a name="line-849"></a> <span class='hs-varid'>parseMaybe</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>parseFn</span>
|
||||
<a name="line-850"></a>
|
||||
<a name="line-851"></a>
|
||||
<a name="line-852"></a>
|
||||
<a name="line-853"></a>
|
||||
<a name="line-854"></a> <span class='hs-comment'>---------------------------</span>
|
||||
<a name="line-855"></a> <span class='hs-comment'>--[ FileType operations ]--</span>
|
||||
<a name="line-856"></a> <span class='hs-comment'>---------------------------</span>
|
||||
<a name="line-857"></a>
|
||||
<a name="line-858"></a>
|
||||
<a name="line-859"></a><a name="getFileType"></a><span class='hs-comment'>-- |Get the file type of the file located at the given path. Does</span>
|
||||
<a name="line-860"></a><span class='hs-comment'>-- not follow symbolic links.</span>
|
||||
<a name="line-861"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-862"></a><span class='hs-comment'>-- Throws:</span>
|
||||
<a name="line-863"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-864"></a><span class='hs-comment'>-- - `NoSuchThing` if the file does not exist</span>
|
||||
<a name="line-865"></a><span class='hs-comment'>-- - `PermissionDenied` if any part of the path is not accessible</span>
|
||||
<a name="line-866"></a><span class='hs-definition'>getFileType</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>FileType</span>
|
||||
<a name="line-867"></a><span class='hs-definition'>getFileType</span> <span class='hs-varid'>p</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-868"></a> <span class='hs-varid'>fs</span> <span class='hs-keyglyph'><-</span> <span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>getSymbolicLinkStatus</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromAbs</span> <span class='hs-varid'>p</span><span class='hs-layout'>)</span>
|
||||
<a name="line-869"></a> <span class='hs-varid'>decide</span> <span class='hs-varid'>fs</span>
|
||||
<a name="line-870"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-871"></a> <span class='hs-varid'>decide</span> <span class='hs-varid'>fs</span>
|
||||
<a name="line-872"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>isDirectory</span> <span class='hs-varid'>fs</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>return</span> <span class='hs-conid'>Directory</span>
|
||||
<a name="line-873"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>isRegularFile</span> <span class='hs-varid'>fs</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>return</span> <span class='hs-conid'>RegularFile</span>
|
||||
<a name="line-874"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>isSymbolicLink</span> <span class='hs-varid'>fs</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>return</span> <span class='hs-conid'>SymbolicLink</span>
|
||||
<a name="line-875"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>isBlockDevice</span> <span class='hs-varid'>fs</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>return</span> <span class='hs-conid'>BlockDevice</span>
|
||||
<a name="line-876"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>isCharacterDevice</span> <span class='hs-varid'>fs</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>return</span> <span class='hs-conid'>CharacterDevice</span>
|
||||
<a name="line-877"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>isNamedPipe</span> <span class='hs-varid'>fs</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>return</span> <span class='hs-conid'>NamedPipe</span>
|
||||
<a name="line-878"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>PF</span><span class='hs-varop'>.</span><span class='hs-varid'>isSocket</span> <span class='hs-varid'>fs</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>return</span> <span class='hs-conid'>Socket</span>
|
||||
<a name="line-879"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>ioError</span> <span class='hs-varop'>$</span> <span class='hs-varid'>userError</span> <span class='hs-str'>"No filetype?!"</span>
|
||||
<a name="line-880"></a>
|
||||
<a name="line-881"></a>
|
||||
<a name="line-882"></a>
|
||||
<a name="line-883"></a> <span class='hs-comment'>--------------</span>
|
||||
<a name="line-884"></a> <span class='hs-comment'>--[ Others ]--</span>
|
||||
<a name="line-885"></a> <span class='hs-comment'>--------------</span>
|
||||
<a name="line-886"></a>
|
||||
<a name="line-887"></a>
|
||||
<a name="line-888"></a>
|
||||
<a name="line-889"></a><a name="canonicalizePath"></a><span class='hs-comment'>-- |Applies `realpath` on the given absolute path.</span>
|
||||
<a name="line-890"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-891"></a><span class='hs-comment'>-- Throws:</span>
|
||||
<a name="line-892"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-893"></a><span class='hs-comment'>-- - `NoSuchThing` if the file at the given path does not exist</span>
|
||||
<a name="line-894"></a><span class='hs-comment'>-- - `NoSuchThing` if the symlink is broken</span>
|
||||
<a name="line-895"></a><span class='hs-definition'>canonicalizePath</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span><span class='hs-layout'>)</span>
|
||||
<a name="line-896"></a><span class='hs-definition'>canonicalizePath</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>l</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-897"></a> <span class='hs-varid'>nl</span> <span class='hs-keyglyph'><-</span> <span class='hs-conid'>SPDT</span><span class='hs-varop'>.</span><span class='hs-varid'>realpath</span> <span class='hs-varid'>l</span>
|
||||
<a name="line-898"></a> <span class='hs-varid'>return</span> <span class='hs-varop'>$</span> <span class='hs-conid'>MkPath</span> <span class='hs-varid'>nl</span>
|
||||
</pre></body>
|
||||
</html>
|
62
src/HPath-Internal.html
Normal file
62
src/HPath-Internal.html
Normal file
@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
|
||||
<title>src/HPath/Internal.hs</title>
|
||||
<link type='text/css' rel='stylesheet' href='hscolour.css' />
|
||||
</head>
|
||||
<body>
|
||||
<pre><a name="line-1"></a><span class='hs-comment'>{-# LANGUAGE DeriveDataTypeable #-}</span>
|
||||
<a name="line-2"></a>
|
||||
<a name="line-3"></a><span class='hs-comment'>-- | Internal types and functions.</span>
|
||||
<a name="line-4"></a>
|
||||
<a name="line-5"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>HPath</span><span class='hs-varop'>.</span><span class='hs-conid'>Internal</span>
|
||||
<a name="line-6"></a> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
|
||||
<a name="line-7"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-8"></a>
|
||||
<a name="line-9"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>DeepSeq</span> <span class='hs-layout'>(</span><span class='hs-conid'>NFData</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
|
||||
<a name="line-10"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span> <span class='hs-layout'>(</span><span class='hs-conid'>ByteString</span><span class='hs-layout'>)</span>
|
||||
<a name="line-11"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Data</span>
|
||||
<a name="line-12"></a>
|
||||
<a name="line-13"></a><a name="Path"></a><span class='hs-comment'>-- | Path of some base and type.</span>
|
||||
<a name="line-14"></a><a name="Path"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-15"></a><a name="Path"></a><span class='hs-comment'>-- Internally is a ByteString. The ByteString can be of two formats only:</span>
|
||||
<a name="line-16"></a><a name="Path"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-17"></a><a name="Path"></a><span class='hs-comment'>-- 1. without trailing path separator: @file.txt@, @foo\/bar.txt@, @\/foo\/bar.txt@</span>
|
||||
<a name="line-18"></a><a name="Path"></a><span class='hs-comment'>-- 2. with trailing path separator: @foo\/@, @\/foo\/bar\/@</span>
|
||||
<a name="line-19"></a><a name="Path"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-20"></a><a name="Path"></a><span class='hs-comment'>-- There are no duplicate</span>
|
||||
<a name="line-21"></a><a name="Path"></a><span class='hs-comment'>-- path separators @\/\/@, no @..@, no @.\/@, no @~\/@, etc.</span>
|
||||
<a name="line-22"></a><a name="Path"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>Path</span> <span class='hs-varid'>b</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>MkPath</span> <span class='hs-conid'>ByteString</span>
|
||||
<a name="line-23"></a> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span><span class='hs-conid'>Typeable</span><span class='hs-layout'>)</span>
|
||||
<a name="line-24"></a>
|
||||
<a name="line-25"></a><a name="instance%20Eq%20(Path%20b)"></a><span class='hs-comment'>-- | ByteString equality.</span>
|
||||
<a name="line-26"></a><a name="instance%20Eq%20(Path%20b)"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-27"></a><a name="instance%20Eq%20(Path%20b)"></a><span class='hs-comment'>-- The following property holds:</span>
|
||||
<a name="line-28"></a><a name="instance%20Eq%20(Path%20b)"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-29"></a><a name="instance%20Eq%20(Path%20b)"></a><span class='hs-comment'>-- @show x == show y ≡ x == y@</span>
|
||||
<a name="line-30"></a><a name="instance%20Eq%20(Path%20b)"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>Eq</span> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
|
||||
<a name="line-31"></a> <span class='hs-layout'>(</span><span class='hs-varop'>==</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>y</span>
|
||||
<a name="line-32"></a>
|
||||
<a name="line-33"></a><a name="instance%20Ord%20(Path%20b)"></a><span class='hs-comment'>-- | ByteString ordering.</span>
|
||||
<a name="line-34"></a><a name="instance%20Ord%20(Path%20b)"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-35"></a><a name="instance%20Ord%20(Path%20b)"></a><span class='hs-comment'>-- The following property holds:</span>
|
||||
<a name="line-36"></a><a name="instance%20Ord%20(Path%20b)"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-37"></a><a name="instance%20Ord%20(Path%20b)"></a><span class='hs-comment'>-- @show x \`compare\` show y ≡ x \`compare\` y@</span>
|
||||
<a name="line-38"></a><a name="instance%20Ord%20(Path%20b)"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>Ord</span> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
|
||||
<a name="line-39"></a> <span class='hs-varid'>compare</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>compare</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span>
|
||||
<a name="line-40"></a>
|
||||
<a name="line-41"></a><a name="instance%20Show%20(Path%20b)"></a><span class='hs-comment'>-- | Same as 'HPath.toFilePath'.</span>
|
||||
<a name="line-42"></a><a name="instance%20Show%20(Path%20b)"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-43"></a><a name="instance%20Show%20(Path%20b)"></a><span class='hs-comment'>-- The following property holds:</span>
|
||||
<a name="line-44"></a><a name="instance%20Show%20(Path%20b)"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-45"></a><a name="instance%20Show%20(Path%20b)"></a><span class='hs-comment'>-- @x == y ≡ show x == show y@</span>
|
||||
<a name="line-46"></a><a name="instance%20Show%20(Path%20b)"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>Show</span> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
|
||||
<a name="line-47"></a> <span class='hs-varid'>show</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>show</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-48"></a>
|
||||
<a name="line-49"></a><a name="instance%20NFData%20(Path%20b)"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>NFData</span> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
|
||||
<a name="line-50"></a> <span class='hs-varid'>rnf</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>rnf</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-51"></a>
|
||||
</pre></body>
|
||||
</html>
|
383
src/HPath.html
Normal file
383
src/HPath.html
Normal file
@ -0,0 +1,383 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
|
||||
<title>src/HPath.hs</title>
|
||||
<link type='text/css' rel='stylesheet' href='hscolour.css' />
|
||||
</head>
|
||||
<body>
|
||||
<pre><a name="line-1"></a><span class='hs-comment'>-- |</span>
|
||||
<a name="line-2"></a><span class='hs-comment'>-- Module : HPath</span>
|
||||
<a name="line-3"></a><span class='hs-comment'>-- Copyright : © 2015–2016 FP Complete, 2016 Julian Ospald</span>
|
||||
<a name="line-4"></a><span class='hs-comment'>-- License : BSD 3 clause</span>
|
||||
<a name="line-5"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-6"></a><span class='hs-comment'>-- Maintainer : Julian Ospald <hasufell@posteo.de></span>
|
||||
<a name="line-7"></a><span class='hs-comment'>-- Stability : experimental</span>
|
||||
<a name="line-8"></a><span class='hs-comment'>-- Portability : portable</span>
|
||||
<a name="line-9"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-10"></a><span class='hs-comment'>-- Support for well-typed paths.</span>
|
||||
<a name="line-11"></a>
|
||||
<a name="line-12"></a>
|
||||
<a name="line-13"></a><span class='hs-comment'>{-# LANGUAGE CPP #-}</span>
|
||||
<a name="line-14"></a><span class='hs-comment'>{-# LANGUAGE DeriveDataTypeable #-}</span>
|
||||
<a name="line-15"></a><span class='hs-comment'>{-# LANGUAGE EmptyDataDecls #-}</span>
|
||||
<a name="line-16"></a><span class='hs-comment'>{-# LANGUAGE PatternSynonyms #-}</span>
|
||||
<a name="line-17"></a>
|
||||
<a name="line-18"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>HPath</span>
|
||||
<a name="line-19"></a> <span class='hs-layout'>(</span>
|
||||
<a name="line-20"></a> <span class='hs-comment'>-- * Types</span>
|
||||
<a name="line-21"></a> <span class='hs-conid'>Abs</span>
|
||||
<a name="line-22"></a> <span class='hs-layout'>,</span><span class='hs-conid'>Path</span>
|
||||
<a name="line-23"></a> <span class='hs-layout'>,</span><span class='hs-conid'>Rel</span>
|
||||
<a name="line-24"></a> <span class='hs-layout'>,</span><span class='hs-conid'>Fn</span>
|
||||
<a name="line-25"></a> <span class='hs-layout'>,</span><span class='hs-conid'>PathParseException</span>
|
||||
<a name="line-26"></a> <span class='hs-layout'>,</span><span class='hs-conid'>PathException</span>
|
||||
<a name="line-27"></a> <span class='hs-layout'>,</span><span class='hs-conid'>RelC</span>
|
||||
<a name="line-28"></a> <span class='hs-comment'>-- * PatternSynonyms/ViewPatterns</span>
|
||||
<a name="line-29"></a> <span class='hs-layout'>,</span><span class='hs-varid'>pattern</span> <span class='hs-conid'>Path</span>
|
||||
<a name="line-30"></a> <span class='hs-comment'>-- * Path Parsing</span>
|
||||
<a name="line-31"></a> <span class='hs-layout'>,</span><span class='hs-varid'>parseAbs</span>
|
||||
<a name="line-32"></a> <span class='hs-layout'>,</span><span class='hs-varid'>parseFn</span>
|
||||
<a name="line-33"></a> <span class='hs-layout'>,</span><span class='hs-varid'>parseRel</span>
|
||||
<a name="line-34"></a> <span class='hs-comment'>-- * Path Conversion</span>
|
||||
<a name="line-35"></a> <span class='hs-layout'>,</span><span class='hs-varid'>fromAbs</span>
|
||||
<a name="line-36"></a> <span class='hs-layout'>,</span><span class='hs-varid'>fromRel</span>
|
||||
<a name="line-37"></a> <span class='hs-layout'>,</span><span class='hs-varid'>toFilePath</span>
|
||||
<a name="line-38"></a> <span class='hs-comment'>-- * Path Operations</span>
|
||||
<a name="line-39"></a> <span class='hs-layout'>,</span><span class='hs-layout'>(</span><span class='hs-varop'></></span><span class='hs-layout'>)</span>
|
||||
<a name="line-40"></a> <span class='hs-layout'>,</span><span class='hs-varid'>basename</span>
|
||||
<a name="line-41"></a> <span class='hs-layout'>,</span><span class='hs-varid'>dirname</span>
|
||||
<a name="line-42"></a> <span class='hs-layout'>,</span><span class='hs-varid'>isParentOf</span>
|
||||
<a name="line-43"></a> <span class='hs-layout'>,</span><span class='hs-varid'>getAllParents</span>
|
||||
<a name="line-44"></a> <span class='hs-layout'>,</span><span class='hs-varid'>stripDir</span>
|
||||
<a name="line-45"></a> <span class='hs-comment'>-- * Path IO helpers</span>
|
||||
<a name="line-46"></a> <span class='hs-layout'>,</span><span class='hs-varid'>withAbsPath</span>
|
||||
<a name="line-47"></a> <span class='hs-layout'>,</span><span class='hs-varid'>withRelPath</span>
|
||||
<a name="line-48"></a> <span class='hs-layout'>,</span><span class='hs-varid'>withFnPath</span>
|
||||
<a name="line-49"></a> <span class='hs-layout'>)</span>
|
||||
<a name="line-50"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-51"></a>
|
||||
<a name="line-52"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Exception</span> <span class='hs-layout'>(</span><span class='hs-conid'>Exception</span><span class='hs-layout'>)</span>
|
||||
<a name="line-53"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Monad</span><span class='hs-varop'>.</span><span class='hs-conid'>Catch</span> <span class='hs-layout'>(</span><span class='hs-conid'>MonadThrow</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
|
||||
<a name="line-54"></a><span class='hs-cpp'>#if MIN_VERSION_bytestring(0,10,8)</span>
|
||||
<a name="line-55"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span><span class='hs-layout'>(</span><span class='hs-conid'>ByteString</span><span class='hs-layout'>,</span> <span class='hs-varid'>stripPrefix</span><span class='hs-layout'>)</span>
|
||||
<a name="line-56"></a><span class='hs-cpp'>#else</span>
|
||||
<a name="line-57"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span><span class='hs-layout'>(</span><span class='hs-conid'>ByteString</span><span class='hs-layout'>)</span>
|
||||
<a name="line-58"></a><span class='hs-keyword'>import</span> <span class='hs-keyword'>qualified</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>List</span> <span class='hs-keyword'>as</span> <span class='hs-conid'>L</span>
|
||||
<a name="line-59"></a><span class='hs-cpp'>#endif</span>
|
||||
<a name="line-60"></a><span class='hs-keyword'>import</span> <span class='hs-keyword'>qualified</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span> <span class='hs-keyword'>as</span> <span class='hs-conid'>BS</span>
|
||||
<a name="line-61"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Data</span>
|
||||
<a name="line-62"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Maybe</span>
|
||||
<a name="line-63"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Word8</span>
|
||||
<a name="line-64"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>HPath</span><span class='hs-varop'>.</span><span class='hs-conid'>Internal</span>
|
||||
<a name="line-65"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>FilePath</span> <span class='hs-varid'>hiding</span> <span class='hs-layout'>(</span><span class='hs-layout'>(</span><span class='hs-varop'></></span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
|
||||
<a name="line-66"></a>
|
||||
<a name="line-67"></a>
|
||||
<a name="line-68"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
|
||||
<a name="line-69"></a><span class='hs-comment'>-- Types</span>
|
||||
<a name="line-70"></a>
|
||||
<a name="line-71"></a><a name="Abs"></a><span class='hs-comment'>-- | An absolute path.</span>
|
||||
<a name="line-72"></a><a name="Abs"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>Abs</span> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span><span class='hs-conid'>Typeable</span><span class='hs-layout'>)</span>
|
||||
<a name="line-73"></a>
|
||||
<a name="line-74"></a><a name="Rel"></a><span class='hs-comment'>-- | A relative path; one without a root.</span>
|
||||
<a name="line-75"></a><a name="Rel"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>Rel</span> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span><span class='hs-conid'>Typeable</span><span class='hs-layout'>)</span>
|
||||
<a name="line-76"></a>
|
||||
<a name="line-77"></a><a name="Fn"></a><span class='hs-comment'>-- | A filename, without any '/'.</span>
|
||||
<a name="line-78"></a><a name="Fn"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>Fn</span> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span><span class='hs-conid'>Typeable</span><span class='hs-layout'>)</span>
|
||||
<a name="line-79"></a>
|
||||
<a name="line-80"></a><a name="PathParseException"></a><span class='hs-comment'>-- | Exception when parsing a location.</span>
|
||||
<a name="line-81"></a><a name="PathParseException"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>PathParseException</span>
|
||||
<a name="line-82"></a> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>InvalidAbs</span> <span class='hs-conid'>ByteString</span>
|
||||
<a name="line-83"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>InvalidRel</span> <span class='hs-conid'>ByteString</span>
|
||||
<a name="line-84"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>InvalidFn</span> <span class='hs-conid'>ByteString</span>
|
||||
<a name="line-85"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>Couldn'tStripPrefixTPS</span> <span class='hs-conid'>ByteString</span> <span class='hs-conid'>ByteString</span>
|
||||
<a name="line-86"></a> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span><span class='hs-conid'>Show</span><span class='hs-layout'>,</span><span class='hs-conid'>Typeable</span><span class='hs-layout'>)</span>
|
||||
<a name="line-87"></a><a name="instance%20Exception%20PathParseException"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>Exception</span> <span class='hs-conid'>PathParseException</span>
|
||||
<a name="line-88"></a>
|
||||
<a name="line-89"></a><a name="PathException"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>PathException</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>RootDirHasNoBasename</span>
|
||||
<a name="line-90"></a> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span><span class='hs-conid'>Show</span><span class='hs-layout'>,</span><span class='hs-conid'>Typeable</span><span class='hs-layout'>)</span>
|
||||
<a name="line-91"></a><a name="instance%20Exception%20PathException"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>Exception</span> <span class='hs-conid'>PathException</span>
|
||||
<a name="line-92"></a>
|
||||
<a name="line-93"></a><a name="ByteString"></a><span class='hs-keyword'>class</span> <span class='hs-conid'>RelC</span> <span class='hs-varid'>m</span>
|
||||
<a name="line-94"></a>
|
||||
<a name="line-95"></a><a name="instance%20RelC%20Rel"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>RelC</span> <span class='hs-conid'>Rel</span>
|
||||
<a name="line-96"></a><a name="instance%20RelC%20Fn"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>RelC</span> <span class='hs-conid'>Fn</span>
|
||||
<a name="line-97"></a>
|
||||
<a name="line-98"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
|
||||
<a name="line-99"></a><span class='hs-comment'>-- PatternSynonyms</span>
|
||||
<a name="line-100"></a>
|
||||
<a name="line-101"></a><span class='hs-cpp'>#if __GLASGOW_HASKELL__ >= 710</span>
|
||||
<a name="line-102"></a><a name="pattern"></a><span class='hs-definition'>pattern</span> <span class='hs-conid'>Path</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>ByteString</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Path</span> <span class='hs-varid'>a</span>
|
||||
<a name="line-103"></a><span class='hs-cpp'>#endif</span>
|
||||
<a name="line-104"></a><span class='hs-definition'>pattern</span> <span class='hs-conid'>Path</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'><-</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span>
|
||||
<a name="line-105"></a>
|
||||
<a name="line-106"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
|
||||
<a name="line-107"></a><span class='hs-comment'>-- Path Parsers</span>
|
||||
<a name="line-108"></a>
|
||||
<a name="line-109"></a>
|
||||
<a name="line-110"></a>
|
||||
<a name="line-111"></a><a name="parseAbs"></a><span class='hs-comment'>-- | Get a location for an absolute path. Produces a normalised path.</span>
|
||||
<a name="line-112"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-113"></a><span class='hs-comment'>-- Throws: 'PathParseException'</span>
|
||||
<a name="line-114"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-115"></a><span class='hs-comment'>-- >>> parseAbs "/abc" :: Maybe (Path Abs)</span>
|
||||
<a name="line-116"></a><span class='hs-comment'>-- Just "/abc"</span>
|
||||
<a name="line-117"></a><span class='hs-comment'>-- >>> parseAbs "/" :: Maybe (Path Abs)</span>
|
||||
<a name="line-118"></a><span class='hs-comment'>-- Just "/"</span>
|
||||
<a name="line-119"></a><span class='hs-comment'>-- >>> parseAbs "/abc/def" :: Maybe (Path Abs)</span>
|
||||
<a name="line-120"></a><span class='hs-comment'>-- Just "/abc/def"</span>
|
||||
<a name="line-121"></a><span class='hs-comment'>-- >>> parseAbs "/abc/def/.///" :: Maybe (Path Abs)</span>
|
||||
<a name="line-122"></a><span class='hs-comment'>-- Just "/abc/def/"</span>
|
||||
<a name="line-123"></a><span class='hs-comment'>-- >>> parseAbs "abc" :: Maybe (Path Abs)</span>
|
||||
<a name="line-124"></a><span class='hs-comment'>-- Nothing</span>
|
||||
<a name="line-125"></a><span class='hs-comment'>-- >>> parseAbs "" :: Maybe (Path Abs)</span>
|
||||
<a name="line-126"></a><span class='hs-comment'>-- Nothing</span>
|
||||
<a name="line-127"></a><span class='hs-comment'>-- >>> parseAbs "/abc/../foo" :: Maybe (Path Abs)</span>
|
||||
<a name="line-128"></a><span class='hs-comment'>-- Nothing</span>
|
||||
<a name="line-129"></a><span class='hs-definition'>parseAbs</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>MonadThrow</span> <span class='hs-varid'>m</span>
|
||||
<a name="line-130"></a> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>ByteString</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span><span class='hs-layout'>)</span>
|
||||
<a name="line-131"></a><span class='hs-definition'>parseAbs</span> <span class='hs-varid'>filepath</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-132"></a> <span class='hs-keyword'>if</span> <span class='hs-varid'>isAbsolute</span> <span class='hs-varid'>filepath</span> <span class='hs-varop'>&&</span>
|
||||
<a name="line-133"></a> <span class='hs-varid'>isValid</span> <span class='hs-varid'>filepath</span> <span class='hs-varop'>&&</span>
|
||||
<a name="line-134"></a> <span class='hs-varid'>not</span> <span class='hs-layout'>(</span><span class='hs-varid'>hasParentDir</span> <span class='hs-varid'>filepath</span><span class='hs-layout'>)</span>
|
||||
<a name="line-135"></a> <span class='hs-keyword'>then</span> <span class='hs-varid'>return</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varop'>$</span> <span class='hs-varid'>normalise</span> <span class='hs-varid'>filepath</span><span class='hs-layout'>)</span>
|
||||
<a name="line-136"></a> <span class='hs-keyword'>else</span> <span class='hs-varid'>throwM</span> <span class='hs-layout'>(</span><span class='hs-conid'>InvalidAbs</span> <span class='hs-varid'>filepath</span><span class='hs-layout'>)</span>
|
||||
<a name="line-137"></a>
|
||||
<a name="line-138"></a>
|
||||
<a name="line-139"></a><a name="parseRel"></a><span class='hs-comment'>-- | Get a location for a relative path. Produces a normalised</span>
|
||||
<a name="line-140"></a><span class='hs-comment'>-- path.</span>
|
||||
<a name="line-141"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-142"></a><span class='hs-comment'>-- Note that @filepath@ may contain any number of @./@ but may not consist</span>
|
||||
<a name="line-143"></a><span class='hs-comment'>-- solely of @./@. It also may not contain a single @..@ anywhere.</span>
|
||||
<a name="line-144"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-145"></a><span class='hs-comment'>-- Throws: 'PathParseException'</span>
|
||||
<a name="line-146"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-147"></a><span class='hs-comment'>-- >>> parseRel "abc" :: Maybe (Path Rel)</span>
|
||||
<a name="line-148"></a><span class='hs-comment'>-- Just "abc"</span>
|
||||
<a name="line-149"></a><span class='hs-comment'>-- >>> parseRel "def/" :: Maybe (Path Rel)</span>
|
||||
<a name="line-150"></a><span class='hs-comment'>-- Just "def/"</span>
|
||||
<a name="line-151"></a><span class='hs-comment'>-- >>> parseRel "abc/def" :: Maybe (Path Rel)</span>
|
||||
<a name="line-152"></a><span class='hs-comment'>-- Just "abc/def"</span>
|
||||
<a name="line-153"></a><span class='hs-comment'>-- >>> parseRel "abc/def/." :: Maybe (Path Rel)</span>
|
||||
<a name="line-154"></a><span class='hs-comment'>-- Just "abc/def/"</span>
|
||||
<a name="line-155"></a><span class='hs-comment'>-- >>> parseRel "/abc" :: Maybe (Path Rel)</span>
|
||||
<a name="line-156"></a><span class='hs-comment'>-- Nothing</span>
|
||||
<a name="line-157"></a><span class='hs-comment'>-- >>> parseRel "" :: Maybe (Path Rel)</span>
|
||||
<a name="line-158"></a><span class='hs-comment'>-- Nothing</span>
|
||||
<a name="line-159"></a><span class='hs-comment'>-- >>> parseRel "abc/../foo" :: Maybe (Path Rel)</span>
|
||||
<a name="line-160"></a><span class='hs-comment'>-- Nothing</span>
|
||||
<a name="line-161"></a><span class='hs-comment'>-- >>> parseRel "." :: Maybe (Path Rel)</span>
|
||||
<a name="line-162"></a><span class='hs-comment'>-- Nothing</span>
|
||||
<a name="line-163"></a><span class='hs-comment'>-- >>> parseRel ".." :: Maybe (Path Rel)</span>
|
||||
<a name="line-164"></a><span class='hs-comment'>-- Nothing</span>
|
||||
<a name="line-165"></a><span class='hs-definition'>parseRel</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>MonadThrow</span> <span class='hs-varid'>m</span>
|
||||
<a name="line-166"></a> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>ByteString</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span> <span class='hs-conid'>Rel</span><span class='hs-layout'>)</span>
|
||||
<a name="line-167"></a><span class='hs-definition'>parseRel</span> <span class='hs-varid'>filepath</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-168"></a> <span class='hs-keyword'>if</span> <span class='hs-varid'>not</span> <span class='hs-layout'>(</span><span class='hs-varid'>isAbsolute</span> <span class='hs-varid'>filepath</span><span class='hs-layout'>)</span> <span class='hs-varop'>&&</span>
|
||||
<a name="line-169"></a> <span class='hs-varid'>filepath</span> <span class='hs-varop'>/=</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>singleton</span> <span class='hs-sel'>_period</span> <span class='hs-varop'>&&</span>
|
||||
<a name="line-170"></a> <span class='hs-varid'>filepath</span> <span class='hs-varop'>/=</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>pack</span> <span class='hs-keyglyph'>[</span><span class='hs-sel'>_period</span><span class='hs-layout'>,</span> <span class='hs-sel'>_period</span><span class='hs-keyglyph'>]</span> <span class='hs-varop'>&&</span>
|
||||
<a name="line-171"></a> <span class='hs-varid'>not</span> <span class='hs-layout'>(</span><span class='hs-varid'>hasParentDir</span> <span class='hs-varid'>filepath</span><span class='hs-layout'>)</span> <span class='hs-varop'>&&</span>
|
||||
<a name="line-172"></a> <span class='hs-varid'>isValid</span> <span class='hs-varid'>filepath</span>
|
||||
<a name="line-173"></a> <span class='hs-keyword'>then</span> <span class='hs-varid'>return</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varop'>$</span> <span class='hs-varid'>normalise</span> <span class='hs-varid'>filepath</span><span class='hs-layout'>)</span>
|
||||
<a name="line-174"></a> <span class='hs-keyword'>else</span> <span class='hs-varid'>throwM</span> <span class='hs-layout'>(</span><span class='hs-conid'>InvalidRel</span> <span class='hs-varid'>filepath</span><span class='hs-layout'>)</span>
|
||||
<a name="line-175"></a>
|
||||
<a name="line-176"></a>
|
||||
<a name="line-177"></a><a name="parseFn"></a><span class='hs-comment'>-- | Parses a filename. Filenames must not contain slashes.</span>
|
||||
<a name="line-178"></a><span class='hs-comment'>-- Excludes '.' and '..'.</span>
|
||||
<a name="line-179"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-180"></a><span class='hs-comment'>-- Throws: 'PathParseException'</span>
|
||||
<a name="line-181"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-182"></a><span class='hs-comment'>-- >>> parseFn "abc" :: Maybe (Path Fn)</span>
|
||||
<a name="line-183"></a><span class='hs-comment'>-- Just "abc"</span>
|
||||
<a name="line-184"></a><span class='hs-comment'>-- >>> parseFn "..." :: Maybe (Path Fn)</span>
|
||||
<a name="line-185"></a><span class='hs-comment'>-- Just "..."</span>
|
||||
<a name="line-186"></a><span class='hs-comment'>-- >>> parseFn "def/" :: Maybe (Path Fn)</span>
|
||||
<a name="line-187"></a><span class='hs-comment'>-- Nothing</span>
|
||||
<a name="line-188"></a><span class='hs-comment'>-- >>> parseFn "abc/def" :: Maybe (Path Fn)</span>
|
||||
<a name="line-189"></a><span class='hs-comment'>-- Nothing</span>
|
||||
<a name="line-190"></a><span class='hs-comment'>-- >>> parseFn "abc/def/." :: Maybe (Path Fn)</span>
|
||||
<a name="line-191"></a><span class='hs-comment'>-- Nothing</span>
|
||||
<a name="line-192"></a><span class='hs-comment'>-- >>> parseFn "/abc" :: Maybe (Path Fn)</span>
|
||||
<a name="line-193"></a><span class='hs-comment'>-- Nothing</span>
|
||||
<a name="line-194"></a><span class='hs-comment'>-- >>> parseFn "" :: Maybe (Path Fn)</span>
|
||||
<a name="line-195"></a><span class='hs-comment'>-- Nothing</span>
|
||||
<a name="line-196"></a><span class='hs-comment'>-- >>> parseFn "abc/../foo" :: Maybe (Path Fn)</span>
|
||||
<a name="line-197"></a><span class='hs-comment'>-- Nothing</span>
|
||||
<a name="line-198"></a><span class='hs-comment'>-- >>> parseFn "." :: Maybe (Path Fn)</span>
|
||||
<a name="line-199"></a><span class='hs-comment'>-- Nothing</span>
|
||||
<a name="line-200"></a><span class='hs-comment'>-- >>> parseFn ".." :: Maybe (Path Fn)</span>
|
||||
<a name="line-201"></a><span class='hs-comment'>-- Nothing</span>
|
||||
<a name="line-202"></a><span class='hs-definition'>parseFn</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>MonadThrow</span> <span class='hs-varid'>m</span>
|
||||
<a name="line-203"></a> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>ByteString</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span> <span class='hs-conid'>Fn</span><span class='hs-layout'>)</span>
|
||||
<a name="line-204"></a><span class='hs-definition'>parseFn</span> <span class='hs-varid'>filepath</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-205"></a> <span class='hs-keyword'>if</span> <span class='hs-varid'>isFileName</span> <span class='hs-varid'>filepath</span> <span class='hs-varop'>&&</span>
|
||||
<a name="line-206"></a> <span class='hs-varid'>filepath</span> <span class='hs-varop'>/=</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>singleton</span> <span class='hs-sel'>_period</span> <span class='hs-varop'>&&</span>
|
||||
<a name="line-207"></a> <span class='hs-varid'>filepath</span> <span class='hs-varop'>/=</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>pack</span> <span class='hs-keyglyph'>[</span><span class='hs-sel'>_period</span><span class='hs-layout'>,</span> <span class='hs-sel'>_period</span><span class='hs-keyglyph'>]</span> <span class='hs-varop'>&&</span>
|
||||
<a name="line-208"></a> <span class='hs-varid'>isValid</span> <span class='hs-varid'>filepath</span>
|
||||
<a name="line-209"></a> <span class='hs-keyword'>then</span> <span class='hs-varid'>return</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>filepath</span><span class='hs-layout'>)</span>
|
||||
<a name="line-210"></a> <span class='hs-keyword'>else</span> <span class='hs-varid'>throwM</span> <span class='hs-layout'>(</span><span class='hs-conid'>InvalidFn</span> <span class='hs-varid'>filepath</span><span class='hs-layout'>)</span>
|
||||
<a name="line-211"></a>
|
||||
<a name="line-212"></a>
|
||||
<a name="line-213"></a>
|
||||
<a name="line-214"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
|
||||
<a name="line-215"></a><span class='hs-comment'>-- Path Conversion</span>
|
||||
<a name="line-216"></a>
|
||||
<a name="line-217"></a><a name="toFilePath"></a><span class='hs-comment'>-- | Convert any Path to a ByteString type.</span>
|
||||
<a name="line-218"></a><span class='hs-definition'>toFilePath</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-varid'>b</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>ByteString</span>
|
||||
<a name="line-219"></a><span class='hs-definition'>toFilePath</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>l</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>l</span>
|
||||
<a name="line-220"></a>
|
||||
<a name="line-221"></a><a name="fromAbs"></a><span class='hs-comment'>-- | Convert an absolute Path to a ByteString type.</span>
|
||||
<a name="line-222"></a><span class='hs-definition'>fromAbs</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>ByteString</span>
|
||||
<a name="line-223"></a><span class='hs-definition'>fromAbs</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>toFilePath</span>
|
||||
<a name="line-224"></a>
|
||||
<a name="line-225"></a><a name="fromRel"></a><span class='hs-comment'>-- | Convert a relative Path to a ByteString type.</span>
|
||||
<a name="line-226"></a><span class='hs-definition'>fromRel</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RelC</span> <span class='hs-varid'>r</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>Path</span> <span class='hs-varid'>r</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>ByteString</span>
|
||||
<a name="line-227"></a><span class='hs-definition'>fromRel</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>toFilePath</span>
|
||||
<a name="line-228"></a>
|
||||
<a name="line-229"></a>
|
||||
<a name="line-230"></a>
|
||||
<a name="line-231"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
|
||||
<a name="line-232"></a><span class='hs-comment'>-- Path Operations</span>
|
||||
<a name="line-233"></a>
|
||||
<a name="line-234"></a><a name="%3c/%3e"></a><span class='hs-comment'>-- | Append two paths.</span>
|
||||
<a name="line-235"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-236"></a><span class='hs-comment'>-- The second argument must always be a relative path, which ensures</span>
|
||||
<a name="line-237"></a><span class='hs-comment'>-- that undefinable things like `"/abc" </> "/def"` cannot happen.</span>
|
||||
<a name="line-238"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-239"></a><span class='hs-comment'>-- Technically, the first argument can be a path that points to a non-directory,</span>
|
||||
<a name="line-240"></a><span class='hs-comment'>-- because this library is IO-agnostic and makes no assumptions about</span>
|
||||
<a name="line-241"></a><span class='hs-comment'>-- file types.</span>
|
||||
<a name="line-242"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-243"></a><span class='hs-comment'>-- >>> (MkPath "/") </> (MkPath "file" :: Path Rel)</span>
|
||||
<a name="line-244"></a><span class='hs-comment'>-- "/file"</span>
|
||||
<a name="line-245"></a><span class='hs-comment'>-- >>> (MkPath "/path/to") </> (MkPath "file" :: Path Rel)</span>
|
||||
<a name="line-246"></a><span class='hs-comment'>-- "/path/to/file"</span>
|
||||
<a name="line-247"></a><span class='hs-comment'>-- >>> (MkPath "/") </> (MkPath "file/lal" :: Path Rel)</span>
|
||||
<a name="line-248"></a><span class='hs-comment'>-- "/file/lal"</span>
|
||||
<a name="line-249"></a><span class='hs-comment'>-- >>> (MkPath "/") </> (MkPath "file/" :: Path Rel)</span>
|
||||
<a name="line-250"></a><span class='hs-comment'>-- "/file/"</span>
|
||||
<a name="line-251"></a><span class='hs-layout'>(</span><span class='hs-varop'></></span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RelC</span> <span class='hs-varid'>r</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>Path</span> <span class='hs-varid'>b</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Path</span> <span class='hs-varid'>r</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Path</span> <span class='hs-varid'>b</span>
|
||||
<a name="line-252"></a><span class='hs-layout'>(</span><span class='hs-varop'></></span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>MkPath</span> <span class='hs-layout'>(</span><span class='hs-varid'>a'</span> <span class='hs-varop'>`</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>append</span><span class='hs-varop'>`</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span>
|
||||
<a name="line-253"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-254"></a> <span class='hs-varid'>a'</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>if</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>last</span> <span class='hs-varid'>a</span> <span class='hs-varop'>==</span> <span class='hs-varid'>pathSeparator</span>
|
||||
<a name="line-255"></a> <span class='hs-keyword'>then</span> <span class='hs-varid'>a</span>
|
||||
<a name="line-256"></a> <span class='hs-keyword'>else</span> <span class='hs-varid'>addTrailingPathSeparator</span> <span class='hs-varid'>a</span>
|
||||
<a name="line-257"></a>
|
||||
<a name="line-258"></a><a name="stripDir"></a><span class='hs-comment'>-- | Strip directory from path, making it relative to that directory.</span>
|
||||
<a name="line-259"></a><span class='hs-comment'>-- Throws 'Couldn'tStripPrefixDir' if directory is not a parent of the path.</span>
|
||||
<a name="line-260"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-261"></a><span class='hs-comment'>-- The bases must match.</span>
|
||||
<a name="line-262"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-263"></a><span class='hs-comment'>-- >>> (MkPath "/lal/lad") `stripDir` (MkPath "/lal/lad/fad") :: Maybe (Path Rel)</span>
|
||||
<a name="line-264"></a><span class='hs-comment'>-- Just "fad"</span>
|
||||
<a name="line-265"></a><span class='hs-comment'>-- >>> (MkPath "lal/lad") `stripDir` (MkPath "lal/lad/fad") :: Maybe (Path Rel)</span>
|
||||
<a name="line-266"></a><span class='hs-comment'>-- Just "fad"</span>
|
||||
<a name="line-267"></a><span class='hs-comment'>-- >>> (MkPath "/") `stripDir` (MkPath "/") :: Maybe (Path Rel)</span>
|
||||
<a name="line-268"></a><span class='hs-comment'>-- Nothing</span>
|
||||
<a name="line-269"></a><span class='hs-comment'>-- >>> (MkPath "/lal/lad/fad") `stripDir` (MkPath "/lal/lad") :: Maybe (Path Rel)</span>
|
||||
<a name="line-270"></a><span class='hs-comment'>-- Nothing</span>
|
||||
<a name="line-271"></a><span class='hs-comment'>-- >>> (MkPath "fad") `stripDir` (MkPath "fad") :: Maybe (Path Rel)</span>
|
||||
<a name="line-272"></a><span class='hs-comment'>-- Nothing</span>
|
||||
<a name="line-273"></a><span class='hs-definition'>stripDir</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>MonadThrow</span> <span class='hs-varid'>m</span>
|
||||
<a name="line-274"></a> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>Path</span> <span class='hs-varid'>b</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Path</span> <span class='hs-varid'>b</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span> <span class='hs-conid'>Rel</span><span class='hs-layout'>)</span>
|
||||
<a name="line-275"></a><span class='hs-definition'>stripDir</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>p</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>l</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-276"></a> <span class='hs-keyword'>case</span> <span class='hs-varid'>stripPrefix</span> <span class='hs-varid'>p'</span> <span class='hs-varid'>l</span> <span class='hs-keyword'>of</span>
|
||||
<a name="line-277"></a> <span class='hs-conid'>Nothing</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>throwM</span> <span class='hs-layout'>(</span><span class='hs-conid'>Couldn'tStripPrefixTPS</span> <span class='hs-varid'>p'</span> <span class='hs-varid'>l</span><span class='hs-layout'>)</span>
|
||||
<a name="line-278"></a> <span class='hs-conid'>Just</span> <span class='hs-varid'>ok</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>if</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span> <span class='hs-varid'>ok</span>
|
||||
<a name="line-279"></a> <span class='hs-keyword'>then</span> <span class='hs-varid'>throwM</span> <span class='hs-layout'>(</span><span class='hs-conid'>Couldn'tStripPrefixTPS</span> <span class='hs-varid'>p'</span> <span class='hs-varid'>l</span><span class='hs-layout'>)</span>
|
||||
<a name="line-280"></a> <span class='hs-keyword'>else</span> <span class='hs-varid'>return</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>ok</span><span class='hs-layout'>)</span>
|
||||
<a name="line-281"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-282"></a> <span class='hs-varid'>p'</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>addTrailingPathSeparator</span> <span class='hs-varid'>p</span>
|
||||
<a name="line-283"></a>
|
||||
<a name="line-284"></a><a name="isParentOf"></a><span class='hs-comment'>-- | Is p a parent of the given location? Implemented in terms of</span>
|
||||
<a name="line-285"></a><span class='hs-comment'>-- 'stripDir'. The bases must match.</span>
|
||||
<a name="line-286"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-287"></a><span class='hs-comment'>-- >>> (MkPath "/lal/lad") `isParentOf` (MkPath "/lal/lad/fad")</span>
|
||||
<a name="line-288"></a><span class='hs-comment'>-- True</span>
|
||||
<a name="line-289"></a><span class='hs-comment'>-- >>> (MkPath "lal/lad") `isParentOf` (MkPath "lal/lad/fad")</span>
|
||||
<a name="line-290"></a><span class='hs-comment'>-- True</span>
|
||||
<a name="line-291"></a><span class='hs-comment'>-- >>> (MkPath "/") `isParentOf` (MkPath "/")</span>
|
||||
<a name="line-292"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-293"></a><span class='hs-comment'>-- >>> (MkPath "/lal/lad/fad") `isParentOf` (MkPath "/lal/lad")</span>
|
||||
<a name="line-294"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-295"></a><span class='hs-comment'>-- >>> (MkPath "fad") `isParentOf` (MkPath "fad")</span>
|
||||
<a name="line-296"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-297"></a><span class='hs-definition'>isParentOf</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-varid'>b</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Path</span> <span class='hs-varid'>b</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Bool</span>
|
||||
<a name="line-298"></a><span class='hs-definition'>isParentOf</span> <span class='hs-varid'>p</span> <span class='hs-varid'>l</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>isJust</span> <span class='hs-layout'>(</span><span class='hs-varid'>stripDir</span> <span class='hs-varid'>p</span> <span class='hs-varid'>l</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Maybe</span> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span> <span class='hs-conid'>Rel</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
|
||||
<a name="line-299"></a>
|
||||
<a name="line-300"></a>
|
||||
<a name="line-301"></a><a name="getAllParents"></a><span class='hs-comment'>-- |Get all parents of a path.</span>
|
||||
<a name="line-302"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-303"></a><span class='hs-comment'>-- >>> getAllParents (MkPath "/abs/def/dod")</span>
|
||||
<a name="line-304"></a><span class='hs-comment'>-- ["/abs/def","/abs","/"]</span>
|
||||
<a name="line-305"></a><span class='hs-comment'>-- >>> getAllParents (MkPath "/")</span>
|
||||
<a name="line-306"></a><span class='hs-comment'>-- []</span>
|
||||
<a name="line-307"></a><span class='hs-definition'>getAllParents</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-308"></a><span class='hs-definition'>getAllParents</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>p</span><span class='hs-layout'>)</span>
|
||||
<a name="line-309"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>np</span> <span class='hs-varop'>==</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>singleton</span> <span class='hs-varid'>pathSeparator</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>[]</span>
|
||||
<a name="line-310"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dirname</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>np</span><span class='hs-layout'>)</span> <span class='hs-conop'>:</span> <span class='hs-varid'>getAllParents</span> <span class='hs-layout'>(</span><span class='hs-varid'>dirname</span> <span class='hs-varop'>$</span> <span class='hs-conid'>MkPath</span> <span class='hs-varid'>np</span><span class='hs-layout'>)</span>
|
||||
<a name="line-311"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-312"></a> <span class='hs-varid'>np</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dropTrailingPathSeparator</span> <span class='hs-varop'>.</span> <span class='hs-varid'>normalise</span> <span class='hs-varop'>$</span> <span class='hs-varid'>p</span>
|
||||
<a name="line-313"></a>
|
||||
<a name="line-314"></a>
|
||||
<a name="line-315"></a><a name="dirname"></a><span class='hs-comment'>-- | Extract the directory name of a path.</span>
|
||||
<a name="line-316"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-317"></a><span class='hs-comment'>-- The following properties hold:</span>
|
||||
<a name="line-318"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-319"></a><span class='hs-comment'>-- @dirname (p \<\/> a) == dirname p@</span>
|
||||
<a name="line-320"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-321"></a><span class='hs-comment'>-- >>> dirname (MkPath "/abc/def/dod")</span>
|
||||
<a name="line-322"></a><span class='hs-comment'>-- "/abc/def"</span>
|
||||
<a name="line-323"></a><span class='hs-comment'>-- >>> dirname (MkPath "/")</span>
|
||||
<a name="line-324"></a><span class='hs-comment'>-- "/"</span>
|
||||
<a name="line-325"></a><span class='hs-definition'>dirname</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span>
|
||||
<a name="line-326"></a><span class='hs-definition'>dirname</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>fp</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>MkPath</span> <span class='hs-layout'>(</span><span class='hs-varid'>takeDirectory</span> <span class='hs-varop'>$</span> <span class='hs-varid'>dropTrailingPathSeparator</span> <span class='hs-varid'>fp</span><span class='hs-layout'>)</span>
|
||||
<a name="line-327"></a>
|
||||
<a name="line-328"></a><a name="basename"></a><span class='hs-comment'>-- | Extract the file part of a path.</span>
|
||||
<a name="line-329"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-330"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-331"></a><span class='hs-comment'>-- The following properties hold:</span>
|
||||
<a name="line-332"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-333"></a><span class='hs-comment'>-- @basename (p \<\/> a) == basename a@</span>
|
||||
<a name="line-334"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-335"></a><span class='hs-comment'>-- Throws: `PathException` if given the root path "/"</span>
|
||||
<a name="line-336"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-337"></a><span class='hs-comment'>-- >>> basename (MkPath "/abc/def/dod") :: Maybe (Path Fn)</span>
|
||||
<a name="line-338"></a><span class='hs-comment'>-- Just "dod"</span>
|
||||
<a name="line-339"></a><span class='hs-comment'>-- >>> basename (MkPath "/") :: Maybe (Path Fn)</span>
|
||||
<a name="line-340"></a><span class='hs-comment'>-- Nothing</span>
|
||||
<a name="line-341"></a><span class='hs-definition'>basename</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>MonadThrow</span> <span class='hs-varid'>m</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>Path</span> <span class='hs-varid'>b</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span> <span class='hs-conid'>Fn</span><span class='hs-layout'>)</span>
|
||||
<a name="line-342"></a><span class='hs-definition'>basename</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>l</span><span class='hs-layout'>)</span>
|
||||
<a name="line-343"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>not</span> <span class='hs-layout'>(</span><span class='hs-varid'>isAbsolute</span> <span class='hs-varid'>rl</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>return</span> <span class='hs-varop'>$</span> <span class='hs-conid'>MkPath</span> <span class='hs-varid'>rl</span>
|
||||
<a name="line-344"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>throwM</span> <span class='hs-conid'>RootDirHasNoBasename</span>
|
||||
<a name="line-345"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-346"></a> <span class='hs-varid'>rl</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>last</span> <span class='hs-varop'>.</span> <span class='hs-varid'>splitPath</span> <span class='hs-varop'>.</span> <span class='hs-varid'>dropTrailingPathSeparator</span> <span class='hs-varop'>$</span> <span class='hs-varid'>l</span>
|
||||
<a name="line-347"></a>
|
||||
<a name="line-348"></a>
|
||||
<a name="line-349"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
|
||||
<a name="line-350"></a><span class='hs-comment'>-- Path IO helpers</span>
|
||||
<a name="line-351"></a>
|
||||
<a name="line-352"></a>
|
||||
<a name="line-353"></a><a name="withAbsPath"></a><span class='hs-definition'>withAbsPath</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-conid'>ByteString</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>a</span>
|
||||
<a name="line-354"></a><span class='hs-definition'>withAbsPath</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>p</span><span class='hs-layout'>)</span> <span class='hs-varid'>action</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>action</span> <span class='hs-varid'>p</span>
|
||||
<a name="line-355"></a>
|
||||
<a name="line-356"></a>
|
||||
<a name="line-357"></a><a name="withRelPath"></a><span class='hs-definition'>withRelPath</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Rel</span> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-conid'>ByteString</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>a</span>
|
||||
<a name="line-358"></a><span class='hs-definition'>withRelPath</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>p</span><span class='hs-layout'>)</span> <span class='hs-varid'>action</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>action</span> <span class='hs-varid'>p</span>
|
||||
<a name="line-359"></a>
|
||||
<a name="line-360"></a>
|
||||
<a name="line-361"></a><a name="withFnPath"></a><span class='hs-definition'>withFnPath</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Path</span> <span class='hs-conid'>Fn</span> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-conid'>ByteString</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>a</span>
|
||||
<a name="line-362"></a><span class='hs-definition'>withFnPath</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>p</span><span class='hs-layout'>)</span> <span class='hs-varid'>action</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>action</span> <span class='hs-varid'>p</span>
|
||||
<a name="line-363"></a>
|
||||
<a name="line-364"></a>
|
||||
<a name="line-365"></a><span class='hs-comment'>------------------------</span>
|
||||
<a name="line-366"></a><span class='hs-comment'>-- ByteString helpers</span>
|
||||
<a name="line-367"></a>
|
||||
<a name="line-368"></a><span class='hs-cpp'>#if MIN_VERSION_bytestring(0,10,8)</span>
|
||||
<a name="line-369"></a><span class='hs-cpp'>#else</span>
|
||||
<a name="line-370"></a><a name="stripPrefix"></a><span class='hs-definition'>stripPrefix</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>ByteString</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>ByteString</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Maybe</span> <span class='hs-conid'>ByteString</span>
|
||||
<a name="line-371"></a><span class='hs-definition'>stripPrefix</span> <span class='hs-varid'>a</span> <span class='hs-varid'>b</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>pack</span> <span class='hs-varop'>`fmap`</span> <span class='hs-conid'>L</span><span class='hs-varop'>.</span><span class='hs-varid'>stripPrefix</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>unpack</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>unpack</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span>
|
||||
<a name="line-372"></a><span class='hs-cpp'>#endif</span>
|
||||
</pre></body>
|
||||
</html>
|
118
src/System-Posix-Directory-Foreign.html
Normal file
118
src/System-Posix-Directory-Foreign.html
Normal file
@ -0,0 +1,118 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
|
||||
<title>dist/build/System/Posix/Directory/Foreign.hs</title>
|
||||
<link type='text/css' rel='stylesheet' href='hscolour.css' />
|
||||
</head>
|
||||
<body>
|
||||
<pre><a name="line-1"></a><span class='hs-comment'>{-# LINE 1 "src/System/Posix/Directory/Foreign.hsc" #-}</span>
|
||||
<a name="line-2"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Directory</span><span class='hs-varop'>.</span><span class='hs-conid'>Foreign</span> <span class='hs-keyword'>where</span>
|
||||
<a name="line-3"></a><span class='hs-comment'>{-# LINE 2 "src/System/Posix/Directory/Foreign.hsc" #-}</span>
|
||||
<a name="line-4"></a>
|
||||
<a name="line-5"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Bits</span>
|
||||
<a name="line-6"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>List</span> <span class='hs-layout'>(</span><span class='hs-varid'>foldl'</span><span class='hs-layout'>)</span>
|
||||
<a name="line-7"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>C</span><span class='hs-varop'>.</span><span class='hs-conid'>Types</span>
|
||||
<a name="line-8"></a>
|
||||
<a name="line-9"></a>
|
||||
<a name="line-10"></a><span class='hs-comment'>{-# LINE 8 "src/System/Posix/Directory/Foreign.hsc" #-}</span>
|
||||
<a name="line-11"></a>
|
||||
<a name="line-12"></a><span class='hs-comment'>{-# LINE 9 "src/System/Posix/Directory/Foreign.hsc" #-}</span>
|
||||
<a name="line-13"></a>
|
||||
<a name="line-14"></a><span class='hs-comment'>{-# LINE 10 "src/System/Posix/Directory/Foreign.hsc" #-}</span>
|
||||
<a name="line-15"></a>
|
||||
<a name="line-16"></a><span class='hs-comment'>{-# LINE 11 "src/System/Posix/Directory/Foreign.hsc" #-}</span>
|
||||
<a name="line-17"></a>
|
||||
<a name="line-18"></a><span class='hs-comment'>{-# LINE 12 "src/System/Posix/Directory/Foreign.hsc" #-}</span>
|
||||
<a name="line-19"></a>
|
||||
<a name="line-20"></a><span class='hs-comment'>{-# LINE 13 "src/System/Posix/Directory/Foreign.hsc" #-}</span>
|
||||
<a name="line-21"></a>
|
||||
<a name="line-22"></a><a name="DirType"></a><span class='hs-keyword'>newtype</span> <span class='hs-conid'>DirType</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>DirType</span> <span class='hs-conid'>Int</span> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span><span class='hs-conid'>Eq</span><span class='hs-layout'>,</span> <span class='hs-conid'>Show</span><span class='hs-layout'>)</span>
|
||||
<a name="line-23"></a><a name="Flags"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>Flags</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Flags</span> <span class='hs-conid'>Int</span> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>UnsupportedFlag</span> <span class='hs-conid'>String</span> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span><span class='hs-conid'>Eq</span><span class='hs-layout'>,</span> <span class='hs-conid'>Show</span><span class='hs-layout'>)</span>
|
||||
<a name="line-24"></a>
|
||||
<a name="line-25"></a><a name="unFlags"></a><span class='hs-definition'>unFlags</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Flags</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Int</span>
|
||||
<a name="line-26"></a><span class='hs-definition'>unFlags</span> <span class='hs-layout'>(</span><span class='hs-conid'>Flags</span> <span class='hs-varid'>i</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>i</span>
|
||||
<a name="line-27"></a><span class='hs-definition'>unFlags</span> <span class='hs-layout'>(</span><span class='hs-conid'>UnsupportedFlag</span> <span class='hs-varid'>name</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>error</span> <span class='hs-layout'>(</span><span class='hs-varid'>name</span> <span class='hs-varop'>++</span> <span class='hs-str'>" is not supported on this platform"</span><span class='hs-layout'>)</span>
|
||||
<a name="line-28"></a>
|
||||
<a name="line-29"></a><a name="isSupported"></a><span class='hs-comment'>-- |Returns @True@ if posix-paths was compiled with support for the provided</span>
|
||||
<a name="line-30"></a><span class='hs-comment'>-- flag. (As of this writing, the only flag for which this check may be</span>
|
||||
<a name="line-31"></a><span class='hs-comment'>-- necessary is 'oCloexec'; all other flags will always yield @True@.)</span>
|
||||
<a name="line-32"></a><span class='hs-definition'>isSupported</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Flags</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Bool</span>
|
||||
<a name="line-33"></a><span class='hs-definition'>isSupported</span> <span class='hs-layout'>(</span><span class='hs-conid'>Flags</span> <span class='hs-keyword'>_</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>True</span>
|
||||
<a name="line-34"></a><span class='hs-definition'>isSupported</span> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>False</span>
|
||||
<a name="line-35"></a>
|
||||
<a name="line-36"></a><a name="oCloexec"></a><span class='hs-comment'>-- |@O_CLOEXEC@ is not supported on every POSIX platform. Use</span>
|
||||
<a name="line-37"></a><span class='hs-comment'>-- @'isSupported' oCloexec@ to determine if support for @O_CLOEXEC@ was</span>
|
||||
<a name="line-38"></a><span class='hs-comment'>-- compiled into your version of posix-paths. (If not, using @oCloexec@ will</span>
|
||||
<a name="line-39"></a><span class='hs-comment'>-- throw an exception.)</span>
|
||||
<a name="line-40"></a><span class='hs-definition'>oCloexec</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Flags</span>
|
||||
<a name="line-41"></a>
|
||||
<a name="line-42"></a><span class='hs-comment'>{-# LINE 34 "src/System/Posix/Directory/Foreign.hsc" #-}</span>
|
||||
<a name="line-43"></a><span class='hs-definition'>oCloexec</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Flags</span> <span class='hs-num'>524288</span>
|
||||
<a name="line-44"></a><span class='hs-comment'>{-# LINE 35 "src/System/Posix/Directory/Foreign.hsc" #-}</span>
|
||||
<a name="line-45"></a>
|
||||
<a name="line-46"></a><span class='hs-comment'>{-# LINE 40 "src/System/Posix/Directory/Foreign.hsc" #-}</span>
|
||||
<a name="line-47"></a>
|
||||
<a name="line-48"></a>
|
||||
<a name="line-49"></a>
|
||||
<a name="line-50"></a><span class='hs-comment'>-- If these enum declarations occur earlier in the file, haddock</span>
|
||||
<a name="line-51"></a><span class='hs-comment'>-- gets royally confused about the above doc comments.</span>
|
||||
<a name="line-52"></a><span class='hs-comment'>-- Probably <a href="http://trac.haskell.org/haddock/ticket/138">http://trac.haskell.org/haddock/ticket/138</a></span>
|
||||
<a name="line-53"></a>
|
||||
<a name="line-54"></a><a name="dtBlk"></a><span class='hs-definition'>dtBlk</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>DirType</span>
|
||||
<a name="line-55"></a><span class='hs-definition'>dtBlk</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>DirType</span> <span class='hs-num'>6</span>
|
||||
<a name="line-56"></a><a name="dtChr"></a><span class='hs-definition'>dtChr</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>DirType</span>
|
||||
<a name="line-57"></a><span class='hs-definition'>dtChr</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>DirType</span> <span class='hs-num'>2</span>
|
||||
<a name="line-58"></a><a name="dtDir"></a><span class='hs-definition'>dtDir</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>DirType</span>
|
||||
<a name="line-59"></a><span class='hs-definition'>dtDir</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>DirType</span> <span class='hs-num'>4</span>
|
||||
<a name="line-60"></a><a name="dtFifo"></a><span class='hs-definition'>dtFifo</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>DirType</span>
|
||||
<a name="line-61"></a><span class='hs-definition'>dtFifo</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>DirType</span> <span class='hs-num'>1</span>
|
||||
<a name="line-62"></a><a name="dtLnk"></a><span class='hs-definition'>dtLnk</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>DirType</span>
|
||||
<a name="line-63"></a><span class='hs-definition'>dtLnk</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>DirType</span> <span class='hs-num'>10</span>
|
||||
<a name="line-64"></a><a name="dtReg"></a><span class='hs-definition'>dtReg</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>DirType</span>
|
||||
<a name="line-65"></a><span class='hs-definition'>dtReg</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>DirType</span> <span class='hs-num'>8</span>
|
||||
<a name="line-66"></a><a name="dtSock"></a><span class='hs-definition'>dtSock</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>DirType</span>
|
||||
<a name="line-67"></a><span class='hs-definition'>dtSock</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>DirType</span> <span class='hs-num'>12</span>
|
||||
<a name="line-68"></a><a name="dtUnknown"></a><span class='hs-definition'>dtUnknown</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>DirType</span>
|
||||
<a name="line-69"></a><span class='hs-definition'>dtUnknown</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>DirType</span> <span class='hs-num'>0</span>
|
||||
<a name="line-70"></a>
|
||||
<a name="line-71"></a><span class='hs-comment'>{-# LINE 48 "src/System/Posix/Directory/Foreign.hsc" #-}</span>
|
||||
<a name="line-72"></a>
|
||||
<a name="line-73"></a><a name="oAppend"></a><span class='hs-definition'>oAppend</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Flags</span>
|
||||
<a name="line-74"></a><span class='hs-definition'>oAppend</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Flags</span> <span class='hs-num'>1024</span>
|
||||
<a name="line-75"></a><a name="oAsync"></a><span class='hs-definition'>oAsync</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Flags</span>
|
||||
<a name="line-76"></a><span class='hs-definition'>oAsync</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Flags</span> <span class='hs-num'>8192</span>
|
||||
<a name="line-77"></a><a name="oCreat"></a><span class='hs-definition'>oCreat</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Flags</span>
|
||||
<a name="line-78"></a><span class='hs-definition'>oCreat</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Flags</span> <span class='hs-num'>64</span>
|
||||
<a name="line-79"></a><a name="oDirectory"></a><span class='hs-definition'>oDirectory</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Flags</span>
|
||||
<a name="line-80"></a><span class='hs-definition'>oDirectory</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Flags</span> <span class='hs-num'>65536</span>
|
||||
<a name="line-81"></a><a name="oExcl"></a><span class='hs-definition'>oExcl</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Flags</span>
|
||||
<a name="line-82"></a><span class='hs-definition'>oExcl</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Flags</span> <span class='hs-num'>128</span>
|
||||
<a name="line-83"></a><a name="oNoctty"></a><span class='hs-definition'>oNoctty</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Flags</span>
|
||||
<a name="line-84"></a><span class='hs-definition'>oNoctty</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Flags</span> <span class='hs-num'>256</span>
|
||||
<a name="line-85"></a><a name="oNofollow"></a><span class='hs-definition'>oNofollow</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Flags</span>
|
||||
<a name="line-86"></a><span class='hs-definition'>oNofollow</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Flags</span> <span class='hs-num'>131072</span>
|
||||
<a name="line-87"></a><a name="oNonblock"></a><span class='hs-definition'>oNonblock</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Flags</span>
|
||||
<a name="line-88"></a><span class='hs-definition'>oNonblock</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Flags</span> <span class='hs-num'>2048</span>
|
||||
<a name="line-89"></a><a name="oRdonly"></a><span class='hs-definition'>oRdonly</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Flags</span>
|
||||
<a name="line-90"></a><span class='hs-definition'>oRdonly</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Flags</span> <span class='hs-num'>0</span>
|
||||
<a name="line-91"></a><a name="oWronly"></a><span class='hs-definition'>oWronly</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Flags</span>
|
||||
<a name="line-92"></a><span class='hs-definition'>oWronly</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Flags</span> <span class='hs-num'>1</span>
|
||||
<a name="line-93"></a><a name="oRdwr"></a><span class='hs-definition'>oRdwr</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Flags</span>
|
||||
<a name="line-94"></a><span class='hs-definition'>oRdwr</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Flags</span> <span class='hs-num'>2</span>
|
||||
<a name="line-95"></a><a name="oSync"></a><span class='hs-definition'>oSync</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Flags</span>
|
||||
<a name="line-96"></a><span class='hs-definition'>oSync</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Flags</span> <span class='hs-num'>1052672</span>
|
||||
<a name="line-97"></a><a name="oTrunc"></a><span class='hs-definition'>oTrunc</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Flags</span>
|
||||
<a name="line-98"></a><span class='hs-definition'>oTrunc</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Flags</span> <span class='hs-num'>512</span>
|
||||
<a name="line-99"></a>
|
||||
<a name="line-100"></a><span class='hs-comment'>{-# LINE 50 "src/System/Posix/Directory/Foreign.hsc" #-}</span>
|
||||
<a name="line-101"></a>
|
||||
<a name="line-102"></a><a name="pathMax"></a><span class='hs-definition'>pathMax</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Int</span>
|
||||
<a name="line-103"></a><span class='hs-definition'>pathMax</span> <span class='hs-keyglyph'>=</span> <span class='hs-num'>4096</span>
|
||||
<a name="line-104"></a><span class='hs-comment'>{-# LINE 53 "src/System/Posix/Directory/Foreign.hsc" #-}</span>
|
||||
<a name="line-105"></a>
|
||||
<a name="line-106"></a><a name="unionFlags"></a><span class='hs-definition'>unionFlags</span> <span class='hs-keyglyph'>::</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>Flags</span><span class='hs-keyglyph'>]</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>CInt</span>
|
||||
<a name="line-107"></a><span class='hs-definition'>unionFlags</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>fromIntegral</span> <span class='hs-varop'>.</span> <span class='hs-varid'>foldl'</span> <span class='hs-layout'>(</span><span class='hs-layout'>(</span><span class='hs-varop'>.</span> <span class='hs-varid'>unFlags</span><span class='hs-layout'>)</span> <span class='hs-varop'>.</span> <span class='hs-layout'>(</span><span class='hs-varop'>.|.</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span> <span class='hs-num'>0</span>
|
||||
</pre></body>
|
||||
</html>
|
271
src/System-Posix-Directory-Traversals.html
Normal file
271
src/System-Posix-Directory-Traversals.html
Normal file
@ -0,0 +1,271 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
|
||||
<title>src/System/Posix/Directory/Traversals.hs</title>
|
||||
<link type='text/css' rel='stylesheet' href='hscolour.css' />
|
||||
</head>
|
||||
<body>
|
||||
<pre><a name="line-1"></a><span class='hs-comment'>-- |</span>
|
||||
<a name="line-2"></a><span class='hs-comment'>-- Module : System.Posix.Directory.Traversals</span>
|
||||
<a name="line-3"></a><span class='hs-comment'>-- Copyright : © 2016 Julian Ospald</span>
|
||||
<a name="line-4"></a><span class='hs-comment'>-- License : BSD3</span>
|
||||
<a name="line-5"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-6"></a><span class='hs-comment'>-- Maintainer : Julian Ospald <hasufell@posteo.de></span>
|
||||
<a name="line-7"></a><span class='hs-comment'>-- Stability : experimental</span>
|
||||
<a name="line-8"></a><span class='hs-comment'>-- Portability : portable</span>
|
||||
<a name="line-9"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-10"></a><span class='hs-comment'>-- Traversal and read operations on directories.</span>
|
||||
<a name="line-11"></a>
|
||||
<a name="line-12"></a>
|
||||
<a name="line-13"></a><span class='hs-comment'>{-# LANGUAGE ForeignFunctionInterface #-}</span>
|
||||
<a name="line-14"></a><span class='hs-comment'>{-# LANGUAGE OverloadedStrings #-}</span>
|
||||
<a name="line-15"></a><span class='hs-comment'>{-# LANGUAGE PackageImports #-}</span>
|
||||
<a name="line-16"></a><span class='hs-comment'>{-# LANGUAGE TupleSections #-}</span>
|
||||
<a name="line-17"></a><span class='hs-comment'>{-# LANGUAGE ViewPatterns #-}</span>
|
||||
<a name="line-18"></a>
|
||||
<a name="line-19"></a><span class='hs-comment'>{-# OPTIONS_GHC -Wall #-}</span>
|
||||
<a name="line-20"></a>
|
||||
<a name="line-21"></a>
|
||||
<a name="line-22"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Directory</span><span class='hs-varop'>.</span><span class='hs-conid'>Traversals</span> <span class='hs-layout'>(</span>
|
||||
<a name="line-23"></a>
|
||||
<a name="line-24"></a> <span class='hs-varid'>getDirectoryContents</span>
|
||||
<a name="line-25"></a><span class='hs-layout'>,</span> <span class='hs-varid'>getDirectoryContents'</span>
|
||||
<a name="line-26"></a>
|
||||
<a name="line-27"></a><span class='hs-layout'>,</span> <span class='hs-varid'>allDirectoryContents</span>
|
||||
<a name="line-28"></a><span class='hs-layout'>,</span> <span class='hs-varid'>allDirectoryContents'</span>
|
||||
<a name="line-29"></a><span class='hs-layout'>,</span> <span class='hs-varid'>traverseDirectory</span>
|
||||
<a name="line-30"></a>
|
||||
<a name="line-31"></a><span class='hs-comment'>-- lower-level stuff</span>
|
||||
<a name="line-32"></a><span class='hs-layout'>,</span> <span class='hs-varid'>readDirEnt</span>
|
||||
<a name="line-33"></a><span class='hs-layout'>,</span> <span class='hs-varid'>packDirStream</span>
|
||||
<a name="line-34"></a><span class='hs-layout'>,</span> <span class='hs-varid'>unpackDirStream</span>
|
||||
<a name="line-35"></a><span class='hs-layout'>,</span> <span class='hs-varid'>fdOpendir</span>
|
||||
<a name="line-36"></a>
|
||||
<a name="line-37"></a><span class='hs-layout'>,</span> <span class='hs-varid'>realpath</span>
|
||||
<a name="line-38"></a><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
|
||||
<a name="line-39"></a>
|
||||
<a name="line-40"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Applicative</span>
|
||||
<a name="line-41"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Monad</span>
|
||||
<a name="line-42"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>FilePath</span> <span class='hs-layout'>(</span><span class='hs-layout'>(</span><span class='hs-varop'></></span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
|
||||
<a name="line-43"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Directory</span><span class='hs-varop'>.</span><span class='hs-conid'>Foreign</span>
|
||||
<a name="line-44"></a>
|
||||
<a name="line-45"></a><span class='hs-keyword'>import</span> <span class='hs-keyword'>qualified</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span> <span class='hs-keyword'>as</span> <span class='hs-conid'>Posix</span>
|
||||
<a name="line-46"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>IO</span><span class='hs-varop'>.</span><span class='hs-conid'>Error</span>
|
||||
<a name="line-47"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Exception</span>
|
||||
<a name="line-48"></a><span class='hs-keyword'>import</span> <span class='hs-keyword'>qualified</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span><span class='hs-varop'>.</span><span class='hs-conid'>Char8</span> <span class='hs-keyword'>as</span> <span class='hs-conid'>BS</span>
|
||||
<a name="line-49"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span><span class='hs-varop'>.</span><span class='hs-conid'>FilePath</span>
|
||||
<a name="line-50"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Directory</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span> <span class='hs-keyword'>as</span> <span class='hs-conid'>PosixBS</span>
|
||||
<a name="line-51"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Files</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span>
|
||||
<a name="line-52"></a>
|
||||
<a name="line-53"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>IO</span><span class='hs-varop'>.</span><span class='hs-conid'>Unsafe</span>
|
||||
<a name="line-54"></a><span class='hs-keyword'>import</span> <span class='hs-str'>"unix"</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>IO</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span> <span class='hs-layout'>(</span><span class='hs-varid'>closeFd</span><span class='hs-layout'>)</span>
|
||||
<a name="line-55"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Unsafe</span><span class='hs-varop'>.</span><span class='hs-conid'>Coerce</span> <span class='hs-layout'>(</span><span class='hs-varid'>unsafeCoerce</span><span class='hs-layout'>)</span>
|
||||
<a name="line-56"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>C</span><span class='hs-varop'>.</span><span class='hs-conid'>Error</span>
|
||||
<a name="line-57"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>C</span><span class='hs-varop'>.</span><span class='hs-conid'>String</span>
|
||||
<a name="line-58"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>C</span><span class='hs-varop'>.</span><span class='hs-conid'>Types</span>
|
||||
<a name="line-59"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>Marshal</span><span class='hs-varop'>.</span><span class='hs-conid'>Alloc</span> <span class='hs-layout'>(</span><span class='hs-varid'>alloca</span><span class='hs-layout'>,</span><span class='hs-varid'>allocaBytes</span><span class='hs-layout'>)</span>
|
||||
<a name="line-60"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>Ptr</span>
|
||||
<a name="line-61"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>Storable</span>
|
||||
<a name="line-62"></a>
|
||||
<a name="line-63"></a>
|
||||
<a name="line-64"></a>
|
||||
<a name="line-65"></a>
|
||||
<a name="line-66"></a><span class='hs-comment'>----------------------------------------------------------</span>
|
||||
<a name="line-67"></a>
|
||||
<a name="line-68"></a><a name="allDirectoryContents"></a><span class='hs-comment'>-- | Get all files from a directory and its subdirectories.</span>
|
||||
<a name="line-69"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-70"></a><span class='hs-comment'>-- Upon entering a directory, 'allDirectoryContents' will get all entries</span>
|
||||
<a name="line-71"></a><span class='hs-comment'>-- strictly. However the returned list is lazy in that directories will only</span>
|
||||
<a name="line-72"></a><span class='hs-comment'>-- be accessed on demand.</span>
|
||||
<a name="line-73"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-74"></a><span class='hs-comment'>-- Follows symbolic links for the input dir.</span>
|
||||
<a name="line-75"></a><span class='hs-definition'>allDirectoryContents</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>RawFilePath</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-76"></a><span class='hs-definition'>allDirectoryContents</span> <span class='hs-varid'>topdir</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-77"></a> <span class='hs-varid'>namesAndTypes</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>getDirectoryContents</span> <span class='hs-varid'>topdir</span>
|
||||
<a name="line-78"></a> <span class='hs-keyword'>let</span> <span class='hs-varid'>properNames</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>filter</span> <span class='hs-layout'>(</span><span class='hs-layout'>(</span><span class='hs-varop'>`notElem`</span> <span class='hs-keyglyph'>[</span><span class='hs-str'>"."</span><span class='hs-layout'>,</span> <span class='hs-str'>".."</span><span class='hs-keyglyph'>]</span><span class='hs-layout'>)</span> <span class='hs-varop'>.</span> <span class='hs-varid'>snd</span><span class='hs-layout'>)</span> <span class='hs-varid'>namesAndTypes</span>
|
||||
<a name="line-79"></a> <span class='hs-varid'>paths</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>forM</span> <span class='hs-varid'>properNames</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-layout'>(</span><span class='hs-varid'>typ</span><span class='hs-layout'>,</span><span class='hs-varid'>name</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>unsafeInterleaveIO</span> <span class='hs-varop'>$</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-80"></a> <span class='hs-keyword'>let</span> <span class='hs-varid'>path</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>topdir</span> <span class='hs-varop'></></span> <span class='hs-varid'>name</span>
|
||||
<a name="line-81"></a> <span class='hs-keyword'>case</span> <span class='hs-conid'>()</span> <span class='hs-keyword'>of</span>
|
||||
<a name="line-82"></a> <span class='hs-conid'>()</span> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>typ</span> <span class='hs-varop'>==</span> <span class='hs-varid'>dtDir</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>allDirectoryContents</span> <span class='hs-varid'>path</span>
|
||||
<a name="line-83"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>typ</span> <span class='hs-varop'>==</span> <span class='hs-varid'>dtUnknown</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-84"></a> <span class='hs-varid'>isDir</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>isDirectory</span> <span class='hs-varop'><$></span> <span class='hs-varid'>getFileStatus</span> <span class='hs-varid'>path</span>
|
||||
<a name="line-85"></a> <span class='hs-keyword'>if</span> <span class='hs-varid'>isDir</span>
|
||||
<a name="line-86"></a> <span class='hs-keyword'>then</span> <span class='hs-varid'>allDirectoryContents</span> <span class='hs-varid'>path</span>
|
||||
<a name="line-87"></a> <span class='hs-keyword'>else</span> <span class='hs-varid'>return</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>path</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-88"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>return</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>path</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-89"></a> <span class='hs-varid'>return</span> <span class='hs-layout'>(</span><span class='hs-varid'>topdir</span> <span class='hs-conop'>:</span> <span class='hs-varid'>concat</span> <span class='hs-varid'>paths</span><span class='hs-layout'>)</span>
|
||||
<a name="line-90"></a>
|
||||
<a name="line-91"></a><a name="allDirectoryContents'"></a><span class='hs-comment'>-- | Get all files from a directory and its subdirectories strictly.</span>
|
||||
<a name="line-92"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-93"></a><span class='hs-comment'>-- Follows symbolic links for the input dir.</span>
|
||||
<a name="line-94"></a><span class='hs-definition'>allDirectoryContents'</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>RawFilePath</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-95"></a><span class='hs-definition'>allDirectoryContents'</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>fmap</span> <span class='hs-varid'>reverse</span> <span class='hs-varop'>.</span> <span class='hs-varid'>traverseDirectory</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>acc</span> <span class='hs-varid'>fp</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>return</span> <span class='hs-layout'>(</span><span class='hs-varid'>fp</span><span class='hs-conop'>:</span><span class='hs-varid'>acc</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span> <span class='hs-conid'>[]</span>
|
||||
<a name="line-96"></a><span class='hs-comment'>-- this uses traverseDirectory because it's more efficient than forcing the</span>
|
||||
<a name="line-97"></a><span class='hs-comment'>-- lazy version.</span>
|
||||
<a name="line-98"></a>
|
||||
<a name="line-99"></a><a name="traverseDirectory"></a><span class='hs-comment'>-- | Recursively apply the 'action' to the parent directory and all</span>
|
||||
<a name="line-100"></a><span class='hs-comment'>-- files/subdirectories.</span>
|
||||
<a name="line-101"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-102"></a><span class='hs-comment'>-- This function allows for memory-efficient traversals.</span>
|
||||
<a name="line-103"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-104"></a><span class='hs-comment'>-- Follows symbolic links for the input dir.</span>
|
||||
<a name="line-105"></a><span class='hs-definition'>traverseDirectory</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-varid'>s</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>s</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>s</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>s</span>
|
||||
<a name="line-106"></a><span class='hs-definition'>traverseDirectory</span> <span class='hs-varid'>act</span> <span class='hs-varid'>s0</span> <span class='hs-varid'>topdir</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>toploop</span>
|
||||
<a name="line-107"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-108"></a> <span class='hs-varid'>toploop</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-109"></a> <span class='hs-varid'>isDir</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>isDirectory</span> <span class='hs-varop'><$></span> <span class='hs-varid'>getFileStatus</span> <span class='hs-varid'>topdir</span>
|
||||
<a name="line-110"></a> <span class='hs-varid'>s'</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>act</span> <span class='hs-varid'>s0</span> <span class='hs-varid'>topdir</span>
|
||||
<a name="line-111"></a> <span class='hs-keyword'>if</span> <span class='hs-varid'>isDir</span> <span class='hs-keyword'>then</span> <span class='hs-varid'>actOnDirContents</span> <span class='hs-varid'>topdir</span> <span class='hs-varid'>s'</span> <span class='hs-varid'>loop</span>
|
||||
<a name="line-112"></a> <span class='hs-keyword'>else</span> <span class='hs-varid'>return</span> <span class='hs-varid'>s'</span>
|
||||
<a name="line-113"></a> <span class='hs-varid'>loop</span> <span class='hs-varid'>typ</span> <span class='hs-varid'>path</span> <span class='hs-varid'>acc</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-114"></a> <span class='hs-varid'>isDir</span> <span class='hs-keyglyph'><-</span> <span class='hs-keyword'>case</span> <span class='hs-conid'>()</span> <span class='hs-keyword'>of</span>
|
||||
<a name="line-115"></a> <span class='hs-conid'>()</span> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>typ</span> <span class='hs-varop'>==</span> <span class='hs-varid'>dtDir</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>return</span> <span class='hs-conid'>True</span>
|
||||
<a name="line-116"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>typ</span> <span class='hs-varop'>==</span> <span class='hs-varid'>dtUnknown</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>isDirectory</span> <span class='hs-varop'><$></span> <span class='hs-varid'>getFileStatus</span> <span class='hs-varid'>path</span>
|
||||
<a name="line-117"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>return</span> <span class='hs-conid'>False</span>
|
||||
<a name="line-118"></a> <span class='hs-keyword'>if</span> <span class='hs-varid'>isDir</span>
|
||||
<a name="line-119"></a> <span class='hs-keyword'>then</span> <span class='hs-varid'>act</span> <span class='hs-varid'>acc</span> <span class='hs-varid'>path</span> <span class='hs-varop'>>>=</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>acc'</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>actOnDirContents</span> <span class='hs-varid'>path</span> <span class='hs-varid'>acc'</span> <span class='hs-varid'>loop</span>
|
||||
<a name="line-120"></a> <span class='hs-keyword'>else</span> <span class='hs-varid'>act</span> <span class='hs-varid'>acc</span> <span class='hs-varid'>path</span>
|
||||
<a name="line-121"></a>
|
||||
<a name="line-122"></a><a name="actOnDirContents"></a><span class='hs-definition'>actOnDirContents</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-123"></a> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>b</span>
|
||||
<a name="line-124"></a> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-conid'>DirType</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>b</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span>
|
||||
<a name="line-125"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-varid'>b</span>
|
||||
<a name="line-126"></a><span class='hs-definition'>actOnDirContents</span> <span class='hs-varid'>pathRelToTop</span> <span class='hs-varid'>b</span> <span class='hs-varid'>f</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-127"></a> <span class='hs-varid'>modifyIOError</span> <span class='hs-layout'>(</span><span class='hs-layout'>(</span><span class='hs-varop'>`ioeSetFileName`</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>unpack</span> <span class='hs-varid'>pathRelToTop</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span> <span class='hs-varop'>.</span>
|
||||
<a name="line-128"></a> <span class='hs-layout'>(</span><span class='hs-varop'>`ioeSetLocation`</span> <span class='hs-str'>"findBSTypRel"</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span>
|
||||
<a name="line-129"></a> <span class='hs-varid'>bracket</span>
|
||||
<a name="line-130"></a> <span class='hs-layout'>(</span><span class='hs-varid'>openDirStream</span> <span class='hs-varid'>pathRelToTop</span><span class='hs-layout'>)</span>
|
||||
<a name="line-131"></a> <span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-varid'>closeDirStream</span>
|
||||
<a name="line-132"></a> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>dirp</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>loop</span> <span class='hs-varid'>dirp</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span>
|
||||
<a name="line-133"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-134"></a> <span class='hs-varid'>loop</span> <span class='hs-varid'>dirp</span> <span class='hs-varid'>b'</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-135"></a> <span class='hs-layout'>(</span><span class='hs-varid'>typ</span><span class='hs-layout'>,</span><span class='hs-varid'>e</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>readDirEnt</span> <span class='hs-varid'>dirp</span>
|
||||
<a name="line-136"></a> <span class='hs-keyword'>if</span> <span class='hs-layout'>(</span><span class='hs-varid'>e</span> <span class='hs-varop'>==</span> <span class='hs-str'>""</span><span class='hs-layout'>)</span>
|
||||
<a name="line-137"></a> <span class='hs-keyword'>then</span> <span class='hs-varid'>return</span> <span class='hs-varid'>b'</span>
|
||||
<a name="line-138"></a> <span class='hs-keyword'>else</span>
|
||||
<a name="line-139"></a> <span class='hs-keyword'>if</span> <span class='hs-layout'>(</span><span class='hs-varid'>e</span> <span class='hs-varop'>==</span> <span class='hs-str'>"."</span> <span class='hs-varop'>||</span> <span class='hs-varid'>e</span> <span class='hs-varop'>==</span> <span class='hs-str'>".."</span><span class='hs-layout'>)</span>
|
||||
<a name="line-140"></a> <span class='hs-keyword'>then</span> <span class='hs-varid'>loop</span> <span class='hs-varid'>dirp</span> <span class='hs-varid'>b'</span>
|
||||
<a name="line-141"></a> <span class='hs-keyword'>else</span> <span class='hs-varid'>f</span> <span class='hs-varid'>typ</span> <span class='hs-layout'>(</span><span class='hs-varid'>pathRelToTop</span> <span class='hs-varop'></></span> <span class='hs-varid'>e</span><span class='hs-layout'>)</span> <span class='hs-varid'>b'</span> <span class='hs-varop'>>>=</span> <span class='hs-varid'>loop</span> <span class='hs-varid'>dirp</span>
|
||||
<a name="line-142"></a>
|
||||
<a name="line-143"></a>
|
||||
<a name="line-144"></a><span class='hs-comment'>----------------------------------------------------------</span>
|
||||
<a name="line-145"></a><span class='hs-comment'>-- dodgy stuff</span>
|
||||
<a name="line-146"></a>
|
||||
<a name="line-147"></a><a name="CDir"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>CDir</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-148"></a><a name="CDirent"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>CDirent</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-149"></a>
|
||||
<a name="line-150"></a><a name="unpackDirStream"></a><span class='hs-comment'>-- Posix doesn't export DirStream, so to re-use that type we need to use</span>
|
||||
<a name="line-151"></a><span class='hs-comment'>-- unsafeCoerce. It's just a newtype, so this is a legitimate usage.</span>
|
||||
<a name="line-152"></a><span class='hs-comment'>-- ugly trick.</span>
|
||||
<a name="line-153"></a><span class='hs-definition'>unpackDirStream</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>DirStream</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Ptr</span> <span class='hs-conid'>CDir</span>
|
||||
<a name="line-154"></a><span class='hs-definition'>unpackDirStream</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unsafeCoerce</span>
|
||||
<a name="line-155"></a>
|
||||
<a name="line-156"></a><a name="packDirStream"></a><span class='hs-definition'>packDirStream</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Ptr</span> <span class='hs-conid'>CDir</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>DirStream</span>
|
||||
<a name="line-157"></a><span class='hs-definition'>packDirStream</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unsafeCoerce</span>
|
||||
<a name="line-158"></a>
|
||||
<a name="line-159"></a><span class='hs-comment'>-- the __hscore_* functions are defined in the unix package. We can import them and let</span>
|
||||
<a name="line-160"></a><span class='hs-comment'>-- the linker figure it out.</span>
|
||||
<a name="line-161"></a><span class='hs-keyword'>foreign</span> <span class='hs-keyword'>import</span> <span class='hs-keyword'>ccall</span> <span class='hs-keyword'>unsafe</span> <span class='hs-str'>"__hscore_readdir"</span>
|
||||
<a name="line-162"></a> <span class='hs-varid'>c_readdir</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Ptr</span> <span class='hs-conid'>CDir</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Ptr</span> <span class='hs-layout'>(</span><span class='hs-conid'>Ptr</span> <span class='hs-conid'>CDirent</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>CInt</span>
|
||||
<a name="line-163"></a>
|
||||
<a name="line-164"></a><span class='hs-keyword'>foreign</span> <span class='hs-keyword'>import</span> <span class='hs-keyword'>ccall</span> <span class='hs-keyword'>unsafe</span> <span class='hs-str'>"__hscore_free_dirent"</span>
|
||||
<a name="line-165"></a> <span class='hs-varid'>c_freeDirEnt</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Ptr</span> <span class='hs-conid'>CDirent</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
|
||||
<a name="line-166"></a>
|
||||
<a name="line-167"></a><span class='hs-keyword'>foreign</span> <span class='hs-keyword'>import</span> <span class='hs-keyword'>ccall</span> <span class='hs-keyword'>unsafe</span> <span class='hs-str'>"__hscore_d_name"</span>
|
||||
<a name="line-168"></a> <span class='hs-varid'>c_name</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Ptr</span> <span class='hs-conid'>CDirent</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>CString</span>
|
||||
<a name="line-169"></a>
|
||||
<a name="line-170"></a><span class='hs-keyword'>foreign</span> <span class='hs-keyword'>import</span> <span class='hs-keyword'>ccall</span> <span class='hs-keyword'>unsafe</span> <span class='hs-str'>"__posixdir_d_type"</span>
|
||||
<a name="line-171"></a> <span class='hs-varid'>c_type</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Ptr</span> <span class='hs-conid'>CDirent</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>DirType</span>
|
||||
<a name="line-172"></a>
|
||||
<a name="line-173"></a><span class='hs-keyword'>foreign</span> <span class='hs-keyword'>import</span> <span class='hs-keyword'>ccall</span> <span class='hs-str'>"realpath"</span>
|
||||
<a name="line-174"></a> <span class='hs-varid'>c_realpath</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>CString</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>CString</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>CString</span>
|
||||
<a name="line-175"></a>
|
||||
<a name="line-176"></a><span class='hs-keyword'>foreign</span> <span class='hs-keyword'>import</span> <span class='hs-keyword'>ccall</span> <span class='hs-keyword'>unsafe</span> <span class='hs-str'>"fdopendir"</span>
|
||||
<a name="line-177"></a> <span class='hs-varid'>c_fdopendir</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Fd</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-layout'>(</span><span class='hs-conid'>Ptr</span> <span class='hs-conid'>()</span><span class='hs-layout'>)</span>
|
||||
<a name="line-178"></a>
|
||||
<a name="line-179"></a><span class='hs-comment'>----------------------------------------------------------</span>
|
||||
<a name="line-180"></a><span class='hs-comment'>-- less dodgy but still lower-level</span>
|
||||
<a name="line-181"></a>
|
||||
<a name="line-182"></a>
|
||||
<a name="line-183"></a><a name="readDirEnt"></a><span class='hs-definition'>readDirEnt</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>DirStream</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-layout'>(</span><span class='hs-conid'>DirType</span><span class='hs-layout'>,</span> <span class='hs-conid'>RawFilePath</span><span class='hs-layout'>)</span>
|
||||
<a name="line-184"></a><span class='hs-definition'>readDirEnt</span> <span class='hs-layout'>(</span><span class='hs-varid'>unpackDirStream</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>dirp</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-185"></a> <span class='hs-varid'>alloca</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>ptr_dEnt</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>loop</span> <span class='hs-varid'>ptr_dEnt</span>
|
||||
<a name="line-186"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-187"></a> <span class='hs-varid'>loop</span> <span class='hs-varid'>ptr_dEnt</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-188"></a> <span class='hs-varid'>resetErrno</span>
|
||||
<a name="line-189"></a> <span class='hs-varid'>r</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>c_readdir</span> <span class='hs-varid'>dirp</span> <span class='hs-varid'>ptr_dEnt</span>
|
||||
<a name="line-190"></a> <span class='hs-keyword'>if</span> <span class='hs-layout'>(</span><span class='hs-varid'>r</span> <span class='hs-varop'>==</span> <span class='hs-num'>0</span><span class='hs-layout'>)</span>
|
||||
<a name="line-191"></a> <span class='hs-keyword'>then</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-192"></a> <span class='hs-varid'>dEnt</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>peek</span> <span class='hs-varid'>ptr_dEnt</span>
|
||||
<a name="line-193"></a> <span class='hs-keyword'>if</span> <span class='hs-layout'>(</span><span class='hs-varid'>dEnt</span> <span class='hs-varop'>==</span> <span class='hs-varid'>nullPtr</span><span class='hs-layout'>)</span>
|
||||
<a name="line-194"></a> <span class='hs-keyword'>then</span> <span class='hs-varid'>return</span> <span class='hs-layout'>(</span><span class='hs-varid'>dtUnknown</span><span class='hs-layout'>,</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>empty</span><span class='hs-layout'>)</span>
|
||||
<a name="line-195"></a> <span class='hs-keyword'>else</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-196"></a> <span class='hs-varid'>dName</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>c_name</span> <span class='hs-varid'>dEnt</span> <span class='hs-varop'>>>=</span> <span class='hs-varid'>peekFilePath</span>
|
||||
<a name="line-197"></a> <span class='hs-varid'>dType</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>c_type</span> <span class='hs-varid'>dEnt</span>
|
||||
<a name="line-198"></a> <span class='hs-varid'>c_freeDirEnt</span> <span class='hs-varid'>dEnt</span>
|
||||
<a name="line-199"></a> <span class='hs-varid'>return</span> <span class='hs-layout'>(</span><span class='hs-varid'>dType</span><span class='hs-layout'>,</span> <span class='hs-varid'>dName</span><span class='hs-layout'>)</span>
|
||||
<a name="line-200"></a> <span class='hs-keyword'>else</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-201"></a> <span class='hs-varid'>errno</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>getErrno</span>
|
||||
<a name="line-202"></a> <span class='hs-keyword'>if</span> <span class='hs-layout'>(</span><span class='hs-varid'>errno</span> <span class='hs-varop'>==</span> <span class='hs-varid'>eINTR</span><span class='hs-layout'>)</span>
|
||||
<a name="line-203"></a> <span class='hs-keyword'>then</span> <span class='hs-varid'>loop</span> <span class='hs-varid'>ptr_dEnt</span>
|
||||
<a name="line-204"></a> <span class='hs-keyword'>else</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-205"></a> <span class='hs-keyword'>let</span> <span class='hs-layout'>(</span><span class='hs-conid'>Errno</span> <span class='hs-varid'>eo</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>errno</span>
|
||||
<a name="line-206"></a> <span class='hs-keyword'>if</span> <span class='hs-layout'>(</span><span class='hs-varid'>eo</span> <span class='hs-varop'>==</span> <span class='hs-num'>0</span><span class='hs-layout'>)</span>
|
||||
<a name="line-207"></a> <span class='hs-keyword'>then</span> <span class='hs-varid'>return</span> <span class='hs-layout'>(</span><span class='hs-varid'>dtUnknown</span><span class='hs-layout'>,</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>empty</span><span class='hs-layout'>)</span>
|
||||
<a name="line-208"></a> <span class='hs-keyword'>else</span> <span class='hs-varid'>throwErrno</span> <span class='hs-str'>"readDirEnt"</span>
|
||||
<a name="line-209"></a>
|
||||
<a name="line-210"></a>
|
||||
<a name="line-211"></a><a name="getDirectoryContents"></a><span class='hs-comment'>-- |Gets all directory contents (not recursively).</span>
|
||||
<a name="line-212"></a><span class='hs-definition'>getDirectoryContents</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-keyglyph'>[</span><span class='hs-layout'>(</span><span class='hs-conid'>DirType</span><span class='hs-layout'>,</span> <span class='hs-conid'>RawFilePath</span><span class='hs-layout'>)</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-213"></a><span class='hs-definition'>getDirectoryContents</span> <span class='hs-varid'>path</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-214"></a> <span class='hs-varid'>modifyIOError</span> <span class='hs-layout'>(</span><span class='hs-layout'>(</span><span class='hs-varop'>`ioeSetFileName`</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>unpack</span> <span class='hs-varid'>path</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span> <span class='hs-varop'>.</span>
|
||||
<a name="line-215"></a> <span class='hs-layout'>(</span><span class='hs-varop'>`ioeSetLocation`</span> <span class='hs-str'>"System.Posix.Directory.Traversals.getDirectoryContents"</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span>
|
||||
<a name="line-216"></a> <span class='hs-varid'>bracket</span>
|
||||
<a name="line-217"></a> <span class='hs-layout'>(</span><span class='hs-conid'>PosixBS</span><span class='hs-varop'>.</span><span class='hs-varid'>openDirStream</span> <span class='hs-varid'>path</span><span class='hs-layout'>)</span>
|
||||
<a name="line-218"></a> <span class='hs-conid'>PosixBS</span><span class='hs-varop'>.</span><span class='hs-varid'>closeDirStream</span>
|
||||
<a name="line-219"></a> <span class='hs-sel'>_dirloop</span>
|
||||
<a name="line-220"></a>
|
||||
<a name="line-221"></a>
|
||||
<a name="line-222"></a><a name="fdOpendir"></a><span class='hs-comment'>-- |Binding to @fdopendir(3)@.</span>
|
||||
<a name="line-223"></a><span class='hs-definition'>fdOpendir</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Fd</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>DirStream</span>
|
||||
<a name="line-224"></a><span class='hs-definition'>fdOpendir</span> <span class='hs-varid'>fd</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-225"></a> <span class='hs-varid'>packDirStream</span> <span class='hs-varop'><$></span> <span class='hs-varid'>throwErrnoIfNull</span> <span class='hs-str'>"fdOpendir"</span> <span class='hs-layout'>(</span><span class='hs-varid'>c_fdopendir</span> <span class='hs-varid'>fd</span><span class='hs-layout'>)</span>
|
||||
<a name="line-226"></a>
|
||||
<a name="line-227"></a>
|
||||
<a name="line-228"></a><a name="getDirectoryContents'"></a><span class='hs-comment'>-- |Like `getDirectoryContents` except for a file descriptor.</span>
|
||||
<a name="line-229"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-230"></a><span class='hs-comment'>-- To avoid complicated error checks, the file descriptor is</span>
|
||||
<a name="line-231"></a><span class='hs-comment'>-- __always__ closed, even if `fdOpendir` fails. Usually, this</span>
|
||||
<a name="line-232"></a><span class='hs-comment'>-- only happens on successful `fdOpendir` and after the directory</span>
|
||||
<a name="line-233"></a><span class='hs-comment'>-- stream is closed. Also see the manpage of @fdopendir(3)@ for</span>
|
||||
<a name="line-234"></a><span class='hs-comment'>-- more details.</span>
|
||||
<a name="line-235"></a><span class='hs-definition'>getDirectoryContents'</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Fd</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-keyglyph'>[</span><span class='hs-layout'>(</span><span class='hs-conid'>DirType</span><span class='hs-layout'>,</span> <span class='hs-conid'>RawFilePath</span><span class='hs-layout'>)</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-236"></a><span class='hs-definition'>getDirectoryContents'</span> <span class='hs-varid'>fd</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-237"></a> <span class='hs-varid'>dirstream</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>fdOpendir</span> <span class='hs-varid'>fd</span> <span class='hs-varop'>`catchIOError`</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>e</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-238"></a> <span class='hs-varid'>closeFd</span> <span class='hs-varid'>fd</span>
|
||||
<a name="line-239"></a> <span class='hs-varid'>ioError</span> <span class='hs-varid'>e</span>
|
||||
<a name="line-240"></a> <span class='hs-comment'>-- closeDirStream closes the filedescriptor</span>
|
||||
<a name="line-241"></a> <span class='hs-varid'>finally</span> <span class='hs-layout'>(</span><span class='hs-sel'>_dirloop</span> <span class='hs-varid'>dirstream</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-conid'>PosixBS</span><span class='hs-varop'>.</span><span class='hs-varid'>closeDirStream</span> <span class='hs-varid'>dirstream</span><span class='hs-layout'>)</span>
|
||||
<a name="line-242"></a>
|
||||
<a name="line-243"></a>
|
||||
<a name="line-244"></a><span class='hs-sel'>_dirloop</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>DirStream</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-keyglyph'>[</span><span class='hs-layout'>(</span><span class='hs-conid'>DirType</span><span class='hs-layout'>,</span> <span class='hs-conid'>RawFilePath</span><span class='hs-layout'>)</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-245"></a><span class='hs-comment'>{-# INLINE _dirloop #-}</span>
|
||||
<a name="line-246"></a><span class='hs-sel'>_dirloop</span> <span class='hs-varid'>dirp</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-247"></a> <span class='hs-varid'>t</span><span class='hs-keyglyph'>@</span><span class='hs-layout'>(</span><span class='hs-sel'>_typ</span><span class='hs-layout'>,</span><span class='hs-varid'>e</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>readDirEnt</span> <span class='hs-varid'>dirp</span>
|
||||
<a name="line-248"></a> <span class='hs-keyword'>if</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span> <span class='hs-varid'>e</span> <span class='hs-keyword'>then</span> <span class='hs-varid'>return</span> <span class='hs-conid'>[]</span> <span class='hs-keyword'>else</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-249"></a> <span class='hs-varid'>es</span> <span class='hs-keyglyph'><-</span> <span class='hs-sel'>_dirloop</span> <span class='hs-varid'>dirp</span>
|
||||
<a name="line-250"></a> <span class='hs-varid'>return</span> <span class='hs-layout'>(</span><span class='hs-varid'>t</span><span class='hs-conop'>:</span><span class='hs-varid'>es</span><span class='hs-layout'>)</span>
|
||||
<a name="line-251"></a>
|
||||
<a name="line-252"></a>
|
||||
<a name="line-253"></a><a name="realpath"></a><span class='hs-comment'>-- | return the canonicalized absolute pathname</span>
|
||||
<a name="line-254"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-255"></a><span class='hs-comment'>-- like canonicalizePath, but uses @realpath(3)@</span>
|
||||
<a name="line-256"></a><span class='hs-definition'>realpath</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-257"></a><span class='hs-definition'>realpath</span> <span class='hs-varid'>inp</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-258"></a> <span class='hs-varid'>allocaBytes</span> <span class='hs-varid'>pathMax</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>tmp</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-259"></a> <span class='hs-varid'>void</span> <span class='hs-varop'>$</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>useAsCString</span> <span class='hs-varid'>inp</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>cstr</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>throwErrnoIfNull</span> <span class='hs-str'>"realpath"</span> <span class='hs-varop'>$</span> <span class='hs-varid'>c_realpath</span> <span class='hs-varid'>cstr</span> <span class='hs-varid'>tmp</span>
|
||||
<a name="line-260"></a> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>packCString</span> <span class='hs-varid'>tmp</span>
|
||||
</pre></body>
|
||||
</html>
|
86
src/System-Posix-FD.html
Normal file
86
src/System-Posix-FD.html
Normal file
@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
|
||||
<title>src/System/Posix/FD.hs</title>
|
||||
<link type='text/css' rel='stylesheet' href='hscolour.css' />
|
||||
</head>
|
||||
<body>
|
||||
<pre><a name="line-1"></a><span class='hs-comment'>-- |</span>
|
||||
<a name="line-2"></a><span class='hs-comment'>-- Module : System.Posix.FD</span>
|
||||
<a name="line-3"></a><span class='hs-comment'>-- Copyright : © 2016 Julian Ospald</span>
|
||||
<a name="line-4"></a><span class='hs-comment'>-- License : BSD3</span>
|
||||
<a name="line-5"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-6"></a><span class='hs-comment'>-- Maintainer : Julian Ospald <hasufell@posteo.de></span>
|
||||
<a name="line-7"></a><span class='hs-comment'>-- Stability : experimental</span>
|
||||
<a name="line-8"></a><span class='hs-comment'>-- Portability : portable</span>
|
||||
<a name="line-9"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-10"></a><span class='hs-comment'>-- Provides an alternative for `System.Posix.IO.ByteString.openFd`</span>
|
||||
<a name="line-11"></a><span class='hs-comment'>-- which gives us more control on what status flags to pass to the</span>
|
||||
<a name="line-12"></a><span class='hs-comment'>-- low-level @open(2)@ call, in contrast to the unix package.</span>
|
||||
<a name="line-13"></a>
|
||||
<a name="line-14"></a>
|
||||
<a name="line-15"></a><span class='hs-comment'>{-# LANGUAGE ForeignFunctionInterface #-}</span>
|
||||
<a name="line-16"></a><span class='hs-comment'>{-# LANGUAGE OverloadedStrings #-}</span>
|
||||
<a name="line-17"></a><span class='hs-comment'>{-# LANGUAGE TupleSections #-}</span>
|
||||
<a name="line-18"></a>
|
||||
<a name="line-19"></a><span class='hs-comment'>{-# OPTIONS_GHC -Wall #-}</span>
|
||||
<a name="line-20"></a>
|
||||
<a name="line-21"></a>
|
||||
<a name="line-22"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>FD</span> <span class='hs-layout'>(</span>
|
||||
<a name="line-23"></a> <span class='hs-varid'>openFd</span>
|
||||
<a name="line-24"></a><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
|
||||
<a name="line-25"></a>
|
||||
<a name="line-26"></a>
|
||||
<a name="line-27"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>C</span><span class='hs-varop'>.</span><span class='hs-conid'>String</span>
|
||||
<a name="line-28"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>C</span><span class='hs-varop'>.</span><span class='hs-conid'>Types</span>
|
||||
<a name="line-29"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Directory</span><span class='hs-varop'>.</span><span class='hs-conid'>Foreign</span>
|
||||
<a name="line-30"></a><span class='hs-keyword'>import</span> <span class='hs-keyword'>qualified</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span> <span class='hs-keyword'>as</span> <span class='hs-conid'>Posix</span>
|
||||
<a name="line-31"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span><span class='hs-varop'>.</span><span class='hs-conid'>FilePath</span>
|
||||
<a name="line-32"></a>
|
||||
<a name="line-33"></a>
|
||||
<a name="line-34"></a><span class='hs-keyword'>foreign</span> <span class='hs-keyword'>import</span> <span class='hs-keyword'>ccall</span> <span class='hs-keyword'>unsafe</span> <span class='hs-str'>"open"</span>
|
||||
<a name="line-35"></a> <span class='hs-varid'>c_open</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>CString</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>CInt</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>CMode</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>CInt</span>
|
||||
<a name="line-36"></a>
|
||||
<a name="line-37"></a>
|
||||
<a name="line-38"></a><a name="open_"></a><span class='hs-definition'>open_</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>CString</span>
|
||||
<a name="line-39"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>OpenMode</span>
|
||||
<a name="line-40"></a> <span class='hs-keyglyph'>-></span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>Flags</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-41"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Maybe</span> <span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>FileMode</span>
|
||||
<a name="line-42"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Fd</span>
|
||||
<a name="line-43"></a><span class='hs-definition'>open_</span> <span class='hs-varid'>str</span> <span class='hs-varid'>how</span> <span class='hs-varid'>optional_flags</span> <span class='hs-varid'>maybe_mode</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
|
||||
<a name="line-44"></a> <span class='hs-varid'>fd</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>c_open</span> <span class='hs-varid'>str</span> <span class='hs-varid'>all_flags</span> <span class='hs-varid'>mode_w</span>
|
||||
<a name="line-45"></a> <span class='hs-varid'>return</span> <span class='hs-layout'>(</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Fd</span> <span class='hs-varid'>fd</span><span class='hs-layout'>)</span>
|
||||
<a name="line-46"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-47"></a> <span class='hs-varid'>all_flags</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>unionFlags</span> <span class='hs-varop'>$</span> <span class='hs-varid'>optional_flags</span> <span class='hs-varop'>++</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>open_mode</span><span class='hs-keyglyph'>]</span> <span class='hs-varop'>++</span> <span class='hs-varid'>creat</span>
|
||||
<a name="line-48"></a>
|
||||
<a name="line-49"></a>
|
||||
<a name="line-50"></a> <span class='hs-layout'>(</span><span class='hs-varid'>creat</span><span class='hs-layout'>,</span> <span class='hs-varid'>mode_w</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>case</span> <span class='hs-varid'>maybe_mode</span> <span class='hs-keyword'>of</span>
|
||||
<a name="line-51"></a> <span class='hs-conid'>Nothing</span> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-conid'>[]</span><span class='hs-layout'>,</span><span class='hs-num'>0</span><span class='hs-layout'>)</span>
|
||||
<a name="line-52"></a> <span class='hs-conid'>Just</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>[</span><span class='hs-varid'>oCreat</span><span class='hs-keyglyph'>]</span><span class='hs-layout'>,</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span>
|
||||
<a name="line-53"></a>
|
||||
<a name="line-54"></a> <span class='hs-varid'>open_mode</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>case</span> <span class='hs-varid'>how</span> <span class='hs-keyword'>of</span>
|
||||
<a name="line-55"></a> <span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>ReadOnly</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>oRdonly</span>
|
||||
<a name="line-56"></a> <span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>WriteOnly</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>oWronly</span>
|
||||
<a name="line-57"></a> <span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>ReadWrite</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>oRdwr</span>
|
||||
<a name="line-58"></a>
|
||||
<a name="line-59"></a>
|
||||
<a name="line-60"></a><a name="openFd"></a><span class='hs-comment'>-- |Open and optionally create this file. See 'System.Posix.Files'</span>
|
||||
<a name="line-61"></a><span class='hs-comment'>-- for information on how to use the 'FileMode' type.</span>
|
||||
<a name="line-62"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-63"></a><span class='hs-comment'>-- Note that passing @Just x@ as the 4th argument triggers the</span>
|
||||
<a name="line-64"></a><span class='hs-comment'>-- `oCreat` status flag, which must be set when you pass in `oExcl`</span>
|
||||
<a name="line-65"></a><span class='hs-comment'>-- to the status flags. Also see the manpage for @open(2)@.</span>
|
||||
<a name="line-66"></a><span class='hs-definition'>openFd</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-67"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>OpenMode</span>
|
||||
<a name="line-68"></a> <span class='hs-keyglyph'>-></span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>Flags</span><span class='hs-keyglyph'>]</span> <span class='hs-comment'>-- ^ status flags of @open(2)@</span>
|
||||
<a name="line-69"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Maybe</span> <span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>FileMode</span> <span class='hs-comment'>-- ^ @Just x@ => creates the file with the given modes, Nothing => the file must exist.</span>
|
||||
<a name="line-70"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Fd</span>
|
||||
<a name="line-71"></a><span class='hs-definition'>openFd</span> <span class='hs-varid'>name</span> <span class='hs-varid'>how</span> <span class='hs-varid'>optional_flags</span> <span class='hs-varid'>maybe_mode</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-72"></a> <span class='hs-varid'>withFilePath</span> <span class='hs-varid'>name</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>str</span> <span class='hs-keyglyph'>-></span>
|
||||
<a name="line-73"></a> <span class='hs-varid'>throwErrnoPathIfMinus1Retry</span> <span class='hs-str'>"openFd"</span> <span class='hs-varid'>name</span> <span class='hs-varop'>$</span>
|
||||
<a name="line-74"></a> <span class='hs-varid'>open_</span> <span class='hs-varid'>str</span> <span class='hs-varid'>how</span> <span class='hs-varid'>optional_flags</span> <span class='hs-varid'>maybe_mode</span>
|
||||
<a name="line-75"></a>
|
||||
</pre></body>
|
||||
</html>
|
834
src/System-Posix-FilePath.html
Normal file
834
src/System-Posix-FilePath.html
Normal file
@ -0,0 +1,834 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
|
||||
<title>src/System/Posix/FilePath.hs</title>
|
||||
<link type='text/css' rel='stylesheet' href='hscolour.css' />
|
||||
</head>
|
||||
<body>
|
||||
<pre><a name="line-1"></a><span class='hs-comment'>-- |</span>
|
||||
<a name="line-2"></a><span class='hs-comment'>-- Module : System.Posix.FilePath</span>
|
||||
<a name="line-3"></a><span class='hs-comment'>-- Copyright : © 2016 Julian Ospald</span>
|
||||
<a name="line-4"></a><span class='hs-comment'>-- License : BSD3</span>
|
||||
<a name="line-5"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-6"></a><span class='hs-comment'>-- Maintainer : Julian Ospald <hasufell@posteo.de></span>
|
||||
<a name="line-7"></a><span class='hs-comment'>-- Stability : experimental</span>
|
||||
<a name="line-8"></a><span class='hs-comment'>-- Portability : portable</span>
|
||||
<a name="line-9"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-10"></a><span class='hs-comment'>-- The equivalent of "System.FilePath" on raw (byte string) file paths.</span>
|
||||
<a name="line-11"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-12"></a><span class='hs-comment'>-- Not all functions of "System.FilePath" are implemented yet. Feel free to contribute!</span>
|
||||
<a name="line-13"></a>
|
||||
<a name="line-14"></a>
|
||||
<a name="line-15"></a><span class='hs-comment'>{-# LANGUAGE CPP #-}</span>
|
||||
<a name="line-16"></a><span class='hs-comment'>{-# LANGUAGE TupleSections #-}</span>
|
||||
<a name="line-17"></a>
|
||||
<a name="line-18"></a><span class='hs-comment'>{-# OPTIONS_GHC -Wall #-}</span>
|
||||
<a name="line-19"></a>
|
||||
<a name="line-20"></a>
|
||||
<a name="line-21"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>FilePath</span> <span class='hs-layout'>(</span>
|
||||
<a name="line-22"></a>
|
||||
<a name="line-23"></a> <span class='hs-comment'>-- * Separator predicates</span>
|
||||
<a name="line-24"></a> <span class='hs-varid'>pathSeparator</span>
|
||||
<a name="line-25"></a><span class='hs-layout'>,</span> <span class='hs-varid'>isPathSeparator</span>
|
||||
<a name="line-26"></a><span class='hs-layout'>,</span> <span class='hs-varid'>searchPathSeparator</span>
|
||||
<a name="line-27"></a><span class='hs-layout'>,</span> <span class='hs-varid'>isSearchPathSeparator</span>
|
||||
<a name="line-28"></a><span class='hs-layout'>,</span> <span class='hs-varid'>extSeparator</span>
|
||||
<a name="line-29"></a><span class='hs-layout'>,</span> <span class='hs-varid'>isExtSeparator</span>
|
||||
<a name="line-30"></a>
|
||||
<a name="line-31"></a> <span class='hs-comment'>-- * $PATH methods</span>
|
||||
<a name="line-32"></a><span class='hs-layout'>,</span> <span class='hs-varid'>splitSearchPath</span>
|
||||
<a name="line-33"></a><span class='hs-layout'>,</span> <span class='hs-varid'>getSearchPath</span>
|
||||
<a name="line-34"></a>
|
||||
<a name="line-35"></a> <span class='hs-comment'>-- * Extension functions</span>
|
||||
<a name="line-36"></a><span class='hs-layout'>,</span> <span class='hs-varid'>splitExtension</span>
|
||||
<a name="line-37"></a><span class='hs-layout'>,</span> <span class='hs-varid'>takeExtension</span>
|
||||
<a name="line-38"></a><span class='hs-layout'>,</span> <span class='hs-varid'>replaceExtension</span>
|
||||
<a name="line-39"></a><span class='hs-layout'>,</span> <span class='hs-varid'>dropExtension</span>
|
||||
<a name="line-40"></a><span class='hs-layout'>,</span> <span class='hs-varid'>addExtension</span>
|
||||
<a name="line-41"></a><span class='hs-layout'>,</span> <span class='hs-varid'>hasExtension</span>
|
||||
<a name="line-42"></a><span class='hs-layout'>,</span> <span class='hs-layout'>(</span><span class='hs-varop'><.></span><span class='hs-layout'>)</span>
|
||||
<a name="line-43"></a><span class='hs-layout'>,</span> <span class='hs-varid'>splitExtensions</span>
|
||||
<a name="line-44"></a><span class='hs-layout'>,</span> <span class='hs-varid'>dropExtensions</span>
|
||||
<a name="line-45"></a><span class='hs-layout'>,</span> <span class='hs-varid'>takeExtensions</span>
|
||||
<a name="line-46"></a><span class='hs-layout'>,</span> <span class='hs-varid'>stripExtension</span>
|
||||
<a name="line-47"></a>
|
||||
<a name="line-48"></a> <span class='hs-comment'>-- * Filename\/directory functions</span>
|
||||
<a name="line-49"></a><span class='hs-layout'>,</span> <span class='hs-varid'>splitFileName</span>
|
||||
<a name="line-50"></a><span class='hs-layout'>,</span> <span class='hs-varid'>takeFileName</span>
|
||||
<a name="line-51"></a><span class='hs-layout'>,</span> <span class='hs-varid'>replaceFileName</span>
|
||||
<a name="line-52"></a><span class='hs-layout'>,</span> <span class='hs-varid'>dropFileName</span>
|
||||
<a name="line-53"></a><span class='hs-layout'>,</span> <span class='hs-varid'>takeBaseName</span>
|
||||
<a name="line-54"></a><span class='hs-layout'>,</span> <span class='hs-varid'>replaceBaseName</span>
|
||||
<a name="line-55"></a><span class='hs-layout'>,</span> <span class='hs-varid'>takeDirectory</span>
|
||||
<a name="line-56"></a><span class='hs-layout'>,</span> <span class='hs-varid'>replaceDirectory</span>
|
||||
<a name="line-57"></a><span class='hs-layout'>,</span> <span class='hs-varid'>combine</span>
|
||||
<a name="line-58"></a><span class='hs-layout'>,</span> <span class='hs-layout'>(</span><span class='hs-varop'></></span><span class='hs-layout'>)</span>
|
||||
<a name="line-59"></a><span class='hs-layout'>,</span> <span class='hs-varid'>splitPath</span>
|
||||
<a name="line-60"></a><span class='hs-layout'>,</span> <span class='hs-varid'>joinPath</span>
|
||||
<a name="line-61"></a><span class='hs-layout'>,</span> <span class='hs-varid'>splitDirectories</span>
|
||||
<a name="line-62"></a>
|
||||
<a name="line-63"></a> <span class='hs-comment'>-- * Trailing slash functions</span>
|
||||
<a name="line-64"></a><span class='hs-layout'>,</span> <span class='hs-varid'>hasTrailingPathSeparator</span>
|
||||
<a name="line-65"></a><span class='hs-layout'>,</span> <span class='hs-varid'>addTrailingPathSeparator</span>
|
||||
<a name="line-66"></a><span class='hs-layout'>,</span> <span class='hs-varid'>dropTrailingPathSeparator</span>
|
||||
<a name="line-67"></a>
|
||||
<a name="line-68"></a> <span class='hs-comment'>-- * File name manipulations</span>
|
||||
<a name="line-69"></a><span class='hs-layout'>,</span> <span class='hs-varid'>normalise</span>
|
||||
<a name="line-70"></a><span class='hs-layout'>,</span> <span class='hs-varid'>makeRelative</span>
|
||||
<a name="line-71"></a><span class='hs-layout'>,</span> <span class='hs-varid'>equalFilePath</span>
|
||||
<a name="line-72"></a><span class='hs-layout'>,</span> <span class='hs-varid'>isRelative</span>
|
||||
<a name="line-73"></a><span class='hs-layout'>,</span> <span class='hs-varid'>isAbsolute</span>
|
||||
<a name="line-74"></a><span class='hs-layout'>,</span> <span class='hs-varid'>isValid</span>
|
||||
<a name="line-75"></a><span class='hs-layout'>,</span> <span class='hs-varid'>makeValid</span>
|
||||
<a name="line-76"></a><span class='hs-layout'>,</span> <span class='hs-varid'>isFileName</span>
|
||||
<a name="line-77"></a><span class='hs-layout'>,</span> <span class='hs-varid'>hasParentDir</span>
|
||||
<a name="line-78"></a><span class='hs-layout'>,</span> <span class='hs-varid'>hiddenFile</span>
|
||||
<a name="line-79"></a>
|
||||
<a name="line-80"></a><span class='hs-layout'>,</span> <span class='hs-keyword'>module</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span><span class='hs-varop'>.</span><span class='hs-conid'>FilePath</span>
|
||||
<a name="line-81"></a><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
|
||||
<a name="line-82"></a>
|
||||
<a name="line-83"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span> <span class='hs-layout'>(</span><span class='hs-conid'>ByteString</span><span class='hs-layout'>)</span>
|
||||
<a name="line-84"></a><span class='hs-keyword'>import</span> <span class='hs-keyword'>qualified</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span> <span class='hs-keyword'>as</span> <span class='hs-conid'>BS</span>
|
||||
<a name="line-85"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>String</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromString</span><span class='hs-layout'>)</span>
|
||||
<a name="line-86"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span><span class='hs-varop'>.</span><span class='hs-conid'>FilePath</span>
|
||||
<a name="line-87"></a><span class='hs-keyword'>import</span> <span class='hs-keyword'>qualified</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>Posix</span><span class='hs-varop'>.</span><span class='hs-conid'>Env</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span> <span class='hs-keyword'>as</span> <span class='hs-conid'>PE</span>
|
||||
<a name="line-88"></a>
|
||||
<a name="line-89"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Maybe</span> <span class='hs-layout'>(</span><span class='hs-varid'>isJust</span><span class='hs-layout'>)</span>
|
||||
<a name="line-90"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Word8</span>
|
||||
<a name="line-91"></a><span class='hs-cpp'>#if !MIN_VERSION_bytestring(0,10,8)</span>
|
||||
<a name="line-92"></a><span class='hs-keyword'>import</span> <span class='hs-keyword'>qualified</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>List</span> <span class='hs-keyword'>as</span> <span class='hs-conid'>L</span>
|
||||
<a name="line-93"></a><span class='hs-cpp'>#endif</span>
|
||||
<a name="line-94"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Arrow</span> <span class='hs-layout'>(</span><span class='hs-varid'>second</span><span class='hs-layout'>)</span>
|
||||
<a name="line-95"></a>
|
||||
<a name="line-96"></a><span class='hs-comment'>-- $setup</span>
|
||||
<a name="line-97"></a><span class='hs-comment'>-- >>> import Data.Char</span>
|
||||
<a name="line-98"></a><span class='hs-comment'>-- >>> import Data.Maybe</span>
|
||||
<a name="line-99"></a><span class='hs-comment'>-- >>> import Test.QuickCheck</span>
|
||||
<a name="line-100"></a><span class='hs-comment'>-- >>> import Control.Applicative</span>
|
||||
<a name="line-101"></a><span class='hs-comment'>-- >>> import qualified Data.ByteString as BS</span>
|
||||
<a name="line-102"></a><span class='hs-comment'>-- >>> instance Arbitrary ByteString where arbitrary = BS.pack <$> arbitrary</span>
|
||||
<a name="line-103"></a><span class='hs-comment'>-- >>> instance CoArbitrary ByteString where coarbitrary = coarbitrary . BS.unpack</span>
|
||||
<a name="line-104"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-105"></a><span class='hs-comment'>-- >>> let _chr :: Word8 -> Char; _chr = chr . fromIntegral</span>
|
||||
<a name="line-106"></a>
|
||||
<a name="line-107"></a>
|
||||
<a name="line-108"></a>
|
||||
<a name="line-109"></a><span class='hs-comment'>------------------------</span>
|
||||
<a name="line-110"></a><span class='hs-comment'>-- Separator predicates</span>
|
||||
<a name="line-111"></a>
|
||||
<a name="line-112"></a>
|
||||
<a name="line-113"></a><a name="pathSeparator"></a><span class='hs-comment'>-- | Path separator character</span>
|
||||
<a name="line-114"></a><span class='hs-definition'>pathSeparator</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Word8</span>
|
||||
<a name="line-115"></a><span class='hs-definition'>pathSeparator</span> <span class='hs-keyglyph'>=</span> <span class='hs-sel'>_slash</span>
|
||||
<a name="line-116"></a>
|
||||
<a name="line-117"></a>
|
||||
<a name="line-118"></a><a name="isPathSeparator"></a><span class='hs-comment'>-- | Check if a character is the path separator</span>
|
||||
<a name="line-119"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-120"></a><span class='hs-comment'>-- prop> \n -> (_chr n == '/') == isPathSeparator n</span>
|
||||
<a name="line-121"></a><span class='hs-definition'>isPathSeparator</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Word8</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Bool</span>
|
||||
<a name="line-122"></a><span class='hs-definition'>isPathSeparator</span> <span class='hs-keyglyph'>=</span> <span class='hs-layout'>(</span><span class='hs-varop'>==</span> <span class='hs-varid'>pathSeparator</span><span class='hs-layout'>)</span>
|
||||
<a name="line-123"></a>
|
||||
<a name="line-124"></a>
|
||||
<a name="line-125"></a><a name="searchPathSeparator"></a><span class='hs-comment'>-- | Search path separator</span>
|
||||
<a name="line-126"></a><span class='hs-definition'>searchPathSeparator</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Word8</span>
|
||||
<a name="line-127"></a><span class='hs-definition'>searchPathSeparator</span> <span class='hs-keyglyph'>=</span> <span class='hs-sel'>_colon</span>
|
||||
<a name="line-128"></a>
|
||||
<a name="line-129"></a>
|
||||
<a name="line-130"></a><a name="isSearchPathSeparator"></a><span class='hs-comment'>-- | Check if a character is the search path separator</span>
|
||||
<a name="line-131"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-132"></a><span class='hs-comment'>-- prop> \n -> (_chr n == ':') == isSearchPathSeparator n</span>
|
||||
<a name="line-133"></a><span class='hs-definition'>isSearchPathSeparator</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Word8</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Bool</span>
|
||||
<a name="line-134"></a><span class='hs-definition'>isSearchPathSeparator</span> <span class='hs-keyglyph'>=</span> <span class='hs-layout'>(</span><span class='hs-varop'>==</span> <span class='hs-varid'>searchPathSeparator</span><span class='hs-layout'>)</span>
|
||||
<a name="line-135"></a>
|
||||
<a name="line-136"></a>
|
||||
<a name="line-137"></a><a name="extSeparator"></a><span class='hs-comment'>-- | File extension separator</span>
|
||||
<a name="line-138"></a><span class='hs-definition'>extSeparator</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Word8</span>
|
||||
<a name="line-139"></a><span class='hs-definition'>extSeparator</span> <span class='hs-keyglyph'>=</span> <span class='hs-sel'>_period</span>
|
||||
<a name="line-140"></a>
|
||||
<a name="line-141"></a>
|
||||
<a name="line-142"></a><a name="isExtSeparator"></a><span class='hs-comment'>-- | Check if a character is the file extension separator</span>
|
||||
<a name="line-143"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-144"></a><span class='hs-comment'>-- prop> \n -> (_chr n == '.') == isExtSeparator n</span>
|
||||
<a name="line-145"></a><span class='hs-definition'>isExtSeparator</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Word8</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Bool</span>
|
||||
<a name="line-146"></a><span class='hs-definition'>isExtSeparator</span> <span class='hs-keyglyph'>=</span> <span class='hs-layout'>(</span><span class='hs-varop'>==</span> <span class='hs-varid'>extSeparator</span><span class='hs-layout'>)</span>
|
||||
<a name="line-147"></a>
|
||||
<a name="line-148"></a>
|
||||
<a name="line-149"></a>
|
||||
<a name="line-150"></a><span class='hs-comment'>------------------------</span>
|
||||
<a name="line-151"></a><span class='hs-comment'>-- $PATH methods</span>
|
||||
<a name="line-152"></a>
|
||||
<a name="line-153"></a>
|
||||
<a name="line-154"></a><a name="splitSearchPath"></a><span class='hs-comment'>-- | Take a ByteString, split it on the 'searchPathSeparator'.</span>
|
||||
<a name="line-155"></a><span class='hs-comment'>-- Blank items are converted to @.@.</span>
|
||||
<a name="line-156"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-157"></a><span class='hs-comment'>-- Follows the recommendations in</span>
|
||||
<a name="line-158"></a><span class='hs-comment'>-- <<a href="http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html">http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html</a>></span>
|
||||
<a name="line-159"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-160"></a><span class='hs-comment'>-- >>> splitSearchPath "File1:File2:File3"</span>
|
||||
<a name="line-161"></a><span class='hs-comment'>-- ["File1","File2","File3"]</span>
|
||||
<a name="line-162"></a><span class='hs-comment'>-- >>> splitSearchPath "File1::File2:File3"</span>
|
||||
<a name="line-163"></a><span class='hs-comment'>-- ["File1",".","File2","File3"]</span>
|
||||
<a name="line-164"></a><span class='hs-comment'>-- >>> splitSearchPath ""</span>
|
||||
<a name="line-165"></a><span class='hs-comment'>-- ["."]</span>
|
||||
<a name="line-166"></a><span class='hs-definition'>splitSearchPath</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>ByteString</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>RawFilePath</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-167"></a><span class='hs-definition'>splitSearchPath</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>f</span>
|
||||
<a name="line-168"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-169"></a> <span class='hs-varid'>f</span> <span class='hs-varid'>bs</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>let</span> <span class='hs-layout'>(</span><span class='hs-varid'>pre</span><span class='hs-layout'>,</span> <span class='hs-varid'>post</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>break</span> <span class='hs-varid'>isSearchPathSeparator</span> <span class='hs-varid'>bs</span>
|
||||
<a name="line-170"></a> <span class='hs-keyword'>in</span> <span class='hs-keyword'>if</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span> <span class='hs-varid'>post</span>
|
||||
<a name="line-171"></a> <span class='hs-keyword'>then</span> <span class='hs-varid'>g</span> <span class='hs-varid'>pre</span>
|
||||
<a name="line-172"></a> <span class='hs-keyword'>else</span> <span class='hs-varid'>g</span> <span class='hs-varid'>pre</span> <span class='hs-varop'>++</span> <span class='hs-varid'>f</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>tail</span> <span class='hs-varid'>post</span><span class='hs-layout'>)</span>
|
||||
<a name="line-173"></a> <span class='hs-varid'>g</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-174"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>singleton</span> <span class='hs-sel'>_period</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-175"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>x</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-176"></a>
|
||||
<a name="line-177"></a>
|
||||
<a name="line-178"></a><a name="getSearchPath"></a><span class='hs-comment'>-- | Get a list of 'RawFilePath's in the $PATH variable.</span>
|
||||
<a name="line-179"></a><span class='hs-definition'>getSearchPath</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>IO</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>RawFilePath</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-180"></a><span class='hs-definition'>getSearchPath</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>fmap</span> <span class='hs-layout'>(</span><span class='hs-varid'>maybe</span> <span class='hs-conid'>[]</span> <span class='hs-varid'>splitSearchPath</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-conid'>PE</span><span class='hs-varop'>.</span><span class='hs-varid'>getEnv</span> <span class='hs-varop'>$</span> <span class='hs-varid'>fromString</span> <span class='hs-str'>"PATH"</span><span class='hs-layout'>)</span>
|
||||
<a name="line-181"></a>
|
||||
<a name="line-182"></a>
|
||||
<a name="line-183"></a>
|
||||
<a name="line-184"></a><span class='hs-comment'>------------------------</span>
|
||||
<a name="line-185"></a><span class='hs-comment'>-- Extension functions</span>
|
||||
<a name="line-186"></a>
|
||||
<a name="line-187"></a><a name="splitExtension"></a><span class='hs-comment'>-- | Split a 'RawFilePath' into a path+filename and extension</span>
|
||||
<a name="line-188"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-189"></a><span class='hs-comment'>-- >>> splitExtension "file.exe"</span>
|
||||
<a name="line-190"></a><span class='hs-comment'>-- ("file",".exe")</span>
|
||||
<a name="line-191"></a><span class='hs-comment'>-- >>> splitExtension "file"</span>
|
||||
<a name="line-192"></a><span class='hs-comment'>-- ("file","")</span>
|
||||
<a name="line-193"></a><span class='hs-comment'>-- >>> splitExtension "/path/file.tar.gz"</span>
|
||||
<a name="line-194"></a><span class='hs-comment'>-- ("/path/file.tar",".gz")</span>
|
||||
<a name="line-195"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-196"></a><span class='hs-comment'>-- prop> \path -> uncurry (BS.append) (splitExtension path) == path</span>
|
||||
<a name="line-197"></a><span class='hs-definition'>splitExtension</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-conid'>RawFilePath</span><span class='hs-layout'>,</span> <span class='hs-conid'>ByteString</span><span class='hs-layout'>)</span>
|
||||
<a name="line-198"></a><span class='hs-definition'>splitExtension</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>if</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span> <span class='hs-varid'>basename</span>
|
||||
<a name="line-199"></a> <span class='hs-keyword'>then</span> <span class='hs-layout'>(</span><span class='hs-varid'>x</span><span class='hs-layout'>,</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>empty</span><span class='hs-layout'>)</span>
|
||||
<a name="line-200"></a> <span class='hs-keyword'>else</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>append</span> <span class='hs-varid'>path</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>init</span> <span class='hs-varid'>basename</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>cons</span> <span class='hs-varid'>extSeparator</span> <span class='hs-varid'>fileExt</span><span class='hs-layout'>)</span>
|
||||
<a name="line-201"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-202"></a> <span class='hs-layout'>(</span><span class='hs-varid'>path</span><span class='hs-layout'>,</span><span class='hs-varid'>file</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>splitFileNameRaw</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-203"></a> <span class='hs-layout'>(</span><span class='hs-varid'>basename</span><span class='hs-layout'>,</span><span class='hs-varid'>fileExt</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>breakEnd</span> <span class='hs-varid'>isExtSeparator</span> <span class='hs-varid'>file</span>
|
||||
<a name="line-204"></a>
|
||||
<a name="line-205"></a>
|
||||
<a name="line-206"></a><a name="takeExtension"></a><span class='hs-comment'>-- | Get the final extension from a 'RawFilePath'</span>
|
||||
<a name="line-207"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-208"></a><span class='hs-comment'>-- >>> takeExtension "file.exe"</span>
|
||||
<a name="line-209"></a><span class='hs-comment'>-- ".exe"</span>
|
||||
<a name="line-210"></a><span class='hs-comment'>-- >>> takeExtension "file"</span>
|
||||
<a name="line-211"></a><span class='hs-comment'>-- ""</span>
|
||||
<a name="line-212"></a><span class='hs-comment'>-- >>> takeExtension "/path/file.tar.gz"</span>
|
||||
<a name="line-213"></a><span class='hs-comment'>-- ".gz"</span>
|
||||
<a name="line-214"></a><span class='hs-definition'>takeExtension</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>ByteString</span>
|
||||
<a name="line-215"></a><span class='hs-definition'>takeExtension</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>snd</span> <span class='hs-varop'>.</span> <span class='hs-varid'>splitExtension</span>
|
||||
<a name="line-216"></a>
|
||||
<a name="line-217"></a>
|
||||
<a name="line-218"></a><a name="replaceExtension"></a><span class='hs-comment'>-- | Change a file's extension</span>
|
||||
<a name="line-219"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-220"></a><span class='hs-comment'>-- prop> \path -> let ext = takeExtension path in replaceExtension path ext == path</span>
|
||||
<a name="line-221"></a><span class='hs-definition'>replaceExtension</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>ByteString</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-222"></a><span class='hs-definition'>replaceExtension</span> <span class='hs-varid'>path</span> <span class='hs-varid'>ext</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dropExtension</span> <span class='hs-varid'>path</span> <span class='hs-varop'><.></span> <span class='hs-varid'>ext</span>
|
||||
<a name="line-223"></a>
|
||||
<a name="line-224"></a>
|
||||
<a name="line-225"></a><a name="dropExtension"></a><span class='hs-comment'>-- | Drop the final extension from a 'RawFilePath'</span>
|
||||
<a name="line-226"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-227"></a><span class='hs-comment'>-- >>> dropExtension "file.exe"</span>
|
||||
<a name="line-228"></a><span class='hs-comment'>-- "file"</span>
|
||||
<a name="line-229"></a><span class='hs-comment'>-- >>> dropExtension "file"</span>
|
||||
<a name="line-230"></a><span class='hs-comment'>-- "file"</span>
|
||||
<a name="line-231"></a><span class='hs-comment'>-- >>> dropExtension "/path/file.tar.gz"</span>
|
||||
<a name="line-232"></a><span class='hs-comment'>-- "/path/file.tar"</span>
|
||||
<a name="line-233"></a><span class='hs-definition'>dropExtension</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-234"></a><span class='hs-definition'>dropExtension</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>fst</span> <span class='hs-varop'>.</span> <span class='hs-varid'>splitExtension</span>
|
||||
<a name="line-235"></a>
|
||||
<a name="line-236"></a>
|
||||
<a name="line-237"></a><a name="addExtension"></a><span class='hs-comment'>-- | Add an extension to a 'RawFilePath'</span>
|
||||
<a name="line-238"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-239"></a><span class='hs-comment'>-- >>> addExtension "file" ".exe"</span>
|
||||
<a name="line-240"></a><span class='hs-comment'>-- "file.exe"</span>
|
||||
<a name="line-241"></a><span class='hs-comment'>-- >>> addExtension "file.tar" ".gz"</span>
|
||||
<a name="line-242"></a><span class='hs-comment'>-- "file.tar.gz"</span>
|
||||
<a name="line-243"></a><span class='hs-comment'>-- >>> addExtension "/path/" ".ext"</span>
|
||||
<a name="line-244"></a><span class='hs-comment'>-- "/path/.ext"</span>
|
||||
<a name="line-245"></a><span class='hs-definition'>addExtension</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>ByteString</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-246"></a><span class='hs-definition'>addExtension</span> <span class='hs-varid'>file</span> <span class='hs-varid'>ext</span>
|
||||
<a name="line-247"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span> <span class='hs-varid'>ext</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>file</span>
|
||||
<a name="line-248"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>isExtSeparator</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>head</span> <span class='hs-varid'>ext</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>append</span> <span class='hs-varid'>file</span> <span class='hs-varid'>ext</span>
|
||||
<a name="line-249"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>intercalate</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>singleton</span> <span class='hs-varid'>extSeparator</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>file</span><span class='hs-layout'>,</span> <span class='hs-varid'>ext</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-250"></a>
|
||||
<a name="line-251"></a>
|
||||
<a name="line-252"></a><a name="hasExtension"></a><span class='hs-comment'>-- | Check if a 'RawFilePath' has an extension</span>
|
||||
<a name="line-253"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-254"></a><span class='hs-comment'>-- >>> hasExtension "file"</span>
|
||||
<a name="line-255"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-256"></a><span class='hs-comment'>-- >>> hasExtension "file.tar"</span>
|
||||
<a name="line-257"></a><span class='hs-comment'>-- True</span>
|
||||
<a name="line-258"></a><span class='hs-comment'>-- >>> hasExtension "/path.part1/"</span>
|
||||
<a name="line-259"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-260"></a><span class='hs-definition'>hasExtension</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Bool</span>
|
||||
<a name="line-261"></a><span class='hs-definition'>hasExtension</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>isJust</span> <span class='hs-varop'>.</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>elemIndex</span> <span class='hs-varid'>extSeparator</span> <span class='hs-varop'>.</span> <span class='hs-varid'>takeFileName</span>
|
||||
<a name="line-262"></a>
|
||||
<a name="line-263"></a>
|
||||
<a name="line-264"></a><a name="%3c.%3e"></a><span class='hs-comment'>-- | Operator version of 'addExtension'</span>
|
||||
<a name="line-265"></a><span class='hs-layout'>(</span><span class='hs-varop'><.></span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>ByteString</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-266"></a><span class='hs-layout'>(</span><span class='hs-varop'><.></span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>addExtension</span>
|
||||
<a name="line-267"></a>
|
||||
<a name="line-268"></a>
|
||||
<a name="line-269"></a><a name="splitExtensions"></a><span class='hs-comment'>-- | Split a 'RawFilePath' on the first extension.</span>
|
||||
<a name="line-270"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-271"></a><span class='hs-comment'>-- >>> splitExtensions "/path/file.tar.gz"</span>
|
||||
<a name="line-272"></a><span class='hs-comment'>-- ("/path/file",".tar.gz")</span>
|
||||
<a name="line-273"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-274"></a><span class='hs-comment'>-- prop> \path -> uncurry addExtension (splitExtensions path) == path</span>
|
||||
<a name="line-275"></a><span class='hs-definition'>splitExtensions</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-conid'>RawFilePath</span><span class='hs-layout'>,</span> <span class='hs-conid'>ByteString</span><span class='hs-layout'>)</span>
|
||||
<a name="line-276"></a><span class='hs-definition'>splitExtensions</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>if</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span> <span class='hs-varid'>basename</span>
|
||||
<a name="line-277"></a> <span class='hs-keyword'>then</span> <span class='hs-layout'>(</span><span class='hs-varid'>path</span><span class='hs-layout'>,</span><span class='hs-varid'>fileExt</span><span class='hs-layout'>)</span>
|
||||
<a name="line-278"></a> <span class='hs-keyword'>else</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>append</span> <span class='hs-varid'>path</span> <span class='hs-varid'>basename</span><span class='hs-layout'>,</span><span class='hs-varid'>fileExt</span><span class='hs-layout'>)</span>
|
||||
<a name="line-279"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-280"></a> <span class='hs-layout'>(</span><span class='hs-varid'>path</span><span class='hs-layout'>,</span><span class='hs-varid'>file</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>splitFileNameRaw</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-281"></a> <span class='hs-layout'>(</span><span class='hs-varid'>basename</span><span class='hs-layout'>,</span><span class='hs-varid'>fileExt</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>break</span> <span class='hs-varid'>isExtSeparator</span> <span class='hs-varid'>file</span>
|
||||
<a name="line-282"></a>
|
||||
<a name="line-283"></a>
|
||||
<a name="line-284"></a><a name="dropExtensions"></a><span class='hs-comment'>-- | Remove all extensions from a 'RawFilePath'</span>
|
||||
<a name="line-285"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-286"></a><span class='hs-comment'>-- >>> dropExtensions "/path/file.tar.gz"</span>
|
||||
<a name="line-287"></a><span class='hs-comment'>-- "/path/file"</span>
|
||||
<a name="line-288"></a><span class='hs-definition'>dropExtensions</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-289"></a><span class='hs-definition'>dropExtensions</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>fst</span> <span class='hs-varop'>.</span> <span class='hs-varid'>splitExtensions</span>
|
||||
<a name="line-290"></a>
|
||||
<a name="line-291"></a>
|
||||
<a name="line-292"></a><a name="takeExtensions"></a><span class='hs-comment'>-- | Take all extensions from a 'RawFilePath'</span>
|
||||
<a name="line-293"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-294"></a><span class='hs-comment'>-- >>> takeExtensions "/path/file.tar.gz"</span>
|
||||
<a name="line-295"></a><span class='hs-comment'>-- ".tar.gz"</span>
|
||||
<a name="line-296"></a><span class='hs-definition'>takeExtensions</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>ByteString</span>
|
||||
<a name="line-297"></a><span class='hs-definition'>takeExtensions</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>snd</span> <span class='hs-varop'>.</span> <span class='hs-varid'>splitExtensions</span>
|
||||
<a name="line-298"></a>
|
||||
<a name="line-299"></a>
|
||||
<a name="line-300"></a><a name="stripExtension"></a><span class='hs-comment'>-- | Drop the given extension from a FilePath, and the @\".\"@ preceding it.</span>
|
||||
<a name="line-301"></a><span class='hs-comment'>-- Returns 'Nothing' if the FilePath does not have the given extension, or</span>
|
||||
<a name="line-302"></a><span class='hs-comment'>-- 'Just' and the part before the extension if it does.</span>
|
||||
<a name="line-303"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-304"></a><span class='hs-comment'>-- This function can be more predictable than 'dropExtensions',</span>
|
||||
<a name="line-305"></a><span class='hs-comment'>-- especially if the filename might itself contain @.@ characters.</span>
|
||||
<a name="line-306"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-307"></a><span class='hs-comment'>-- >>> stripExtension "hs.o" "foo.x.hs.o"</span>
|
||||
<a name="line-308"></a><span class='hs-comment'>-- Just "foo.x"</span>
|
||||
<a name="line-309"></a><span class='hs-comment'>-- >>> stripExtension "hi.o" "foo.x.hs.o"</span>
|
||||
<a name="line-310"></a><span class='hs-comment'>-- Nothing</span>
|
||||
<a name="line-311"></a><span class='hs-comment'>-- >>> stripExtension ".c.d" "a.b.c.d"</span>
|
||||
<a name="line-312"></a><span class='hs-comment'>-- Just "a.b"</span>
|
||||
<a name="line-313"></a><span class='hs-comment'>-- >>> stripExtension ".c.d" "a.b..c.d"</span>
|
||||
<a name="line-314"></a><span class='hs-comment'>-- Just "a.b."</span>
|
||||
<a name="line-315"></a><span class='hs-comment'>-- >>> stripExtension "baz" "foo.bar"</span>
|
||||
<a name="line-316"></a><span class='hs-comment'>-- Nothing</span>
|
||||
<a name="line-317"></a><span class='hs-comment'>-- >>> stripExtension "bar" "foobar"</span>
|
||||
<a name="line-318"></a><span class='hs-comment'>-- Nothing</span>
|
||||
<a name="line-319"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-320"></a><span class='hs-comment'>-- prop> \path -> stripExtension "" path == Just path</span>
|
||||
<a name="line-321"></a><span class='hs-comment'>-- prop> \path -> dropExtension path == fromJust (stripExtension (takeExtension path) path)</span>
|
||||
<a name="line-322"></a><span class='hs-comment'>-- prop> \path -> dropExtensions path == fromJust (stripExtension (takeExtensions path) path)</span>
|
||||
<a name="line-323"></a><span class='hs-definition'>stripExtension</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>ByteString</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Maybe</span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-324"></a><span class='hs-definition'>stripExtension</span> <span class='hs-varid'>bs</span> <span class='hs-varid'>path</span>
|
||||
<a name="line-325"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span> <span class='hs-varid'>bs</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Just</span> <span class='hs-varid'>path</span>
|
||||
<a name="line-326"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>stripSuffix'</span> <span class='hs-varid'>dotExt</span> <span class='hs-varid'>path</span>
|
||||
<a name="line-327"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-328"></a> <span class='hs-varid'>dotExt</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>if</span> <span class='hs-varid'>isExtSeparator</span> <span class='hs-varop'>$</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>head</span> <span class='hs-varid'>bs</span>
|
||||
<a name="line-329"></a> <span class='hs-keyword'>then</span> <span class='hs-varid'>bs</span>
|
||||
<a name="line-330"></a> <span class='hs-keyword'>else</span> <span class='hs-varid'>extSeparator</span> <span class='hs-varop'>`</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>cons</span><span class='hs-varop'>`</span> <span class='hs-varid'>bs</span>
|
||||
<a name="line-331"></a><span class='hs-cpp'>#if MIN_VERSION_bytestring(0,10,8)</span>
|
||||
<a name="line-332"></a> <span class='hs-varid'>stripSuffix'</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>stripSuffix</span>
|
||||
<a name="line-333"></a><span class='hs-cpp'>#else</span>
|
||||
<a name="line-334"></a> <span class='hs-varid'>stripSuffix'</span> <span class='hs-varid'>xs</span> <span class='hs-varid'>ys</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>fmap</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>pack</span> <span class='hs-varop'>.</span> <span class='hs-varid'>reverse</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-conid'>L</span><span class='hs-varop'>.</span><span class='hs-varid'>stripPrefix</span> <span class='hs-layout'>(</span><span class='hs-varid'>reverse</span> <span class='hs-varop'>$</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>unpack</span> <span class='hs-varid'>xs</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>reverse</span> <span class='hs-varop'>$</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>unpack</span> <span class='hs-varid'>ys</span><span class='hs-layout'>)</span>
|
||||
<a name="line-335"></a><span class='hs-cpp'>#endif</span>
|
||||
<a name="line-336"></a>
|
||||
<a name="line-337"></a>
|
||||
<a name="line-338"></a><span class='hs-comment'>------------------------</span>
|
||||
<a name="line-339"></a><span class='hs-comment'>-- Filename/directory functions</span>
|
||||
<a name="line-340"></a>
|
||||
<a name="line-341"></a>
|
||||
<a name="line-342"></a><a name="splitFileName"></a><span class='hs-comment'>-- | Split a 'RawFilePath' into (path,file). 'combine' is the inverse</span>
|
||||
<a name="line-343"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-344"></a><span class='hs-comment'>-- >>> splitFileName "path/file.txt"</span>
|
||||
<a name="line-345"></a><span class='hs-comment'>-- ("path/","file.txt")</span>
|
||||
<a name="line-346"></a><span class='hs-comment'>-- >>> splitFileName "path/"</span>
|
||||
<a name="line-347"></a><span class='hs-comment'>-- ("path/","")</span>
|
||||
<a name="line-348"></a><span class='hs-comment'>-- >>> splitFileName "file.txt"</span>
|
||||
<a name="line-349"></a><span class='hs-comment'>-- ("./","file.txt")</span>
|
||||
<a name="line-350"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-351"></a><span class='hs-comment'>-- prop> \path -> uncurry combine (splitFileName path) == path || fst (splitFileName path) == "./"</span>
|
||||
<a name="line-352"></a><span class='hs-definition'>splitFileName</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-conid'>RawFilePath</span><span class='hs-layout'>,</span> <span class='hs-conid'>RawFilePath</span><span class='hs-layout'>)</span>
|
||||
<a name="line-353"></a><span class='hs-definition'>splitFileName</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>if</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span> <span class='hs-varid'>path</span>
|
||||
<a name="line-354"></a> <span class='hs-keyword'>then</span> <span class='hs-layout'>(</span><span class='hs-varid'>dotSlash</span><span class='hs-layout'>,</span> <span class='hs-varid'>file</span><span class='hs-layout'>)</span>
|
||||
<a name="line-355"></a> <span class='hs-keyword'>else</span> <span class='hs-layout'>(</span><span class='hs-varid'>path</span><span class='hs-layout'>,</span><span class='hs-varid'>file</span><span class='hs-layout'>)</span>
|
||||
<a name="line-356"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-357"></a> <span class='hs-layout'>(</span><span class='hs-varid'>path</span><span class='hs-layout'>,</span><span class='hs-varid'>file</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>splitFileNameRaw</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-358"></a> <span class='hs-varid'>dotSlash</span> <span class='hs-keyglyph'>=</span> <span class='hs-sel'>_period</span> <span class='hs-varop'>`</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>cons</span><span class='hs-varop'>`</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>singleton</span> <span class='hs-varid'>pathSeparator</span><span class='hs-layout'>)</span>
|
||||
<a name="line-359"></a>
|
||||
<a name="line-360"></a>
|
||||
<a name="line-361"></a><a name="takeFileName"></a><span class='hs-comment'>-- | Get the file name</span>
|
||||
<a name="line-362"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-363"></a><span class='hs-comment'>-- >>> takeFileName "path/file.txt"</span>
|
||||
<a name="line-364"></a><span class='hs-comment'>-- "file.txt"</span>
|
||||
<a name="line-365"></a><span class='hs-comment'>-- >>> takeFileName "path/"</span>
|
||||
<a name="line-366"></a><span class='hs-comment'>-- ""</span>
|
||||
<a name="line-367"></a><span class='hs-definition'>takeFileName</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-368"></a><span class='hs-definition'>takeFileName</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>snd</span> <span class='hs-varop'>.</span> <span class='hs-varid'>splitFileName</span>
|
||||
<a name="line-369"></a>
|
||||
<a name="line-370"></a>
|
||||
<a name="line-371"></a><a name="replaceFileName"></a><span class='hs-comment'>-- | Change the file name</span>
|
||||
<a name="line-372"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-373"></a><span class='hs-comment'>-- prop> \path -> replaceFileName path (takeFileName path) == path</span>
|
||||
<a name="line-374"></a><span class='hs-definition'>replaceFileName</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>ByteString</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-375"></a><span class='hs-definition'>replaceFileName</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>fst</span> <span class='hs-layout'>(</span><span class='hs-varid'>splitFileNameRaw</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-varop'></></span> <span class='hs-varid'>y</span>
|
||||
<a name="line-376"></a>
|
||||
<a name="line-377"></a>
|
||||
<a name="line-378"></a><a name="dropFileName"></a><span class='hs-comment'>-- | Drop the file name</span>
|
||||
<a name="line-379"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-380"></a><span class='hs-comment'>-- >>> dropFileName "path/file.txt"</span>
|
||||
<a name="line-381"></a><span class='hs-comment'>-- "path/"</span>
|
||||
<a name="line-382"></a><span class='hs-comment'>-- >>> dropFileName "file.txt"</span>
|
||||
<a name="line-383"></a><span class='hs-comment'>-- "./"</span>
|
||||
<a name="line-384"></a><span class='hs-definition'>dropFileName</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-385"></a><span class='hs-definition'>dropFileName</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>fst</span> <span class='hs-varop'>.</span> <span class='hs-varid'>splitFileName</span>
|
||||
<a name="line-386"></a>
|
||||
<a name="line-387"></a>
|
||||
<a name="line-388"></a><a name="takeBaseName"></a><span class='hs-comment'>-- | Get the file name, without a trailing extension</span>
|
||||
<a name="line-389"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-390"></a><span class='hs-comment'>-- >>> takeBaseName "path/file.tar.gz"</span>
|
||||
<a name="line-391"></a><span class='hs-comment'>-- "file.tar"</span>
|
||||
<a name="line-392"></a><span class='hs-comment'>-- >>> takeBaseName ""</span>
|
||||
<a name="line-393"></a><span class='hs-comment'>-- ""</span>
|
||||
<a name="line-394"></a><span class='hs-definition'>takeBaseName</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>ByteString</span>
|
||||
<a name="line-395"></a><span class='hs-definition'>takeBaseName</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dropExtension</span> <span class='hs-varop'>.</span> <span class='hs-varid'>takeFileName</span>
|
||||
<a name="line-396"></a>
|
||||
<a name="line-397"></a>
|
||||
<a name="line-398"></a><a name="replaceBaseName"></a><span class='hs-comment'>-- | Change the base name</span>
|
||||
<a name="line-399"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-400"></a><span class='hs-comment'>-- >>> replaceBaseName "path/file.tar.gz" "bob"</span>
|
||||
<a name="line-401"></a><span class='hs-comment'>-- "path/bob.gz"</span>
|
||||
<a name="line-402"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-403"></a><span class='hs-comment'>-- prop> \path -> replaceBaseName path (takeBaseName path) == path</span>
|
||||
<a name="line-404"></a><span class='hs-definition'>replaceBaseName</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>ByteString</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-405"></a><span class='hs-definition'>replaceBaseName</span> <span class='hs-varid'>path</span> <span class='hs-varid'>name</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>combineRaw</span> <span class='hs-varid'>dir</span> <span class='hs-layout'>(</span><span class='hs-varid'>name</span> <span class='hs-varop'><.></span> <span class='hs-varid'>ext</span><span class='hs-layout'>)</span>
|
||||
<a name="line-406"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-407"></a> <span class='hs-layout'>(</span><span class='hs-varid'>dir</span><span class='hs-layout'>,</span><span class='hs-varid'>file</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>splitFileNameRaw</span> <span class='hs-varid'>path</span>
|
||||
<a name="line-408"></a> <span class='hs-varid'>ext</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>takeExtension</span> <span class='hs-varid'>file</span>
|
||||
<a name="line-409"></a>
|
||||
<a name="line-410"></a>
|
||||
<a name="line-411"></a><a name="takeDirectory"></a><span class='hs-comment'>-- | Get the directory, moving up one level if it's already a directory</span>
|
||||
<a name="line-412"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-413"></a><span class='hs-comment'>-- >>> takeDirectory "path/file.txt"</span>
|
||||
<a name="line-414"></a><span class='hs-comment'>-- "path"</span>
|
||||
<a name="line-415"></a><span class='hs-comment'>-- >>> takeDirectory "file"</span>
|
||||
<a name="line-416"></a><span class='hs-comment'>-- "."</span>
|
||||
<a name="line-417"></a><span class='hs-comment'>-- >>> takeDirectory "/path/to/"</span>
|
||||
<a name="line-418"></a><span class='hs-comment'>-- "/path/to"</span>
|
||||
<a name="line-419"></a><span class='hs-comment'>-- >>> takeDirectory "/path/to"</span>
|
||||
<a name="line-420"></a><span class='hs-comment'>-- "/path"</span>
|
||||
<a name="line-421"></a><span class='hs-definition'>takeDirectory</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-422"></a><span class='hs-definition'>takeDirectory</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>case</span> <span class='hs-conid'>()</span> <span class='hs-keyword'>of</span>
|
||||
<a name="line-423"></a> <span class='hs-conid'>()</span> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>singleton</span> <span class='hs-varid'>pathSeparator</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>x</span>
|
||||
<a name="line-424"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span> <span class='hs-varid'>res</span> <span class='hs-varop'>&&</span> <span class='hs-varid'>not</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span> <span class='hs-varid'>file</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>file</span>
|
||||
<a name="line-425"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>res</span>
|
||||
<a name="line-426"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-427"></a> <span class='hs-varid'>res</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>fst</span> <span class='hs-varop'>$</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>spanEnd</span> <span class='hs-varid'>isPathSeparator</span> <span class='hs-varid'>file</span>
|
||||
<a name="line-428"></a> <span class='hs-varid'>file</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dropFileName</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-429"></a>
|
||||
<a name="line-430"></a>
|
||||
<a name="line-431"></a><a name="replaceDirectory"></a><span class='hs-comment'>-- | Change the directory component of a 'RawFilePath'</span>
|
||||
<a name="line-432"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-433"></a><span class='hs-comment'>-- prop> \path -> replaceDirectory path (takeDirectory path) `equalFilePath` path || takeDirectory path == "."</span>
|
||||
<a name="line-434"></a><span class='hs-definition'>replaceDirectory</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>ByteString</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-435"></a><span class='hs-definition'>replaceDirectory</span> <span class='hs-varid'>file</span> <span class='hs-varid'>dir</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>combineRaw</span> <span class='hs-varid'>dir</span> <span class='hs-layout'>(</span><span class='hs-varid'>takeFileName</span> <span class='hs-varid'>file</span><span class='hs-layout'>)</span>
|
||||
<a name="line-436"></a>
|
||||
<a name="line-437"></a>
|
||||
<a name="line-438"></a><a name="combine"></a><span class='hs-comment'>-- | Join two paths together</span>
|
||||
<a name="line-439"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-440"></a><span class='hs-comment'>-- >>> combine "/" "file"</span>
|
||||
<a name="line-441"></a><span class='hs-comment'>-- "/file"</span>
|
||||
<a name="line-442"></a><span class='hs-comment'>-- >>> combine "/path/to" "file"</span>
|
||||
<a name="line-443"></a><span class='hs-comment'>-- "/path/to/file"</span>
|
||||
<a name="line-444"></a><span class='hs-comment'>-- >>> combine "file" "/absolute/path"</span>
|
||||
<a name="line-445"></a><span class='hs-comment'>-- "/absolute/path"</span>
|
||||
<a name="line-446"></a><span class='hs-definition'>combine</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-447"></a><span class='hs-definition'>combine</span> <span class='hs-varid'>a</span> <span class='hs-varid'>b</span> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>not</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span> <span class='hs-varop'>&&</span> <span class='hs-varid'>isPathSeparator</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>head</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>b</span>
|
||||
<a name="line-448"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>combineRaw</span> <span class='hs-varid'>a</span> <span class='hs-varid'>b</span>
|
||||
<a name="line-449"></a>
|
||||
<a name="line-450"></a>
|
||||
<a name="line-451"></a><a name="%3c/%3e"></a><span class='hs-comment'>-- | Operator version of combine</span>
|
||||
<a name="line-452"></a><span class='hs-layout'>(</span><span class='hs-varop'></></span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-453"></a><span class='hs-layout'>(</span><span class='hs-varop'></></span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>combine</span>
|
||||
<a name="line-454"></a>
|
||||
<a name="line-455"></a><a name="splitPath"></a><span class='hs-comment'>-- | Split a path into a list of components:</span>
|
||||
<a name="line-456"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-457"></a><span class='hs-comment'>-- >>> splitPath "/path/to/file.txt"</span>
|
||||
<a name="line-458"></a><span class='hs-comment'>-- ["/","path/","to/","file.txt"]</span>
|
||||
<a name="line-459"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-460"></a><span class='hs-comment'>-- prop> \path -> BS.concat (splitPath path) == path</span>
|
||||
<a name="line-461"></a><span class='hs-definition'>splitPath</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>RawFilePath</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-462"></a><span class='hs-definition'>splitPath</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>splitter</span>
|
||||
<a name="line-463"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-464"></a> <span class='hs-varid'>splitter</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-465"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>[]</span>
|
||||
<a name="line-466"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>case</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>elemIndex</span> <span class='hs-varid'>pathSeparator</span> <span class='hs-varid'>x</span> <span class='hs-keyword'>of</span>
|
||||
<a name="line-467"></a> <span class='hs-conid'>Nothing</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>x</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-468"></a> <span class='hs-conid'>Just</span> <span class='hs-varid'>ix</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>case</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>findIndex</span> <span class='hs-layout'>(</span><span class='hs-varid'>not</span> <span class='hs-varop'>.</span> <span class='hs-varid'>isPathSeparator</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>drop</span> <span class='hs-layout'>(</span><span class='hs-varid'>ix</span><span class='hs-varop'>+</span><span class='hs-num'>1</span><span class='hs-layout'>)</span> <span class='hs-varid'>x</span> <span class='hs-keyword'>of</span>
|
||||
<a name="line-469"></a> <span class='hs-conid'>Nothing</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>x</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-470"></a> <span class='hs-conid'>Just</span> <span class='hs-varid'>runlen</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>uncurry</span> <span class='hs-layout'>(</span><span class='hs-conop'>:</span><span class='hs-layout'>)</span> <span class='hs-varop'>.</span> <span class='hs-varid'>second</span> <span class='hs-varid'>splitter</span> <span class='hs-varop'>$</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>splitAt</span> <span class='hs-layout'>(</span><span class='hs-varid'>ix</span><span class='hs-varop'>+</span><span class='hs-num'>1</span><span class='hs-varop'>+</span><span class='hs-varid'>runlen</span><span class='hs-layout'>)</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-471"></a>
|
||||
<a name="line-472"></a>
|
||||
<a name="line-473"></a><a name="joinPath"></a><span class='hs-comment'>-- | Join a split path back together</span>
|
||||
<a name="line-474"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-475"></a><span class='hs-comment'>-- prop> \path -> joinPath (splitPath path) == path</span>
|
||||
<a name="line-476"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-477"></a><span class='hs-comment'>-- >>> joinPath ["path","to","file.txt"]</span>
|
||||
<a name="line-478"></a><span class='hs-comment'>-- "path/to/file.txt"</span>
|
||||
<a name="line-479"></a><span class='hs-definition'>joinPath</span> <span class='hs-keyglyph'>::</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>RawFilePath</span><span class='hs-keyglyph'>]</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-480"></a><span class='hs-definition'>joinPath</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>foldr</span> <span class='hs-layout'>(</span><span class='hs-varop'></></span><span class='hs-layout'>)</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>empty</span>
|
||||
<a name="line-481"></a>
|
||||
<a name="line-482"></a>
|
||||
<a name="line-483"></a><a name="splitDirectories"></a><span class='hs-comment'>-- | Like 'splitPath', but without trailing slashes</span>
|
||||
<a name="line-484"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-485"></a><span class='hs-comment'>-- >>> splitDirectories "/path/to/file.txt"</span>
|
||||
<a name="line-486"></a><span class='hs-comment'>-- ["/","path","to","file.txt"]</span>
|
||||
<a name="line-487"></a><span class='hs-comment'>-- >>> splitDirectories ""</span>
|
||||
<a name="line-488"></a><span class='hs-comment'>-- []</span>
|
||||
<a name="line-489"></a><span class='hs-definition'>splitDirectories</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>RawFilePath</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-490"></a><span class='hs-definition'>splitDirectories</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-491"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>[]</span>
|
||||
<a name="line-492"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>isPathSeparator</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>head</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>let</span> <span class='hs-layout'>(</span><span class='hs-varid'>root</span><span class='hs-layout'>,</span><span class='hs-varid'>rest</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>splitAt</span> <span class='hs-num'>1</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-493"></a> <span class='hs-keyword'>in</span> <span class='hs-varid'>root</span> <span class='hs-conop'>:</span> <span class='hs-varid'>splitter</span> <span class='hs-varid'>rest</span>
|
||||
<a name="line-494"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>splitter</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-495"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-496"></a> <span class='hs-varid'>splitter</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>filter</span> <span class='hs-layout'>(</span><span class='hs-varid'>not</span> <span class='hs-varop'>.</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span><span class='hs-layout'>)</span> <span class='hs-varop'>.</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>split</span> <span class='hs-varid'>pathSeparator</span>
|
||||
<a name="line-497"></a>
|
||||
<a name="line-498"></a>
|
||||
<a name="line-499"></a>
|
||||
<a name="line-500"></a><span class='hs-comment'>------------------------</span>
|
||||
<a name="line-501"></a><span class='hs-comment'>-- Trailing slash functions</span>
|
||||
<a name="line-502"></a>
|
||||
<a name="line-503"></a><a name="hasTrailingPathSeparator"></a><span class='hs-comment'>-- | Check if the last character of a 'RawFilePath' is '/'.</span>
|
||||
<a name="line-504"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-505"></a><span class='hs-comment'>-- >>> hasTrailingPathSeparator "/path/"</span>
|
||||
<a name="line-506"></a><span class='hs-comment'>-- True</span>
|
||||
<a name="line-507"></a><span class='hs-comment'>-- >>> hasTrailingPathSeparator "/"</span>
|
||||
<a name="line-508"></a><span class='hs-comment'>-- True</span>
|
||||
<a name="line-509"></a><span class='hs-comment'>-- >>> hasTrailingPathSeparator "/path"</span>
|
||||
<a name="line-510"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-511"></a><span class='hs-definition'>hasTrailingPathSeparator</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Bool</span>
|
||||
<a name="line-512"></a><span class='hs-definition'>hasTrailingPathSeparator</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-513"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>False</span>
|
||||
<a name="line-514"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>isPathSeparator</span> <span class='hs-varop'>$</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>last</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-515"></a>
|
||||
<a name="line-516"></a>
|
||||
<a name="line-517"></a><a name="addTrailingPathSeparator"></a><span class='hs-comment'>-- | Add a trailing path separator.</span>
|
||||
<a name="line-518"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-519"></a><span class='hs-comment'>-- >>> addTrailingPathSeparator "/path"</span>
|
||||
<a name="line-520"></a><span class='hs-comment'>-- "/path/"</span>
|
||||
<a name="line-521"></a><span class='hs-comment'>-- >>> addTrailingPathSeparator "/path/"</span>
|
||||
<a name="line-522"></a><span class='hs-comment'>-- "/path/"</span>
|
||||
<a name="line-523"></a><span class='hs-comment'>-- >>> addTrailingPathSeparator "/"</span>
|
||||
<a name="line-524"></a><span class='hs-comment'>-- "/"</span>
|
||||
<a name="line-525"></a><span class='hs-definition'>addTrailingPathSeparator</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-526"></a><span class='hs-definition'>addTrailingPathSeparator</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>if</span> <span class='hs-varid'>hasTrailingPathSeparator</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-527"></a> <span class='hs-keyword'>then</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-528"></a> <span class='hs-keyword'>else</span> <span class='hs-varid'>x</span> <span class='hs-varop'>`</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>snoc</span><span class='hs-varop'>`</span> <span class='hs-varid'>pathSeparator</span>
|
||||
<a name="line-529"></a>
|
||||
<a name="line-530"></a>
|
||||
<a name="line-531"></a><a name="dropTrailingPathSeparator"></a><span class='hs-comment'>-- | Remove a trailing path separator</span>
|
||||
<a name="line-532"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-533"></a><span class='hs-comment'>-- >>> dropTrailingPathSeparator "/path/"</span>
|
||||
<a name="line-534"></a><span class='hs-comment'>-- "/path"</span>
|
||||
<a name="line-535"></a><span class='hs-comment'>-- >>> dropTrailingPathSeparator "/path////"</span>
|
||||
<a name="line-536"></a><span class='hs-comment'>-- "/path"</span>
|
||||
<a name="line-537"></a><span class='hs-comment'>-- >>> dropTrailingPathSeparator "/"</span>
|
||||
<a name="line-538"></a><span class='hs-comment'>-- "/"</span>
|
||||
<a name="line-539"></a><span class='hs-comment'>-- >>> dropTrailingPathSeparator "//"</span>
|
||||
<a name="line-540"></a><span class='hs-comment'>-- "/"</span>
|
||||
<a name="line-541"></a><span class='hs-definition'>dropTrailingPathSeparator</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-542"></a><span class='hs-definition'>dropTrailingPathSeparator</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-543"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>singleton</span> <span class='hs-varid'>pathSeparator</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-544"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>if</span> <span class='hs-varid'>hasTrailingPathSeparator</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-545"></a> <span class='hs-keyword'>then</span> <span class='hs-varid'>dropTrailingPathSeparator</span> <span class='hs-varop'>$</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>init</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-546"></a> <span class='hs-keyword'>else</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-547"></a>
|
||||
<a name="line-548"></a>
|
||||
<a name="line-549"></a>
|
||||
<a name="line-550"></a><span class='hs-comment'>------------------------</span>
|
||||
<a name="line-551"></a><span class='hs-comment'>-- File name manipulations</span>
|
||||
<a name="line-552"></a>
|
||||
<a name="line-553"></a>
|
||||
<a name="line-554"></a><a name="normalise"></a><span class='hs-comment'>-- |Normalise a file.</span>
|
||||
<a name="line-555"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-556"></a><span class='hs-comment'>-- >>> normalise "/file/\\test////"</span>
|
||||
<a name="line-557"></a><span class='hs-comment'>-- "/file/\\test/"</span>
|
||||
<a name="line-558"></a><span class='hs-comment'>-- >>> normalise "/file/./test"</span>
|
||||
<a name="line-559"></a><span class='hs-comment'>-- "/file/test"</span>
|
||||
<a name="line-560"></a><span class='hs-comment'>-- >>> normalise "/test/file/../bob/fred/"</span>
|
||||
<a name="line-561"></a><span class='hs-comment'>-- "/test/file/../bob/fred/"</span>
|
||||
<a name="line-562"></a><span class='hs-comment'>-- >>> normalise "../bob/fred/"</span>
|
||||
<a name="line-563"></a><span class='hs-comment'>-- "../bob/fred/"</span>
|
||||
<a name="line-564"></a><span class='hs-comment'>-- >>> normalise "./bob/fred/"</span>
|
||||
<a name="line-565"></a><span class='hs-comment'>-- "bob/fred/"</span>
|
||||
<a name="line-566"></a><span class='hs-comment'>-- >>> normalise "./bob////.fred/./...///./..///#."</span>
|
||||
<a name="line-567"></a><span class='hs-comment'>-- "bob/.fred/.../../#."</span>
|
||||
<a name="line-568"></a><span class='hs-comment'>-- >>> normalise "."</span>
|
||||
<a name="line-569"></a><span class='hs-comment'>-- "."</span>
|
||||
<a name="line-570"></a><span class='hs-comment'>-- >>> normalise "./"</span>
|
||||
<a name="line-571"></a><span class='hs-comment'>-- "./"</span>
|
||||
<a name="line-572"></a><span class='hs-comment'>-- >>> normalise "./."</span>
|
||||
<a name="line-573"></a><span class='hs-comment'>-- "./"</span>
|
||||
<a name="line-574"></a><span class='hs-comment'>-- >>> normalise "/./"</span>
|
||||
<a name="line-575"></a><span class='hs-comment'>-- "/"</span>
|
||||
<a name="line-576"></a><span class='hs-comment'>-- >>> normalise "/"</span>
|
||||
<a name="line-577"></a><span class='hs-comment'>-- "/"</span>
|
||||
<a name="line-578"></a><span class='hs-comment'>-- >>> normalise "bob/fred/."</span>
|
||||
<a name="line-579"></a><span class='hs-comment'>-- "bob/fred/"</span>
|
||||
<a name="line-580"></a><span class='hs-comment'>-- >>> normalise "//home"</span>
|
||||
<a name="line-581"></a><span class='hs-comment'>-- "/home"</span>
|
||||
<a name="line-582"></a><span class='hs-definition'>normalise</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-583"></a><span class='hs-definition'>normalise</span> <span class='hs-varid'>filepath</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-584"></a> <span class='hs-varid'>result</span> <span class='hs-varop'>`</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>append</span><span class='hs-varop'>`</span>
|
||||
<a name="line-585"></a> <span class='hs-layout'>(</span><span class='hs-keyword'>if</span> <span class='hs-varid'>addPathSeparator</span>
|
||||
<a name="line-586"></a> <span class='hs-keyword'>then</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>singleton</span> <span class='hs-varid'>pathSeparator</span>
|
||||
<a name="line-587"></a> <span class='hs-keyword'>else</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>empty</span><span class='hs-layout'>)</span>
|
||||
<a name="line-588"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-589"></a> <span class='hs-varid'>result</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>let</span> <span class='hs-varid'>n</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>f</span> <span class='hs-varid'>filepath</span>
|
||||
<a name="line-590"></a> <span class='hs-keyword'>in</span> <span class='hs-keyword'>if</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span> <span class='hs-varid'>n</span>
|
||||
<a name="line-591"></a> <span class='hs-keyword'>then</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>singleton</span> <span class='hs-sel'>_period</span>
|
||||
<a name="line-592"></a> <span class='hs-keyword'>else</span> <span class='hs-varid'>n</span>
|
||||
<a name="line-593"></a> <span class='hs-varid'>addPathSeparator</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>isDirPath</span> <span class='hs-varid'>filepath</span> <span class='hs-varop'>&&</span>
|
||||
<a name="line-594"></a> <span class='hs-varid'>not</span> <span class='hs-layout'>(</span><span class='hs-varid'>hasTrailingPathSeparator</span> <span class='hs-varid'>result</span><span class='hs-layout'>)</span>
|
||||
<a name="line-595"></a> <span class='hs-varid'>isDirPath</span> <span class='hs-varid'>xs</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>hasTrailingPathSeparator</span> <span class='hs-varid'>xs</span>
|
||||
<a name="line-596"></a> <span class='hs-varop'>||</span> <span class='hs-varid'>not</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span> <span class='hs-varid'>xs</span><span class='hs-layout'>)</span> <span class='hs-varop'>&&</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>last</span> <span class='hs-varid'>xs</span> <span class='hs-varop'>==</span> <span class='hs-sel'>_period</span>
|
||||
<a name="line-597"></a> <span class='hs-varop'>&&</span> <span class='hs-varid'>hasTrailingPathSeparator</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>init</span> <span class='hs-varid'>xs</span><span class='hs-layout'>)</span>
|
||||
<a name="line-598"></a> <span class='hs-varid'>f</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>joinPath</span> <span class='hs-varop'>.</span> <span class='hs-varid'>dropDots</span> <span class='hs-varop'>.</span> <span class='hs-varid'>propSep</span> <span class='hs-varop'>.</span> <span class='hs-varid'>splitDirectories</span>
|
||||
<a name="line-599"></a> <span class='hs-varid'>propSep</span> <span class='hs-keyglyph'>::</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>ByteString</span><span class='hs-keyglyph'>]</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>ByteString</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-600"></a> <span class='hs-varid'>propSep</span> <span class='hs-layout'>(</span><span class='hs-varid'>x</span><span class='hs-conop'>:</span><span class='hs-varid'>xs</span><span class='hs-layout'>)</span>
|
||||
<a name="line-601"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>all</span> <span class='hs-layout'>(</span><span class='hs-varop'>==</span> <span class='hs-varid'>pathSeparator</span><span class='hs-layout'>)</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>singleton</span> <span class='hs-varid'>pathSeparator</span> <span class='hs-conop'>:</span> <span class='hs-varid'>xs</span>
|
||||
<a name="line-602"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>x</span> <span class='hs-conop'>:</span> <span class='hs-varid'>xs</span>
|
||||
<a name="line-603"></a> <span class='hs-varid'>propSep</span> <span class='hs-conid'>[]</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>[]</span>
|
||||
<a name="line-604"></a> <span class='hs-varid'>dropDots</span> <span class='hs-keyglyph'>::</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>ByteString</span><span class='hs-keyglyph'>]</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>ByteString</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-605"></a> <span class='hs-varid'>dropDots</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>filter</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>singleton</span> <span class='hs-sel'>_period</span> <span class='hs-varop'>/=</span><span class='hs-layout'>)</span>
|
||||
<a name="line-606"></a>
|
||||
<a name="line-607"></a>
|
||||
<a name="line-608"></a>
|
||||
<a name="line-609"></a><a name="makeRelative"></a><span class='hs-comment'>-- | Contract a filename, based on a relative path. Note that the resulting</span>
|
||||
<a name="line-610"></a><span class='hs-comment'>-- path will never introduce @..@ paths, as the presence of symlinks</span>
|
||||
<a name="line-611"></a><span class='hs-comment'>-- means @..\/b@ may not reach @a\/b@ if it starts from @a\/c@. For a</span>
|
||||
<a name="line-612"></a><span class='hs-comment'>-- worked example see</span>
|
||||
<a name="line-613"></a><span class='hs-comment'>-- <<a href="http://neilmitchell.blogspot.co.uk/2015/10/filepaths-are-subtle-symlinks-are-hard.html">http://neilmitchell.blogspot.co.uk/2015/10/filepaths-are-subtle-symlinks-are-hard.html</a> this blog post>.</span>
|
||||
<a name="line-614"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-615"></a><span class='hs-comment'>-- >>> makeRelative "/directory" "/directory/file.ext"</span>
|
||||
<a name="line-616"></a><span class='hs-comment'>-- "file.ext"</span>
|
||||
<a name="line-617"></a><span class='hs-comment'>-- >>> makeRelative "/Home" "/home/bob"</span>
|
||||
<a name="line-618"></a><span class='hs-comment'>-- "/home/bob"</span>
|
||||
<a name="line-619"></a><span class='hs-comment'>-- >>> makeRelative "/home/" "/home/bob/foo/bar"</span>
|
||||
<a name="line-620"></a><span class='hs-comment'>-- "bob/foo/bar"</span>
|
||||
<a name="line-621"></a><span class='hs-comment'>-- >>> makeRelative "/fred" "bob"</span>
|
||||
<a name="line-622"></a><span class='hs-comment'>-- "bob"</span>
|
||||
<a name="line-623"></a><span class='hs-comment'>-- >>> makeRelative "/file/test" "/file/test/fred"</span>
|
||||
<a name="line-624"></a><span class='hs-comment'>-- "fred"</span>
|
||||
<a name="line-625"></a><span class='hs-comment'>-- >>> makeRelative "/file/test" "/file/test/fred/"</span>
|
||||
<a name="line-626"></a><span class='hs-comment'>-- "fred/"</span>
|
||||
<a name="line-627"></a><span class='hs-comment'>-- >>> makeRelative "some/path" "some/path/a/b/c"</span>
|
||||
<a name="line-628"></a><span class='hs-comment'>-- "a/b/c"</span>
|
||||
<a name="line-629"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-630"></a><span class='hs-comment'>-- prop> \p -> makeRelative p p == "."</span>
|
||||
<a name="line-631"></a><span class='hs-comment'>-- prop> \p -> makeRelative (takeDirectory p) p `equalFilePath` takeFileName p</span>
|
||||
<a name="line-632"></a><span class='hs-comment'>-- prop \x y -> equalFilePath x y || (isRelative x && makeRelative y x == x) || equalFilePath (y </> makeRelative y x) x</span>
|
||||
<a name="line-633"></a><span class='hs-definition'>makeRelative</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-634"></a><span class='hs-definition'>makeRelative</span> <span class='hs-varid'>root</span> <span class='hs-varid'>path</span>
|
||||
<a name="line-635"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>equalFilePath</span> <span class='hs-varid'>root</span> <span class='hs-varid'>path</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>singleton</span> <span class='hs-sel'>_period</span>
|
||||
<a name="line-636"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>takeAbs</span> <span class='hs-varid'>root</span> <span class='hs-varop'>/=</span> <span class='hs-varid'>takeAbs</span> <span class='hs-varid'>path</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>path</span>
|
||||
<a name="line-637"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>f</span> <span class='hs-layout'>(</span><span class='hs-varid'>dropAbs</span> <span class='hs-varid'>root</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>dropAbs</span> <span class='hs-varid'>path</span><span class='hs-layout'>)</span>
|
||||
<a name="line-638"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-639"></a> <span class='hs-varid'>f</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span>
|
||||
<a name="line-640"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>dropWhile</span> <span class='hs-varid'>isPathSeparator</span> <span class='hs-varid'>y</span>
|
||||
<a name="line-641"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>let</span> <span class='hs-layout'>(</span><span class='hs-varid'>x1</span><span class='hs-layout'>,</span><span class='hs-varid'>x2</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>g</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-642"></a> <span class='hs-layout'>(</span><span class='hs-varid'>y1</span><span class='hs-layout'>,</span><span class='hs-varid'>y2</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>g</span> <span class='hs-varid'>y</span>
|
||||
<a name="line-643"></a> <span class='hs-keyword'>in</span> <span class='hs-keyword'>if</span> <span class='hs-varid'>equalFilePath</span> <span class='hs-varid'>x1</span> <span class='hs-varid'>y1</span> <span class='hs-keyword'>then</span> <span class='hs-varid'>f</span> <span class='hs-varid'>x2</span> <span class='hs-varid'>y2</span> <span class='hs-keyword'>else</span> <span class='hs-varid'>path</span>
|
||||
<a name="line-644"></a> <span class='hs-varid'>g</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>dropWhile</span> <span class='hs-varid'>isPathSeparator</span> <span class='hs-varid'>a</span><span class='hs-layout'>,</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>dropWhile</span> <span class='hs-varid'>isPathSeparator</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span>
|
||||
<a name="line-645"></a> <span class='hs-keyword'>where</span> <span class='hs-layout'>(</span><span class='hs-varid'>a</span><span class='hs-layout'>,</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>break</span> <span class='hs-varid'>isPathSeparator</span> <span class='hs-varop'>$</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>dropWhile</span> <span class='hs-varid'>isPathSeparator</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-646"></a> <span class='hs-varid'>dropAbs</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>snd</span> <span class='hs-varop'>$</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>span</span> <span class='hs-layout'>(</span><span class='hs-varop'>==</span> <span class='hs-sel'>_slash</span><span class='hs-layout'>)</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-647"></a> <span class='hs-varid'>takeAbs</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>fst</span> <span class='hs-varop'>$</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>span</span> <span class='hs-layout'>(</span><span class='hs-varop'>==</span> <span class='hs-sel'>_slash</span><span class='hs-layout'>)</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-648"></a>
|
||||
<a name="line-649"></a>
|
||||
<a name="line-650"></a><a name="equalFilePath"></a><span class='hs-comment'>-- |Equality of two filepaths. The filepaths are normalised</span>
|
||||
<a name="line-651"></a><span class='hs-comment'>-- and trailing path separators are dropped.</span>
|
||||
<a name="line-652"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-653"></a><span class='hs-comment'>-- >>> equalFilePath "foo" "foo"</span>
|
||||
<a name="line-654"></a><span class='hs-comment'>-- True</span>
|
||||
<a name="line-655"></a><span class='hs-comment'>-- >>> equalFilePath "foo" "foo/"</span>
|
||||
<a name="line-656"></a><span class='hs-comment'>-- True</span>
|
||||
<a name="line-657"></a><span class='hs-comment'>-- >>> equalFilePath "foo" "./foo"</span>
|
||||
<a name="line-658"></a><span class='hs-comment'>-- True</span>
|
||||
<a name="line-659"></a><span class='hs-comment'>-- >>> equalFilePath "" ""</span>
|
||||
<a name="line-660"></a><span class='hs-comment'>-- True</span>
|
||||
<a name="line-661"></a><span class='hs-comment'>-- >>> equalFilePath "foo" "/foo"</span>
|
||||
<a name="line-662"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-663"></a><span class='hs-comment'>-- >>> equalFilePath "foo" "FOO"</span>
|
||||
<a name="line-664"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-665"></a><span class='hs-comment'>-- >>> equalFilePath "foo" "../foo"</span>
|
||||
<a name="line-666"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-667"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-668"></a><span class='hs-comment'>-- prop> \p -> equalFilePath p p</span>
|
||||
<a name="line-669"></a><span class='hs-definition'>equalFilePath</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Bool</span>
|
||||
<a name="line-670"></a><span class='hs-definition'>equalFilePath</span> <span class='hs-varid'>p1</span> <span class='hs-varid'>p2</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>f</span> <span class='hs-varid'>p1</span> <span class='hs-varop'>==</span> <span class='hs-varid'>f</span> <span class='hs-varid'>p2</span>
|
||||
<a name="line-671"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-672"></a> <span class='hs-varid'>f</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>dropTrailingPathSeparator</span> <span class='hs-varop'>$</span> <span class='hs-varid'>normalise</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-673"></a>
|
||||
<a name="line-674"></a>
|
||||
<a name="line-675"></a><a name="isRelative"></a><span class='hs-comment'>-- | Check if a path is relative</span>
|
||||
<a name="line-676"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-677"></a><span class='hs-comment'>-- prop> \path -> isRelative path /= isAbsolute path</span>
|
||||
<a name="line-678"></a><span class='hs-definition'>isRelative</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Bool</span>
|
||||
<a name="line-679"></a><span class='hs-definition'>isRelative</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>not</span> <span class='hs-varop'>.</span> <span class='hs-varid'>isAbsolute</span>
|
||||
<a name="line-680"></a>
|
||||
<a name="line-681"></a>
|
||||
<a name="line-682"></a><a name="isAbsolute"></a><span class='hs-comment'>-- | Check if a path is absolute</span>
|
||||
<a name="line-683"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-684"></a><span class='hs-comment'>-- >>> isAbsolute "/path"</span>
|
||||
<a name="line-685"></a><span class='hs-comment'>-- True</span>
|
||||
<a name="line-686"></a><span class='hs-comment'>-- >>> isAbsolute "path"</span>
|
||||
<a name="line-687"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-688"></a><span class='hs-comment'>-- >>> isAbsolute ""</span>
|
||||
<a name="line-689"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-690"></a><span class='hs-definition'>isAbsolute</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Bool</span>
|
||||
<a name="line-691"></a><span class='hs-definition'>isAbsolute</span> <span class='hs-varid'>x</span>
|
||||
<a name="line-692"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>length</span> <span class='hs-varid'>x</span> <span class='hs-varop'>></span> <span class='hs-num'>0</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>isPathSeparator</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>head</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span>
|
||||
<a name="line-693"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>False</span>
|
||||
<a name="line-694"></a>
|
||||
<a name="line-695"></a>
|
||||
<a name="line-696"></a><a name="isValid"></a><span class='hs-comment'>-- | Is a FilePath valid, i.e. could you create a file like it?</span>
|
||||
<a name="line-697"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-698"></a><span class='hs-comment'>-- >>> isValid ""</span>
|
||||
<a name="line-699"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-700"></a><span class='hs-comment'>-- >>> isValid "\0"</span>
|
||||
<a name="line-701"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-702"></a><span class='hs-comment'>-- >>> isValid "/random_ path:*"</span>
|
||||
<a name="line-703"></a><span class='hs-comment'>-- True</span>
|
||||
<a name="line-704"></a><span class='hs-definition'>isValid</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Bool</span>
|
||||
<a name="line-705"></a><span class='hs-definition'>isValid</span> <span class='hs-varid'>filepath</span>
|
||||
<a name="line-706"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span> <span class='hs-varid'>filepath</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>False</span>
|
||||
<a name="line-707"></a> <span class='hs-keyglyph'>|</span> <span class='hs-sel'>_nul</span> <span class='hs-varop'>`</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>elem</span><span class='hs-varop'>`</span> <span class='hs-varid'>filepath</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>False</span>
|
||||
<a name="line-708"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>True</span>
|
||||
<a name="line-709"></a>
|
||||
<a name="line-710"></a>
|
||||
<a name="line-711"></a><a name="makeValid"></a><span class='hs-comment'>-- | Take a FilePath and make it valid; does not change already valid FilePaths.</span>
|
||||
<a name="line-712"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-713"></a><span class='hs-comment'>-- >>> makeValid ""</span>
|
||||
<a name="line-714"></a><span class='hs-comment'>-- "_"</span>
|
||||
<a name="line-715"></a><span class='hs-comment'>-- >>> makeValid "file\0name"</span>
|
||||
<a name="line-716"></a><span class='hs-comment'>-- "file_name"</span>
|
||||
<a name="line-717"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-718"></a><span class='hs-comment'>-- prop> \p -> if isValid p then makeValid p == p else makeValid p /= p</span>
|
||||
<a name="line-719"></a><span class='hs-comment'>-- prop> \p -> isValid (makeValid p)</span>
|
||||
<a name="line-720"></a><span class='hs-definition'>makeValid</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-721"></a><span class='hs-definition'>makeValid</span> <span class='hs-varid'>path</span>
|
||||
<a name="line-722"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span> <span class='hs-varid'>path</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>singleton</span> <span class='hs-sel'>_underscore</span>
|
||||
<a name="line-723"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>map</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>x</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>if</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-sel'>_nul</span> <span class='hs-keyword'>then</span> <span class='hs-sel'>_underscore</span> <span class='hs-keyword'>else</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-varid'>path</span>
|
||||
<a name="line-724"></a>
|
||||
<a name="line-725"></a>
|
||||
<a name="line-726"></a><a name="isFileName"></a><span class='hs-comment'>-- | Is the given path a valid filename? This includes</span>
|
||||
<a name="line-727"></a><span class='hs-comment'>-- "." and "..".</span>
|
||||
<a name="line-728"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-729"></a><span class='hs-comment'>-- >>> isFileName "lal"</span>
|
||||
<a name="line-730"></a><span class='hs-comment'>-- True</span>
|
||||
<a name="line-731"></a><span class='hs-comment'>-- >>> isFileName "."</span>
|
||||
<a name="line-732"></a><span class='hs-comment'>-- True</span>
|
||||
<a name="line-733"></a><span class='hs-comment'>-- >>> isFileName ".."</span>
|
||||
<a name="line-734"></a><span class='hs-comment'>-- True</span>
|
||||
<a name="line-735"></a><span class='hs-comment'>-- >>> isFileName ""</span>
|
||||
<a name="line-736"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-737"></a><span class='hs-comment'>-- >>> isFileName "\0"</span>
|
||||
<a name="line-738"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-739"></a><span class='hs-comment'>-- >>> isFileName "/random_ path:*"</span>
|
||||
<a name="line-740"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-741"></a><span class='hs-definition'>isFileName</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Bool</span>
|
||||
<a name="line-742"></a><span class='hs-definition'>isFileName</span> <span class='hs-varid'>filepath</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-743"></a> <span class='hs-varid'>not</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>singleton</span> <span class='hs-varid'>pathSeparator</span> <span class='hs-varop'>`</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>isInfixOf</span><span class='hs-varop'>`</span> <span class='hs-varid'>filepath</span><span class='hs-layout'>)</span> <span class='hs-varop'>&&</span>
|
||||
<a name="line-744"></a> <span class='hs-varid'>not</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span> <span class='hs-varid'>filepath</span><span class='hs-layout'>)</span> <span class='hs-varop'>&&</span>
|
||||
<a name="line-745"></a> <span class='hs-varid'>not</span> <span class='hs-layout'>(</span><span class='hs-sel'>_nul</span> <span class='hs-varop'>`</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>elem</span><span class='hs-varop'>`</span> <span class='hs-varid'>filepath</span><span class='hs-layout'>)</span>
|
||||
<a name="line-746"></a>
|
||||
<a name="line-747"></a>
|
||||
<a name="line-748"></a><a name="hasParentDir"></a><span class='hs-comment'>-- | Check if the filepath has any parent directories in it.</span>
|
||||
<a name="line-749"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-750"></a><span class='hs-comment'>-- >>> hasParentDir "/.."</span>
|
||||
<a name="line-751"></a><span class='hs-comment'>-- True</span>
|
||||
<a name="line-752"></a><span class='hs-comment'>-- >>> hasParentDir "foo/bar/.."</span>
|
||||
<a name="line-753"></a><span class='hs-comment'>-- True</span>
|
||||
<a name="line-754"></a><span class='hs-comment'>-- >>> hasParentDir "foo/../bar/."</span>
|
||||
<a name="line-755"></a><span class='hs-comment'>-- True</span>
|
||||
<a name="line-756"></a><span class='hs-comment'>-- >>> hasParentDir "foo/bar"</span>
|
||||
<a name="line-757"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-758"></a><span class='hs-comment'>-- >>> hasParentDir "foo"</span>
|
||||
<a name="line-759"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-760"></a><span class='hs-comment'>-- >>> hasParentDir ""</span>
|
||||
<a name="line-761"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-762"></a><span class='hs-comment'>-- >>> hasParentDir ".."</span>
|
||||
<a name="line-763"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-764"></a><span class='hs-definition'>hasParentDir</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Bool</span>
|
||||
<a name="line-765"></a><span class='hs-definition'>hasParentDir</span> <span class='hs-varid'>filepath</span> <span class='hs-keyglyph'>=</span>
|
||||
<a name="line-766"></a> <span class='hs-layout'>(</span><span class='hs-varid'>pathSeparator</span> <span class='hs-varop'>`</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>cons</span><span class='hs-varop'>`</span> <span class='hs-varid'>pathDoubleDot</span><span class='hs-layout'>)</span>
|
||||
<a name="line-767"></a> <span class='hs-varop'>`</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>isSuffixOf</span><span class='hs-varop'>`</span> <span class='hs-varid'>filepath</span>
|
||||
<a name="line-768"></a> <span class='hs-varop'>||</span>
|
||||
<a name="line-769"></a> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>singleton</span> <span class='hs-varid'>pathSeparator</span>
|
||||
<a name="line-770"></a> <span class='hs-varop'>`</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>append</span><span class='hs-varop'>`</span> <span class='hs-varid'>pathDoubleDot</span>
|
||||
<a name="line-771"></a> <span class='hs-varop'>`</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>append</span><span class='hs-varop'>`</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>singleton</span> <span class='hs-varid'>pathSeparator</span><span class='hs-layout'>)</span>
|
||||
<a name="line-772"></a> <span class='hs-varop'>`</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>isInfixOf</span><span class='hs-varop'>`</span> <span class='hs-varid'>filepath</span>
|
||||
<a name="line-773"></a> <span class='hs-varop'>||</span>
|
||||
<a name="line-774"></a> <span class='hs-layout'>(</span><span class='hs-varid'>pathDoubleDot</span> <span class='hs-varop'>`</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>append</span><span class='hs-varop'>`</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>singleton</span> <span class='hs-varid'>pathSeparator</span><span class='hs-layout'>)</span>
|
||||
<a name="line-775"></a> <span class='hs-varop'>`</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>isPrefixOf</span><span class='hs-varop'>`</span> <span class='hs-varid'>filepath</span>
|
||||
<a name="line-776"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-777"></a> <span class='hs-varid'>pathDoubleDot</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>pack</span> <span class='hs-keyglyph'>[</span><span class='hs-sel'>_period</span><span class='hs-layout'>,</span> <span class='hs-sel'>_period</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-778"></a>
|
||||
<a name="line-779"></a>
|
||||
<a name="line-780"></a><a name="hiddenFile"></a><span class='hs-comment'>-- | Whether the file is a hidden file.</span>
|
||||
<a name="line-781"></a><span class='hs-comment'>--</span>
|
||||
<a name="line-782"></a><span class='hs-comment'>-- >>> hiddenFile ".foo"</span>
|
||||
<a name="line-783"></a><span class='hs-comment'>-- True</span>
|
||||
<a name="line-784"></a><span class='hs-comment'>-- >>> hiddenFile "..foo.bar"</span>
|
||||
<a name="line-785"></a><span class='hs-comment'>-- True</span>
|
||||
<a name="line-786"></a><span class='hs-comment'>-- >>> hiddenFile "some/path/.bar"</span>
|
||||
<a name="line-787"></a><span class='hs-comment'>-- True</span>
|
||||
<a name="line-788"></a><span class='hs-comment'>-- >>> hiddenFile "..."</span>
|
||||
<a name="line-789"></a><span class='hs-comment'>-- True</span>
|
||||
<a name="line-790"></a><span class='hs-comment'>-- >>> hiddenFile "dod.bar"</span>
|
||||
<a name="line-791"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-792"></a><span class='hs-comment'>-- >>> hiddenFile "."</span>
|
||||
<a name="line-793"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-794"></a><span class='hs-comment'>-- >>> hiddenFile ".."</span>
|
||||
<a name="line-795"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-796"></a><span class='hs-comment'>-- >>> hiddenFile ""</span>
|
||||
<a name="line-797"></a><span class='hs-comment'>-- False</span>
|
||||
<a name="line-798"></a><span class='hs-definition'>hiddenFile</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Bool</span>
|
||||
<a name="line-799"></a><span class='hs-definition'>hiddenFile</span> <span class='hs-varid'>fp</span>
|
||||
<a name="line-800"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>fn</span> <span class='hs-varop'>==</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>pack</span> <span class='hs-keyglyph'>[</span><span class='hs-sel'>_period</span><span class='hs-layout'>,</span> <span class='hs-sel'>_period</span><span class='hs-keyglyph'>]</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>False</span>
|
||||
<a name="line-801"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>fn</span> <span class='hs-varop'>==</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>pack</span> <span class='hs-keyglyph'>[</span><span class='hs-sel'>_period</span><span class='hs-keyglyph'>]</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>False</span>
|
||||
<a name="line-802"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>pack</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>extSeparator</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-803"></a> <span class='hs-varop'>`</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>isPrefixOf</span><span class='hs-varop'>`</span> <span class='hs-varid'>fn</span>
|
||||
<a name="line-804"></a> <span class='hs-keyword'>where</span>
|
||||
<a name="line-805"></a> <span class='hs-varid'>fn</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>takeFileName</span> <span class='hs-varid'>fp</span>
|
||||
<a name="line-806"></a>
|
||||
<a name="line-807"></a>
|
||||
<a name="line-808"></a>
|
||||
<a name="line-809"></a><span class='hs-comment'>------------------------</span>
|
||||
<a name="line-810"></a><span class='hs-comment'>-- internal stuff</span>
|
||||
<a name="line-811"></a>
|
||||
<a name="line-812"></a><a name="splitFileNameRaw"></a><span class='hs-comment'>-- Just split the input FileName without adding/normalizing or changing</span>
|
||||
<a name="line-813"></a><span class='hs-comment'>-- anything.</span>
|
||||
<a name="line-814"></a><span class='hs-definition'>splitFileNameRaw</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-layout'>(</span><span class='hs-conid'>RawFilePath</span><span class='hs-layout'>,</span> <span class='hs-conid'>RawFilePath</span><span class='hs-layout'>)</span>
|
||||
<a name="line-815"></a><span class='hs-definition'>splitFileNameRaw</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>breakEnd</span> <span class='hs-varid'>isPathSeparator</span>
|
||||
<a name="line-816"></a>
|
||||
<a name="line-817"></a><a name="combineRaw"></a><span class='hs-comment'>-- | Combine two paths, assuming rhs is NOT absolute.</span>
|
||||
<a name="line-818"></a><span class='hs-definition'>combineRaw</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>RawFilePath</span>
|
||||
<a name="line-819"></a><span class='hs-definition'>combineRaw</span> <span class='hs-varid'>a</span> <span class='hs-varid'>b</span> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>b</span>
|
||||
<a name="line-820"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>null</span> <span class='hs-varid'>b</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>a</span>
|
||||
<a name="line-821"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>isPathSeparator</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>last</span> <span class='hs-varid'>a</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>append</span> <span class='hs-varid'>a</span> <span class='hs-varid'>b</span>
|
||||
<a name="line-822"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>intercalate</span> <span class='hs-layout'>(</span><span class='hs-conid'>BS</span><span class='hs-varop'>.</span><span class='hs-varid'>singleton</span> <span class='hs-varid'>pathSeparator</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>[</span><span class='hs-varid'>a</span><span class='hs-layout'>,</span> <span class='hs-varid'>b</span><span class='hs-keyglyph'>]</span>
|
||||
<a name="line-823"></a>
|
||||
</pre></body>
|
||||
</html>
|
5
src/hscolour.css
Normal file
5
src/hscolour.css
Normal file
@ -0,0 +1,5 @@
|
||||
.hs-keyglyph, .hs-layout {color: red;}
|
||||
.hs-keyword {color: blue;}
|
||||
.hs-comment, .hs-comment a {color: green;}
|
||||
.hs-str, .hs-chr {color: teal;}
|
||||
.hs-keyword, .hs-conid, .hs-varid, .hs-conop, .hs-varop, .hs-num, .hs-cpp, .hs-sel, .hs-definition {}
|
BIN
synopsis.png
Normal file
BIN
synopsis.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
Loading…
Reference in New Issue
Block a user