Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > ac00cb96767d9c54367b331f839b9a30 > files > 168

ocaml-batteries-2.1-3.mga4.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<link rel="Start" href="index.html">
<link rel="previous" href="BatEnum.html">
<link rel="next" href="BatFingerTree.html">
<link rel="Up" href="index.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of class methods" rel=Appendix href="index_methods.html">
<link title="Index of classes" rel=Appendix href="index_classes.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Index of module types" rel=Appendix href="index_module_types.html">
<link title="BatArray" rel="Chapter" href="BatArray.html">
<link title="BatAvlTree" rel="Chapter" href="BatAvlTree.html">
<link title="BatBase64" rel="Chapter" href="BatBase64.html">
<link title="BatBig_int" rel="Chapter" href="BatBig_int.html">
<link title="BatBigarray" rel="Chapter" href="BatBigarray.html">
<link title="BatBitSet" rel="Chapter" href="BatBitSet.html">
<link title="BatBool" rel="Chapter" href="BatBool.html">
<link title="BatBounded" rel="Chapter" href="BatBounded.html">
<link title="BatBuffer" rel="Chapter" href="BatBuffer.html">
<link title="BatCache" rel="Chapter" href="BatCache.html">
<link title="BatChar" rel="Chapter" href="BatChar.html">
<link title="BatCharParser" rel="Chapter" href="BatCharParser.html">
<link title="BatComplex" rel="Chapter" href="BatComplex.html">
<link title="BatConcurrent" rel="Chapter" href="BatConcurrent.html">
<link title="BatDeque" rel="Chapter" href="BatDeque.html">
<link title="BatDigest" rel="Chapter" href="BatDigest.html">
<link title="BatDllist" rel="Chapter" href="BatDllist.html">
<link title="BatDynArray" rel="Chapter" href="BatDynArray.html">
<link title="BatEnum" rel="Chapter" href="BatEnum.html">
<link title="BatFile" rel="Chapter" href="BatFile.html">
<link title="BatFingerTree" rel="Chapter" href="BatFingerTree.html">
<link title="BatFloat" rel="Chapter" href="BatFloat.html">
<link title="BatFormat" rel="Chapter" href="BatFormat.html">
<link title="BatGc" rel="Chapter" href="BatGc.html">
<link title="BatGenlex" rel="Chapter" href="BatGenlex.html">
<link title="BatGlobal" rel="Chapter" href="BatGlobal.html">
<link title="BatHashcons" rel="Chapter" href="BatHashcons.html">
<link title="BatHashtbl" rel="Chapter" href="BatHashtbl.html">
<link title="BatHeap" rel="Chapter" href="BatHeap.html">
<link title="BatIMap" rel="Chapter" href="BatIMap.html">
<link title="BatIO" rel="Chapter" href="BatIO.html">
<link title="BatISet" rel="Chapter" href="BatISet.html">
<link title="BatInnerIO" rel="Chapter" href="BatInnerIO.html">
<link title="BatInnerPervasives" rel="Chapter" href="BatInnerPervasives.html">
<link title="BatInnerWeaktbl" rel="Chapter" href="BatInnerWeaktbl.html">
<link title="BatInt" rel="Chapter" href="BatInt.html">
<link title="BatInt32" rel="Chapter" href="BatInt32.html">
<link title="BatInt64" rel="Chapter" href="BatInt64.html">
<link title="BatInterfaces" rel="Chapter" href="BatInterfaces.html">
<link title="BatLazyList" rel="Chapter" href="BatLazyList.html">
<link title="BatLexing" rel="Chapter" href="BatLexing.html">
<link title="BatList" rel="Chapter" href="BatList.html">
<link title="BatLog" rel="Chapter" href="BatLog.html">
<link title="BatLogger" rel="Chapter" href="BatLogger.html">
<link title="BatMap" rel="Chapter" href="BatMap.html">
<link title="BatMarshal" rel="Chapter" href="BatMarshal.html">
<link title="BatMultiMap" rel="Chapter" href="BatMultiMap.html">
<link title="BatMultiPMap" rel="Chapter" href="BatMultiPMap.html">
<link title="BatMutex" rel="Chapter" href="BatMutex.html">
<link title="BatNativeint" rel="Chapter" href="BatNativeint.html">
<link title="BatNum" rel="Chapter" href="BatNum.html">
<link title="BatNumber" rel="Chapter" href="BatNumber.html">
<link title="BatOo" rel="Chapter" href="BatOo.html">
<link title="BatOptParse" rel="Chapter" href="BatOptParse.html">
<link title="BatOption" rel="Chapter" href="BatOption.html">
<link title="BatOrd" rel="Chapter" href="BatOrd.html">
<link title="BatParserCo" rel="Chapter" href="BatParserCo.html">
<link title="BatPathGen" rel="Chapter" href="BatPathGen.html">
<link title="BatPervasives" rel="Chapter" href="BatPervasives.html">
<link title="BatPrintexc" rel="Chapter" href="BatPrintexc.html">
<link title="BatPrintf" rel="Chapter" href="BatPrintf.html">
<link title="BatQueue" rel="Chapter" href="BatQueue.html">
<link title="BatRMutex" rel="Chapter" href="BatRMutex.html">
<link title="BatRandom" rel="Chapter" href="BatRandom.html">
<link title="BatRef" rel="Chapter" href="BatRef.html">
<link title="BatRefList" rel="Chapter" href="BatRefList.html">
<link title="BatResult" rel="Chapter" href="BatResult.html">
<link title="BatReturn" rel="Chapter" href="BatReturn.html">
<link title="BatScanf" rel="Chapter" href="BatScanf.html">
<link title="BatSeq" rel="Chapter" href="BatSeq.html">
<link title="BatSet" rel="Chapter" href="BatSet.html">
<link title="BatSplay" rel="Chapter" href="BatSplay.html">
<link title="BatStack" rel="Chapter" href="BatStack.html">
<link title="BatStream" rel="Chapter" href="BatStream.html">
<link title="BatString" rel="Chapter" href="BatString.html">
<link title="BatSubstring" rel="Chapter" href="BatSubstring.html">
<link title="BatSys" rel="Chapter" href="BatSys.html">
<link title="BatText" rel="Chapter" href="BatText.html">
<link title="BatTuple" rel="Chapter" href="BatTuple.html">
<link title="BatUChar" rel="Chapter" href="BatUChar.html">
<link title="BatUTF8" rel="Chapter" href="BatUTF8.html">
<link title="BatUnit" rel="Chapter" href="BatUnit.html">
<link title="BatUnix" rel="Chapter" href="BatUnix.html">
<link title="BatUref" rel="Chapter" href="BatUref.html">
<link title="BatVect" rel="Chapter" href="BatVect.html">
<link title="Batteries" rel="Chapter" href="Batteries.html">
<link title="BatteriesConfig" rel="Chapter" href="BatteriesConfig.html">
<link title="BatteriesPrint" rel="Chapter" href="BatteriesPrint.html">
<link title="BatteriesThread" rel="Chapter" href="BatteriesThread.html">
<link title="Extlib" rel="Chapter" href="Extlib.html"><link title="Utilities" rel="Section" href="#6_Utilities">
<link title="File permissions" rel="Section" href="#6_Filepermissions">
<link title="Opening a file for reading" rel="Section" href="#6_Openingafileforreading">
<link title="Opening a file for writing" rel="Section" href="#6_Openingafileforwriting">
<link title="Opening a temporary file for writing" rel="Section" href="#6_Openingatemporaryfileforwriting">
<title>Batteries user guide : BatFile</title>
</head>
<body>
<div class="navbar"><a class="pre" href="BatEnum.html" title="BatEnum">Previous</a>
&nbsp;<a class="up" href="index.html" title="Index">Up</a>
&nbsp;<a class="post" href="BatFingerTree.html" title="BatFingerTree">Next</a>
</div>
<h1>Module <a href="type_BatFile.html">BatFile</a></h1>

<pre><span class="keyword">module</span> BatFile: <code class="code"><span class="keyword">sig</span></code> <a href="BatFile.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info module top">
File manipulation.<br>
<b>Author(s):</b> David Teller<br>
</div>
<hr width="100%">
<br>
<h6 id="6_Utilities">Utilities</h6><br>

<pre><span id="VALlines_of"><span class="keyword">val</span> lines_of</span> : <code class="type">string -> string <a href="BatEnum.html#TYPEt">BatEnum.t</a></code></pre><div class="info ">
<code class="code">line_of name</code> reads the contents of file <code class="code">name</code> as an enumeration of lines.
    The file is automatically closed once the last line has been reached or the
    enumeration is garbage-collected.<br>
</div>

<pre><span id="VALwrite_lines"><span class="keyword">val</span> write_lines</span> : <code class="type">string -> string <a href="BatEnum.html#TYPEt">BatEnum.t</a> -> unit</code></pre><div class="info ">
<code class="code">write_lines name lines</code> writes strings given by <code class="code">lines</code> to file <code class="code">name</code> with newline character appended to each line.<br>
</div>

<pre><span id="VALsize_of"><span class="keyword">val</span> size_of</span> : <code class="type">string -> int</code></pre><div class="info ">
<code class="code">size_of name</code> returns the size of file <code class="code">name</code> in bytes.<br>
</div>

<pre><span id="VALsize_of_big"><span class="keyword">val</span> size_of_big</span> : <code class="type">string -> Int64.t</code></pre><div class="info ">
<code class="code">size_of_big name</code> returns the size of file <code class="code">name</code> in bytes, as a 64-bit integer.
<p>

    This function is provided as the size of a file larger than 1 Gb cannot
    be represented with an <code class="code">int</code> on a 32-bit machine.<br>
</div>
<br>
<h6 id="6_Filepermissions">File permissions</h6>
<p>

    File permissions are used when creating a file to allow controlling which users
    may read, write or open that file. To use a permission, create a value of type
    <a href="BatFile.html#TYPEpermission"><code class="code"><span class="constructor">BatFile</span>.permission</code></a> and pass it as argument to <a href="BatFile.html#VALopen_in"><code class="code"><span class="constructor">BatFile</span>.open_in</code></a>, <a href="BatFile.html#VALopen_out"><code class="code"><span class="constructor">BatFile</span>.open_out</code></a>, <a href="BatFile.html#VALwith_file_in"><code class="code"><span class="constructor">BatFile</span>.with_file_in</code></a> or
    <a href="BatFile.html#VALwith_file_out"><code class="code"><span class="constructor">BatFile</span>.with_file_out</code></a>.<br>

<pre><span id="TYPEpermission"><span class="keyword">type</span> <code class="type"></code>permission</span> </pre>
<div class="info ">
The list of operations which are permitted on a file.<br>
</div>


<pre><span id="VALdefault_permission"><span class="keyword">val</span> default_permission</span> : <code class="type"><a href="BatFile.html#TYPEpermission">permission</a></code></pre><div class="info ">
Default permissions.<br>
</div>

<pre><span id="VALuser_read"><span class="keyword">val</span> user_read</span> : <code class="type"><a href="BatFile.html#TYPEpermission">permission</a></code></pre><div class="info ">
Give the current user permission to read the file.
   Ignored under Windows.<br>
</div>

<pre><span id="VALuser_write"><span class="keyword">val</span> user_write</span> : <code class="type"><a href="BatFile.html#TYPEpermission">permission</a></code></pre><div class="info ">
Give the current user permission to write the file<br>
</div>

<pre><span id="VALuser_exec"><span class="keyword">val</span> user_exec</span> : <code class="type"><a href="BatFile.html#TYPEpermission">permission</a></code></pre><div class="info ">
Give the current user permission to execute the file.
   Ignored under Windows.<br>
</div>

<pre><span id="VALgroup_read"><span class="keyword">val</span> group_read</span> : <code class="type"><a href="BatFile.html#TYPEpermission">permission</a></code></pre><div class="info ">
Give the permission to read the file to the group
   containing the user. Ignored under Windows.<br>
</div>

<pre><span id="VALgroup_write"><span class="keyword">val</span> group_write</span> : <code class="type"><a href="BatFile.html#TYPEpermission">permission</a></code></pre><div class="info ">
Give the permission to write the file to the group
   containing the user. Ignored under Windows.<br>
</div>

<pre><span id="VALgroup_exec"><span class="keyword">val</span> group_exec</span> : <code class="type"><a href="BatFile.html#TYPEpermission">permission</a></code></pre><div class="info ">
Give the permission to execute the file to the group
   containing the user. Ignored under Windows.<br>
</div>

<pre><span id="VALother_read"><span class="keyword">val</span> other_read</span> : <code class="type"><a href="BatFile.html#TYPEpermission">permission</a></code></pre><div class="info ">
Give the permission to read the file to the rest
   of the world. Ignored under Windows.<br>
</div>

<pre><span id="VALother_write"><span class="keyword">val</span> other_write</span> : <code class="type"><a href="BatFile.html#TYPEpermission">permission</a></code></pre><div class="info ">
Give the permission to modify the file to the rest
   of the world. Ignored under Windows.<br>
</div>

<pre><span id="VALother_exec"><span class="keyword">val</span> other_exec</span> : <code class="type"><a href="BatFile.html#TYPEpermission">permission</a></code></pre><div class="info ">
Give the permission to execute the file to the rest
   of the world. Ignored under Windows.<br>
</div>

<pre><span id="VALperm"><span class="keyword">val</span> perm</span> : <code class="type"><a href="BatFile.html#TYPEpermission">permission</a> list -> <a href="BatFile.html#TYPEpermission">permission</a></code></pre><div class="info ">
Join permissions<br>
</div>

<pre><span id="VALunix_perm"><span class="keyword">val</span> unix_perm</span> : <code class="type">int -> <a href="BatFile.html#TYPEpermission">permission</a></code></pre><div class="info ">
Create a permission from a Unix-style octal integer.
   See your favorite Unix documentation on <code class="code">chmod</code>
   for more details.<br>
<b>Raises</b> <code>Invalid_argument</code> if given number outside the <code class="code">[0, 0o777]</code> range<br>
</div>

<pre><span id="VALset_permissions"><span class="keyword">val</span> set_permissions</span> : <code class="type">string -> <a href="BatFile.html#TYPEpermission">permission</a> -> unit</code></pre><div class="info ">
Set the permissions on a file.<br>
</div>

<pre><span id="VALchmod"><span class="keyword">val</span> chmod</span> : <code class="type">string -> <a href="BatFile.html#TYPEpermission">permission</a> -> unit</code></pre><div class="info ">
As <a href="BatFile.html#VALset_permissions"><code class="code"><span class="constructor">BatFile</span>.set_permissions</code></a><br>
</div>
<br>
<h6 id="6_Openingafileforreading">Opening a file for reading</h6><br>

<pre><span id="TYPEopen_in_flag"><span class="keyword">type</span> <code class="type"></code>open_in_flag</span> = <code class="type">[ `create | `excl | `mmap | `nonblock | `text ]</code> </pre>


<pre><span id="VALopen_in"><span class="keyword">val</span> open_in</span> : <code class="type">?mode:<a href="BatFile.html#TYPEopen_in_flag">open_in_flag</a> list -><br>       ?perm:<a href="BatFile.html#TYPEpermission">permission</a> -> string -> <a href="BatInnerIO.html#TYPEinput">BatInnerIO.input</a></code></pre><div class="info ">
<code class="code">open_in file_name</code> opens the file named <code class="code">file_name</code> for reading.
<p>

    <b>Note</b> You will need to close the file manually, with
    <a href="BatIO.html#VALclose_in"><code class="code"><span class="constructor">BatIO</span>.close_in</code></a>. An alternative is to call <code class="code">with_file_in</code> instead
    of <code class="code">open_in</code>.
<p>

    Naming conventions for files are platform-dependent.<br>
</div>

<pre><span id="VALwith_file_in"><span class="keyword">val</span> with_file_in</span> : <code class="type">?mode:<a href="BatFile.html#TYPEopen_in_flag">open_in_flag</a> list -><br>       ?perm:<a href="BatFile.html#TYPEpermission">permission</a> -> string -> (<a href="BatInnerIO.html#TYPEinput">BatInnerIO.input</a> -> 'a) -> 'a</code></pre><div class="info ">
<code class="code">with_file_in file_name f</code> opens the file named <code class="code">file_name</code> for reading,
    invokes <code class="code">f</code> to process the contents of that file then, once <code class="code">f</code> has returned
    or triggered an exception, closes the file before proceeding.<br>
</div>
<br>
<h6 id="6_Openingafileforwriting">Opening a file for writing</h6><br>

<pre><span id="TYPEopen_out_flag"><span class="keyword">type</span> <code class="type"></code>open_out_flag</span> = <code class="type">[ `append | `create | `excl | `nonblock | `text | `trunc ]</code> </pre>
<div class="info ">
Flags governing file output; they correspond to the relevant
    flags to the POSIX <code class="code"><span class="keyword">open</span>()</code> call.  The default flags are
    <code class="code">[<span class="keywordsign">`</span>create; <span class="keywordsign">`</span>trunc]</code>.<br>
</div>


<pre><span id="VALopen_out"><span class="keyword">val</span> open_out</span> : <code class="type">?mode:<a href="BatFile.html#TYPEopen_out_flag">open_out_flag</a> list -><br>       ?perm:<a href="BatFile.html#TYPEpermission">permission</a> -> string -> unit <a href="BatInnerIO.html#TYPEoutput">BatInnerIO.output</a></code></pre><div class="info ">
<code class="code">open_out file_name</code> opens the file named <code class="code">file_name</code> for writing.
<p>

    <b>Note</b> You will need to close the file manually, with
    <a href="BatIO.html#VALclose_out"><code class="code"><span class="constructor">BatIO</span>.close_out</code></a>. An alternative is to call <code class="code">with_file_out</code>
    instead of <code class="code">open_out</code>.
<p>

    Naming conventions for files are platform-dependent.<br>
</div>

<pre><span id="VALwith_file_out"><span class="keyword">val</span> with_file_out</span> : <code class="type">?mode:<a href="BatFile.html#TYPEopen_out_flag">open_out_flag</a> list -><br>       ?perm:<a href="BatFile.html#TYPEpermission">permission</a> -> string -> (unit <a href="BatInnerIO.html#TYPEoutput">BatInnerIO.output</a> -> 'a) -> 'a</code></pre><div class="info ">
<code class="code">with_file_out file_name f</code> opens the file named <code class="code">file_name</code> for writing,
    invokes <code class="code">f</code> to write onto that file then, once <code class="code">f</code> has returned or triggered
    an exception, closes the file before proceeding.<br>
</div>
<br>
<h6 id="6_Openingatemporaryfileforwriting">Opening a temporary file for writing</h6><br>

<pre><span id="TYPEopen_temporary_out_flag"><span class="keyword">type</span> <code class="type"></code>open_temporary_out_flag</span> = <code class="type">[ `append | `create | `delete_on_exit | `excl | `nonblock | `text | `trunc ]</code> </pre>


<pre><span id="VALopen_temporary_out"><span class="keyword">val</span> open_temporary_out</span> : <code class="type">?mode:<a href="BatFile.html#TYPEopen_temporary_out_flag">open_temporary_out_flag</a> list -><br>       ?prefix:string -><br>       ?suffix:string -> ?temp_dir:string -> unit -> unit <a href="BatInnerIO.html#TYPEoutput">BatInnerIO.output</a> * string</code></pre><div class="info ">
<code class="code">open_temporary_out ()</code> opens a new temporary file for writing.<br>
<b>Returns</b> The name of the file and the <code class="code">output</code> for writing in it.
<p>

    <b>Note</b> You will need to close the file manually. An alternative is
    to call <code class="code">with_temporary_out</code> instead of <code class="code">open_out</code>.
<p>

    Naming conventions for files are platform-dependent.<br>
</div>
<div class="param_info"><code class="code">prefix</code> : a string which should appear at the start of your temporary file name
    (by default <code class="code"><span class="string">"ocaml"</span></code>)</div>
<div class="param_info"><code class="code">suffix</code> : a string which should appear at the end of your temporary file name
    (by default <code class="code"><span class="string">"tmp"</span></code>)</div>
<div class="param_info"><code class="code">temp_dir</code> : indicates what temp dir to use</div>

<pre><span id="VALwith_temporary_out"><span class="keyword">val</span> with_temporary_out</span> : <code class="type">?mode:<a href="BatFile.html#TYPEopen_temporary_out_flag">open_temporary_out_flag</a> list -><br>       ?prefix:string -><br>       ?suffix:string -><br>       ?temp_dir:string -> (unit <a href="BatInnerIO.html#TYPEoutput">BatInnerIO.output</a> -> string -> 'a) -> 'a</code></pre><div class="info ">
<code class="code">with_temporary_out f</code> opens a new temporary file for writing, invokes <code class="code">f</code> with
      to write onto that file then, once <code class="code">f</code> has returned or triggered an exception,
      closes the file before proceeding.<br>
<b>Returns</b> The name of the file and the <code class="code">output</code> for writing in it.
<p>

      Naming conventions for files are platform-dependent.<br>
</div>
<div class="param_info"><code class="code">prefix</code> : a string which should appear at the start of your temporary file name
      (by default <code class="code"><span class="string">"ocaml"</span></code>)</div>
<div class="param_info"><code class="code">suffix</code> : a string which should appear at the end of your temporary file name
      (by default <code class="code"><span class="string">"tmp"</span></code>)</div>
<div class="param_info"><code class="code">temp_dir</code> : indicates what temp dir to use</div>
</body></html>