mirror of
https://github.com/boostorg/filesystem.git
synced 2026-01-30 07:52:08 +00:00
123 lines
4.0 KiB
HTML
123 lines
4.0 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="../../../c++boost.gif" 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>void 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>Postcondition:</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 defintion of extension is probably not sufficient
|
|
when using <a href="http://tinyurl.com/9tih">Alternate Data Streams</a> —
|
|
a filesystem feature specific to NTFS. However, semantic in this case was not
|
|
clear, and the current one is quite usefull still.
|
|
</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 basename( 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 -->02 October, 2003<!--webbot bot="Timestamp" endspan i-checksum="38549" --></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> |