ocaml-containers/dev/containers/CCIO/File/index.html
2023-02-15 17:36:59 +00:00

7 lines
No EOL
12 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>File (containers.CCIO.File)</title><link rel="stylesheet" href="../../../_odoc-theme/odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 2.2.0"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> <a href="../../index.html">containers</a> &#x00BB; <a href="../index.html">CCIO</a> &#x00BB; File</nav><header class="odoc-preamble"><h1>Module <code><span>CCIO.File</span></code></h1></header><div class="odoc-content"><div class="odoc-spec"><div class="spec type anchored" id="type-t"><a href="#type-t" class="anchor"></a><code><span><span class="keyword">type</span> t</span><span> = string</span></code></div><div class="spec-doc"><p>A file should be represented by its absolute path, but currently this is not enforced.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-to_string"><a href="#val-to_string" class="anchor"></a><code><span><span class="keyword">val</span> to_string : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> string</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-make"><a href="#val-make" class="anchor"></a><code><span><span class="keyword">val</span> make : <span>string <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Build a file representation from a path (absolute or relative).</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-exists"><a href="#val-exists" class="anchor"></a><code><span><span class="keyword">val</span> exists : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> bool</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-is_directory"><a href="#val-is_directory" class="anchor"></a><code><span><span class="keyword">val</span> is_directory : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> bool</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-remove_exn"><a href="#val-remove_exn" class="anchor"></a><code><span><span class="keyword">val</span> remove_exn : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p><code>remove_exn path</code> tries to remove the file at <code>path</code> from the file system.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Sys_error</span> <p>if there is no file at <code>path</code> or access rights are wrong.</p></li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.8</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-remove"><a href="#val-remove" class="anchor"></a><code><span><span class="keyword">val</span> remove : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>unit <a href="../index.html#type-or_error">or_error</a></span></span></code></div><div class="spec-doc"><p>Like <code>remove_exn</code> but with an error monad.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.8</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-remove_noerr"><a href="#val-remove_noerr" class="anchor"></a><code><span><span class="keyword">val</span> remove_noerr : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p>Like <code>remove_exn</code> but do not raise any exception on failure.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.8</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-read_dir"><a href="#val-read_dir" class="anchor"></a><code><span><span class="keyword">val</span> read_dir : <span>?recurse:bool <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <a href="../index.html#type-gen">gen</a></span></span></code></div><div class="spec-doc"><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><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Sys_error</span> <p>in case of error (e.g. permission denied).</p></li></ul><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">recurse</span> <p>if true (default <code>false</code>), sub-directories are also explored.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-read_exn"><a href="#val-read_exn" class="anchor"></a><code><span><span class="keyword">val</span> read_exn : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p>Read the content of the given file, or raises some exception.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Sys_error</span> <p>in case of error.</p></li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.16</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-read"><a href="#val-read" class="anchor"></a><code><span><span class="keyword">val</span> read : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>string <a href="../index.html#type-or_error">or_error</a></span></span></code></div><div class="spec-doc"><p>Read the content of the given file.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.16</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-append_exn"><a href="#val-append_exn" class="anchor"></a><code><span><span class="keyword">val</span> append_exn : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p>Append the given string into the given file, possibly raising.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Sys_error</span> <p>in case of error.</p></li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.16</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-append"><a href="#val-append" class="anchor"></a><code><span><span class="keyword">val</span> append : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> <span>unit <a href="../index.html#type-or_error">or_error</a></span></span></code></div><div class="spec-doc"><p>Append the given string into the given file.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.16</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-write_exn"><a href="#val-write_exn" class="anchor"></a><code><span><span class="keyword">val</span> write_exn : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p>Write the given string into the given file, possibly raising.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Sys_error</span> <p>in case of error.</p></li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.16</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-write"><a href="#val-write" class="anchor"></a><code><span><span class="keyword">val</span> write : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span>string <span class="arrow">&#45;&gt;</span></span> <span>unit <a href="../index.html#type-or_error">or_error</a></span></span></code></div><div class="spec-doc"><p>Write the given string into the given file.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.16</li></ul></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-walk_item"><a href="#type-walk_item" class="anchor"></a><code><span><span class="keyword">type</span> walk_item</span><span> = <span>[ `File <span>| `Dir</span> ]</span> * <a href="#type-t">t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-walk"><a href="#val-walk" class="anchor"></a><code><span><span class="keyword">val</span> walk : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-walk_item">walk_item</a> <a href="../index.html#type-gen">gen</a></span></span></code></div><div class="spec-doc"><p>Like <a href="#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="#val-is_directory"><code>is_directory</code></a> (including symlinks, etc.)</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Sys_error</span> <p>in case of error (e.g. permission denied) during iteration.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-walk_iter"><a href="#val-walk_iter" class="anchor"></a><code><span><span class="keyword">val</span> walk_iter : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-walk_item">walk_item</a> <a href="../index.html#type-iter">iter</a></span></span></code></div><div class="spec-doc"><p>Like <a href="#val-walk"><code>walk</code></a> but with an imperative iterator.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 3.6</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-walk_l"><a href="#val-walk_l" class="anchor"></a><code><span><span class="keyword">val</span> walk_l : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-walk_item">walk_item</a> list</span></span></code></div><div class="spec-doc"><p>Like <a href="#val-walk"><code>walk</code></a> but returns a list (therefore it's eager and might take some time on large directories).</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 1.1</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-walk_seq"><a href="#val-walk_seq" class="anchor"></a><code><span><span class="keyword">val</span> walk_seq : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-walk_item">walk_item</a> <a href="../../../ocaml/Stdlib/Seq/index.html#type-t">Stdlib.Seq.t</a></span></span></code></div><div class="spec-doc"><p>Like <a href="#val-walk"><code>walk</code></a> but returns a Seq</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 3.6</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-show_walk_item"><a href="#val-show_walk_item" class="anchor"></a><code><span><span class="keyword">val</span> show_walk_item : <span><a href="#type-walk_item">walk_item</a> <span class="arrow">&#45;&gt;</span></span> string</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-with_temp"><a href="#val-with_temp" class="anchor"></a><code><span><span class="keyword">val</span> with_temp :
<span>?temp_dir:string <span class="arrow">&#45;&gt;</span></span>
<span>prefix:string <span class="arrow">&#45;&gt;</span></span>
<span>suffix:string <span class="arrow">&#45;&gt;</span></span>
<span><span>(<span>string <span class="arrow">&#45;&gt;</span></span> <span class="type-var">'a</span>)</span> <span class="arrow">&#45;&gt;</span></span>
<span class="type-var">'a</span></span></code></div><div class="spec-doc"><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 <code>Filename</code>.temp_file.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.17</li></ul></div></div></div></body></html>