Sophie

Sophie

distrib > Mageia > 7 > i586 > media > core-release > by-pkgid > 016232f1d9a3f7bee85855d35a2bca58 > files > 62

elixir-doc-1.7.2-1.mga7.noarch.rpm

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="generator" content="ExDoc v0.19.1">
    <title>File – Elixir v1.7.2</title>
    <link rel="stylesheet" href="dist/app-240d7fc7e5.css" />
      <link rel="canonical" href="https://hexdocs.pm/elixir/v1.7/File.html" />
    <script src="dist/sidebar_items-cdf4e58b19.js"></script>
    
  </head>
  <body data-type="modules">
    <script>try { if(localStorage.getItem('night-mode')) document.body.className += ' night-mode'; } catch (e) { }</script>
    <div class="main">
<button class="sidebar-button sidebar-toggle">
  <span class="icon-menu" aria-hidden="true"></span>
  <span class="sr-only">Toggle Sidebar</span>
</button>
<button class="sidebar-button night-mode-toggle">
  <span class="icon-theme" aria-hidden="true"></span>
  <span class="sr-only">Toggle Theme</span>
</button>
<section class="sidebar">

  <a href="http://elixir-lang.org/docs.html" class="sidebar-projectLink">
    <div class="sidebar-projectDetails">
      <h1 class="sidebar-projectName">
Elixir      </h1>
      <h2 class="sidebar-projectVersion">
        v1.7.2
      </h2>
    </div>
      <img src="assets/logo.png" alt="Elixir" class="sidebar-projectImage">
  </a>

  <form class="sidebar-search" action="search.html">
    <button type="submit" class="search-button">
      <span class="icon-search" aria-hidden="true"></span>
    </button>
    <input name="q" type="text" id="search-list" class="search-input" placeholder="Search" aria-label="Search" autocomplete="off" />
  </form>

  <ul class="sidebar-listNav">
    <li><a id="extras-list" href="#full-list">Pages</a></li>

      <li><a id="modules-list" href="#full-list">Modules</a></li>

      <li><a id="exceptions-list" href="#full-list">Exceptions</a></li>

  </ul>
  <div class="gradient"></div>
  <ul id="full-list" class="sidebar-fullList"></ul>
</section>

<section class="content">
  <div class="content-outer">
    <div id="content" class="content-inner">


      <h1>
        <small class="visible-xs">Elixir v1.7.2</small>
File        
          <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1" title="View Source" class="view-source" rel="help">
            <span class="icon-code" aria-hidden="true"></span>
            <span class="sr-only">View Source</span>
          </a>
      </h1>


        <section id="moduledoc">
<p>This module contains functions to manipulate files.</p>
<p>Some of those functions are low-level, allowing the user
to interact with files or IO devices, like <a href="#open/2"><code class="inline">open/2</code></a>,
<a href="#copy/3"><code class="inline">copy/3</code></a> and others. This module also provides higher
level functions that work with filenames and have their naming
based on UNIX variants. For example, one can copy a file
via <a href="#cp/3"><code class="inline">cp/3</code></a> and remove files and directories recursively
via <a href="#rm_rf/1"><code class="inline">rm_rf/1</code></a>.</p>
<p>Paths given to functions in this module can be either relative to the
current working directory (as returned by <a href="File.html#cwd/0"><code class="inline">File.cwd/0</code></a>), or absolute
paths. Shell conventions like <code class="inline">~</code> are not expanded automatically.
To use paths like <code class="inline">~/Downloads</code>, you can use <a href="Path.html#expand/1"><code class="inline">Path.expand/1</code></a> or
<a href="Path.html#expand/2"><code class="inline">Path.expand/2</code></a> to expand your path to an absolute path.</p>
<h2 id="module-encoding" class="section-heading">
  <a href="#module-encoding" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  Encoding
</h2>

<p>In order to write and read files, one must use the functions
in the <a href="IO.html"><code class="inline">IO</code></a> module. By default, a file is opened in binary mode,
which requires the functions <a href="IO.html#binread/2"><code class="inline">IO.binread/2</code></a> and <a href="IO.html#binwrite/2"><code class="inline">IO.binwrite/2</code></a>
to interact with the file. A developer may pass <code class="inline">:utf8</code> as an
option when opening the file, then the slower <a href="IO.html#read/2"><code class="inline">IO.read/2</code></a> and
<a href="IO.html#write/2"><code class="inline">IO.write/2</code></a> functions must be used as they are responsible for
doing the proper conversions and providing the proper data guarantees.</p>
<p>Note that filenames when given as charlists in Elixir are
always treated as UTF-8. In particular, we expect that the
shell and the operating system are configured to use UTF-8
encoding. Binary filenames are considered raw and passed
to the OS as is.</p>
<h2 id="module-api" class="section-heading">
  <a href="#module-api" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  API
</h2>

<p>Most of the functions in this module return <code class="inline">:ok</code> or
<code class="inline">{:ok, result}</code> in case of success, <code class="inline">{:error, reason}</code>
otherwise. Those functions also have a variant
that ends with <code class="inline">!</code> which returns the result (instead of the
<code class="inline">{:ok, result}</code> tuple) in case of success or raises an
exception in case it fails. For example:</p>
<pre><code class="nohighlight makeup elixir"><span class="nc">File</span><span class="o">.</span><span class="n">read</span><span class="p" data-group-id="7351169062-1">(</span><span class="s">&quot;hello.txt&quot;</span><span class="p" data-group-id="7351169062-1">)</span><span class="w">
</span><span class="c1">#=&gt; {:ok, &quot;World&quot;}</span><span class="w">

</span><span class="nc">File</span><span class="o">.</span><span class="n">read</span><span class="p" data-group-id="7351169062-2">(</span><span class="s">&quot;invalid.txt&quot;</span><span class="p" data-group-id="7351169062-2">)</span><span class="w">
</span><span class="c1">#=&gt; {:error, :enoent}</span><span class="w">

</span><span class="nc">File</span><span class="o">.</span><span class="n">read!</span><span class="p" data-group-id="7351169062-3">(</span><span class="s">&quot;hello.txt&quot;</span><span class="p" data-group-id="7351169062-3">)</span><span class="w">
</span><span class="c1">#=&gt; &quot;World&quot;</span><span class="w">

</span><span class="nc">File</span><span class="o">.</span><span class="n">read!</span><span class="p" data-group-id="7351169062-4">(</span><span class="s">&quot;invalid.txt&quot;</span><span class="p" data-group-id="7351169062-4">)</span><span class="w">
</span><span class="c1">#=&gt; raises File.Error</span></code></pre>
<p>In general, a developer should use the former in case they want
to react if the file does not exist. The latter should be used
when the developer expects their software to fail in case the
file cannot be read (i.e. it is literally an exception).</p>
<h2 id="module-processes-and-raw-files" class="section-heading">
  <a href="#module-processes-and-raw-files" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  Processes and raw files
</h2>

<p>Every time a file is opened, Elixir spawns a new process. Writing
to a file is equivalent to sending messages to the process that
writes to the file descriptor.</p>
<p>This means files can be passed between nodes and message passing
guarantees they can write to the same file in a network.</p>
<p>However, you may not always want to pay the price for this abstraction.
In such cases, a file can be opened in <code class="inline">:raw</code> mode. The options <code class="inline">:read_ahead</code>
and <code class="inline">:delayed_write</code> are also useful when operating on large files or
working with files in tight loops.</p>
<p>Check <a href="http://www.erlang.org/doc/man/file.html#open-2"><code class="inline">:file.open/2</code></a> for more information about such options and
other performance considerations.</p>
        </section>

        <section id="summary" class="details-list">
          <h1 class="section-heading">
            <a class="hover-link" href="#summary">
              <span class="icon-link" aria-hidden="true"></span>
              <span class="sr-only">Link to this section</span>
            </a>
            Summary
          </h1>
  <div class="summary-types summary">
    <h2>
      <a href="#types">Types</a>
    </h2>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#t:encoding_mode/0">encoding_mode()</a>
  </div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#t:io_device/0">io_device()</a>
  </div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#t:mode/0">mode()</a>
  </div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#t:posix/0">posix()</a>
  </div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#t:stat_options/0">stat_options()</a>
  </div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#t:stream_mode/0">stream_mode()</a>
  </div>
</div>
  </div>
          
  <div class="summary-functions summary">
    <h2>
      <a href="#functions">Functions</a>
    </h2>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#cd!/1">cd!(path)</a>
  </div>
    <div class="summary-synopsis"><p>The same as <a href="#cd/1"><code class="inline">cd/1</code></a>, but raises an exception if it fails</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#cd!/2">cd!(path, function)</a>
  </div>
    <div class="summary-synopsis"><p>Changes the current directory to the given <code class="inline">path</code>,
executes the given function and then reverts back
to the previous path regardless of whether there is an exception</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#cd/1">cd(path)</a>
  </div>
    <div class="summary-synopsis"><p>Sets the current working directory</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#chgrp!/2">chgrp!(path, gid)</a>
  </div>
    <div class="summary-synopsis"><p>Same as <a href="#chgrp/2"><code class="inline">chgrp/2</code></a>, but raises an exception in case of failure. Otherwise <code class="inline">:ok</code></p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#chgrp/2">chgrp(path, gid)</a>
  </div>
    <div class="summary-synopsis"><p>Changes the group given by the group id <code class="inline">gid</code>
for a given <code class="inline">file</code>. Returns <code class="inline">:ok</code> on success, or
<code class="inline">{:error, reason}</code> on failure</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#chmod!/2">chmod!(path, mode)</a>
  </div>
    <div class="summary-synopsis"><p>Same as <a href="#chmod/2"><code class="inline">chmod/2</code></a>, but raises an exception in case of failure. Otherwise <code class="inline">:ok</code></p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#chmod/2">chmod(path, mode)</a>
  </div>
    <div class="summary-synopsis"><p>Changes the <code class="inline">mode</code> for a given <code class="inline">file</code></p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#chown!/2">chown!(path, uid)</a>
  </div>
    <div class="summary-synopsis"><p>Same as <a href="#chown/2"><code class="inline">chown/2</code></a>, but raises an exception in case of failure. Otherwise <code class="inline">:ok</code></p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#chown/2">chown(path, uid)</a>
  </div>
    <div class="summary-synopsis"><p>Changes the owner given by the user id <code class="inline">uid</code>
for a given <code class="inline">file</code>. Returns <code class="inline">:ok</code> on success,
or <code class="inline">{:error, reason}</code> on failure</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#close/1">close(io_device)</a>
  </div>
    <div class="summary-synopsis"><p>Closes the file referenced by <code class="inline">io_device</code>. It mostly returns <code class="inline">:ok</code>, except
for some severe errors such as out of memory</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#copy!/3">copy!(source, destination, bytes_count \\ :infinity)</a>
  </div>
    <div class="summary-synopsis"><p>The same as <a href="#copy/3"><code class="inline">copy/3</code></a> but raises an <a href="File.CopyError.html"><code class="inline">File.CopyError</code></a> if it fails.
Returns the <code class="inline">bytes_copied</code> otherwise</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#copy/3">copy(source, destination, bytes_count \\ :infinity)</a>
  </div>
    <div class="summary-synopsis"><p>Copies the contents of <code class="inline">source</code> to <code class="inline">destination</code></p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#cp!/3">cp!(source, destination, callback \\ fn _, _ -&gt; true end)</a>
  </div>
    <div class="summary-synopsis"><p>The same as <a href="#cp/3"><code class="inline">cp/3</code></a>, but raises <a href="File.CopyError.html"><code class="inline">File.CopyError</code></a> if it fails.
Returns <code class="inline">:ok</code> otherwise</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#cp/3">cp(source, destination, callback \\ fn _, _ -&gt; true end)</a>
  </div>
    <div class="summary-synopsis"><p>Copies the contents in <code class="inline">source</code> to <code class="inline">destination</code> preserving its mode</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#cp_r!/3">cp_r!(source, destination, callback \\ fn _, _ -&gt; true end)</a>
  </div>
    <div class="summary-synopsis"><p>The same as <a href="#cp_r/3"><code class="inline">cp_r/3</code></a>, but raises <a href="File.CopyError.html"><code class="inline">File.CopyError</code></a> if it fails.
Returns the list of copied files otherwise</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#cp_r/3">cp_r(source, destination, callback \\ fn _, _ -&gt; true end)</a>
  </div>
    <div class="summary-synopsis"><p>Copies the contents in source to destination</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#cwd!/0">cwd!()</a>
  </div>
    <div class="summary-synopsis"><p>The same as <a href="#cwd/0"><code class="inline">cwd/0</code></a>, but raises an exception if it fails</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#cwd/0">cwd()</a>
  </div>
    <div class="summary-synopsis"><p>Gets the current working directory</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#dir?/1">dir?(path)</a>
  </div>
    <div class="summary-synopsis"><p>Returns <code class="inline">true</code> if the given path is a directory</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#exists?/1">exists?(path)</a>
  </div>
    <div class="summary-synopsis"><p>Returns <code class="inline">true</code> if the given path exists</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#ln!/2">ln!(existing, new)</a>
  </div>
    <div class="summary-synopsis"><p>Same as <a href="#ln/2"><code class="inline">ln/2</code></a> but raises an exception if it fails</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#ln/2">ln(existing, new)</a>
  </div>
    <div class="summary-synopsis"><p>Creates a hard link <code class="inline">new</code> to the file <code class="inline">existing</code></p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#ln_s!/2">ln_s!(existing, new)</a>
  </div>
    <div class="summary-synopsis"><p>Same as <a href="#ln_s/2"><code class="inline">ln_s/2</code></a> but raises an exception if it fails</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#ln_s/2">ln_s(existing, new)</a>
  </div>
    <div class="summary-synopsis"><p>Creates a symbolic link <code class="inline">new</code> to the file or directory <code class="inline">existing</code></p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#ls!/1">ls!(path \\ &quot;.&quot;)</a>
  </div>
    <div class="summary-synopsis"><p>The same as <a href="#ls/1"><code class="inline">ls/1</code></a> but raises <a href="File.Error.html"><code class="inline">File.Error</code></a>
in case of an error</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#ls/1">ls(path \\ &quot;.&quot;)</a>
  </div>
    <div class="summary-synopsis"><p>Returns the list of files in the given directory</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#lstat!/2">lstat!(path, opts \\ [])</a>
  </div>
    <div class="summary-synopsis"><p>Same as <a href="#lstat/2"><code class="inline">lstat/2</code></a> but returns the <a href="File.Stat.html"><code class="inline">File.Stat</code></a> struct directly, or
throws <a href="File.Error.html"><code class="inline">File.Error</code></a> if an error is returned</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#lstat/2">lstat(path, opts \\ [])</a>
  </div>
    <div class="summary-synopsis"><p>Returns information about the <code class="inline">path</code>. If the file is a symlink, sets
the <code class="inline">type</code> to <code class="inline">:symlink</code> and returns a <a href="File.Stat.html"><code class="inline">File.Stat</code></a> struct for the link. For any
other file, returns exactly the same values as <a href="#stat/2"><code class="inline">stat/2</code></a></p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#mkdir!/1">mkdir!(path)</a>
  </div>
    <div class="summary-synopsis"><p>Same as <a href="#mkdir/1"><code class="inline">mkdir/1</code></a>, but raises an exception in case of failure. Otherwise <code class="inline">:ok</code></p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#mkdir/1">mkdir(path)</a>
  </div>
    <div class="summary-synopsis"><p>Tries to create the directory <code class="inline">path</code></p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#mkdir_p!/1">mkdir_p!(path)</a>
  </div>
    <div class="summary-synopsis"><p>Same as <a href="#mkdir_p/1"><code class="inline">mkdir_p/1</code></a>, but raises an exception in case of failure. Otherwise <code class="inline">:ok</code></p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#mkdir_p/1">mkdir_p(path)</a>
  </div>
    <div class="summary-synopsis"><p>Tries to create the directory <code class="inline">path</code></p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#open!/2">open!(path, modes_or_function \\ [])</a>
  </div>
    <div class="summary-synopsis"><p>Similar to <a href="#open/2"><code class="inline">open/2</code></a> but raises an error if file could not be opened</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#open!/3">open!(path, modes, function)</a>
  </div>
    <div class="summary-synopsis"><p>Similar to <a href="#open/3"><code class="inline">open/3</code></a> but raises an error if file could not be opened</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#open/2">open(path, modes_or_function \\ [])</a>
  </div>
    <div class="summary-synopsis"><p>Opens the given <code class="inline">path</code></p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#open/3">open(path, modes, function)</a>
  </div>
    <div class="summary-synopsis"><p>Similar to <a href="#open/2"><code class="inline">open/2</code></a> but expects a function as its last argument</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#read!/1">read!(path)</a>
  </div>
    <div class="summary-synopsis"><p>Returns a binary with the contents of the given filename or raises
<a href="File.Error.html"><code class="inline">File.Error</code></a> if an error occurs</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#read/1">read(path)</a>
  </div>
    <div class="summary-synopsis"><p>Returns <code class="inline">{:ok, binary}</code>, where <code class="inline">binary</code> is a binary data object that contains the contents
of <code class="inline">path</code>, or <code class="inline">{:error, reason}</code> if an error occurs</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#read_link!/1">read_link!(path)</a>
  </div>
    <div class="summary-synopsis"><p>Same as <a href="#read_link/1"><code class="inline">read_link/1</code></a> but returns the target directly or throws <a href="File.Error.html"><code class="inline">File.Error</code></a> if an error is
returned</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#read_link/1">read_link(path)</a>
  </div>
    <div class="summary-synopsis"><p>Reads the symbolic link at <code class="inline">path</code></p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#regular?/1">regular?(path)</a>
  </div>
    <div class="summary-synopsis"><p>Returns <code class="inline">true</code> if the path is a regular file</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#rename/2">rename(source, destination)</a>
  </div>
    <div class="summary-synopsis"><p>Renames the <code class="inline">source</code> file to <code class="inline">destination</code> file.  It can be used to move files
(and directories) between directories.  If moving a file, you must fully
specify the <code class="inline">destination</code> filename, it is not sufficient to simply specify
its directory</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#rm!/1">rm!(path)</a>
  </div>
    <div class="summary-synopsis"><p>Same as <a href="#rm/1"><code class="inline">rm/1</code></a>, but raises an exception in case of failure. Otherwise <code class="inline">:ok</code></p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#rm/1">rm(path)</a>
  </div>
    <div class="summary-synopsis"><p>Tries to delete the file <code class="inline">path</code></p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#rm_rf!/1">rm_rf!(path)</a>
  </div>
    <div class="summary-synopsis"><p>Same as <a href="#rm_rf/1"><code class="inline">rm_rf/1</code></a> but raises <a href="File.Error.html"><code class="inline">File.Error</code></a> in case of failures,
otherwise the list of files or directories removed</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#rm_rf/1">rm_rf(path)</a>
  </div>
    <div class="summary-synopsis"><p>Removes files and directories recursively at the given <code class="inline">path</code>.
Symlinks are not followed but simply removed, non-existing
files are simply ignored (i.e. doesn’t make this function fail)</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#rmdir!/1">rmdir!(path)</a>
  </div>
    <div class="summary-synopsis"><p>Same as <a href="#rmdir/1"><code class="inline">rmdir/1</code></a>, but raises an exception in case of failure. Otherwise <code class="inline">:ok</code></p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#rmdir/1">rmdir(path)</a>
  </div>
    <div class="summary-synopsis"><p>Tries to delete the dir at <code class="inline">path</code></p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#stat!/2">stat!(path, opts \\ [])</a>
  </div>
    <div class="summary-synopsis"><p>Same as <a href="#stat/2"><code class="inline">stat/2</code></a> but returns the <a href="File.Stat.html"><code class="inline">File.Stat</code></a> directly, or
throws <a href="File.Error.html"><code class="inline">File.Error</code></a> if an error is returned</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#stat/2">stat(path, opts \\ [])</a>
  </div>
    <div class="summary-synopsis"><p>Returns information about the <code class="inline">path</code>. If it exists, it
returns a <code class="inline">{:ok, info}</code> tuple, where info is a
<a href="File.Stat.html"><code class="inline">File.Stat</code></a> struct. Returns <code class="inline">{:error, reason}</code> with
the same reasons as <a href="#read/1"><code class="inline">read/1</code></a> if a failure occurs</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#stream!/3">stream!(path, modes \\ [], line_or_bytes \\ :line)</a>
  </div>
    <div class="summary-synopsis"><p>Returns a <a href="File.Stream.html"><code class="inline">File.Stream</code></a> for the given <code class="inline">path</code> with the given <code class="inline">modes</code></p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#touch!/2">touch!(path, time \\ :calendar.universal_time())</a>
  </div>
    <div class="summary-synopsis"><p>Same as <a href="#touch/2"><code class="inline">touch/2</code></a> but raises an exception if it fails</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#touch/2">touch(path, time \\ :calendar.universal_time())</a>
  </div>
    <div class="summary-synopsis"><p>Updates modification time (mtime) and access time (atime) of
the given file</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#write!/3">write!(path, content, modes \\ [])</a>
  </div>
    <div class="summary-synopsis"><p>Same as <a href="#write/3"><code class="inline">write/3</code></a> but raises an exception if it fails, returns <code class="inline">:ok</code> otherwise</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#write/3">write(path, content, modes \\ [])</a>
  </div>
    <div class="summary-synopsis"><p>Writes <code class="inline">content</code> to the file <code class="inline">path</code></p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#write_stat!/3">write_stat!(path, stat, opts \\ [])</a>
  </div>
    <div class="summary-synopsis"><p>Same as <a href="#write_stat/3"><code class="inline">write_stat/3</code></a> but raises an exception if it fails.
Returns <code class="inline">:ok</code> otherwise</p>
</div>
</div>
<div class="summary-row">
  <div class="summary-signature">
    <a href="#write_stat/3">write_stat(path, stat, opts \\ [])</a>
  </div>
    <div class="summary-synopsis"><p>Writes the given <a href="File.Stat.html"><code class="inline">File.Stat</code></a> back to the filesystem at the given
path. Returns <code class="inline">:ok</code> or <code class="inline">{:error, reason}</code></p>
</div>
</div>
  </div>
          
        </section>

        <section id="types" class="details-list">
          <h1 class="section-heading">
            <a class="hover-link" href="#types">
              <span class="icon-link" aria-hidden="true"></span>
              <span class="sr-only">Link to this section</span>
            </a>
            Types
          </h1>
          <div class="types-list">
<div class="detail" id="t:encoding_mode/0">
    <div class="detail-header">
    <a href="#t:encoding_mode/0" class="detail-link" title="Link to this type">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this type</span>
    </a>
    <span class="signature">encoding_mode()</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L98" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>encoding_mode() ::
  :utf8
  | {:encoding,
     :latin1
     | :unicode
     | :utf8
     | :utf16
     | :utf32
     | {:utf16, :big | :little}
     | {:utf32, :big | :little}}</pre>
      </div>
  </div>
  <section class="docstring">
  </section>
</div>
<div class="detail" id="t:io_device/0">
    <div class="detail-header">
    <a href="#t:io_device/0" class="detail-link" title="Link to this type">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this type</span>
    </a>
    <span class="signature">io_device()</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L80" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>io_device() :: <a href="http://www.erlang.org/doc/man/file.html#type-io_device">:file.io_device</a>()</pre>
      </div>
  </div>
  <section class="docstring">
  </section>
</div>
<div class="detail" id="t:mode/0">
    <div class="detail-header">
    <a href="#t:mode/0" class="detail-link" title="Link to this type">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this type</span>
    </a>
    <span class="signature">mode()</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L82" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>mode() ::
  :append
  | :binary
  | :charlist
  | :compressed
  | :delayed_write
  | :exclusive
  | :raw
  | :read
  | :read_ahead
  | :sync
  | :write
  | {:read_ahead, <a href="typespecs.html#basic-types">pos_integer</a>()}
  | {:delayed_write, <a href="typespecs.html#basic-types">non_neg_integer</a>(), <a href="typespecs.html#basic-types">non_neg_integer</a>()}
  | <a href="#t:encoding_mode/0">encoding_mode</a>()</pre>
      </div>
  </div>
  <section class="docstring">
  </section>
</div>
<div class="detail" id="t:posix/0">
    <div class="detail-header">
    <a href="#t:posix/0" class="detail-link" title="Link to this type">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this type</span>
    </a>
    <span class="signature">posix()</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L79" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>posix() :: <a href="http://www.erlang.org/doc/man/file.html#type-posix">:file.posix</a>()</pre>
      </div>
  </div>
  <section class="docstring">
  </section>
</div>
<div class="detail" id="t:stat_options/0">
    <div class="detail-header">
    <a href="#t:stat_options/0" class="detail-link" title="Link to this type">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this type</span>
    </a>
    <span class="signature">stat_options()</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L81" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>stat_options() :: [{:time, :local | :universal | :posix}]</pre>
      </div>
  </div>
  <section class="docstring">
  </section>
</div>
<div class="detail" id="t:stream_mode/0">
    <div class="detail-header">
    <a href="#t:stream_mode/0" class="detail-link" title="Link to this type">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this type</span>
    </a>
    <span class="signature">stream_mode()</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L111" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>stream_mode() ::
  <a href="#t:encoding_mode/0">encoding_mode</a>()
  | :trim_bom
  | {:read_ahead, <a href="typespecs.html#basic-types">pos_integer</a>() | false}
  | {:delayed_write, <a href="typespecs.html#basic-types">non_neg_integer</a>(), <a href="typespecs.html#basic-types">non_neg_integer</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
  </section>
</div>
          </div>
        </section>


        <section id="functions" class="details-list">
          <h1 class="section-heading">
            <a class="hover-link" href="#functions">
              <span class="icon-link" aria-hidden="true"></span>
              <span class="sr-only">Link to this section</span>
            </a>
            Functions
          </h1>
<div class="detail" id="cd!/1">
    <div class="detail-header">
    <a href="#cd!/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">cd!(path)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1416" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>cd!(<a href="Path.html#t:t/0">Path.t</a>()) :: :ok | <a href="typespecs.html#built-in-types">no_return</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>The same as <a href="#cd/1"><code class="inline">cd/1</code></a>, but raises an exception if it fails.</p>
  </section>
</div>
<div class="detail" id="cd!/2">
    <div class="detail-header">
    <a href="#cd!/2" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">cd!(path, function)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1438" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>cd!(<a href="Path.html#t:t/0">Path.t</a>(), (() -> res)) :: res when res: var</pre>
      </div>
  </div>
  <section class="docstring">
<p>Changes the current directory to the given <code class="inline">path</code>,
executes the given function and then reverts back
to the previous path regardless of whether there is an exception.</p>
<p>Raises an error if retrieving or changing the current
directory fails.</p>
  </section>
</div>
<div class="detail" id="cd/1">
    <div class="detail-header">
    <a href="#cd/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">cd(path)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1408" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>cd(<a href="Path.html#t:t/0">Path.t</a>()) :: :ok | {:error, <a href="#t:posix/0">posix</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Sets the current working directory.</p>
<p>Returns <code class="inline">:ok</code> if successful, <code class="inline">{:error, reason}</code> otherwise.</p>
  </section>
</div>
<div class="detail" id="chgrp!/2">
    <div class="detail-header">
    <a href="#chgrp!/2" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">chgrp!(path, gid)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1609" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>chgrp!(<a href="Path.html#t:t/0">Path.t</a>(), <a href="typespecs.html#basic-types">non_neg_integer</a>()) :: :ok | <a href="typespecs.html#built-in-types">no_return</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>Same as <a href="#chgrp/2"><code class="inline">chgrp/2</code></a>, but raises an exception in case of failure. Otherwise <code class="inline">:ok</code>.</p>
  </section>
</div>
<div class="detail" id="chgrp/2">
    <div class="detail-header">
    <a href="#chgrp/2" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">chgrp(path, gid)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1601" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>chgrp(<a href="Path.html#t:t/0">Path.t</a>(), <a href="typespecs.html#basic-types">non_neg_integer</a>()) :: :ok | {:error, <a href="#t:posix/0">posix</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Changes the group given by the group id <code class="inline">gid</code>
for a given <code class="inline">file</code>. Returns <code class="inline">:ok</code> on success, or
<code class="inline">{:error, reason}</code> on failure.</p>
  </section>
</div>
<div class="detail" id="chmod!/2">
    <div class="detail-header">
    <a href="#chmod!/2" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">chmod!(path, mode)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1582" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>chmod!(<a href="Path.html#t:t/0">Path.t</a>(), <a href="typespecs.html#basic-types">non_neg_integer</a>()) :: :ok | <a href="typespecs.html#built-in-types">no_return</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>Same as <a href="#chmod/2"><code class="inline">chmod/2</code></a>, but raises an exception in case of failure. Otherwise <code class="inline">:ok</code>.</p>
  </section>
</div>
<div class="detail" id="chmod/2">
    <div class="detail-header">
    <a href="#chmod/2" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">chmod(path, mode)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1574" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>chmod(<a href="Path.html#t:t/0">Path.t</a>(), <a href="typespecs.html#basic-types">non_neg_integer</a>()) :: :ok | {:error, <a href="#t:posix/0">posix</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Changes the <code class="inline">mode</code> for a given <code class="inline">file</code>.</p>
<p>Returns <code class="inline">:ok</code> on success, or <code class="inline">{:error, reason}</code> on failure.</p>
<h2 id="chmod/2-permissions" class="section-heading">
  <a href="#chmod/2-permissions" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  Permissions
</h2>

<p>File permissions are specified by adding together the following octal flags:</p>
<ul>
<li><p><code class="inline">0o400</code> - read permission: owner</p>
</li>
<li><p><code class="inline">0o200</code> - write permission: owner</p>
</li>
<li><p><code class="inline">0o100</code> - execute permission: owner</p>
</li>
<li><p><code class="inline">0o040</code> - read permission: group</p>
</li>
<li><p><code class="inline">0o020</code> - write permission: group</p>
</li>
<li><p><code class="inline">0o010</code> - execute permission: group</p>
</li>
<li><p><code class="inline">0o004</code> - read permission: other</p>
</li>
<li><p><code class="inline">0o002</code> - write permission: other</p>
</li>
<li><p><code class="inline">0o001</code> - execute permission: other</p>
</li>
</ul>
<p>For example, setting the mode <code class="inline">0o755</code> gives it
write, read and execute permission to the owner
and both read and execute permission to group
and others.</p>
  </section>
</div>
<div class="detail" id="chown!/2">
    <div class="detail-header">
    <a href="#chown!/2" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">chown!(path, uid)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1636" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>chown!(<a href="Path.html#t:t/0">Path.t</a>(), <a href="typespecs.html#basic-types">non_neg_integer</a>()) :: :ok | <a href="typespecs.html#built-in-types">no_return</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>Same as <a href="#chown/2"><code class="inline">chown/2</code></a>, but raises an exception in case of failure. Otherwise <code class="inline">:ok</code>.</p>
  </section>
</div>
<div class="detail" id="chown/2">
    <div class="detail-header">
    <a href="#chown/2" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">chown(path, uid)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1628" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>chown(<a href="Path.html#t:t/0">Path.t</a>(), <a href="typespecs.html#basic-types">non_neg_integer</a>()) :: :ok | {:error, <a href="#t:posix/0">posix</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Changes the owner given by the user id <code class="inline">uid</code>
for a given <code class="inline">file</code>. Returns <code class="inline">:ok</code> on success,
or <code class="inline">{:error, reason}</code> on failure.</p>
  </section>
</div>
<div class="detail" id="close/1">
    <div class="detail-header">
    <a href="#close/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">close(io_device)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1490" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>close(<a href="#t:io_device/0">io_device</a>()) :: :ok | {:error, <a href="#t:posix/0">posix</a>() | :badarg | :terminated}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Closes the file referenced by <code class="inline">io_device</code>. It mostly returns <code class="inline">:ok</code>, except
for some severe errors such as out of memory.</p>
<p>Note that if the option <code class="inline">:delayed_write</code> was used when opening the file,
<a href="#close/1"><code class="inline">close/1</code></a> might return an old write error and not even try to close the file.
See <a href="#open/2"><code class="inline">open/2</code></a> for more information.</p>
  </section>
</div>
<div class="detail" id="copy!/3">
  
    <span id="copy!/2"></span>
  <div class="detail-header">
    <a href="#copy!/3" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">copy!(source, destination, bytes_count \\ :infinity)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L633" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>copy!(<a href="Path.html#t:t/0">Path.t</a>() | <a href="#t:io_device/0">io_device</a>(), <a href="Path.html#t:t/0">Path.t</a>() | <a href="#t:io_device/0">io_device</a>(), <a href="typespecs.html#basic-types">pos_integer</a>() | :infinity) ::
  <a href="typespecs.html#basic-types">non_neg_integer</a>() | <a href="typespecs.html#built-in-types">no_return</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>The same as <a href="#copy/3"><code class="inline">copy/3</code></a> but raises an <a href="File.CopyError.html"><code class="inline">File.CopyError</code></a> if it fails.
Returns the <code class="inline">bytes_copied</code> otherwise.</p>
  </section>
</div>
<div class="detail" id="copy/3">
  
    <span id="copy/2"></span>
  <div class="detail-header">
    <a href="#copy/3" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">copy(source, destination, bytes_count \\ :infinity)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L623" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>copy(<a href="Path.html#t:t/0">Path.t</a>() | <a href="#t:io_device/0">io_device</a>(), <a href="Path.html#t:t/0">Path.t</a>() | <a href="#t:io_device/0">io_device</a>(), <a href="typespecs.html#basic-types">pos_integer</a>() | :infinity) ::
  {:ok, <a href="typespecs.html#basic-types">non_neg_integer</a>()} | {:error, <a href="#t:posix/0">posix</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Copies the contents of <code class="inline">source</code> to <code class="inline">destination</code>.</p>
<p>Both parameters can be a filename or an IO device opened
with <a href="#open/2"><code class="inline">open/2</code></a>. <code class="inline">bytes_count</code> specifies the number of
bytes to copy, the default being <code class="inline">:infinity</code>.</p>
<p>If file <code class="inline">destination</code> already exists, it is overwritten
by the contents in <code class="inline">source</code>.</p>
<p>Returns <code class="inline">{:ok, bytes_copied}</code> if successful,
<code class="inline">{:error, reason}</code> otherwise.</p>
<p>Compared to the <a href="#cp/3"><code class="inline">cp/3</code></a>, this function is more low-level,
allowing a copy from device to device limited by a number of
bytes. On the other hand, <a href="#cp/3"><code class="inline">cp/3</code></a> performs more extensive
checks on both source and destination and it also preserves
the file mode after copy.</p>
<p>Typical error reasons are the same as in <a href="#open/2"><code class="inline">open/2</code></a>,
<a href="#read/1"><code class="inline">read/1</code></a> and <a href="#write/3"><code class="inline">write/3</code></a>.</p>
  </section>
</div>
<div class="detail" id="cp!/3">
  
    <span id="cp!/2"></span>
  <div class="detail-header">
    <a href="#cp!/3" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">cp!(source, destination, callback \\ fn _, _ -&gt; true end)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L714" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>cp!(<a href="Path.html#t:t/0">Path.t</a>(), <a href="Path.html#t:t/0">Path.t</a>(), (<a href="Path.html#t:t/0">Path.t</a>(), <a href="Path.html#t:t/0">Path.t</a>() -> <a href="typespecs.html#built-in-types">boolean</a>())) :: :ok | <a href="typespecs.html#built-in-types">no_return</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>The same as <a href="#cp/3"><code class="inline">cp/3</code></a>, but raises <a href="File.CopyError.html"><code class="inline">File.CopyError</code></a> if it fails.
Returns <code class="inline">:ok</code> otherwise.</p>
  </section>
</div>
<div class="detail" id="cp/3">
  
    <span id="cp/2"></span>
  <div class="detail-header">
    <a href="#cp/3" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">cp(source, destination, callback \\ fn _, _ -&gt; true end)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L693" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>cp(<a href="Path.html#t:t/0">Path.t</a>(), <a href="Path.html#t:t/0">Path.t</a>(), (<a href="Path.html#t:t/0">Path.t</a>(), <a href="Path.html#t:t/0">Path.t</a>() -> <a href="typespecs.html#built-in-types">boolean</a>())) ::
  :ok | {:error, <a href="#t:posix/0">posix</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Copies the contents in <code class="inline">source</code> to <code class="inline">destination</code> preserving its mode.</p>
<p>If a file already exists in the destination, it invokes a
callback which should return <code class="inline">true</code> if the existing file
should be overwritten, <code class="inline">false</code> otherwise. The callback defaults to return <code class="inline">true</code>.</p>
<p>The function returns <code class="inline">:ok</code> in case of success, returns
<code class="inline">{:error, reason}</code> otherwise.</p>
<p>If you want to copy contents from an IO device to another device
or do a straight copy from a source to a destination without
preserving modes, check <a href="#copy/3"><code class="inline">copy/3</code></a> instead.</p>
<p>Note: The command <code class="inline">cp</code> in Unix systems behaves differently depending
if <code class="inline">destination</code> is an existing directory or not. We have chosen to
explicitly disallow this behaviour. If destination is a directory, an
error will be returned.</p>
  </section>
</div>
<div class="detail" id="cp_r!/3">
  
    <span id="cp_r!/2"></span>
  <div class="detail-header">
    <a href="#cp_r!/3" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">cp_r!(source, destination, callback \\ fn _, _ -&gt; true end)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L794" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>cp_r!(<a href="Path.html#t:t/0">Path.t</a>(), <a href="Path.html#t:t/0">Path.t</a>(), (<a href="Path.html#t:t/0">Path.t</a>(), <a href="Path.html#t:t/0">Path.t</a>() -> <a href="typespecs.html#built-in-types">boolean</a>())) ::
  [<a href="typespecs.html#built-in-types">binary</a>()] | <a href="typespecs.html#built-in-types">no_return</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>The same as <a href="#cp_r/3"><code class="inline">cp_r/3</code></a>, but raises <a href="File.CopyError.html"><code class="inline">File.CopyError</code></a> if it fails.
Returns the list of copied files otherwise.</p>
  </section>
</div>
<div class="detail" id="cp_r/3">
  
    <span id="cp_r/2"></span>
  <div class="detail-header">
    <a href="#cp_r/3" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">cp_r(source, destination, callback \\ fn _, _ -&gt; true end)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L772" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>cp_r(<a href="Path.html#t:t/0">Path.t</a>(), <a href="Path.html#t:t/0">Path.t</a>(), (<a href="Path.html#t:t/0">Path.t</a>(), <a href="Path.html#t:t/0">Path.t</a>() -> <a href="typespecs.html#built-in-types">boolean</a>())) ::
  {:ok, [<a href="typespecs.html#built-in-types">binary</a>()]} | {:error, <a href="#t:posix/0">posix</a>(), <a href="typespecs.html#built-in-types">binary</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Copies the contents in source to destination.</p>
<p>If the source is a file, it copies <code class="inline">source</code> to
<code class="inline">destination</code>. If the source is a directory, it copies
the contents inside source into the destination.</p>
<p>If a file already exists in the destination, it invokes <code class="inline">callback</code>.
<code class="inline">callback</code> must be a function that takes two arguments: <code class="inline">source</code> and <code class="inline">destination</code>.
The callback should return <code class="inline">true</code> if the existing file should be overwritten and <code class="inline">false</code> otherwise.</p>
<p>If a directory already exists in the destination
where a file is meant to be (or vice versa), this
function will fail.</p>
<p>This function may fail while copying files,
in such cases, it will leave the destination
directory in a dirty state, where file which have already been copied
won’t be removed.</p>
<p>The function returns <code class="inline">{:ok, files_and_directories}</code> in case of
success, <code class="inline">files_and_directories</code> lists all files and directories copied in no
specific order. It returns <code class="inline">{:error, reason, file}</code> otherwise.</p>
<p>Note: The command <code class="inline">cp</code> in Unix systems behaves differently
depending if <code class="inline">destination</code> is an existing directory or not.
We have chosen to explicitly disallow this behaviour.</p>
<h2 id="cp_r/3-examples" class="section-heading">
  <a href="#cp_r/3-examples" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  Examples
</h2>

<pre><code class="nohighlight makeup elixir"><span class="c1"># Copies file &quot;a.txt&quot; to &quot;b.txt&quot;</span><span class="w">
</span><span class="nc">File</span><span class="o">.</span><span class="n">cp_r</span><span class="w"> </span><span class="s">&quot;a.txt&quot;</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;b.txt&quot;</span><span class="w">

</span><span class="c1"># Copies all files in &quot;samples&quot; to &quot;tmp&quot;</span><span class="w">
</span><span class="nc">File</span><span class="o">.</span><span class="n">cp_r</span><span class="w"> </span><span class="s">&quot;samples&quot;</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;tmp&quot;</span><span class="w">

</span><span class="c1"># Same as before, but asks the user how to proceed in case of conflicts</span><span class="w">
</span><span class="nc">File</span><span class="o">.</span><span class="n">cp_r</span><span class="w"> </span><span class="s">&quot;samples&quot;</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;tmp&quot;</span><span class="p">,</span><span class="w"> </span><span class="k" data-group-id="5656569026-1">fn</span><span class="w"> </span><span class="n">source</span><span class="p">,</span><span class="w"> </span><span class="n">destination</span><span class="w"> </span><span class="o">-&gt;</span><span class="w">
  </span><span class="nc">IO</span><span class="o">.</span><span class="n">gets</span><span class="p" data-group-id="5656569026-2">(</span><span class="s">&quot;Overwriting </span><span class="si" data-group-id="5656569026-3">#{</span><span class="n">destination</span><span class="si" data-group-id="5656569026-3">}</span><span class="s"> by </span><span class="si" data-group-id="5656569026-4">#{</span><span class="n">source</span><span class="si" data-group-id="5656569026-4">}</span><span class="s">. Type y to confirm. &quot;</span><span class="p" data-group-id="5656569026-2">)</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="s">&quot;y</span><span class="se">\n</span><span class="s">&quot;</span><span class="w">
</span><span class="k" data-group-id="5656569026-1">end</span></code></pre>
  </section>
</div>
<div class="detail" id="cwd!/0">
    <div class="detail-header">
    <a href="#cwd!/0" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">cwd!()</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1392" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>cwd!() :: <a href="typespecs.html#built-in-types">binary</a>() | <a href="typespecs.html#built-in-types">no_return</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>The same as <a href="#cwd/0"><code class="inline">cwd/0</code></a>, but raises an exception if it fails.</p>
  </section>
</div>
<div class="detail" id="cwd/0">
    <div class="detail-header">
    <a href="#cwd/0" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">cwd()</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1372" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>cwd() :: {:ok, <a href="typespecs.html#built-in-types">binary</a>()} | {:error, <a href="#t:posix/0">posix</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Gets the current working directory.</p>
<p>In rare circumstances, this function can fail on Unix. It may happen
if read permissions do not exist for the parent directories of the
current directory. For this reason, returns <code class="inline">{:ok, cwd}</code> in case
of success, <code class="inline">{:error, reason}</code> otherwise.</p>
  </section>
</div>
<div class="detail" id="dir?/1">
    <div class="detail-header">
    <a href="#dir?/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">dir?(path)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L158" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>dir?(<a href="Path.html#t:t/0">Path.t</a>()) :: <a href="typespecs.html#built-in-types">boolean</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>Returns <code class="inline">true</code> if the given path is a directory.</p>
<p>This function follows symbolic links, so if a symbolic link points to a
directory, <code class="inline">true</code> is returned.</p>
<h2 id="dir?/1-examples" class="section-heading">
  <a href="#dir?/1-examples" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  Examples
</h2>

<pre><code class="nohighlight makeup elixir"><span class="nc">File</span><span class="o">.</span><span class="n">dir?</span><span class="p" data-group-id="7882551373-1">(</span><span class="s">&quot;./test&quot;</span><span class="p" data-group-id="7882551373-1">)</span><span class="w">
</span><span class="c1">#=&gt; true</span><span class="w">

</span><span class="nc">File</span><span class="o">.</span><span class="n">dir?</span><span class="p" data-group-id="7882551373-2">(</span><span class="s">&quot;test&quot;</span><span class="p" data-group-id="7882551373-2">)</span><span class="w">
</span><span class="c1">#=&gt; true</span><span class="w">

</span><span class="nc">File</span><span class="o">.</span><span class="n">dir?</span><span class="p" data-group-id="7882551373-3">(</span><span class="s">&quot;/usr/bin&quot;</span><span class="p" data-group-id="7882551373-3">)</span><span class="w">
</span><span class="c1">#=&gt; true</span><span class="w">

</span><span class="nc">File</span><span class="o">.</span><span class="n">dir?</span><span class="p" data-group-id="7882551373-4">(</span><span class="s">&quot;~/Downloads&quot;</span><span class="p" data-group-id="7882551373-4">)</span><span class="w">
</span><span class="c1">#=&gt; false</span><span class="w">

</span><span class="s">&quot;~/Downloads&quot;</span><span class="w"> </span><span class="o">|&gt;</span><span class="w"> </span><span class="nc">Path</span><span class="o">.</span><span class="n">expand</span><span class="w"> </span><span class="o">|&gt;</span><span class="w"> </span><span class="nc">File</span><span class="o">.</span><span class="n">dir?</span><span class="w">
</span><span class="c1">#=&gt; true</span></code></pre>
  </section>
</div>
<div class="detail" id="exists?/1">
    <div class="detail-header">
    <a href="#exists?/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">exists?(path)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L181" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>exists?(<a href="Path.html#t:t/0">Path.t</a>()) :: <a href="typespecs.html#built-in-types">boolean</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>Returns <code class="inline">true</code> if the given path exists.</p>
<p>It can be regular file, directory, socket, symbolic link, named pipe or device file.
Returns <code class="inline">false</code> for symbolic links pointing to non-existing targets.</p>
<h2 id="exists?/1-examples" class="section-heading">
  <a href="#exists?/1-examples" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  Examples
</h2>

<pre><code class="nohighlight makeup elixir"><span class="nc">File</span><span class="o">.</span><span class="n">exists?</span><span class="p" data-group-id="2473717351-1">(</span><span class="s">&quot;test/&quot;</span><span class="p" data-group-id="2473717351-1">)</span><span class="w">
</span><span class="c1">#=&gt; true</span><span class="w">

</span><span class="nc">File</span><span class="o">.</span><span class="n">exists?</span><span class="p" data-group-id="2473717351-2">(</span><span class="s">&quot;missing.txt&quot;</span><span class="p" data-group-id="2473717351-2">)</span><span class="w">
</span><span class="c1">#=&gt; false</span><span class="w">

</span><span class="nc">File</span><span class="o">.</span><span class="n">exists?</span><span class="p" data-group-id="2473717351-3">(</span><span class="s">&quot;/dev/null&quot;</span><span class="p" data-group-id="2473717351-3">)</span><span class="w">
</span><span class="c1">#=&gt; true</span></code></pre>
  </section>
</div>
<div class="detail" id="ln!/2">
    <div class="detail-header">
    <a href="#ln!/2" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">ln!(existing, new)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L552" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
    
      <span class="note">(since 1.5.0)</span>
    
      <div class="specs">
          <pre>ln!(<a href="Path.html#t:t/0">Path.t</a>(), <a href="Path.html#t:t/0">Path.t</a>()) :: :ok | <a href="typespecs.html#built-in-types">no_return</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>Same as <a href="#ln/2"><code class="inline">ln/2</code></a> but raises an exception if it fails.</p>
<p>Returns <code class="inline">:ok</code> otherwise</p>
  </section>
</div>
<div class="detail" id="ln/2">
    <div class="detail-header">
    <a href="#ln/2" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">ln(existing, new)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L541" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
    
      <span class="note">(since 1.5.0)</span>
    
      <div class="specs">
          <pre>ln(<a href="Path.html#t:t/0">Path.t</a>(), <a href="Path.html#t:t/0">Path.t</a>()) :: :ok | {:error, <a href="#t:posix/0">posix</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Creates a hard link <code class="inline">new</code> to the file <code class="inline">existing</code>.</p>
<p>Returns <code class="inline">:ok</code> if successful, <code class="inline">{:error, reason}</code> otherwise.
If the operating system does not support hard links, returns
<code class="inline">{:error, :enotsup}</code>.</p>
  </section>
</div>
<div class="detail" id="ln_s!/2">
    <div class="detail-header">
    <a href="#ln_s!/2" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">ln_s!(existing, new)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L585" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>ln_s!(<a href="Path.html#t:t/0">Path.t</a>(), <a href="Path.html#t:t/0">Path.t</a>()) :: :ok | <a href="typespecs.html#built-in-types">no_return</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>Same as <a href="#ln_s/2"><code class="inline">ln_s/2</code></a> but raises an exception if it fails.</p>
<p>Returns <code class="inline">:ok</code> otherwise</p>
  </section>
</div>
<div class="detail" id="ln_s/2">
    <div class="detail-header">
    <a href="#ln_s/2" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">ln_s(existing, new)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L575" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
    
      <span class="note">(since 1.5.0)</span>
    
      <div class="specs">
          <pre>ln_s(<a href="Path.html#t:t/0">Path.t</a>(), <a href="Path.html#t:t/0">Path.t</a>()) :: :ok | {:error, <a href="#t:posix/0">posix</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Creates a symbolic link <code class="inline">new</code> to the file or directory <code class="inline">existing</code>.</p>
<p>Returns <code class="inline">:ok</code> if successful, <code class="inline">{:error, reason}</code> otherwise.
If the operating system does not support symlinks, returns
<code class="inline">{:error, :enotsup}</code>.</p>
  </section>
</div>
<div class="detail" id="ls!/1">
  
    <span id="ls!/0"></span>
  <div class="detail-header">
    <a href="#ls!/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">ls!(path \\ &quot;.&quot;)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1468" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>ls!(<a href="Path.html#t:t/0">Path.t</a>()) :: [<a href="typespecs.html#built-in-types">binary</a>()] | <a href="typespecs.html#built-in-types">no_return</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>The same as <a href="#ls/1"><code class="inline">ls/1</code></a> but raises <a href="File.Error.html"><code class="inline">File.Error</code></a>
in case of an error.</p>
  </section>
</div>
<div class="detail" id="ls/1">
  
    <span id="ls/0"></span>
  <div class="detail-header">
    <a href="#ls/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">ls(path \\ &quot;.&quot;)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1456" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>ls(<a href="Path.html#t:t/0">Path.t</a>()) :: {:ok, [<a href="typespecs.html#built-in-types">binary</a>()]} | {:error, <a href="#t:posix/0">posix</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Returns the list of files in the given directory.</p>
<p>Returns <code class="inline">{:ok, files}</code> in case of success,
<code class="inline">{:error, reason}</code> otherwise.</p>
  </section>
</div>
<div class="detail" id="lstat!/2">
  
    <span id="lstat!/1"></span>
  <div class="detail-header">
    <a href="#lstat!/2" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">lstat!(path, opts \\ [])</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L412" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>lstat!(<a href="Path.html#t:t/0">Path.t</a>(), <a href="#t:stat_options/0">stat_options</a>()) :: <a href="File.Stat.html#t:t/0">File.Stat.t</a>() | <a href="typespecs.html#built-in-types">no_return</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>Same as <a href="#lstat/2"><code class="inline">lstat/2</code></a> but returns the <a href="File.Stat.html"><code class="inline">File.Stat</code></a> struct directly, or
throws <a href="File.Error.html"><code class="inline">File.Error</code></a> if an error is returned.</p>
  </section>
</div>
<div class="detail" id="lstat/2">
  
    <span id="lstat/1"></span>
  <div class="detail-header">
    <a href="#lstat/2" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">lstat(path, opts \\ [])</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L395" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>lstat(<a href="Path.html#t:t/0">Path.t</a>(), <a href="#t:stat_options/0">stat_options</a>()) :: {:ok, <a href="File.Stat.html#t:t/0">File.Stat.t</a>()} | {:error, <a href="#t:posix/0">posix</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Returns information about the <code class="inline">path</code>. If the file is a symlink, sets
the <code class="inline">type</code> to <code class="inline">:symlink</code> and returns a <a href="File.Stat.html"><code class="inline">File.Stat</code></a> struct for the link. For any
other file, returns exactly the same values as <a href="#stat/2"><code class="inline">stat/2</code></a>.</p>
<p>For more details, see <a href="http://www.erlang.org/doc/man/file.html#read_link_info-2"><code class="inline">:file.read_link_info/2</code></a>.</p>
<h2 id="lstat/2-options" class="section-heading">
  <a href="#lstat/2-options" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  Options
</h2>

<p>The accepted options are:</p>
<ul>
<li><code class="inline">:time</code> - configures how the file timestamps are returned
</li>
</ul>
<p>The values for <code class="inline">:time</code> can be:</p>
<ul>
<li><code class="inline">:universal</code> - returns a <code class="inline">{date, time}</code> tuple in UTC (default)
</li>
<li><code class="inline">:local</code> - returns a <code class="inline">{date, time}</code> tuple using the machine time
</li>
<li><code class="inline">:posix</code> - returns the time as integer seconds since epoch
</li>
</ul>
  </section>
</div>
<div class="detail" id="mkdir!/1">
    <div class="detail-header">
    <a href="#mkdir!/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">mkdir!(path)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L211" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>mkdir!(<a href="Path.html#t:t/0">Path.t</a>()) :: :ok | <a href="typespecs.html#built-in-types">no_return</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>Same as <a href="#mkdir/1"><code class="inline">mkdir/1</code></a>, but raises an exception in case of failure. Otherwise <code class="inline">:ok</code>.</p>
  </section>
</div>
<div class="detail" id="mkdir/1">
    <div class="detail-header">
    <a href="#mkdir/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">mkdir(path)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L203" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>mkdir(<a href="Path.html#t:t/0">Path.t</a>()) :: :ok | {:error, <a href="#t:posix/0">posix</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Tries to create the directory <code class="inline">path</code>.</p>
<p>Missing parent directories are not created.
Returns <code class="inline">:ok</code> if successful, or <code class="inline">{:error, reason}</code> if an error occurs.</p>
<p>Typical error reasons are:</p>
<ul>
<li><code class="inline">:eacces</code>  - missing search or write permissions for the parent
directories of <code class="inline">path</code>
</li>
<li><code class="inline">:eexist</code>  - there is already a file or directory named <code class="inline">path</code>
</li>
<li><code class="inline">:enoent</code>  - a component of <code class="inline">path</code> does not exist
</li>
<li><code class="inline">:enospc</code>  - there is no space left on the device
</li>
<li><code class="inline">:enotdir</code> - a component of <code class="inline">path</code> is not a directory;
on some platforms, <code class="inline">:enoent</code> is returned instead
</li>
</ul>
  </section>
</div>
<div class="detail" id="mkdir_p!/1">
    <div class="detail-header">
    <a href="#mkdir_p!/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">mkdir_p!(path)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L274" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>mkdir_p!(<a href="Path.html#t:t/0">Path.t</a>()) :: :ok | <a href="typespecs.html#built-in-types">no_return</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>Same as <a href="#mkdir_p/1"><code class="inline">mkdir_p/1</code></a>, but raises an exception in case of failure. Otherwise <code class="inline">:ok</code>.</p>
  </section>
</div>
<div class="detail" id="mkdir_p/1">
    <div class="detail-header">
    <a href="#mkdir_p/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">mkdir_p(path)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L239" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>mkdir_p(<a href="Path.html#t:t/0">Path.t</a>()) :: :ok | {:error, <a href="#t:posix/0">posix</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Tries to create the directory <code class="inline">path</code>.</p>
<p>Missing parent directories are created. Returns <code class="inline">:ok</code> if successful, or
<code class="inline">{:error, reason}</code> if an error occurs.</p>
<p>Typical error reasons are:</p>
<ul>
<li><code class="inline">:eacces</code>  - missing search or write permissions for the parent
directories of <code class="inline">path</code>
</li>
<li><code class="inline">:enospc</code>  - there is no space left on the device
</li>
<li><code class="inline">:enotdir</code> - a component of <code class="inline">path</code> is not a directory
</li>
</ul>
  </section>
</div>
<div class="detail" id="open!/2">
  
    <span id="open!/1"></span>
  <div class="detail-header">
    <a href="#open!/2" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">open!(path, modes_or_function \\ [])</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1335" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>open!(<a href="Path.html#t:t/0">Path.t</a>(), [<a href="#t:mode/0">mode</a>() | :ram]) :: <a href="#t:io_device/0">io_device</a>() | <a href="typespecs.html#built-in-types">no_return</a>()</pre>
          <pre>open!(<a href="Path.html#t:t/0">Path.t</a>(), (<a href="#t:io_device/0">io_device</a>() -> res)) :: res | <a href="typespecs.html#built-in-types">no_return</a>() when res: var</pre>
      </div>
  </div>
  <section class="docstring">
<p>Similar to <a href="#open/2"><code class="inline">open/2</code></a> but raises an error if file could not be opened.</p>
<p>Returns the IO device otherwise.</p>
<p>See <a href="#open/2"><code class="inline">open/2</code></a> for the list of available modes.</p>
  </section>
</div>
<div class="detail" id="open!/3">
    <div class="detail-header">
    <a href="#open!/3" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">open!(path, modes, function)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1353" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>open!(<a href="Path.html#t:t/0">Path.t</a>(), [<a href="#t:mode/0">mode</a>() | :ram], (<a href="#t:io_device/0">io_device</a>() -> res)) :: res | <a href="typespecs.html#built-in-types">no_return</a>()
when res: var</pre>
      </div>
  </div>
  <section class="docstring">
<p>Similar to <a href="#open/3"><code class="inline">open/3</code></a> but raises an error if file could not be opened.</p>
<p>If it succeeds opening the file, it returns the <code class="inline">function</code> result on the IO device.</p>
<p>See <a href="#open/2"><code class="inline">open/2</code></a> for the list of available <code class="inline">modes</code>.</p>
  </section>
</div>
<div class="detail" id="open/2">
  
    <span id="open/1"></span>
  <div class="detail-header">
    <a href="#open/2" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">open(path, modes_or_function \\ [])</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1283" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>open(<a href="Path.html#t:t/0">Path.t</a>(), [<a href="#t:mode/0">mode</a>() | :ram]) :: {:ok, <a href="#t:io_device/0">io_device</a>()} | {:error, <a href="#t:posix/0">posix</a>()}</pre>
          <pre>open(<a href="Path.html#t:t/0">Path.t</a>(), (<a href="#t:io_device/0">io_device</a>() -> res)) :: {:ok, res} | {:error, <a href="#t:posix/0">posix</a>()}
when res: var</pre>
      </div>
  </div>
  <section class="docstring">
<p>Opens the given <code class="inline">path</code>.</p>
<p>In order to write and read files, one must use the functions
in the <a href="IO.html"><code class="inline">IO</code></a> module. By default, a file is opened in <code class="inline">:binary</code> mode,
which requires the functions <a href="IO.html#binread/2"><code class="inline">IO.binread/2</code></a> and <a href="IO.html#binwrite/2"><code class="inline">IO.binwrite/2</code></a>
to interact with the file. A developer may pass <code class="inline">:utf8</code> as an
option when opening the file and then all other functions from
<a href="IO.html"><code class="inline">IO</code></a> are available, since they work directly with Unicode data.</p>
<p><code class="inline">modes_or_function</code> can either be a list of modes or a function. If it’s a
list, it’s considered to be a list of modes (that are documented below). If
it’s a function, then it’s equivalent to calling <code class="inline">open(path, [],
modes_or_function)</code>. See the documentation for <a href="#open/3"><code class="inline">open/3</code></a> for more information
on this function.</p>
<p>The allowed modes:</p>
<ul>
<li><p><code class="inline">:binary</code> - opens the file in binary mode, disabling special handling of unicode sequences
(default mode).</p>
</li>
<li><p><code class="inline">:read</code> - the file, which must exist, is opened for reading.</p>
</li>
<li><p><code class="inline">:write</code> - the file is opened for writing. It is created if it does not
exist.</p>
<p>If the file does exists, and if write is not combined with read, the file
will be truncated.</p>
</li>
<li><p><code class="inline">:append</code> - the file will be opened for writing, and it will be created
if it does not exist. Every write operation to a file opened with append
will take place at the end of the file.</p>
</li>
<li><p><code class="inline">:exclusive</code> - the file, when opened for writing, is created if it does
not exist. If the file exists, open will return <code class="inline">{:error, :eexist}</code>.</p>
</li>
<li><p><code class="inline">:charlist</code> - when this term is given, read operations on the file will
return charlists rather than binaries.</p>
</li>
<li><p><code class="inline">:compressed</code> - makes it possible to read or write gzip compressed files.</p>
<p>The compressed option must be combined with either read or write, but not
both. Note that the file size obtained with <a href="#stat/1"><code class="inline">stat/1</code></a> will most probably
not match the number of bytes that can be read from a compressed file.</p>
</li>
<li><p><code class="inline">:utf8</code> - this option denotes how data is actually stored in the disk
file and makes the file perform automatic translation of characters to
and from UTF-8.</p>
<p>If data is sent to a file in a format that cannot be converted to the
UTF-8 or if data is read by a function that returns data in a format that
cannot cope with the character range of the data, an error occurs and the
file will be closed.</p>
</li>
<li><p><code class="inline">:delayed_write</code>, <code class="inline">:raw</code>, <code class="inline">:ram</code>, <code class="inline">:read_ahead</code>, <code class="inline">:sync</code>, <code class="inline">{:encoding, ...}</code>,
<code class="inline">{:read_ahead, pos_integer}</code>, <code class="inline">{:delayed_write, non_neg_integer, non_neg_integer}</code> -
for more information about these options see <a href="http://www.erlang.org/doc/man/file.html#open-2"><code class="inline">:file.open/2</code></a>.</p>
</li>
</ul>
<p>This function returns:</p>
<ul>
<li><p><code class="inline">{:ok, io_device}</code> - the file has been opened in the requested mode.</p>
<p><code class="inline">io_device</code> is actually the PID of the process which handles the file.
This process is linked to the process which originally opened the file.
If any process to which the <code class="inline">io_device</code> is linked terminates, the file
will be closed and the process itself will be terminated.</p>
<p>An <code class="inline">io_device</code> returned from this call can be used as an argument to the
<a href="IO.html"><code class="inline">IO</code></a> module functions.</p>
</li>
<li><p><code class="inline">{:error, reason}</code> - the file could not be opened.</p>
</li>
</ul>
<h2 id="open/2-examples" class="section-heading">
  <a href="#open/2-examples" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  Examples
</h2>

<pre><code class="nohighlight makeup elixir"><span class="p" data-group-id="3677185294-1">{</span><span class="ss">:ok</span><span class="p">,</span><span class="w"> </span><span class="n">file</span><span class="p" data-group-id="3677185294-1">}</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">File</span><span class="o">.</span><span class="n">open</span><span class="p" data-group-id="3677185294-2">(</span><span class="s">&quot;foo.tar.gz&quot;</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="3677185294-3">[</span><span class="ss">:read</span><span class="p">,</span><span class="w"> </span><span class="ss">:compressed</span><span class="p" data-group-id="3677185294-3">]</span><span class="p" data-group-id="3677185294-2">)</span><span class="w">
</span><span class="nc">IO</span><span class="o">.</span><span class="n">read</span><span class="p" data-group-id="3677185294-4">(</span><span class="n">file</span><span class="p">,</span><span class="w"> </span><span class="ss">:line</span><span class="p" data-group-id="3677185294-4">)</span><span class="w">
</span><span class="nc">File</span><span class="o">.</span><span class="n">close</span><span class="p" data-group-id="3677185294-5">(</span><span class="n">file</span><span class="p" data-group-id="3677185294-5">)</span></code></pre>
  </section>
</div>
<div class="detail" id="open/3">
    <div class="detail-header">
    <a href="#open/3" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">open(path, modes, function)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1312" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>open(<a href="Path.html#t:t/0">Path.t</a>(), [<a href="#t:mode/0">mode</a>() | :ram], (<a href="#t:io_device/0">io_device</a>() -> res)) ::
  {:ok, res} | {:error, <a href="#t:posix/0">posix</a>()}
when res: var</pre>
      </div>
  </div>
  <section class="docstring">
<p>Similar to <a href="#open/2"><code class="inline">open/2</code></a> but expects a function as its last argument.</p>
<p>The file is opened, given to the function as an argument and
automatically closed after the function returns, regardless
if there was an error when executing the function.</p>
<p>Returns <code class="inline">{:ok, function_result}</code> in case of success,
<code class="inline">{:error, reason}</code> otherwise.</p>
<p>This function expects the file to be closed with success,
which is usually the case unless the <code class="inline">:delayed_write</code> option
is given. For this reason, we do not recommend passing
<code class="inline">:delayed_write</code> to this function.</p>
<h2 id="open/3-examples" class="section-heading">
  <a href="#open/3-examples" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  Examples
</h2>

<pre><code class="nohighlight makeup elixir"><span class="nc">File</span><span class="o">.</span><span class="n">open</span><span class="p" data-group-id="6225862458-1">(</span><span class="s">&quot;file.txt&quot;</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="6225862458-2">[</span><span class="ss">:read</span><span class="p">,</span><span class="w"> </span><span class="ss">:write</span><span class="p" data-group-id="6225862458-2">]</span><span class="p">,</span><span class="w"> </span><span class="k" data-group-id="6225862458-3">fn</span><span class="p" data-group-id="6225862458-4">(</span><span class="n">file</span><span class="p" data-group-id="6225862458-4">)</span><span class="w"> </span><span class="o">-&gt;</span><span class="w">
  </span><span class="nc">IO</span><span class="o">.</span><span class="n">read</span><span class="p" data-group-id="6225862458-5">(</span><span class="n">file</span><span class="p">,</span><span class="w"> </span><span class="ss">:line</span><span class="p" data-group-id="6225862458-5">)</span><span class="w">
</span><span class="k" data-group-id="6225862458-3">end</span><span class="p" data-group-id="6225862458-1">)</span></code></pre>
<p>See <a href="#open/2"><code class="inline">open/2</code></a> for the list of available <code class="inline">modes</code>.</p>
  </section>
</div>
<div class="detail" id="read!/1">
    <div class="detail-header">
    <a href="#read!/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">read!(path)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L313" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>read!(<a href="Path.html#t:t/0">Path.t</a>()) :: <a href="typespecs.html#built-in-types">binary</a>() | <a href="typespecs.html#built-in-types">no_return</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>Returns a binary with the contents of the given filename or raises
<a href="File.Error.html"><code class="inline">File.Error</code></a> if an error occurs.</p>
  </section>
</div>
<div class="detail" id="read/1">
    <div class="detail-header">
    <a href="#read/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">read(path)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L304" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>read(<a href="Path.html#t:t/0">Path.t</a>()) :: {:ok, <a href="typespecs.html#built-in-types">binary</a>()} | {:error, <a href="#t:posix/0">posix</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Returns <code class="inline">{:ok, binary}</code>, where <code class="inline">binary</code> is a binary data object that contains the contents
of <code class="inline">path</code>, or <code class="inline">{:error, reason}</code> if an error occurs.</p>
<p>Typical error reasons:</p>
<ul>
<li><code class="inline">:enoent</code>  - the file does not exist
</li>
<li><code class="inline">:eacces</code>  - missing permission for reading the file,
or for searching one of the parent directories
</li>
<li><code class="inline">:eisdir</code>  - the named file is a directory
</li>
<li><code class="inline">:enotdir</code> - a component of the file name is not a directory;
on some platforms, <code class="inline">:enoent</code> is returned instead
</li>
<li><code class="inline">:enomem</code>  - there is not enough memory for the contents of the file
</li>
</ul>
<p>You can use <a href="http://www.erlang.org/doc/man/file.html#format_error-1"><code class="inline">:file.format_error/1</code></a> to get a descriptive string of the error.</p>
  </section>
</div>
<div class="detail" id="read_link!/1">
    <div class="detail-header">
    <a href="#read_link!/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">read_link!(path)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L455" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
    
      <span class="note">(since 1.5.0)</span>
    
      <div class="specs">
          <pre>read_link!(<a href="Path.html#t:t/0">Path.t</a>()) :: <a href="typespecs.html#built-in-types">binary</a>() | <a href="typespecs.html#built-in-types">no_return</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>Same as <a href="#read_link/1"><code class="inline">read_link/1</code></a> but returns the target directly or throws <a href="File.Error.html"><code class="inline">File.Error</code></a> if an error is
returned.</p>
  </section>
</div>
<div class="detail" id="read_link/1">
    <div class="detail-header">
    <a href="#read_link/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">read_link(path)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L442" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
    
      <span class="note">(since 1.5.0)</span>
    
      <div class="specs">
          <pre>read_link(<a href="Path.html#t:t/0">Path.t</a>()) :: {:ok, <a href="typespecs.html#built-in-types">binary</a>()} | {:error, <a href="#t:posix/0">posix</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Reads the symbolic link at <code class="inline">path</code>.</p>
<p>If <code class="inline">path</code> exists and is a symlink, returns <code class="inline">{:ok, target}</code>, otherwise returns
<code class="inline">{:error, reason}</code>.</p>
<p>For more details, see <a href="http://www.erlang.org/doc/man/file.html#read_link-1"><code class="inline">:file.read_link/1</code></a>.</p>
<p>Typical error reasons are:</p>
<ul>
<li><code class="inline">:einval</code> - path is not a symbolic link
</li>
<li><code class="inline">:enoent</code> - path does not exist
</li>
<li><code class="inline">:enotsup</code> - symbolic links are not supported on the current platform
</li>
</ul>
  </section>
</div>
<div class="detail" id="regular?/1">
    <div class="detail-header">
    <a href="#regular?/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">regular?(path)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L129" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>regular?(<a href="Path.html#t:t/0">Path.t</a>()) :: <a href="typespecs.html#built-in-types">boolean</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>Returns <code class="inline">true</code> if the path is a regular file.</p>
<p>This function follows symbolic links, so if a symbolic link points to a
regular file, <code class="inline">true</code> is returned.</p>
<h2 id="regular?/1-examples" class="section-heading">
  <a href="#regular?/1-examples" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  Examples
</h2>

<pre><code class="nohighlight makeup elixir"><span class="nc">File</span><span class="o">.</span><span class="n">regular?</span><span class="w"> </span><span class="bp">__ENV__</span><span class="o">.</span><span class="n">file</span><span class="w"> </span><span class="c1">#=&gt; true</span></code></pre>
  </section>
</div>
<div class="detail" id="rename/2">
    <div class="detail-header">
    <a href="#rename/2" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">rename(source, destination)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L669" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>rename(<a href="Path.html#t:t/0">Path.t</a>(), <a href="Path.html#t:t/0">Path.t</a>()) :: :ok | {:error, <a href="#t:posix/0">posix</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Renames the <code class="inline">source</code> file to <code class="inline">destination</code> file.  It can be used to move files
(and directories) between directories.  If moving a file, you must fully
specify the <code class="inline">destination</code> filename, it is not sufficient to simply specify
its directory.</p>
<p>Returns <code class="inline">:ok</code> in case of success, <code class="inline">{:error, reason}</code> otherwise.</p>
<p>Note: The command <code class="inline">mv</code> in Unix systems behaves differently depending
if <code class="inline">source</code> is a file and the <code class="inline">destination</code> is an existing directory.
We have chosen to explicitly disallow this behaviour.</p>
<h2 id="rename/2-examples" class="section-heading">
  <a href="#rename/2-examples" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  Examples
</h2>

<pre><code class="nohighlight makeup elixir"><span class="c1"># Rename file &quot;a.txt&quot; to &quot;b.txt&quot;</span><span class="w">
</span><span class="nc">File</span><span class="o">.</span><span class="n">rename</span><span class="w"> </span><span class="s">&quot;a.txt&quot;</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;b.txt&quot;</span><span class="w">

</span><span class="c1"># Rename directory &quot;samples&quot; to &quot;tmp&quot;</span><span class="w">
</span><span class="nc">File</span><span class="o">.</span><span class="n">rename</span><span class="w"> </span><span class="s">&quot;samples&quot;</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;tmp&quot;</span></code></pre>
  </section>
</div>
<div class="detail" id="rm!/1">
    <div class="detail-header">
    <a href="#rm!/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">rm!(path)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1024" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>rm!(<a href="Path.html#t:t/0">Path.t</a>()) :: :ok | <a href="typespecs.html#built-in-types">no_return</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>Same as <a href="#rm/1"><code class="inline">rm/1</code></a>, but raises an exception in case of failure. Otherwise <code class="inline">:ok</code>.</p>
  </section>
</div>
<div class="detail" id="rm/1">
    <div class="detail-header">
    <a href="#rm/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">rm(path)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L986" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>rm(<a href="Path.html#t:t/0">Path.t</a>()) :: :ok | {:error, <a href="#t:posix/0">posix</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Tries to delete the file <code class="inline">path</code>.</p>
<p>Returns <code class="inline">:ok</code> if successful, or <code class="inline">{:error, reason}</code> if an error occurs.</p>
<p>Note the file is deleted even if in read-only mode.</p>
<p>Typical error reasons are:</p>
<ul>
<li><code class="inline">:enoent</code>  - the file does not exist
</li>
<li><code class="inline">:eacces</code>  - missing permission for the file or one of its parents
</li>
<li><code class="inline">:eperm</code>   - the file is a directory and user is not super-user
</li>
<li><code class="inline">:enotdir</code> - a component of the file name is not a directory;
on some platforms, <code class="inline">:enoent</code> is returned instead
</li>
<li><code class="inline">:einval</code>  - filename had an improper type, such as tuple
</li>
</ul>
<h2 id="rm/1-examples" class="section-heading">
  <a href="#rm/1-examples" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  Examples
</h2>

<pre><code class="nohighlight makeup elixir"><span class="nc">File</span><span class="o">.</span><span class="n">rm</span><span class="p" data-group-id="7167585211-1">(</span><span class="s">&quot;file.txt&quot;</span><span class="p" data-group-id="7167585211-1">)</span><span class="w">
</span><span class="c1">#=&gt; :ok</span><span class="w">

</span><span class="nc">File</span><span class="o">.</span><span class="n">rm</span><span class="p" data-group-id="7167585211-2">(</span><span class="s">&quot;tmp_dir/&quot;</span><span class="p" data-group-id="7167585211-2">)</span><span class="w">
</span><span class="c1">#=&gt; {:error, :eperm}</span></code></pre>
  </section>
</div>
<div class="detail" id="rm_rf!/1">
    <div class="detail-header">
    <a href="#rm_rf!/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">rm_rf!(path)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1183" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>rm_rf!(<a href="Path.html#t:t/0">Path.t</a>()) :: [<a href="typespecs.html#built-in-types">binary</a>()] | <a href="typespecs.html#built-in-types">no_return</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>Same as <a href="#rm_rf/1"><code class="inline">rm_rf/1</code></a> but raises <a href="File.Error.html"><code class="inline">File.Error</code></a> in case of failures,
otherwise the list of files or directories removed.</p>
  </section>
</div>
<div class="detail" id="rm_rf/1">
    <div class="detail-header">
    <a href="#rm_rf/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">rm_rf(path)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1093" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>rm_rf(<a href="Path.html#t:t/0">Path.t</a>()) :: {:ok, [<a href="typespecs.html#built-in-types">binary</a>()]} | {:error, <a href="#t:posix/0">posix</a>(), <a href="typespecs.html#built-in-types">binary</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Removes files and directories recursively at the given <code class="inline">path</code>.
Symlinks are not followed but simply removed, non-existing
files are simply ignored (i.e. doesn’t make this function fail).</p>
<p>Returns <code class="inline">{:ok, files_and_directories}</code> with all files and
directories removed in no specific order, <code class="inline">{:error, reason, file}</code>
otherwise.</p>
<h2 id="rm_rf/1-examples" class="section-heading">
  <a href="#rm_rf/1-examples" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  Examples
</h2>

<pre><code class="nohighlight makeup elixir"><span class="nc">File</span><span class="o">.</span><span class="n">rm_rf</span><span class="w"> </span><span class="s">&quot;samples&quot;</span><span class="w">
</span><span class="c1">#=&gt; {:ok, [&quot;samples&quot;, &quot;samples/1.txt&quot;]}</span><span class="w">

</span><span class="nc">File</span><span class="o">.</span><span class="n">rm_rf</span><span class="w"> </span><span class="s">&quot;unknown&quot;</span><span class="w">
</span><span class="c1">#=&gt; {:ok, []}</span></code></pre>
  </section>
</div>
<div class="detail" id="rmdir!/1">
    <div class="detail-header">
    <a href="#rmdir!/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">rmdir!(path)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1061" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>rmdir!(<a href="Path.html#t:t/0">Path.t</a>()) :: :ok | {:error, <a href="#t:posix/0">posix</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Same as <a href="#rmdir/1"><code class="inline">rmdir/1</code></a>, but raises an exception in case of failure. Otherwise <code class="inline">:ok</code>.</p>
  </section>
</div>
<div class="detail" id="rmdir/1">
    <div class="detail-header">
    <a href="#rmdir/1" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">rmdir(path)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1053" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>rmdir(<a href="Path.html#t:t/0">Path.t</a>()) :: :ok | {:error, <a href="#t:posix/0">posix</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Tries to delete the dir at <code class="inline">path</code>.</p>
<p>Returns <code class="inline">:ok</code> if successful, or <code class="inline">{:error, reason}</code> if an error occurs.
It returns <code class="inline">{:error, :eexist}</code> if the directory is not empty.</p>
<h2 id="rmdir/1-examples" class="section-heading">
  <a href="#rmdir/1-examples" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  Examples
</h2>

<pre><code class="nohighlight makeup elixir"><span class="nc">File</span><span class="o">.</span><span class="n">rmdir</span><span class="p" data-group-id="7953389351-1">(</span><span class="s">&quot;tmp_dir&quot;</span><span class="p" data-group-id="7953389351-1">)</span><span class="w">
</span><span class="c1">#=&gt; :ok</span><span class="w">

</span><span class="nc">File</span><span class="o">.</span><span class="n">rmdir</span><span class="p" data-group-id="7953389351-2">(</span><span class="s">&quot;non_empty_dir&quot;</span><span class="p" data-group-id="7953389351-2">)</span><span class="w">
</span><span class="c1">#=&gt; {:error, :eexist}</span><span class="w">

</span><span class="nc">File</span><span class="o">.</span><span class="n">rmdir</span><span class="p" data-group-id="7953389351-3">(</span><span class="s">&quot;file.txt&quot;</span><span class="p" data-group-id="7953389351-3">)</span><span class="w">
</span><span class="c1">#=&gt; {:error, :enotdir}</span></code></pre>
  </section>
</div>
<div class="detail" id="stat!/2">
  
    <span id="stat!/1"></span>
  <div class="detail-header">
    <a href="#stat!/2" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">stat!(path, opts \\ [])</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L361" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>stat!(<a href="Path.html#t:t/0">Path.t</a>(), <a href="#t:stat_options/0">stat_options</a>()) :: <a href="File.Stat.html#t:t/0">File.Stat.t</a>() | <a href="typespecs.html#built-in-types">no_return</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>Same as <a href="#stat/2"><code class="inline">stat/2</code></a> but returns the <a href="File.Stat.html"><code class="inline">File.Stat</code></a> directly, or
throws <a href="File.Error.html"><code class="inline">File.Error</code></a> if an error is returned.</p>
  </section>
</div>
<div class="detail" id="stat/2">
  
    <span id="stat/1"></span>
  <div class="detail-header">
    <a href="#stat/2" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">stat(path, opts \\ [])</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L344" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>stat(<a href="Path.html#t:t/0">Path.t</a>(), <a href="#t:stat_options/0">stat_options</a>()) :: {:ok, <a href="File.Stat.html#t:t/0">File.Stat.t</a>()} | {:error, <a href="#t:posix/0">posix</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Returns information about the <code class="inline">path</code>. If it exists, it
returns a <code class="inline">{:ok, info}</code> tuple, where info is a
<a href="File.Stat.html"><code class="inline">File.Stat</code></a> struct. Returns <code class="inline">{:error, reason}</code> with
the same reasons as <a href="#read/1"><code class="inline">read/1</code></a> if a failure occurs.</p>
<h2 id="stat/2-options" class="section-heading">
  <a href="#stat/2-options" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  Options
</h2>

<p>The accepted options are:</p>
<ul>
<li><code class="inline">:time</code> - configures how the file timestamps are returned
</li>
</ul>
<p>The values for <code class="inline">:time</code> can be:</p>
<ul>
<li><code class="inline">:universal</code> - returns a <code class="inline">{date, time}</code> tuple in UTC (default)
</li>
<li><code class="inline">:local</code> - returns a <code class="inline">{date, time}</code> tuple using the same time zone as the
machine
</li>
<li><code class="inline">:posix</code> - returns the time as integer seconds since epoch
</li>
</ul>
  </section>
</div>
<div class="detail" id="stream!/3">
  
    <span id="stream!/1"></span>

    <span id="stream!/2"></span>
  <div class="detail-header">
    <a href="#stream!/3" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">stream!(path, modes \\ [], line_or_bytes \\ :line)</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L1542" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>stream!(<a href="Path.html#t:t/0">Path.t</a>(), <a href="#t:stream_mode/0">stream_mode</a>(), :line | <a href="typespecs.html#basic-types">pos_integer</a>()) :: <a href="File.Stream.html#t:t/0">File.Stream.t</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>Returns a <a href="File.Stream.html"><code class="inline">File.Stream</code></a> for the given <code class="inline">path</code> with the given <code class="inline">modes</code>.</p>
<p>The stream implements both <a href="Enumerable.html"><code class="inline">Enumerable</code></a> and <a href="Collectable.html"><code class="inline">Collectable</code></a> protocols,
which means it can be used both for read and write.</p>
<p>The <code class="inline">line_or_bytes</code> argument configures how the file is read when
streaming, by <code class="inline">:line</code> (default) or by a given number of bytes.</p>
<p>Operating the stream can fail on open for the same reasons as
<a href="File.html#open!/2"><code class="inline">File.open!/2</code></a>. Note that the file is automatically opened each time streaming
begins. There is no need to pass <code class="inline">:read</code> and <code class="inline">:write</code> modes, as those are
automatically set by Elixir.</p>
<h2 id="stream!/3-raw-files" class="section-heading">
  <a href="#stream!/3-raw-files" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  Raw files
</h2>

<p>Since Elixir controls when the streamed file is opened, the underlying
device cannot be shared and as such it is convenient to open the file
in raw mode for performance reasons. Therefore, Elixir <strong>will</strong> open
streams in <code class="inline">:raw</code> mode with the <code class="inline">:read_ahead</code> option unless an encoding
is specified. This means any data streamed into the file must be
converted to <a href="typespecs.html#built-in-types"><code class="inline">iodata/0</code></a> type. If you pass e.g. <code class="inline">[encoding: :utf8]</code>
or <code class="inline">[encoding: {:utf16, :little}]</code> in the modes parameter,
the underlying stream will use <a href="IO.html#write/2"><code class="inline">IO.write/2</code></a> and the <a href="String.Chars.html"><code class="inline">String.Chars</code></a> protocol
to convert the data. See <a href="IO.html#binwrite/2"><code class="inline">IO.binwrite/2</code></a> and <a href="IO.html#write/2"><code class="inline">IO.write/2</code></a> .</p>
<p>One may also consider passing the <code class="inline">:delayed_write</code> option if the stream
is meant to be written to under a tight loop.</p>
<h2 id="stream!/3-byte-order-marks" class="section-heading">
  <a href="#stream!/3-byte-order-marks" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  Byte order marks
</h2>

<p>If you pass <code class="inline">:trim_bom</code> in the modes parameter, the stream will
trim UTF-8, UTF-16 and UTF-32 byte order marks when reading from file.</p>
<p>Note that this function does not try to discover the file encoding basing
on BOM.</p>
<h2 id="stream!/3-examples" class="section-heading">
  <a href="#stream!/3-examples" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
  Examples
</h2>

<pre><code class="nohighlight makeup elixir"><span class="c1"># Read in 2048 byte chunks rather than lines</span><span class="w">
</span><span class="nc">File</span><span class="o">.</span><span class="n">stream!</span><span class="p" data-group-id="8156520136-1">(</span><span class="s">&quot;./test/test.data&quot;</span><span class="p">,</span><span class="w"> </span><span class="p" data-group-id="8156520136-2">[</span><span class="p" data-group-id="8156520136-2">]</span><span class="p">,</span><span class="w"> </span><span class="mi">2048</span><span class="p" data-group-id="8156520136-1">)</span><span class="w">
</span><span class="c1">#=&gt; %File.Stream{line_or_bytes: 2048, modes: [:raw, :read_ahead, :binary],</span><span class="w">
</span><span class="c1">#=&gt;   path: &quot;./test/test.data&quot;, raw: true}</span></code></pre>
<p>See <a href="Stream.html#run/1"><code class="inline">Stream.run/1</code></a> for an example of streaming into a file.</p>
  </section>
</div>
<div class="detail" id="touch!/2">
  
    <span id="touch!/1"></span>
  <div class="detail-header">
    <a href="#touch!/2" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">touch!(path, time \\ :calendar.universal_time())</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L522" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>touch!(<a href="Path.html#t:t/0">Path.t</a>(), <a href="http://www.erlang.org/doc/man/calendar.html#type-datetime">:calendar.datetime</a>()) :: :ok | <a href="typespecs.html#built-in-types">no_return</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>Same as <a href="#touch/2"><code class="inline">touch/2</code></a> but raises an exception if it fails.</p>
<p>Returns <code class="inline">:ok</code> otherwise. Requires datetime in UTC.</p>
  </section>
</div>
<div class="detail" id="touch/2">
  
    <span id="touch/1"></span>
  <div class="detail-header">
    <a href="#touch/2" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">touch(path, time \\ :calendar.universal_time())</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L500" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>touch(<a href="Path.html#t:t/0">Path.t</a>(), <a href="http://www.erlang.org/doc/man/calendar.html#type-datetime">:calendar.datetime</a>()) :: :ok | {:error, <a href="#t:posix/0">posix</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Updates modification time (mtime) and access time (atime) of
the given file.</p>
<p>The file is created if it doesn’t exist. Requires datetime in UTC.</p>
  </section>
</div>
<div class="detail" id="write!/3">
  
    <span id="write!/2"></span>
  <div class="detail-header">
    <a href="#write!/3" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">write!(path, content, modes \\ [])</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L945" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>write!(<a href="Path.html#t:t/0">Path.t</a>(), <a href="typespecs.html#built-in-types">iodata</a>(), [<a href="#t:mode/0">mode</a>()]) :: :ok | <a href="typespecs.html#built-in-types">no_return</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>Same as <a href="#write/3"><code class="inline">write/3</code></a> but raises an exception if it fails, returns <code class="inline">:ok</code> otherwise.</p>
  </section>
</div>
<div class="detail" id="write/3">
  
    <span id="write/2"></span>
  <div class="detail-header">
    <a href="#write/3" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">write(path, content, modes \\ [])</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L936" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>write(<a href="Path.html#t:t/0">Path.t</a>(), <a href="typespecs.html#built-in-types">iodata</a>(), [<a href="#t:mode/0">mode</a>()]) :: :ok | {:error, <a href="#t:posix/0">posix</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Writes <code class="inline">content</code> to the file <code class="inline">path</code>.</p>
<p>The file is created if it does not exist. If it exists, the previous
contents are overwritten. Returns <code class="inline">:ok</code> if successful, or <code class="inline">{:error, reason}</code>
if an error occurs.</p>
<p><code class="inline">content</code> must be <code class="inline">iodata</code> (a list of bytes or a binary). Setting the
encoding for this function has no effect.</p>
<p><strong>Warning:</strong> Every time this function is invoked, a file descriptor is opened
and a new process is spawned to write to the file. For this reason, if you are
doing multiple writes in a loop, opening the file via <a href="File.html#open/2"><code class="inline">File.open/2</code></a> and using
the functions in <a href="IO.html"><code class="inline">IO</code></a> to write to the file will yield much better performance
than calling this function multiple times.</p>
<p>Typical error reasons are:</p>
<ul>
<li><code class="inline">:enoent</code>  - a component of the file name does not exist
</li>
<li><code class="inline">:enotdir</code> - a component of the file name is not a directory;
on some platforms, <code class="inline">:enoent</code> is returned instead
</li>
<li><code class="inline">:enospc</code>  - there is no space left on the device
</li>
<li><code class="inline">:eacces</code>  - missing permission for writing the file or searching one of
the parent directories
</li>
<li><code class="inline">:eisdir</code>  - the named file is a directory
</li>
</ul>
<p>Check <a href="File.html#open/2"><code class="inline">File.open/2</code></a> for other available options.</p>
  </section>
</div>
<div class="detail" id="write_stat!/3">
  
    <span id="write_stat!/2"></span>
  <div class="detail-header">
    <a href="#write_stat!/3" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">write_stat!(path, stat, opts \\ [])</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L480" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>write_stat!(<a href="Path.html#t:t/0">Path.t</a>(), <a href="File.Stat.html#t:t/0">File.Stat.t</a>(), <a href="#t:stat_options/0">stat_options</a>()) :: :ok | <a href="typespecs.html#built-in-types">no_return</a>()</pre>
      </div>
  </div>
  <section class="docstring">
<p>Same as <a href="#write_stat/3"><code class="inline">write_stat/3</code></a> but raises an exception if it fails.
Returns <code class="inline">:ok</code> otherwise.</p>
  </section>
</div>
<div class="detail" id="write_stat/3">
  
    <span id="write_stat/2"></span>
  <div class="detail-header">
    <a href="#write_stat/3" class="detail-link" title="Link to this function">
      <span class="icon-link" aria-hidden="true"></span>
      <span class="sr-only">Link to this function</span>
    </a>
    <span class="signature">write_stat(path, stat, opts \\ [])</span>
      <a href="https://github.com/elixir-lang/elixir/blob/v1.7.2/lib/elixir/lib/file.ex#L470" class="view-source" rel="help" title="View Source">
       <span class="icon-code" aria-hidden="true"></span>
       <span class="sr-only">View Source</span>
     </a>
        
      <div class="specs">
          <pre>write_stat(<a href="Path.html#t:t/0">Path.t</a>(), <a href="File.Stat.html#t:t/0">File.Stat.t</a>(), <a href="#t:stat_options/0">stat_options</a>()) :: :ok | {:error, <a href="#t:posix/0">posix</a>()}</pre>
      </div>
  </div>
  <section class="docstring">
<p>Writes the given <a href="File.Stat.html"><code class="inline">File.Stat</code></a> back to the filesystem at the given
path. Returns <code class="inline">:ok</code> or <code class="inline">{:error, reason}</code>.</p>
  </section>
</div>
        </section>

          <footer class="footer">
        <p>
          <span class="line">
            Built using
            <a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" target="_blank" rel="help noopener">ExDoc</a> (v0.19.1),
          </span>
          <span class="line">
            designed by
            <a href="https://twitter.com/dignifiedquire" target="_blank" rel="noopener" title="@dignifiedquire">Friedel Ziegelmayer</a>.
            </span>
        </p>
      </footer>
    </div>
  </div>
</section>
</div>
  <script src="dist/app-a0c90688fa.js"></script>
  
  </body>
</html>