<!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="FileUtilStr.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 modules" rel=Appendix href="index_modules.html"> <link title="Index of module types" rel=Appendix href="index_module_types.html"> <link title="FileUtil" rel="Chapter" href="FileUtil.html"> <link title="FileUtilStr" rel="Chapter" href="FileUtilStr.html"> <link title="FilePath" rel="Chapter" href="FilePath.html"><link title="Exceptions and types" rel="Section" href="#2_Exceptionsandtypes"> <link title="Ordering" rel="Section" href="#2_Ordering"> <link title="Standard operations " rel="Section" href="#2_Standardoperations"> <link title="Extension" rel="Section" href="#2_Extension"> <link title="PATH-like operation" rel="Section" href="#2_PATHlikeoperation"> <link title="Filename specifications" rel="Section" href="#2_Filenamespecifications"> <title>FilePath</title> </head> <body> <div class="navbar"><a href="FileUtilStr.html">Previous</a> <a href="index.html">Up</a> </div> <center><h1>Module <a href="type_FilePath.html">FilePath</a></h1></center> <br> <pre><span class="keyword">module</span> FilePath: <code class="code">sig</code> <a href="FilePath.html">..</a> <code class="code">end</code></pre>Operations on abstract filenames. <p> This module allow to manipulate string or abstract representation of a filename. <p> Abstract representation of a filename allow to decode it only once, and should speed up further operation on it (comparison in particular). If you intend to do a lot of processing on filename, you should consider using its abstract representation. <p> This module manipulate abstract path that are not bound to a real filesystem. In particular, it makes the assumption that there is no symbolic link that should modify the meaning of a path. If you intend to use this module against a real set of filename, the best solution is to apply to every filename to solve symbolic link through <a href="FileUtil.html#VALreadlink"><code class="code">FileUtil.readlink</code></a>.<br> <b>Author(s):</b> Sylvain Le Gall<br> <hr width="100%"> <pre><span class="keyword">type</span> <a name="TYPEfilename"></a><code class="type"></code>filename = <code class="type">string</code> </pre> <div class="info"> Filename type.<br> </div> <pre><span class="keyword">type</span> <a name="TYPEextension"></a><code class="type"></code>extension = <code class="type">string</code> </pre> <div class="info"> Extension type.<br> </div> <br> <a name="2_Exceptionsandtypes"></a> <h2>Exceptions and types</h2><br> <pre><span class="keyword">exception</span> <a name="EXCEPTIONBaseFilenameRelative"></a>BaseFilenameRelative <span class="keyword">of</span> <code class="type"><a href="FilePath.html#TYPEfilename">filename</a></code></pre> <div class="info"> Cannot pass a base filename which is relative.<br> </div> <pre><span class="keyword">exception</span> <a name="EXCEPTIONUnrecognizedOS"></a>UnrecognizedOS <span class="keyword">of</span> <code class="type">string</code></pre> <div class="info"> We do not have recognized any OS, please contact upstream.<br> </div> <pre><span class="keyword">exception</span> <a name="EXCEPTIONEmptyFilename"></a>EmptyFilename</pre> <div class="info"> The filename use was empty.<br> </div> <pre><span class="keyword">exception</span> <a name="EXCEPTIONNoExtension"></a>NoExtension <span class="keyword">of</span> <code class="type"><a href="FilePath.html#TYPEfilename">filename</a></code></pre> <div class="info"> The last component of the filename does not support extension (Root, ParentDir...)<br> </div> <pre><span class="keyword">exception</span> <a name="EXCEPTIONInvalidFilename"></a>InvalidFilename <span class="keyword">of</span> <code class="type"><a href="FilePath.html#TYPEfilename">filename</a></code></pre> <div class="info"> The filename used is invalid.<br> </div> <br> <a name="2_Ordering"></a> <h2>Ordering</h2><br> <pre><span class="keyword">val</span> <a name="VALis_subdir"></a>is_subdir : <code class="type"><a href="FilePath.html#TYPEfilename">filename</a> -> <a href="FilePath.html#TYPEfilename">filename</a> -> bool</code></pre><div class="info"> <code class="code">is_subdir fl1 fl2</code> Is <code class="code">fl2</code> a sub directory of <code class="code">fl1</code><br> </div> <pre><span class="keyword">val</span> <a name="VALis_updir"></a>is_updir : <code class="type"><a href="FilePath.html#TYPEfilename">filename</a> -> <a href="FilePath.html#TYPEfilename">filename</a> -> bool</code></pre><div class="info"> <code class="code">is_updir fl1 fl2</code> Is <code class="code">fl1</code> a sub directory of <code class="code">fl2</code><br> </div> <pre><span class="keyword">val</span> <a name="VALcompare"></a>compare : <code class="type"><a href="FilePath.html#TYPEfilename">filename</a> -> <a href="FilePath.html#TYPEfilename">filename</a> -> int</code></pre><div class="info"> <code class="code">compare fl1 fl2</code> Give an order between the two filename. The classification is done by sub directory relation, <code class="code">fl1</code> < <code class="code">fl2</code> iff <code class="code">fl1</code> is a subdirectory of <code class="code">fl2</code>, and lexicographical order of each part of the reduce filename when <code class="code">fl1</code> and <code class="code">fl2</code> has no hierarchical relation<br> </div> <br> <a name="2_Standardoperations"></a> <h2>Standard operations </h2><br> <pre><span class="keyword">val</span> <a name="VALcurrent_dir"></a>current_dir : <code class="type"><a href="FilePath.html#TYPEfilename">filename</a></code></pre><div class="info"> Current dir.<br> </div> <pre><span class="keyword">val</span> <a name="VALparent_dir"></a>parent_dir : <code class="type"><a href="FilePath.html#TYPEfilename">filename</a></code></pre><div class="info"> Upper dir.<br> </div> <pre><span class="keyword">val</span> <a name="VALmake_filename"></a>make_filename : <code class="type">string list -> <a href="FilePath.html#TYPEfilename">filename</a></code></pre><div class="info"> Make a filename from a set of strings.<br> </div> <pre><span class="keyword">val</span> <a name="VALbasename"></a>basename : <code class="type"><a href="FilePath.html#TYPEfilename">filename</a> -> <a href="FilePath.html#TYPEfilename">filename</a></code></pre><div class="info"> Extract only the file name of a filename.<br> </div> <pre><span class="keyword">val</span> <a name="VALdirname"></a>dirname : <code class="type"><a href="FilePath.html#TYPEfilename">filename</a> -> <a href="FilePath.html#TYPEfilename">filename</a></code></pre><div class="info"> Extract the directory name of a filename.<br> </div> <pre><span class="keyword">val</span> <a name="VALconcat"></a>concat : <code class="type"><a href="FilePath.html#TYPEfilename">filename</a> -> <a href="FilePath.html#TYPEfilename">filename</a> -> <a href="FilePath.html#TYPEfilename">filename</a></code></pre><div class="info"> Append a filename to a filename.<br> </div> <pre><span class="keyword">val</span> <a name="VALreduce"></a>reduce : <code class="type">?no_symlink:bool -> <a href="FilePath.html#TYPEfilename">filename</a> -> <a href="FilePath.html#TYPEfilename">filename</a></code></pre><div class="info"> Return the shortest filename which is equal to the filename given. It remove the "." in Unix filename, for example. If <code class="code">no_symlink</code> flag is set, consider that the path doesn't contain symlink and in this case ".." for Unix filename are also reduced.<br> </div> <pre><span class="keyword">val</span> <a name="VALmake_absolute"></a>make_absolute : <code class="type"><a href="FilePath.html#TYPEfilename">filename</a> -> <a href="FilePath.html#TYPEfilename">filename</a> -> <a href="FilePath.html#TYPEfilename">filename</a></code></pre><div class="info"> Create an absolute filename from a filename relative and an absolute base filename.<br> </div> <pre><span class="keyword">val</span> <a name="VALmake_relative"></a>make_relative : <code class="type"><a href="FilePath.html#TYPEfilename">filename</a> -> <a href="FilePath.html#TYPEfilename">filename</a> -> <a href="FilePath.html#TYPEfilename">filename</a></code></pre><div class="info"> Create a filename which is relative to the base filename.<br> </div> <pre><span class="keyword">val</span> <a name="VALreparent"></a>reparent : <code class="type"><a href="FilePath.html#TYPEfilename">filename</a> -><br> <a href="FilePath.html#TYPEfilename">filename</a> -> <a href="FilePath.html#TYPEfilename">filename</a> -> <a href="FilePath.html#TYPEfilename">filename</a></code></pre><div class="info"> <code class="code">reparent fln_src fln_dst fln</code> Return the same filename as <code class="code">fln</code> but the root is no more <code class="code">fln_src</code> but <code class="code">fln_dst</code>. It replaces the <code class="code">fln_src</code> prefix by <code class="code">fln_dst</code>.<br> </div> <pre><span class="keyword">val</span> <a name="VALidentity"></a>identity : <code class="type"><a href="FilePath.html#TYPEfilename">filename</a> -> <a href="FilePath.html#TYPEfilename">filename</a></code></pre><div class="info"> Identity for testing the stability of implode/explode.<br> </div> <pre><span class="keyword">val</span> <a name="VALis_valid"></a>is_valid : <code class="type"><a href="FilePath.html#TYPEfilename">filename</a> -> bool</code></pre><div class="info"> Test if the filename is a valid one.<br> </div> <pre><span class="keyword">val</span> <a name="VALis_relative"></a>is_relative : <code class="type"><a href="FilePath.html#TYPEfilename">filename</a> -> bool</code></pre><div class="info"> Check if the filename is relative to a dir or not.<br> </div> <pre><span class="keyword">val</span> <a name="VALis_current"></a>is_current : <code class="type"><a href="FilePath.html#TYPEfilename">filename</a> -> bool</code></pre><div class="info"> Check if the filename is the current directory.<br> </div> <pre><span class="keyword">val</span> <a name="VALis_parent"></a>is_parent : <code class="type"><a href="FilePath.html#TYPEfilename">filename</a> -> bool</code></pre><div class="info"> Check if the filename is the parent directory.<br> </div> <br> <a name="2_Extension"></a> <h2>Extension</h2><br> <br> Extension is define as the suffix of a filename, just after the last ".".<br> <pre><span class="keyword">val</span> <a name="VALchop_extension"></a>chop_extension : <code class="type"><a href="FilePath.html#TYPEfilename">filename</a> -> <a href="FilePath.html#TYPEfilename">filename</a></code></pre><div class="info"> Remove extension and the trailing ".".<br> </div> <pre><span class="keyword">val</span> <a name="VALget_extension"></a>get_extension : <code class="type"><a href="FilePath.html#TYPEfilename">filename</a> -> <a href="FilePath.html#TYPEextension">extension</a></code></pre><div class="info"> Extract the extension.<br> </div> <pre><span class="keyword">val</span> <a name="VALcheck_extension"></a>check_extension : <code class="type"><a href="FilePath.html#TYPEfilename">filename</a> -> <a href="FilePath.html#TYPEextension">extension</a> -> bool</code></pre><div class="info"> Check the extension.<br> </div> <pre><span class="keyword">val</span> <a name="VALadd_extension"></a>add_extension : <code class="type"><a href="FilePath.html#TYPEfilename">filename</a> -> <a href="FilePath.html#TYPEextension">extension</a> -> <a href="FilePath.html#TYPEfilename">filename</a></code></pre><div class="info"> Add an extension with a "." before.<br> </div> <pre><span class="keyword">val</span> <a name="VALreplace_extension"></a>replace_extension : <code class="type"><a href="FilePath.html#TYPEfilename">filename</a> -> <a href="FilePath.html#TYPEextension">extension</a> -> <a href="FilePath.html#TYPEfilename">filename</a></code></pre><div class="info"> Replace extension.<br> </div> <br> <a name="2_PATHlikeoperation"></a> <h2>PATH-like operation</h2><br> <br> PATH-like refers the environment variable PATH. This variable holds a list of filename. The functions <code class="code">string_of_path</code> and <code class="code">path_of_string</code> allow to convert this kind of list by using the good separator between filename.<br> <pre><span class="keyword">val</span> <a name="VALstring_of_path"></a>string_of_path : <code class="type"><a href="FilePath.html#TYPEfilename">filename</a> list -> string</code></pre><div class="info"> Create a PATH-like string.<br> </div> <pre><span class="keyword">val</span> <a name="VALpath_of_string"></a>path_of_string : <code class="type">string -> <a href="FilePath.html#TYPEfilename">filename</a> list</code></pre><div class="info"> Extract filenames from a PATH-like string.<br> </div> <br> <a name="2_Filenamespecifications"></a> <h2>Filename specifications</h2><br> <br> Definition of operations for path manipulation.<br> <pre><span class="keyword">module type</span> <a href="FilePath.PATH_SPECIFICATION.html">PATH_SPECIFICATION</a> = <code class="code">sig</code> <a href="FilePath.PATH_SPECIFICATION.html">..</a> <code class="code">end</code></pre><div class="info"> Generic operations. </div> <pre><span class="keyword">module type</span> <a href="FilePath.PATH_STRING_SPECIFICATION.html">PATH_STRING_SPECIFICATION</a> = <code class="code">sig</code> <a href="FilePath.PATH_STRING_SPECIFICATION.html">..</a> <code class="code">end</code></pre><div class="info"> Generic operations, with type filename and extension as strings. </div> <br> Operations on filenames for other OS. The <a href="FilePath.DefaultPath.html"><code class="code">FilePath.DefaultPath</code></a> always match the current OS.<br> <pre><span class="keyword">module</span> <a href="FilePath.DefaultPath.html">DefaultPath</a>: <code class="type"><a href="FilePath.PATH_STRING_SPECIFICATION.html">PATH_STRING_SPECIFICATION</a></code><code class="type"> </code></pre><div class="info"> Default operating system. </div> <pre><span class="keyword">module</span> <a href="FilePath.UnixPath.html">UnixPath</a>: <code class="type"><a href="FilePath.PATH_STRING_SPECIFICATION.html">PATH_STRING_SPECIFICATION</a></code><code class="type"> </code></pre><div class="info"> Unix operating system. </div> <pre><span class="keyword">module</span> <a href="FilePath.MacOSPath.html">MacOSPath</a>: <code class="type"><a href="FilePath.PATH_STRING_SPECIFICATION.html">PATH_STRING_SPECIFICATION</a></code><code class="type"> </code></pre><div class="info"> MacOS operating system. </div> <pre><span class="keyword">module</span> <a href="FilePath.Win32Path.html">Win32Path</a>: <code class="type"><a href="FilePath.PATH_STRING_SPECIFICATION.html">PATH_STRING_SPECIFICATION</a></code><code class="type"> </code></pre><div class="info"> Win32 operating system. </div> <pre><span class="keyword">module</span> <a href="FilePath.CygwinPath.html">CygwinPath</a>: <code class="type"><a href="FilePath.PATH_STRING_SPECIFICATION.html">PATH_STRING_SPECIFICATION</a></code><code class="type"> </code></pre><div class="info"> Cygwin operating system. </div> </body></html>