Sophie

Sophie

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

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="BatPathGen.StringType.html">
<link rel="Up" href="BatPathGen.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="Construction" rel="Section" href="#6_Construction">
<link title="Validation" rel="Section" href="#6_Validation">
<link title="Conversions" rel="Section" href="#6_Conversions">
<link title="Name related functions" rel="Section" href="#6_Namerelatedfunctions">
<link title="Supplementary functions" rel="Section" href="#6_Supplementaryfunctions">
<link title="Convenience aliases" rel="Subsection" href="#7_Conveniencealiases">
<title>Batteries user guide : BatPathGen.PathType</title>
</head>
<body>
<div class="navbar"><a class="pre" href="BatPathGen.StringType.html" title="BatPathGen.StringType">Previous</a>
&nbsp;<a class="up" href="BatPathGen.html" title="BatPathGen">Up</a>
&nbsp;</div>
<h1>Module type <a href="type_BatPathGen.PathType.html">BatPathGen.PathType</a></h1>

<pre><span class="keyword">module type</span> PathType = <code class="code"><span class="keyword">sig</span></code> <a href="BatPathGen.PathType.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info modtype top">
All implementations of <code class="code"><span class="constructor">Path</span></code> functionality have this module type.<br>
</div>
<hr width="100%">

<pre><span id="TYPEustring"><span class="keyword">type</span> <code class="type"></code>ustring</span> </pre>
<div class="info ">
Type of strings used. In case of <code class="code"><span class="constructor">Path</span>.<span class="constructor">OfRope</span></code> it is <code class="code"><span class="constructor">Rope</span>.t</code> and in <code class="code"><span class="constructor">Path</span>.<span class="constructor">OfString</span></code> module it is  <code class="code">string</code>.<br>
</div>


<pre><span id="TYPEuchar"><span class="keyword">type</span> <code class="type"></code>uchar</span> </pre>
<div class="info ">
Type of characters. It corresponds to <code class="code">ustring</code> type.<br>
</div>


<pre><span class="keyword">module</span> <a href="BatPathGen.PathType.OperatorLift.html">OperatorLift</a>: <code class="code"><span class="keyword">sig</span></code> <a href="BatPathGen.PathType.OperatorLift.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info">
Convenience operator for lifting primitive strings to <code class="code">ustring</code> type.
</div>

<pre><span id="TYPEt"><span class="keyword">type</span> <code class="type"></code>t</span> = <code class="type"><a href="BatPathGen.PathType.html#TYPEustring">ustring</a> list</code> </pre>
<div class="info ">
A type for storing paths. It is reversed list of names. In case of absolute path, the last element of the list is empty string (<em>Windows:</em> empty or letter-colon; details below). Empty list represents empty relative path.
<p>

      Examples: <code class="code">[<span class="string">"a"</span>;<span class="string">"b"</span>;<span class="string">"c"</span>]</code> is c/b/a (relative path); <code class="code">[<span class="string">"d"</span>;<span class="string">"e"</span>;<span class="string">""</span>]</code> stays for /e/d (absolute path).
<p>

      All examples here and below are given for <code class="code">ustring</code>=<code class="code">string</code> case for clarity. To have the code working with other string types, one should prepend the <code class="code">!!</code> operator (<a href="BatPathGen.PathType.OperatorLift.html#VAL(!!)"><code class="code"><span class="constructor">BatPathGen</span>.<span class="constructor">PathType</span>.<span class="constructor">OperatorLift</span>.(!!)</code></a>) to all string literals.
<p>

      There are two infix operators provided to allow to write expressions in natural order. For example, to build a path using <a href="BatPathGen.PathType.Operators.html#VAL(/:)"><code class="code"><span class="constructor">BatPathGen</span>.<span class="constructor">PathType</span>.<span class="constructor">Operators</span>.(/:)</code></a> one can write:
<p>

      <code class="code">base_dir/:<span class="string">"bar"</span></code> instead of <code class="code"><span class="string">"bar"</span>::base_dir</code>
<p>

      However it may be sometimes inevitable to write components in reverse, for example:
<p>

      <code class="code"><span class="keyword">let</span> whose_readme = <span class="keyword">function</span> <span class="string">"README"</span>::app::<span class="string">"doc"</span>::<span class="string">"share"</span>::_ <span class="keywordsign">-&gt;</span> <span class="constructor">Some</span> app <span class="keywordsign">|</span> _ <span class="keywordsign">-&gt;</span> <span class="constructor">None</span></code>
<p>

      <em>Windows:</em> Windows absolute paths start with "\\" or with drive letter. Use following representation:<ul>
<li><code class="code"><span class="constructor">Path</span>.root/:<span class="string">"."</span>/:<span class="string">"pipe"</span> = [<span class="string">"pipe"</span>;<span class="string">"."</span>;<span class="string">""</span>]</code>  for "\\.\pipe"</li>
<li><code class="code">[<span class="string">"C:"</span>]/:<span class="string">"foo"</span> = [<span class="string">"foo"</span>;<span class="string">"C:"</span>]</code> for "C:\foo"</li>
</ul>

      In principle the first type of paths has broader range of allowed characters, but this implementation applies more strict rules to both (<a href="BatPathGen.PathType.html#VALdefault_validator"><code class="code"><span class="constructor">BatPathGen</span>.<span class="constructor">PathType</span>.default_validator</code></a>).<br>
</div>


<pre><span id="VALis_relative"><span class="keyword">val</span> is_relative</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEt">t</a> -> bool</code></pre>
<pre><span id="VALis_absolute"><span class="keyword">val</span> is_absolute</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEt">t</a> -> bool</code></pre><br>
<h6 id="6_Construction">Construction</h6><br>

<pre><span id="VALroot"><span class="keyword">val</span> root</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEt">t</a></code></pre><div class="info ">
Root of the filesystem (<code class="code">[<span class="string">""</span>]</code>). It is minimal absolute path. Below it is called 'empty'. However it yields "/" or "\\" when converted to a string.
<p>

      <em>Windows:</em> This path (root and nothing more) is meaningless, but for simplicity it is considered valid here. To create absolute path starting with drive letter, construct the list explicitly (as in <code class="code">[<span class="string">"C:"</span>]/:<span class="string">"foo"</span></code>).
      A path consisting of drive letter only is also called 'empty' here.<br>
</div>

<pre><span id="VALappend"><span class="keyword">val</span> append</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEt">t</a> -> <a href="BatPathGen.PathType.html#TYPEustring">ustring</a> -> <a href="BatPathGen.PathType.html#TYPEt">t</a></code></pre><div class="info ">
Alternative name for <a href="BatPathGen.PathType.Operators.html#VAL(/:)"><code class="code"><span class="constructor">BatPathGen</span>.<span class="constructor">PathType</span>.<span class="constructor">Operators</span>.(/:)</code></a><br>
</div>

<pre><span id="VALconcat"><span class="keyword">val</span> concat</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEt">t</a> -> <a href="BatPathGen.PathType.html#TYPEt">t</a> -> <a href="BatPathGen.PathType.html#TYPEt">t</a></code></pre><div class="info ">
Alternative name for <a href="BatPathGen.PathType.Operators.html#VAL(//@)"><code class="code"><span class="constructor">BatPathGen</span>.<span class="constructor">PathType</span>.<span class="constructor">Operators</span>.(//@)</code></a><br>
</div>

<pre><span class="keyword">module</span> <a href="BatPathGen.PathType.Operators.html">Operators</a>: <code class="code"><span class="keyword">sig</span></code> <a href="BatPathGen.PathType.Operators.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info">
Infix operators for path construction.
</div>

<pre><span class="keyword">module</span> <a href="BatPathGen.PathType.Infix.html">Infix</a>: <code class="code"><span class="keyword">sig</span></code> <a href="BatPathGen.PathType.Infix.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info">
As other Operators modules in batteries are named "Infix" we provide Infix as well.
</div>

<pre><span id="EXCEPTIONMalformed_path"><span class="keyword">exception</span> Malformed_path</span></pre>

<pre><span id="VALnormalize_filepath"><span class="keyword">val</span> normalize_filepath</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEt">t</a> -> <a href="BatPathGen.PathType.html#TYPEt">t</a></code></pre><div class="info ">
Consumes single dots where possible, e.g.:
<p>

     <code class="code">normalize ([<span class="string">".."</span>]/:<span class="string">"foo"</span>/:<span class="string">"."</span>/:<span class="string">"bar"</span>/:<span class="string">"sub1"</span>/:<span class="string">".."</span>/:<span class="string">"sub2"</span>) = [<span class="string">".."</span>]/:<span class="string">"foo"</span>/:<span class="string">"bar"</span>/:<span class="string">"sub1"</span>/:<span class="string">".."</span>/:<span class="string">"sub2"</span></code>
<p>

     When a directory structure contains links, it can be not pefectly pure tree. Then meaing of the ".." symbol depends on the real nature of parent of what is denoted by the name that preceded the ".." symbol. This symbol cannot be resolved for a graph traversal case when dealing with abstract paths only.
<p>

     <em>Windows:</em> If single dot is next to root, it is preserved.<br>
</div>

<pre><span id="VALnormalize_in_graph"><span class="keyword">val</span> normalize_in_graph</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEt">t</a> -> <a href="BatPathGen.PathType.html#TYPEt">t</a></code></pre><div class="info ">
Another name for <code class="code">normalize_filepath</code>.<br>
</div>

<pre><span id="VALnormalize_in_tree"><span class="keyword">val</span> normalize_in_tree</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEt">t</a> -> <a href="BatPathGen.PathType.html#TYPEt">t</a></code></pre><div class="info ">
Consumes single dots and applies double dots where possible, e.g.:
<p>

     <code class="code">normalize ([<span class="string">".."</span>]/:<span class="string">"foo"</span>/:<span class="string">"."</span>/:<span class="string">"bar"</span>/:<span class="string">"sub1"</span>/:<span class="string">".."</span>/:<span class="string">"sub2"</span>) = [<span class="string">".."</span>]/:<span class="string">"foo"</span>/:<span class="string">"bar"</span>/:<span class="string">"sub2"</span></code>
<p>

     This normalization is useful when dealing with paths that describe locations in a tree and the ".." symbol always points to the only parent of what precedes this symbol.
<p>

     <em>Windows:</em> If single dot is next to root, it is preserved.<br>
<b>Raises</b> <code>Malformed_path</code> when absolute path is given that contains double dots that would be applied to the root.<br>
</div>

<pre><span id="VALnormalize"><span class="keyword">val</span> normalize</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEt">t</a> -> <a href="BatPathGen.PathType.html#TYPEt">t</a></code></pre><div class="info ">
Deprecated name for <code class="code">normalize_in_tree</code><br>
</div>

<pre><span id="VALparent"><span class="keyword">val</span> parent</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEt">t</a> -> <a href="BatPathGen.PathType.html#TYPEt">t</a></code></pre><div class="info ">
Returns parent path, i.e. immediate ancestor: <code class="code">parent (foo/:bar) = foo</code><br>
<b>Raises</b> <code>Invalid_argument</code> if empty path (relative <code class="code">[]</code> or absolute <code class="code">[<span class="string">""</span>]</code>) is given<br>
</div>

<pre><span id="VALbelongs"><span class="keyword">val</span> belongs</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEt">t</a> -> <a href="BatPathGen.PathType.html#TYPEt">t</a> -> bool</code></pre><div class="info ">
<code class="code">belongs base sub</code> is <code class="code"><span class="keyword">true</span></code> when <code class="code">sub</code> descends from <code class="code">base</code>, i.e. <code class="code">base</code> is a prefix of <code class="code">sub</code>. If <code class="code">base</code>=<code class="code">sub</code> the function returns <code class="code"><span class="keyword">true</span></code>. It is otherwise <code class="code"><span class="keyword">false</span></code>.
      Both arguments must be absolute paths or both relative.
<p>

      If both arguments have a root portion with drive letter and these letters are different, <code class="code">belongs base sub</code> returns false.<br>
<b>Raises</b> <code>Invalid_argument</code> if exactly one of given arguments is absolute path<br>
</div>

<pre><span id="VALrelative_to_any"><span class="keyword">val</span> relative_to_any</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEt">t</a> -> <a href="BatPathGen.PathType.html#TYPEt">t</a> -> <a href="BatPathGen.PathType.html#TYPEt">t</a></code></pre><div class="info ">
<code class="code">relative_to_any base sub</code> returns relative path <code class="code">rel</code> such that
      <code class="code">normalize (base/:rel) = normalize sub</code>, i.e. common base is stripped and ".." are added if necessary.
      Both arguments must be absolute paths or both relative.
<p>

      This function normalizes <code class="code">base</code> and <code class="code">sub</code> before calculation of the relative path.
<p>

      <em>Windows:</em> If <code class="code">base</code> and <code class="code">sub</code> are absolute, they must have the same root element: have the same drive letter or both starting with <a href="BatPathGen.PathType.html#VALroot"><code class="code"><span class="constructor">BatPathGen</span>.<span class="constructor">PathType</span>.root</code></a> (i.e. <code class="code"><span class="string">""</span></code> is the last element of the list).
      Exceptionally it is possible to get an absolute path as a result if drive letter is in <code class="code">sub</code> but not as a root element (e .g. <code class="code">base = root/:<span class="string">"bar"</span></code> and <code class="code">sub = root/:bar//@([<span class="string">"C:"</span>]/:<span class="string">"foo"</span></code>).<br>
<b>Raises</b><ul><li><code>Invalid_argument</code> if exactly one of given arguments is an absolute path</li>
<li><code>Malformed_path</code> if normalization fails (see <a href="BatPathGen.PathType.html#VALnormalize"><code class="code"><span class="constructor">BatPathGen</span>.<span class="constructor">PathType</span>.normalize</code></a>)</li>
</ul>
<b>See also</b> <code class="code">relative_to_parent</code> may be sometimes more suitable<br>
</div>

<pre><span id="EXCEPTIONNot_parent"><span class="keyword">exception</span> Not_parent</span></pre>

<pre><span id="VALrelative_to_parent"><span class="keyword">val</span> relative_to_parent</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEt">t</a> -> <a href="BatPathGen.PathType.html#TYPEt">t</a> -> <a href="BatPathGen.PathType.html#TYPEt">t</a></code></pre><div class="info ">
<code class="code">relative_to_parent parent sub</code> returns relative path <code class="code">rel</code> such that
      <code class="code">(normalize parent)/:rel = normalize sub</code>. It is checked if <code class="code">sub</code> is really a descendant of <code class="code">parent</code>.
      Both arguments must be absolute paths or both relative.
<p>

      This function normalizes <code class="code">base</code> and <code class="code">sub</code> before calculation of the relative path.
<p>

      <em>Windows:</em> Exceptionally it is possible to get an absolute path as a result if drive letter is in <code class="code">sub</code> but not as a root element (e .g. <code class="code">base = root/:<span class="string">"bar"</span></code> and <code class="code">sub = root/:bar//@([<span class="string">"C:"</span>]/:<span class="string">"foo"</span>)</code>).<br>
<b>Raises</b><ul><li><code>Not_parent</code> if <code class="code">sub</code> is not descendant of <code class="code">parent</code></li>
<li><code>Invalid_argument</code> if exactly one of given arguments is absolute path</li>
<li><code>Malformed_path</code> if normalization fails (see <a href="BatPathGen.PathType.html#VALnormalize"><code class="code"><span class="constructor">BatPathGen</span>.<span class="constructor">PathType</span>.normalize</code></a>)</li>
</ul>
</div>
<br>
<h6 id="6_Validation">Validation</h6><br>

<pre><span id="EXCEPTIONIllegal_char"><span class="keyword">exception</span> Illegal_char</span></pre>
<div class="info ">
Raised by <a href="BatPathGen.PathType.html#VALof_string"><code class="code"><span class="constructor">BatPathGen</span>.<span class="constructor">PathType</span>.of_string</code></a>, <a href="BatPathGen.PathType.html#VALappend"><code class="code"><span class="constructor">BatPathGen</span>.<span class="constructor">PathType</span>.append</code></a> and <a href="BatPathGen.PathType.Operators.html#VAL(/:)"><code class="code"><span class="constructor">BatPathGen</span>.<span class="constructor">PathType</span>.<span class="constructor">Operators</span>.(/:)</code></a> when used validator finds illegal character.<br>
</div>

<pre><span id="TYPEvalidator"><span class="keyword">type</span> <code class="type"></code>validator</span> = <code class="type"><a href="BatPathGen.PathType.html#TYPEustring">ustring</a> -> bool</code> </pre>
<div class="info ">
Validators should check if all characters of given string can be used in a name (path component). Return true if the name is valid. Return false if illegal character is found.
<p>

     If a name should be rejected for some other reason, user defined validator may raise an exception.<br>
</div>


<pre><span id="VALdefault_validator"><span class="keyword">val</span> default_validator</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEvalidator">validator</a> Pervasives.ref</code></pre><div class="info ">
Forward slash and code zero are considered invalid.
<p>

     <em>Windows:</em> Invalid characters are *?:\/&lt;&gt; and all with code &lt;32. Exception: the function <a href="BatPathGen.PathType.html#VALof_string"><code class="code"><span class="constructor">BatPathGen</span>.<span class="constructor">PathType</span>.of_string</code></a> doesn't use validator against drive letter with colon.<br>
</div>
<br>
<h6 id="6_Conversions">Conversions</h6><br>

<pre><span id="VALto_ustring"><span class="keyword">val</span> to_ustring</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEt">t</a> -> <a href="BatPathGen.PathType.html#TYPEustring">ustring</a></code></pre><div class="info ">
Convert to the chosen <code class="code">ustring</code> type. Empty relative path is converted to "." (single dot).
<p>

      <em>Windows:</em> backslash is used as a separator and double backslash for root. If the path is only a drive letter (empty absolute path) trailing backslash is added (e.g. <code class="code">to_string ["C:"] = "C:\"</code>).<br>
<b>See also</b> <code class="code">to_string</code> is likely to bo more useful
      "<br>
</div>

<pre><span id="VALto_string"><span class="keyword">val</span> to_string</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEt">t</a> -> string</code></pre><div class="info ">
Convert to type primitive string with UTF-8 content. The string is built in the same way as by <code class="code">to_ustring</code> function.<br>
</div>

<pre><span id="VALof_string"><span class="keyword">val</span> of_string</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEustring">ustring</a> -> <a href="BatPathGen.PathType.html#TYPEt">t</a></code></pre><div class="info ">
Parse path in a given string. Any number of consecutive separators collapse ("a//b" becomes "a/b"). <code class="code"><span class="constructor">Path</span>.default_validator</code> is applied to each resulting name.
<p>

      <em>Windows:</em> both slashes '\' and '/' are accepted as separators. Paths of the 'semi-relative' form "C:foo\bar" are not recognized. For example "C:" string is parsed as <code class="code">[<span class="string">"C:"</span>]</code> which has different meaning (see <a href="BatPathGen.PathType.html#VALto_string"><code class="code"><span class="constructor">BatPathGen</span>.<span class="constructor">PathType</span>.to_string</code></a>).<br>
<b>Raises</b> <code>Illegal_char</code> when a character not allowed in paths is found.<br>
</div>
<br>
<div class="h7" id="7_Conveniencealiases">Convenience aliases</div><br>

<pre><span id="VALs"><span class="keyword">val</span> s</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEt">t</a> -> string</code></pre><div class="info ">
= <a href="BatPathGen.PathType.html#VALto_string"><code class="code"><span class="constructor">BatPathGen</span>.<span class="constructor">PathType</span>.to_string</code></a><br>
</div>

<pre><span id="VALp"><span class="keyword">val</span> p</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEustring">ustring</a> -> <a href="BatPathGen.PathType.html#TYPEt">t</a></code></pre><div class="info ">
= <a href="BatPathGen.PathType.html#VALof_string"><code class="code"><span class="constructor">BatPathGen</span>.<span class="constructor">PathType</span>.of_string</code></a><br>
</div>
<br>
<h6 id="6_Namerelatedfunctions">Name related functions</h6>
      These funtions do not accept empty paths, i.e. <code class="code">[]</code>, <code class="code">[<span class="string">""</span>]</code> or <code class="code">[<span class="string">"C:"</span>]</code>.<br>

<pre><span id="VALname"><span class="keyword">val</span> name</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEt">t</a> -> <a href="BatPathGen.PathType.html#TYPEustring">ustring</a></code></pre><div class="info ">
Returns name of the object the pathname points to, i.e.
      <code class="code">name (foo/:bar) = bar</code><br>
<b>Raises</b> <code>Invalid_argument</code> if empty path (relative <code class="code">[]</code> or absolute <code class="code">[<span class="string">""</span>]</code>) is given<br>
</div>

<pre><span id="VALmap_name"><span class="keyword">val</span> map_name</span> : <code class="type">(<a href="BatPathGen.PathType.html#TYPEustring">ustring</a> -> <a href="BatPathGen.PathType.html#TYPEustring">ustring</a>) -><br>       <a href="BatPathGen.PathType.html#TYPEt">t</a> -> <a href="BatPathGen.PathType.html#TYPEt">t</a></code></pre><div class="info ">
<code class="code">map_name fu path</code> returns <code class="code">path</code> with the name replaced by <code class="code">fu (</code><a href="BatPathGen.PathType.html#VALname"><code class="code"><span class="constructor">BatPathGen</span>.<span class="constructor">PathType</span>.name</code></a><code class="code"> path)</code>.
<p>

      Example: <code class="code">map_name (<span class="keyword">fun</span> nn <span class="keywordsign">-&gt;</span> nn ^ <span class="string">".backup"</span>) ([<span class="string">"foo"</span>]/:<span class="string">"bar"</span>) = [<span class="string">"foo"</span>]/:<span class="string">"bar.backup"</span></code>
<p>

      <a href="BatPathGen.PathType.html#VALdefault_validator"><code class="code"><span class="constructor">BatPathGen</span>.<span class="constructor">PathType</span>.default_validator</code></a> is applied to new name.<br>
<b>Raises</b> <code>Illegal_char</code> (raised by validator if any bad character is found)<br>
</div>

<pre><span id="VALext"><span class="keyword">val</span> ext</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEt">t</a> -> <a href="BatPathGen.PathType.html#TYPEustring">ustring</a> option</code></pre><div class="info ">
Returns extension of the name of the object the pathname points to. Examples:
<p>

      <code class="code">ext [<span class="string">"aa.bb"</span>] = <span class="constructor">Some</span> <span class="string">"bb"</span></code>
<p>

      <code class="code">ext [<span class="string">"aa."</span>] = <span class="constructor">Some</span> <span class="string">""</span></code>
<p>

      <code class="code">ext [<span class="string">"aa"</span>] = <span class="constructor">None</span></code>
<p>

      <code class="code">ext [<span class="string">".hidden"</span>] = <span class="constructor">Some</span> <span class="string">"hidden"</span></code> <em>(!)</em>
<p>

      Extension begins where the rightmost dot in the name is found. If the name ends with a dot, the extension is empty and <code class="code"><span class="constructor">Some</span> <span class="string">""</span></code> is returned. If there is no extension (no dot) the function returns <code class="code"><span class="constructor">None</span></code>.<br>
<b>Raises</b> <code>Invalid_argument</code> if empty path (relative <code class="code">[]</code> or absolute <code class="code">[<span class="string">""</span>]</code>) is given<br>
</div>

<pre><span id="VALmap_ext"><span class="keyword">val</span> map_ext</span> : <code class="type">(<a href="BatPathGen.PathType.html#TYPEustring">ustring</a> option -> <a href="BatPathGen.PathType.html#TYPEustring">ustring</a> option) -><br>       <a href="BatPathGen.PathType.html#TYPEt">t</a> -> <a href="BatPathGen.PathType.html#TYPEt">t</a></code></pre><div class="info ">
<code class="code">map_ext fu path</code> returns <code class="code">path</code> but with the name with extension given by <code class="code">fu (</code><a href="BatPathGen.PathType.html#VALext"><code class="code"><span class="constructor">BatPathGen</span>.<span class="constructor">PathType</span>.ext</code></a><code class="code"> path)</code>. If <code class="code">fu</code> returns <code class="code"><span class="constructor">Some</span> _</code>, the original extension may be replaced (when <code class="code"><span class="constructor">Some</span> ext</code> is passed to <code class="code">fu</code>) or new added (when <code class="code">fu</code> gets <code class="code"><span class="constructor">None</span></code>). In case <code class="code">fu</code> returns <code class="code"><span class="constructor">None</span></code>, the extension is removed (if exists).<br>
<b>Raises</b><ul><li><code>Illegal_char</code> (raised by validator if any bad character is found)</li>
<li><code>Invalid_argument</code> if empty path (relative <code class="code">[]</code> or absolute <code class="code">[<span class="string">""</span>]</code>) is given</li>
</ul>
</div>

<pre><span id="VALname_core"><span class="keyword">val</span> name_core</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEt">t</a> -> <a href="BatPathGen.PathType.html#TYPEustring">ustring</a></code></pre><div class="info ">
Returns part of the name to the left of rightmost dot. Returns empty string if the name starts with a dot.<br>
<b>Raises</b> <code>Invalid_argument</code> if empty path (relative <code class="code">[]</code> or absolute <code class="code">[<span class="string">""</span>]</code>) is given<br>
</div>

<pre><span id="TYPEcomponents"><span class="keyword">type</span> <code class="type"></code>components</span> = <code class="type"><a href="BatPathGen.PathType.html#TYPEt">t</a> * <a href="BatPathGen.PathType.html#TYPEustring">ustring</a> *<br>       <a href="BatPathGen.PathType.html#TYPEustring">ustring</a> option</code> </pre>
<div class="info ">
A <code class="code">path</code> can be represented by the following triple:
      <code class="code">(<span class="constructor">Path</span>.parent path, <span class="constructor">Path</span>.name_core path, <span class="constructor">Path</span>.ext path)</code><br>
</div>


<pre><span id="VALsplit"><span class="keyword">val</span> split</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEt">t</a> -> <a href="BatPathGen.PathType.html#TYPEcomponents">components</a></code></pre><div class="info ">
Dissect the path to its components (parent path, core part of name and possibly an extension).
<p>

      Resulting <code class="code">name_core</code> string can be empty. For example,
      <code class="code"><span class="constructor">Path</span>.split (<span class="constructor">Path</span>.root/:<span class="string">"home"</span>/:<span class="string">"user"</span>/:<span class="string">".bashrc"</span>)</code> equals <code class="code">(<span class="constructor">Path</span>.root/:<span class="string">"home"</span>/:<span class="string">"user"</span>, <span class="string">""</span>, <span class="constructor">Some</span> <span class="string">"bashrc"</span>)</code>.<br>
<b>Raises</b> <code>Invalid_argument</code> if empty path (relative <code class="code">[]</code> or absolute <code class="code">[<span class="string">""</span>]</code>) is given<br>
</div>

<pre><span id="VALjoin"><span class="keyword">val</span> join</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEcomponents">components</a> -> <a href="BatPathGen.PathType.html#TYPEt">t</a></code></pre><div class="info ">
Create a path from given components.<br>
<b>Raises</b> <code>Illegal_char</code> (raised by validator on any bad character)<br>
</div>

<pre><span id="VALmap"><span class="keyword">val</span> map</span> : <code class="type">(<a href="BatPathGen.PathType.html#TYPEcomponents">components</a> -> <a href="BatPathGen.PathType.html#TYPEcomponents">components</a>) -><br>       <a href="BatPathGen.PathType.html#TYPEt">t</a> -> <a href="BatPathGen.PathType.html#TYPEt">t</a></code></pre><div class="info ">
Map a path through a function that operates on separate components.<br>
<b>Raises</b><ul><li><code>Illegal_char</code> (raised by validator on any bad character)</li>
<li><code>Invalid_argument</code> if empty path (relative <code class="code">[]</code> or absolute <code class="code">[<span class="string">""</span>]</code>) is given</li>
</ul>
</div>
<br>
<h6 id="6_Supplementaryfunctions">Supplementary functions</h6><br>

<pre><span id="VALdrive_letter"><span class="keyword">val</span> drive_letter</span> : <code class="type"><a href="BatPathGen.PathType.html#TYPEt">t</a> -> <a href="BatPathGen.PathType.html#TYPEuchar">uchar</a> option</code></pre><div class="info ">
Return drive letter of the given absolute path.
<p>

       <em>Windows:</em> <code class="code">drive_letter abs</code> returns <code class="code"><span class="constructor">None</span></code> if <code class="code">abs</code> is simple absolute path (i.e. begins with a separator), otherwise the root element of <code class="code">abs</code> consists of a letter <code class="code">ch</code> with a colon - in this case <code class="code"><span class="constructor">Some</span> ch</code> is returned.
<p>

       <em>Other systems:</em> Returns <code class="code"><span class="constructor">None</span></code> on all absolute paths.<br>
<b>Raises</b> <code>Invalid_argument</code> if relative path is given<br>
</div>
</body></html>