<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"/><title>HPath.IO</title><linkhref="ocean.css"rel="stylesheet"type="text/css"title="Ocean"/><scriptsrc="haddock-util.js"type="text/javascript"></script><scripttype="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_HPath-IO.html");};
//]]>
</script></head><body><divid="package-header"><ulclass="links"id="page-menu"><li><ahref="src/HPath-IO.html">Source</a></li><li><ahref="index.html">Contents</a></li><li><ahref="doc-index.html">Index</a></li></ul><pclass="caption">hpath-0.7.3: Support for well-typed paths</p></div><divid="content"><divid="module-header"><tableclass="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>None</td></tr><tr><th>Language</th><td>Haskell2010</td></tr></table><pclass="caption">HPath.IO</p></div><divid="table-of-contents"><pclass="caption">Contents</p><ul><li><ahref="#g:1">Types</a></li><li><ahref="#g:2">File copying</a></li><li><ahref="#g:3">File deletion</a></li><li><ahref="#g:4">File opening</a></li><li><ahref="#g:5">File creation</a></li><li><ahref="#g:6">File renaming/moving</a></li><li><ahref="#g:7">File permissions</a></li><li><ahref="#g:8">Directory reading</a></li><li><ahref="#g:9">Filetype operations</a></li><li><ahref="#g:10">Others</a></li></ul></div><divid="description"><pclass="caption">Description</p><divclass="doc"><p>This module provides high-level IO related file operations like
copy, delete, move and so on. It only operates on <em>Path Abs</em> which
guarantees us well-typed paths which are absolute.</p><p>Some functions are just path-safe wrappers around
unix functions, others have stricter exception handling
and some implement functionality that doesn't have a unix
counterpart (like <code><ahref="HPath-IO.html#v:copyDirRecursive">copyDirRecursive</a></code>).</p><p>Some of these operations are due to their nature <strong>not atomic</strong>, which
means they may do multiple syscalls which form one context. Some
of them also have to examine the filetypes explicitly before the
syscalls, so a reasonable decision can be made. That means
the result is undefined if another process changes that context
while the non-atomic operation is still happening. However, where
possible, as few syscalls as possible are used and the underlying
exception handling is kept.</p><p>Note: <code><ahref="HPath-IO.html#v:BlockDevice">BlockDevice</a></code>, <code><ahref="HPath-IO.html#v:CharacterDevice">CharacterDevice</a></code>, <code><ahref="HPath-IO.html#v:NamedPipe">NamedPipe</a></code> and <code><ahref="HPath-IO.html#v:Socket">Socket</a></code>
are ignored by some of the more high-level functions (like <code><ahref="HPath-IO.html#v:easyCopy">easyCopy</a></code>).
For other functions (like <code><ahref="HPath-IO.html#v:copyFile">copyFile</a></code>), the behavior on these file types is
Does not follow symbolic links.</p><p>For directory contents, this has the same behavior as <code><ahref="HPath-IO.html#v:easyCopy">easyCopy</a></code>
and thus will ignore any file type that is not <code><ahref="HPath-IO.html#v:RegularFile">RegularFile</a></code>,
<code><ahref="HPath-IO.html#v:SymbolicLink">SymbolicLink</a></code> or <code><ahref="HPath-IO.html#v:Directory">Directory</a></code>.</p><p>Safety/reliability concerns:</p><ul><li>not atomic</li><li>examines filetypes explicitly</li><li>an explicit check <code><ahref="HPath-IO-Errors.html#v:throwDestinationInSource">throwDestinationInSource</a></code> is carried out for the
top directory for basic sanity, because otherwise we might end up
with an infinite copy loop... however, this operation is not
carried out recursively (because it's slow)</li></ul><p>Throws:</p><ul><li><code>NoSuchThing</code> if source directory does not exist</li><li><code>PermissionDenied</code> if output directory is not writable</li><li><code>PermissionDenied</code> if source directory can't be opened</li><li><code>InvalidArgument</code> if source directory is wrong type (symlink)</li><li><code>InvalidArgument</code> if source directory is wrong type (regular file)</li><li><code>AlreadyExists</code> if destination already exists</li><li><code><ahref="HPath-IO-Errors.html#v:SameFile">SameFile</a></code> if source and destination are the same file (<code><ahref="HPath-IO-Errors.html#t:HPathIOException">HPathIOException</a></code>)</li><li><code><ahref="HPath-IO-Errors.html#v:DestinationInSource">DestinationInSource</a></code> if destination is contained in source (<code><ahref="HPath-IO-Errors.html#t:HPathIOException">HPathIOException</a></code>)</li></ul></div></div><divclass="top"><pclass="src"><aname="v:copyDirRecursiveOverwrite"class="def">copyDirRecursiveOverwrite</a><ahref="src/HPath-IO.html#copyDirRecursiveOverwrite"class="link">Source</a></p><divclass="subs arguments"><pclass="caption">Arguments</p><table><tr><tdclass="src">:: <ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a></td><tdclass="doc"><p>source dir</p></td></tr><tr><tdclass="src">-><ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a></td><tdclass="doc"><p>full destination</p></td></tr><tr><tdclass="src">-><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> ()</td><tdclass="doc empty"> </td></tr></table></div><divclass="doc"><p>Like <code><ahref="HPath-IO.html#v:copyDirRecursive">copyDirRecursive</a></code> except it overwrites contents of directories
<code><ahref="HPath-IO.html#v:SymbolicLink">SymbolicLink</a></code> or <code><ahref="HPath-IO.html#v:Directory">Directory</a></code>.</p><p>Throws:</p><ul><li><code>NoSuchThing</code> if source directory does not exist</li><li><code>PermissionDenied</code> if output directory is not writable</li><li><code>PermissionDenied</code> if source directory can't be opened</li><li><code>InvalidArgument</code> if source directory is wrong type (symlink)</li><li><code>InvalidArgument</code> if source directory is wrong type (regular file)</li><li><code><ahref="HPath-IO-Errors.html#v:SameFile">SameFile</a></code> if source and destination are the same file (<code><ahref="HPath-IO-Errors.html#t:HPathIOException">HPathIOException</a></code>)</li><li><code><ahref="HPath-IO-Errors.html#v:DestinationInSource">DestinationInSource</a></code> if destination is contained in source (<code><ahref="HPath-IO-Errors.html#t:HPathIOException">HPathIOException</a></code>)</li></ul></div></div><divclass="top"><pclass="src"><aname="v:recreateSymlink"class="def">recreateSymlink</a><ahref="src/HPath-IO.html#recreateSymlink"class="link">Source</a></p><divclass="subs arguments"><pclass="caption">Arguments</p><table><tr><tdclass="src">:: <ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a></td><tdclass="doc"><p>the old symlink file</p></td></tr><tr><tdclass="src">-><ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a></td><tdclass="doc"><p>destination file</p></td></tr><tr><tdclass="src">-><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> ()</td><tdclass="doc empty"> </td></tr></table></div><divclass="doc"><p>Recreate a symlink.</p><p>Throws:</p><ul><li><code>InvalidArgument</code> if source file is wrong type (not a symlink)</li><li><code>PermissionDenied</code> if output directory cannot be written to</li><li><code>PermissionDenied</code> if source directory cannot be opened</li><li><code>AlreadyExists</code> if destination file already exists</li><li><code><ahref="HPath-IO-Errors.html#v:SameFile">SameFile</a></code> if source and destination are the same file (<code><ahref="HPath-IO-Errors.html#t:HPathIOException">HPathIOException</a></code>)</li></ul><p>Note: calls <code>symlink</code></p></div></div><divclass="top"><pclass="src"><aname="v:copyFile"class="def">copyFile</a><ahref="src/HPath-IO.html#copyFile"class="link">Source</a></p><divclass="subs arguments"><pclass="caption">Arguments</p><table><tr><tdclass="src">:: <ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a></td><tdclass="doc"><p>source file</p></td></tr><tr><tdclass="src">-><ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a></td><tdclass="doc"><p>destination file</p></td></tr><tr><tdclass="src">-><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> ()</td><tdclass="doc empty"> </td></tr></table></div><divclass="doc"><p>Copies the given regular file to the given destination.
For "copying" symbolic links, use <code><ahref="HPath-IO.html#v:recreateSymlink">recreateSymlink</a></code> instead.</p><p>Note that this is still sort of a low-level function and doesn't
examine file types. For a more high-level version, use <code><ahref="HPath-IO.html#v:easyCopy">easyCopy</a></code>
instead.</p><p>Safety/reliability concerns:</p><ul><li>when used on <code><ahref="HPath-IO.html#v:CharacterDevice">CharacterDevice</a></code>, reads the "contents" and copies
them to a regular file, which might take indefinitely</li><li>when used on <code><ahref="HPath-IO.html#v:BlockDevice">BlockDevice</a></code>, may either read the "contents"
and copy them to a regular file (potentially hanging indefinitely)
or may create a regular empty destination file</li><li>when used on <code><ahref="HPath-IO.html#v:NamedPipe">NamedPipe</a></code>, will hang indefinitely</li></ul><p>Throws:</p><ul><li><code>NoSuchThing</code> if source file does not exist</li><li><code>NoSuchThing</code> if source file is a a <code><ahref="HPath-IO.html#v:Socket">Socket</a></code></li><li><code>PermissionDenied</code> if output directory is not writable</li><li><code>PermissionDenied</code> if source directory can't be opened</li><li><code>InvalidArgument</code> if source file is wrong type (symlink or directory)</li><li><code>AlreadyExists</code> if destination already exists</li><li><code><ahref="HPath-IO-Errors.html#v:SameFile">SameFile</a></code> if source and destination are the same file (<code><ahref="HPath-IO-Errors.html#t:HPathIOException">HPathIOException</a></code>)</li></ul><p>Note: calls <code>sendfile</code> and possibly <code><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/Text-Read.html#v:read">read</a></code>/<code>write</code> as fallback</p></div></div><divclass="top"><pclass="src"><aname="v:copyFileOverwrite"class="def">copyFileOverwrite</a><ahref="src/HPath-IO.html#copyFileOverwrite"class="link">Source</a></p><divclass="subs arguments"><pclass="caption">Arguments</p><table><tr><tdclass="src">:: <ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a></td><tdclass="doc"><p>source file</p></td></tr><tr><tdclass="src">-><ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a></td><tdclass="doc"><p>destination file</p></td></tr><tr><tdclass="src">-><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> ()</td><tdclass="doc empty"> </td></tr></table></div><divclass="doc"><p>Like <code><ahref="HPath-IO.html#v:copyFile">copyFile</a></code> except it overwrites the destination if it already
exists.</p><p>Safety/reliability concerns:</p><ul><li>when used on <code><ahref="HPath-IO.html#v:CharacterDevice">CharacterDevice</a></code>, reads the "contents" and copies
them to a regular file, which might take indefinitely</li><li>when used on <code><ahref="HPath-IO.html#v:BlockDevice">BlockDevice</a></code>, may either read the "contents"
and copy them to a regular file (potentially hanging indefinitely)
or may create a regular empty destination file</li><li>when used on <code><ahref="HPath-IO.html#v:NamedPipe">NamedPipe</a></code>, will hang indefinitely</li><li>not atomic, since it uses read/write</li></ul><p>Throws:</p><ul><li><code>NoSuchThing</code> if source file does not exist</li><li><code>NoSuchThing</code> if source file is a <code><ahref="HPath-IO.html#v:Socket">Socket</a></code></li><li><code>PermissionDenied</code> if output directory is not writable</li><li><code>PermissionDenied</code> if source directory can't be opened</li><li><code>InvalidArgument</code> if source file is wrong type (symlink or directory)</li><li><code><ahref="HPath-IO-Errors.html#v:SameFile">SameFile</a></code> if source and destination are the same file (<code><ahref="HPath-IO-Errors.html#t:HPathIOException">HPathIOException</a></code>)</li></ul><p>Note: calls <code>sendfile</code> and possibly <code><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/Text-Read.html#v:read">read</a></code>/<code>write</code> as fallback</p></div></div><divclass="top"><pclass="src"><aname="v:easyCopy"class="def">easyCopy</a> :: <ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a> -><ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a> -><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> () <ahref="src/HPath-IO.html#easyCopy"class="link">Source</a></p><divclass="doc"><p>Copies a regular file, directory or symbolic link. In case of a
Any other file type is ignored.</p><p>Safety/reliability concerns:</p><ul><li>examines filetypes explicitly</li><li>calls <code><ahref="HPath-IO.html#v:copyDirRecursive">copyDirRecursive</a></code> for directories</li></ul></div></div><divclass="top"><pclass="src"><aname="v:easyCopyOverwrite"class="def">easyCopyOverwrite</a> :: <ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a> -><ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a> -><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> () <ahref="src/HPath-IO.html#easyCopyOverwrite"class="link">Source</a></p><divclass="doc"><p>Like <code><ahref="HPath-IO.html#v:easyCopy">easyCopy</a></code> except it overwrites the destination if it already exists.
directory may have more files than have been copied.</p><p>Safety/reliability concerns:</p><ul><li>examines filetypes explicitly</li><li>calls <code><ahref="HPath-IO.html#v:copyDirRecursive">copyDirRecursive</a></code> for directories</li></ul></div></div><h1id="g:3">File deletion</h1><divclass="top"><pclass="src"><aname="v:deleteFile"class="def">deleteFile</a> :: <ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a> -><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> () <ahref="src/HPath-IO.html#deleteFile"class="link">Source</a></p><divclass="doc"><p>Deletes the given file. Raises <code>eISDIR</code>
if run on a directory. Does not follow symbolic links.</p><p>Throws:</p><ul><li><code>InappropriateType</code> for wrong file type (directory)</li><li><code>NoSuchThing</code> if the file does not exist</li><li><code>PermissionDenied</code> if the directory cannot be read</li></ul></div></div><divclass="top"><pclass="src"><aname="v:deleteDir"class="def">deleteDir</a> :: <ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a> -><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> () <ahref="src/HPath-IO.html#deleteDir"class="link">Source</a></p><divclass="doc"><p>Deletes the given directory, which must be empty, never symlinks.</p><p>Throws:</p><ul><li><code>InappropriateType</code> for wrong file type (symlink to directory)</li><li><code>InappropriateType</code> for wrong file type (regular file)</li><li><code>NoSuchThing</code> if directory does not exist</li><li><code>UnsatisfiedConstraints</code> if directory is not empty</li><li><code>PermissionDenied</code> if we can't open or write to parent directory</li></ul><p>Notes: calls <code>rmdir</code></p></div></div><divclass="top"><pclass="src"><aname="v:deleteDirRecursive"class="def">deleteDirRecursive</a> :: <ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a> -><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> () <ahref="src/HPath-IO.html#deleteDirRecursive"class="link">Source</a></p><divclass="doc"><p>Deletes the given directory recursively. Does not follow symbolic
<code><ahref="HPath-IO.html#v:SymbolicLink">SymbolicLink</a></code> or <code><ahref="HPath-IO.html#v:Directory">Directory</a></code>.</p><p>Safety/reliability concerns:</p><ul><li>not atomic</li><li>examines filetypes explicitly</li></ul><p>Throws:</p><ul><li><code>InappropriateType</code> for wrong file type (symlink to directory)</li><li><code>InappropriateType</code> for wrong file type (regular file)</li><li><code>NoSuchThing</code> if directory does not exist</li><li><code>PermissionDenied</code> if we can't open or write to parent directory</li></ul></div></div><divclass="top"><pclass="src"><aname="v:easyDelete"class="def">easyDelete</a> :: <ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a> -><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> () <ahref="src/HPath-IO.html#easyDelete"class="link">Source</a></p><divclass="doc"><p>Deletes a file, directory or symlink.
Any other file type is ignored.</p><p>Safety/reliability concerns:</p><ul><li>examines filetypes explicitly</li><li>calls <code><ahref="HPath-IO.html#v:deleteDirRecursive">deleteDirRecursive</a></code> for directories</li></ul></div></div><h1id="g:4">File opening</h1><divclass="top"><pclass="src"><aname="v:openFile"class="def">openFile</a> :: <ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a> -><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-Posix-Types.html#t:ProcessID">ProcessID</a><ahref="src/HPath-IO.html#openFile"class="link">Source</a></p><divclass="doc"><p>Opens a file appropriately by invoking xdg-open. The file type
is not checked. This forks a process.</p></div></div><divclass="top"><pclass="src"><aname="v:executeFile"class="def">executeFile</a><ahref="src/HPath-IO.html#executeFile"class="link">Source</a></p><divclass="subs arguments"><pclass="caption">Arguments</p><table><tr><tdclass="src">:: <ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a></td><tdclass="doc"><p>program</p></td></tr><tr><tdclass="src">-> [<ahref="https://hackage.haskell.org/package/bytestring-0.10.6.0/docs/Data-ByteString.html#t:ByteString">ByteString</a>]</td><tdclass="doc"><p>arguments</p></td></tr><tr><tdclass="src">-><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-Posix-Types.html#t:ProcessID">ProcessID</a></td><tdclass="doc empty"> </td></tr></table></div><divclass="doc"><p>Executes a program with the given arguments. This forks a process.</p></div></div><h1id="g:5">File creation</h1><divclass="top"><pclass="src"><aname="v:createRegularFile"class="def">createRegularFile</a> :: <ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a> -><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> () <ahref="src/HPath-IO.html#createRegularFile"class="link">Source</a></p><divclass="doc"><p>Create an empty regular file at the given directory with the given filename.</p><p>Throws:</p><ul><li><code>PermissionDenied</code> if output directory cannot be written to</li><li><code>AlreadyExists</code> if destination file already exists</li></ul></div></div><divclass="top"><pclass="src"><aname="v:createDir"class="def">createDir</a> :: <ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a> -><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> () <ahref="src/HPath-IO.html#createDir"class="link">Source</a></p><divclass="doc"><p>Create an empty directory at the given directory with the given filename.</p><p>Throws:</p><ul><li><code>PermissionDenied</code> if output directory cannot be written to</li><li><code>AlreadyExists</code> if destination directory already exists</li></ul></div></div><divclass="top"><pclass="src"><aname="v:createSymlink"class="def">createSymlink</a><ahref="src/HPath-IO.html#createSymlink"class="link">Source</a></p><divclass="subs arguments"><pclass="caption">Arguments</p><table><tr><tdclass="src">:: <ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a></td><tdclass="doc"><p>destination file</p></td></tr><tr><tdclass="src">-><ahref="https://hackage.haskell.org/package/bytestring-0.10.6.0/docs/Data-ByteString.html#t:ByteString">ByteString</a></td><tdclass="doc"><p>path the symlink points to</p></td></tr><tr><tdclass="src">-><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> ()</td><tdclass="doc empty"> </td></tr></table></div><divclass="doc"><p>Create a symlink.</p><p>Throws:</p><ul><li><code>PermissionDenied</code> if output directory cannot be written to</li><li><code>AlreadyExists</code> if destination file already exists</li></ul><p>Note: calls <code>symlink</code></p></div></div><h1id="g:6">File renaming/moving</h1><divclass="top"><pclass="src"><aname="v:renameFile"class="def">renameFile</a> :: <ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a> -><ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a> -><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> () <ahref="src/HPath-IO.html#renameFile"class="link">Source</a></p><divclass="doc"><p>Rename a given file with the provided filename. Destination and source
must be on the same device, otherwise <code><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/Foreign-C-Error.html#v:eXDEV">eXDEV</a></code> will be raised.</p><p>Does not follow symbolic links, but renames the symbolic link file.</p><p>Safety/reliability concerns:</p><ul><li>has a separate set of exception handling, apart from the syscall</li></ul><p>Throws:</p><ul><li><code>NoSuchThing</code> if source file does not exist</li><li><code>PermissionDenied</code> if output directory cannot be written to</li><li><code>PermissionDenied</code> if source directory cannot be opened</li><li><code>UnsupportedOperation</code> if source and destination are on different devices</li><li><code><ahref="HPath-IO-Errors.html#v:FileDoesExist">FileDoesExist</a></code> if destination file already exists (<code><ahref="HPath-IO-Errors.html#t:HPathIOException">HPathIOException</a></code>)</li><li><code><ahref="HPath-IO-Errors.html#v:DirDoesExist">DirDoesExist</a></code> if destination directory already exists (<code><ahref="HPath-IO-Errors.html#t:HPathIOException">HPathIOException</a></code>)</li><li><code><ahref="HPath-IO-Errors.html#v:SameFile">SameFile</a></code> if destination and source are the same file (<code><ahref="HPath-IO-Errors.html#t:HPathIOException">HPathIOException</a></code>)</li></ul><p>Note: calls <code><ahref="https://hackage.haskell.org/package/unix-2.7.1.0/docs/System-Posix-Files-ByteString.html#v:rename">rename</a></code> (but does not allow to rename over existing files)</p></div></div><divclass="top"><pclass="src"><aname="v:moveFile"class="def">moveFile</a><ahref="src/HPath-IO.html#moveFile"class="link">Source</a></p><divclass="subs arguments"><pclass="caption">Arguments</p><table><tr><tdclass="src">:: <ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a></td><tdclass="doc"><p>file to move</p></td></tr><tr><tdclass="src">-><ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a></td><tdclass="doc"><p>destination</p></td></tr><tr><tdclass="src">-><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> ()</td><tdclass="doc empty"> </td></tr></table></div><divclass="doc"><p>Move a file. This also works across devices by copy-delete fallback.
And also works on directories.</p><p>Does not follow symbolic links, but renames the symbolic link file.</p><p>Safety/reliability concerns:</p><ul><li>copy-delete fallback is inherently non-atomic</li><li>since this function calls <code><ahref="HPath-IO.html#v:easyCopy">easyCopy</a></code> and <code><ahref="HPath-IO.html#v:easyDelete">easyDelete</a></code> as a fallback
to <code><ahref="HPath-IO.html#v:renameFile">renameFile</a></code>, file types that are not <code><ahref="HPath-IO.html#v:RegularFile">RegularFile</a></code>, <code><ahref="HPath-IO.html#v:SymbolicLink">SymbolicLink</a></code>
or <code><ahref="HPath-IO.html#v:Directory">Directory</a></code> may be ignored</li></ul><p>Throws:</p><ul><li><code>NoSuchThing</code> if source file does not exist</li><li><code>PermissionDenied</code> if output directory cannot be written to</li><li><code>PermissionDenied</code> if source directory cannot be opened</li><li><code><ahref="HPath-IO-Errors.html#v:FileDoesExist">FileDoesExist</a></code> if destination file already exists (<code><ahref="HPath-IO-Errors.html#t:HPathIOException">HPathIOException</a></code>)</li><li><code><ahref="HPath-IO-Errors.html#v:DirDoesExist">DirDoesExist</a></code> if destination directory already exists (<code><ahref="HPath-IO-Errors.html#t:HPathIOException">HPathIOException</a></code>)</li><li><code><ahref="HPath-IO-Errors.html#v:SameFile">SameFile</a></code> if destination and source are the same file (<code><ahref="HPath-IO-Errors.html#t:HPathIOException">HPathIOException</a></code>)</li></ul><p>Note: calls <code><ahref="https://hackage.haskell.org/package/unix-2.7.1.0/docs/System-Posix-Files-ByteString.html#v:rename">rename</a></code> (but does not allow to rename over existing files)</p></div></div><divclass="top"><pclass="src"><aname="v:moveFileOverwrite"class="def">moveFileOverwrite</a><ahref="src/HPath-IO.html#moveFileOverwrite"class="link">Source</a></p><divclass="subs arguments"><pclass="caption">Arguments</p><table><tr><tdclass="src">:: <ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a></td><tdclass="doc"><p>file to move</p></td></tr><tr><tdclass="src">-><ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a></td><tdclass="doc"><p>destination</p></td></tr><tr><tdclass="src">-><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> ()</td><tdclass="doc empty"> </td></tr></table></div><divclass="doc"><p>Like <code><ahref="HPath-IO.html#v:moveFile">moveFile</a></code>, but overwrites the destination if it exists.</p><p>Does not follow symbolic links, but renames the symbolic link file.</p><p>Ignores any file type that is not <code><ahref="HPath-IO.html#v:RegularFile">RegularFile</a></code>, <code><ahref="HPath-IO.html#v:SymbolicLink">SymbolicLink</a></code> or
<code><ahref="HPath-IO.html#v:Directory">Directory</a></code>.</p><p>Safety/reliability concerns:</p><ul><li>copy-delete fallback is inherently non-atomic</li><li>checks for file types and destination file existence explicitly</li></ul><p>Throws:</p><ul><li><code>NoSuchThing</code> if source file does not exist</li><li><code>PermissionDenied</code> if output directory cannot be written to</li><li><code>PermissionDenied</code> if source directory cannot be opened</li><li><code><ahref="HPath-IO-Errors.html#v:SameFile">SameFile</a></code> if destination and source are the same file (<code><ahref="HPath-IO-Errors.html#t:HPathIOException">HPathIOException</a></code>)</li></ul><p>Note: calls <code><ahref="https://hackage.haskell.org/package/unix-2.7.1.0/docs/System-Posix-Files-ByteString.html#v:rename">rename</a></code> (but does not allow to rename over existing files)</p></div></div><h1id="g:7">File permissions</h1><divclass="top"><pclass="src"><aname="v:newFilePerms"class="def">newFilePerms</a> :: <ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-Posix-Types.html#t:FileMode">FileMode</a><ahref="src/HPath-IO.html#newFilePerms"class="link">Source</a></p><divclass="doc"><p>Default permissions for a new file.</p></div></div><divclass="top"><pclass="src"><aname="v:newDirPerms"class="def">newDirPerms</a> :: <ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-Posix-Types.html#t:FileMode">FileMode</a><ahref="src/HPath-IO.html#newDirPerms"class="link">Source</a></p><divclass="doc"><p>Default permissions for a new directory.</p></div></div><h1id="g:8">Directory reading</h1><divclass="top"><pclass="src"><aname="v:getDirsFiles"class="def">getDirsFiles</a><ahref="src/HPath-IO.html#getDirsFiles"class="link">Source</a></p><divclass="subs arguments"><pclass="caption">Arguments</p><table><tr><tdclass="src">:: <ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a></td><tdclass="doc"><p>dir to read</p></td></tr><tr><tdclass="src">-><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> [<ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a>]</td><tdclass="doc empty"> </td></tr></table></div><divclass="doc"><p>Gets all filenames of the given directory. This excludes "." and "..".
This version does not follow symbolic links.</p><p>Throws:</p><ul><li><code>NoSuchThing</code> if directory does not exist</li><li><code>InappropriateType</code> if file type is wrong (file)</li><li><code>InappropriateType</code> if file type is wrong (symlink to file)</li><li><code>InappropriateType</code> if file type is wrong (symlink to dir)</li><li><code>PermissionDenied</code> if directory cannot be opened</li></ul></div></div><h1id="g:9">Filetype operations</h1><divclass="top"><pclass="src"><aname="v:getFileType"class="def">getFileType</a> :: <ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a> -><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a><ahref="HPath-IO.html#t:FileType">FileType</a><ahref="src/HPath-IO.html#getFileType"class="link">Source</a></p><divclass="doc"><p>Get the file type of the file located at the given path. Does
not follow symbolic links.</p><p>Throws:</p><ul><li><code>NoSuchThing</code> if the file does not exist</li><li><code>PermissionDenied</code> if any part of the path is not accessible</li></ul></div></div><h1id="g:10">Others</h1><divclass="top"><pclass="src"><aname="v:canonicalizePath"class="def">canonicalizePath</a> :: <ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a> -><ahref="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> (<ahref="HPath.html#t:Path">Path</a><ahref="HPath.html#t:Abs">Abs</a>) <ahref="src/HPath-IO.html#canonicalizePath"class="link">Source</a></p><divclass="doc"><p>Applies <code>realpath</code> on the given absolute path.</p><p>Throws:</p><ul><li><code>NoSuchThing</code> if the file at the given path does not exist</li><li><code>NoSuchThing</code> if the symlink is broken</li></ul></div></div></div></div><divid="footer"><p>Produced by <ahref="http://www.haskell.org/haddock/">Haddock</a> version 2.16.1</p></div></body></html>