1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
<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_directories">create_directories</h2>
<blockquote>
<p><code>bool create_directories( const path & 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>exists(ph) && is_directory(ph)</code></p>
<p><b>Throws:</b> <code>exists(ph) && !is_directory(ph)</code></p>
<p>Contributed by Vladimir Prus.</p>
</blockquote>
<h2 id="extension">extension</h2>
<blockquote>
<p><code>std::string extension( const path & 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 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://support.microsoft.com/kb/105763">Alternate Data Streams</a> —
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>std::string basename( const path & 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>path change_extension( const path & ph, const std::string & new_extension );</code></p>
<p><b>Postcondition:</b> <code>basename(return_value) == basename(ph)
&& 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 -->11 March, 2004<!--webbot bot="Timestamp" endspan i-checksum="28863" --></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>
|