mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
2 lines
No EOL
9.1 KiB
HTML
2 lines
No EOL
9.1 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>File (containers.CCIO.File)</title><link rel="stylesheet" href="../../../odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 1.5.3"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div class="content"><header><nav><a href="../index.html">Up</a> – <a href="../../index.html">containers</a> » <a href="../index.html">CCIO</a> » File</nav><h1>Module <code>CCIO.File</code></h1></header><dl><dt class="spec type" id="type-t"><a href="#type-t" class="anchor"></a><code><span class="keyword">type</span> t</code><code> = string</code></dt><dd><p>A file should be represented by its absolute path, but currently this is not enforced.</p></dd></dl><dl><dt class="spec value" id="val-to_string"><a href="#val-to_string" class="anchor"></a><code><span class="keyword">val</span> to_string : <a href="index.html#type-t">t</a> <span>-></span> string</code></dt><dt class="spec value" id="val-make"><a href="#val-make" class="anchor"></a><code><span class="keyword">val</span> make : string <span>-></span> <a href="index.html#type-t">t</a></code></dt><dd><p>Build a file representation from a path (absolute or relative).</p></dd></dl><dl><dt class="spec value" id="val-exists"><a href="#val-exists" class="anchor"></a><code><span class="keyword">val</span> exists : <a href="index.html#type-t">t</a> <span>-></span> bool</code></dt><dt class="spec value" id="val-is_directory"><a href="#val-is_directory" class="anchor"></a><code><span class="keyword">val</span> is_directory : <a href="index.html#type-t">t</a> <span>-></span> bool</code></dt><dt class="spec value" id="val-remove_exn"><a href="#val-remove_exn" class="anchor"></a><code><span class="keyword">val</span> remove_exn : <a href="index.html#type-t">t</a> <span>-></span> unit</code></dt><dd><p><code>remove_exn path</code> tries to remove the file at <code>path</code> from the file system.</p><dl><dt>raises Sys_error</dt><dd><p>if there is no file at <code>path</code> or access rights are wrong.</p></dd></dl><dl><dt>since</dt><dd>0.8</dd></dl></dd></dl><dl><dt class="spec value" id="val-remove"><a href="#val-remove" class="anchor"></a><code><span class="keyword">val</span> remove : <a href="index.html#type-t">t</a> <span>-></span> <span>unit <a href="../index.html#type-or_error">or_error</a></span></code></dt><dd><p>Like <code>remove_exn</code> but with an error monad.</p><dl><dt>since</dt><dd>0.8</dd></dl></dd></dl><dl><dt class="spec value" id="val-remove_noerr"><a href="#val-remove_noerr" class="anchor"></a><code><span class="keyword">val</span> remove_noerr : <a href="index.html#type-t">t</a> <span>-></span> unit</code></dt><dd><p>Like <code>remove_exn</code> but do not raise any exception on failure.</p><dl><dt>since</dt><dd>0.8</dd></dl></dd></dl><dl><dt class="spec value" id="val-read_dir"><a href="#val-read_dir" class="anchor"></a><code><span class="keyword">val</span> read_dir : <span>?⁠recurse:bool</span> <span>-></span> <a href="index.html#type-t">t</a> <span>-></span> <span><a href="index.html#type-t">t</a> <a href="../index.html#type-gen">gen</a></span></code></dt><dd><p><code>read_dir d</code> returns a sequence of files and directory contained in the directory <code>d</code> (or an empty stream if <code>d</code> is not a directory).</p><dl><dt>raises Sys_error</dt><dd><p>in case of error (e.g. permission denied).</p></dd></dl><dl><dt>parameter recurse</dt><dd><p>if true (default <code>false</code>), sub-directories are also explored.</p></dd></dl></dd></dl><dl><dt class="spec value" id="val-read_exn"><a href="#val-read_exn" class="anchor"></a><code><span class="keyword">val</span> read_exn : <a href="index.html#type-t">t</a> <span>-></span> string</code></dt><dd><p>Read the content of the given file, or raises some exception.</p><dl><dt>raises Sys_error</dt><dd><p>in case of error.</p></dd></dl><dl><dt>since</dt><dd>0.16</dd></dl></dd></dl><dl><dt class="spec value" id="val-read"><a href="#val-read" class="anchor"></a><code><span class="keyword">val</span> read : <a href="index.html#type-t">t</a> <span>-></span> <span>string <a href="../index.html#type-or_error">or_error</a></span></code></dt><dd><p>Read the content of the given file.</p><dl><dt>since</dt><dd>0.16</dd></dl></dd></dl><dl><dt class="spec value" id="val-append_exn"><a href="#val-append_exn" class="anchor"></a><code><span class="keyword">val</span> append_exn : <a href="index.html#type-t">t</a> <span>-></span> string <span>-></span> unit</code></dt><dd><p>Append the given string into the given file, possibly raising.</p><dl><dt>raises Sys_error</dt><dd><p>in case of error.</p></dd></dl><dl><dt>since</dt><dd>0.16</dd></dl></dd></dl><dl><dt class="spec value" id="val-append"><a href="#val-append" class="anchor"></a><code><span class="keyword">val</span> append : <a href="index.html#type-t">t</a> <span>-></span> string <span>-></span> <span>unit <a href="../index.html#type-or_error">or_error</a></span></code></dt><dd><p>Append the given string into the given file.</p><dl><dt>since</dt><dd>0.16</dd></dl></dd></dl><dl><dt class="spec value" id="val-write_exn"><a href="#val-write_exn" class="anchor"></a><code><span class="keyword">val</span> write_exn : <a href="index.html#type-t">t</a> <span>-></span> string <span>-></span> unit</code></dt><dd><p>Write the given string into the given file, possibly raising.</p><dl><dt>raises Sys_error</dt><dd><p>in case of error.</p></dd></dl><dl><dt>since</dt><dd>0.16</dd></dl></dd></dl><dl><dt class="spec value" id="val-write"><a href="#val-write" class="anchor"></a><code><span class="keyword">val</span> write : <a href="index.html#type-t">t</a> <span>-></span> string <span>-></span> <span>unit <a href="../index.html#type-or_error">or_error</a></span></code></dt><dd><p>Write the given string into the given file.</p><dl><dt>since</dt><dd>0.16</dd></dl></dd></dl><dl><dt class="spec type" id="type-walk_item"><a href="#type-walk_item" class="anchor"></a><code><span class="keyword">type</span> walk_item</code><code> = <span>[ `File <span>| `Dir</span> ]</span> * <a href="index.html#type-t">t</a></code></dt></dl><dl><dt class="spec value" id="val-walk"><a href="#val-walk" class="anchor"></a><code><span class="keyword">val</span> walk : <a href="index.html#type-t">t</a> <span>-></span> <span><a href="index.html#type-walk_item">walk_item</a> <a href="../index.html#type-gen">gen</a></span></code></dt><dd><p>Like <a href="index.html#val-read_dir"><code>read_dir</code></a> (with <code>recurse=true</code>), this function walks a directory recursively and yields either files or directories. Is a file anything that doesn't satisfy <a href="index.html#val-is_directory"><code>is_directory</code></a> (including symlinks, etc.)</p><dl><dt>raises Sys_error</dt><dd><p>in case of error (e.g. permission denied) during iteration.</p></dd></dl></dd></dl><dl><dt class="spec value" id="val-walk_iter"><a href="#val-walk_iter" class="anchor"></a><code><span class="keyword">val</span> walk_iter : <a href="index.html#type-t">t</a> <span>-></span> <span><a href="index.html#type-walk_item">walk_item</a> <a href="../index.html#type-iter">iter</a></span></code></dt><dd><p>Like <a href="index.html#val-walk"><code>walk</code></a> but with an imperative iterator.</p><dl><dt>since</dt><dd>NEXT_RELEASE</dd></dl></dd></dl><dl><dt class="spec value" id="val-walk_l"><a href="#val-walk_l" class="anchor"></a><code><span class="keyword">val</span> walk_l : <a href="index.html#type-t">t</a> <span>-></span> <span><a href="index.html#type-walk_item">walk_item</a> list</span></code></dt><dd><p>Like <a href="index.html#val-walk"><code>walk</code></a> but returns a list (therefore it's eager and might take some time on large directories).</p><dl><dt>since</dt><dd>1.1</dd></dl></dd></dl><dl><dt class="spec value" id="val-show_walk_item"><a href="#val-show_walk_item" class="anchor"></a><code><span class="keyword">val</span> show_walk_item : <a href="index.html#type-walk_item">walk_item</a> <span>-></span> string</code></dt><dt class="spec value" id="val-with_temp"><a href="#val-with_temp" class="anchor"></a><code><span class="keyword">val</span> with_temp : <span>?⁠temp_dir:string</span> <span>-></span> <span>prefix:string</span> <span>-></span> <span>suffix:string</span> <span>-></span> <span>(string <span>-></span> <span class="type-var">'a</span>)</span> <span>-></span> <span class="type-var">'a</span></code></dt><dd><p><code>with_temp ~prefix ~suffix f</code> will call <code>f</code> with the name of a new temporary file (located in <code>temp_dir</code>). After <code>f</code> returns, the file is deleted. Best to be used in combination with <a href="../index.html#val-with_out"><code>with_out</code></a>. See <span class="xref-unresolved" title="unresolved reference to "Filename.temp_file""><code>Filename</code>.temp_file</span>.</p><dl><dt>since</dt><dd>0.17</dd></dl></dd></dl></div></body></html> |