Files
filesystem/doc/convenience.htm
2005-05-14 12:38:44 +00:00

132 lines
4.4 KiB
HTML

<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
<title>Boost Filesystem convenience.hpp Header</title>
</head>
<body bgcolor="#FFFFFF">
<h1>
<img border="0" src="../../../boost.png" align="center" width="277" height="86"><a href="../../../boost/filesystem/convenience.hpp">boost/filesystem/convenience.hpp</a></h1>
<p>Header <a href="../../../boost/filesystem/convenience.hpp">convenience.hpp</a>
provides convenience functions that combine lower-level functions in useful
ways.</p>
<h2>Contents</h2>
<dl class="index">
<dt><a href="#create_directories">create_directories</a>
<dt><a href="#extension">extension</a>
<dt><a href="#basename">basename</a>
<dt><a href="#change_extension">change_extension</a>
</dl>
<h2 id="create_directoies">create_directories</h2>
<blockquote>
<p><code>template&lt;class Path&gt;<br>
bool create_directories( const Path &amp; ph );</code></p>
<p><b>Precondition:</b> <code>ph.empty() || <br>
forall p: p == ph || is_parent(p, ph): is_directory(p) || !exists( p )</code>
</p>
<p><b>Returns:</b> The value of <code>!exists(ph)</code> prior to the
establishment of the postcondition.</p>
<p><b>Postcondition:</b> <code>is_directory(ph)</code></p>
<p><b>Throws:</b> <code>exists(ph) &amp;&amp; !is_directory(ph)</code></p>
<p>Contributed by Vladimir Prus.</p>
</blockquote>
<h2 id="extension">extension</h2>
<blockquote>
<p><code>template&lt;class Path&gt;<br>
typename Path::string_type extension( const Path &amp; ph );</code></p>
<p><b>Returns:</b> if <code>ph.leaf()</code> contains a dot ('.'),
returns the substring of <code>ph.leaf()</code> starting from the last dot and
ending at the string's end. Otherwise, returns an empty string.
<p><b>Rationale:</b> <ul>
<li>The dot is included in the return value so that it's
possible to tell if extension is empty or absent.
<li>It was noted that this definition of extension is probably not sufficient
when using <a href="http://tinyurl.com/9tih">Alternate Data Streams</a> &mdash;
a filesystem feature specific to NTFS. However, semantics in this case were not
clear, and the current behavior is still quite useful.
</ul>
<p><b>Acknowlegements:</b> Carl Daniel and Pavel Vozenilek noticed and
discussed the ADS issue.
<p>Contributed by Vladimir Prus.</p>
</blockquote>
<h2 id="basename">basename</h2>
<blockquote>
<p><code>template&lt;class Path&gt;<br>
typename Path::string_type basename( const Path &amp; ph );</code></p>
<p><b>Returns:</b> if <code>ph.leaf()</code> contains a dot ('.'),
returns the substring of <code>ph.leaf()</code> starting from beginning and
ending at the last dot (the dot is not included). Otherwise, returns
<code>ph.leaf()</code>
</p>
<p>Contributed by Vladimir Prus.</p>
</blockquote>
<h2 id="change_extension">change_extension</h2>
<blockquote>
<p><code>template&lt;class Path&gt;<br>
Path change_extension( const Path &amp; ph, const typename Path::string_type &amp; new_extension );</code></p>
<p><b>Postcondition:</b> <code>basename(return_value) == basename(ph)
&amp;&amp; extension(return_value) == new_extension</code>
<p><b>Note:</b> It follows from the semantic of <code>extension</code> that
<code>new_extension</code> should include dot to achieve reasonable results.
</p>
<p><b>Rationale:</b> Previously, this functions had
<code>!ph.leaf().empty()</code> as precondition. It's not clear if it was
right or wrong. Changing extension of an empty path looks pointless. On the
other hand, the value of precondition was questionable: one would better place such
checks at the points where paths are entered by the user. Current decision
is to drop the precondition.</p>
<p>Contributed by Vladimir Prus.</p>
</blockquote>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->14 May, 2005<!--webbot bot="Timestamp" endspan i-checksum="13995" --></p>
<p>© Copyright Vladimir Prus, 2003</p>
<p> Use, modification, and distribution are subject to the Boost Software
License, Version 1.0. (See accompanying file <a href="../../../LICENSE_1_0.txt">
LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
www.boost.org/LICENSE_1_0.txt</a>)</p>
</body>
</html>