Skip to content

Commit 7339882

Browse files
committed
Added BOOST_FILESYSTEM_VERSION 4 and moved breaking path changes to v4.
Boost.Filesystem v4 will contain breaking changes from v3 that are required for better compatibility with C++17 std::filesystem. It will also remove the deprecated features of v3. Updated docs to reflect the differences between v3 and v4. Updated tests to verify both v3 and v4 where the differences are present.
1 parent 9df2bfa commit 7339882

28 files changed

+435
-102
lines changed

doc/deprecated.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<a href="faq.htm">FAQ</a> &nbsp;&nbsp;
3232
<a href="release_history.html">Releases</a> &nbsp;&nbsp;
3333
<a href="portability_guide.htm">Portability</a> &nbsp;&nbsp;
34+
<a href="v4.html">V4</a> &nbsp;&nbsp;
3435
<a href="v3.html">V3 Intro</a> &nbsp;&nbsp;
3536
<a href="v3_design.html">V3 Design</a> &nbsp;&nbsp;
3637
<a href="deprecated.html">Deprecated</a> &nbsp;&nbsp;

doc/faq.htm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<a href="faq.htm">FAQ</a> &nbsp;&nbsp;
3232
<a href="release_history.html">Releases</a> &nbsp;&nbsp;
3333
<a href="portability_guide.htm">Portability</a> &nbsp;&nbsp;
34+
<a href="v4.html">V4</a> &nbsp;&nbsp;
3435
<a href="v3.html">V3 Intro</a> &nbsp;&nbsp;
3536
<a href="v3_design.html">V3 Design</a> &nbsp;&nbsp;
3637
<a href="deprecated.html">Deprecated</a> &nbsp;&nbsp;

doc/index.htm

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
width="300" height="86" border="0"></a></td>
2121
<td align="middle">
2222
<font size="7">Filesystem Library<br>
23-
Version 3</font>
23+
Version 4</font>
2424
</td>
2525
</tr>
2626
</table>
@@ -34,6 +34,7 @@
3434
<a href="faq.htm">FAQ</a> &nbsp;&nbsp;
3535
<a href="release_history.html">Releases</a> &nbsp;&nbsp;
3636
<a href="portability_guide.htm">Portability</a> &nbsp;&nbsp;
37+
<a href="v4.html">V4</a> &nbsp;&nbsp;
3738
<a href="v3.html">V3 Intro</a> &nbsp;&nbsp;
3839
<a href="v3_design.html">V3 Design</a> &nbsp;&nbsp;
3940
<a href="deprecated.html">Deprecated</a> &nbsp;&nbsp;
@@ -147,6 +148,9 @@ <h2><a name="Documentation">Documentation</a></h2>
147148
<p><b><a href="deprecated.html">Deprecated Features</a></b> - Identifies
148149
deprecated features and their replacements.</p>
149150

151+
<p><b><a href="v4.html">Version 4 Description</a></b> - Summary of changes from
152+
Version 3.</p>
153+
150154
<p><b><a href="v3.html">Version 3 Introduction</a></b> - Aimed at users of prior
151155
Boost.Filesystem versions.</p>
152156

@@ -229,11 +233,12 @@ <h2><a name="Headers">Headers</a></h2>
229233
<li>Header &lt;<a href="../../../boost/filesystem.hpp">boost/filesystem.hpp</a>&gt;
230234
provides access to all features of the library, except file streams.<br>
231235
&nbsp;</li>
232-
<li>Header &lt;<a href="../../../boost/filesystem/fstream.hpp">boost/filesystem<i>/</i>fstream.hpp</a>&gt;
236+
<li>Header &lt;<a href="../../../boost/filesystem/fstream.hpp">boost/filesystem/fstream.hpp</a>&gt;
233237
inherits the same components as the C++ Standard
234238
Library's <i>fstream</i> header, but files are identified by <code>const path&amp;</code>
235239
arguments rather that <code>const char*</code> arguments.</li>
236240
</ul>
241+
237242
<h2><a name="Examples">Example programs</a></h2>
238243
<p>See the <a href="tutorial.html">tutorial</a> for example programs.</p>
239244
<h2><a name="Implementation">Implementation</a></h2>
@@ -242,6 +247,7 @@ <h2><a name="Implementation">Implementation</a></h2>
242247
<p>The library is in regular use on Apple OS X, HP-UX, IBM AIX, Linux,
243248
Microsoft Windows, SGI IRIX, and Sun Solaris operating systems using a variety
244249
of compilers. It is also used by several smart phone operating systems.</p>
250+
245251
<h2><a name="Macros">Macros</a></h2>
246252
<p>Users may define the following macros if desired. Sensible defaults are
247253
provided, so users can ignore these macros unless they have special needs.</p>
@@ -251,6 +257,12 @@ <h2><a name="Macros">Macros</a></h2>
251257
<td><b><i>Default</i></b></td>
252258
<td><b><i>Effect if defined</i></b></td>
253259
</tr>
260+
<tr>
261+
<td valign="top"><code>BOOST_FILESYSTEM_VERSION</code></td>
262+
<td valign="top">3</td>
263+
<td valign="top">Selects the Boost.Filesystem library version. Can have values of 3 or 4.
264+
Defining to 4 also implies <code>BOOST_FILESYSTEM_NO_DEPRECATED</code>.</td>
265+
</tr>
254266
<tr>
255267
<td valign="top"><code>BOOST_FILESYSTEM_NO_DEPRECATED</code></td>
256268
<td valign="top">Not defined.</td>
@@ -321,7 +333,7 @@ <h2><a name="Building">Building</a> the object-library</h2>
321333
This is controlled by the BOOST_ALL_DYN_LINK or BOOST_FILESYSTEM_DYN_LINK
322334
macros. See the <a href="http://www.boost.org/development/separate_compilation.html">Separate
323335
Compilation</a> page for a description of the techniques used.</p>
324-
<h3>Note for <a name="Cgywin">Cygwin</a> users</h3>
336+
<h3>Note for <a name="Cygwin">Cygwin</a> users</h3>
325337
<p> <a href="http://www.cygwin.com/">Cygwin</a> version 1.7 or later is
326338
required because only versions of GCC with wide character strings are supported.</p>
327339

@@ -333,11 +345,12 @@ <h2><a name="Change-history">Version history</a></h2>
333345

334346
<h3>Version 4</h3>
335347

336-
<p><b>Under development </b>- Add support for the
337-
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4099.html">ISO
338-
C++ File System Technical Specification</a>. The Filesystem TS is based on
348+
<p><b>Under development</b> - Improve compatibility with std::filesystem introduced in C++17
349+
(original proposal: <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4099.html">ISO
350+
C++ File System Technical Specification</a>). The Filesystem TS was based on
339351
Boost.Filesystem Version 3, with only a small number of changes. Most user code
340-
written for Version 3 should work unchanged with Version 4.</p>
352+
written for Version 3 should work unchanged with Version 4. The differences can be seen in a
353+
<a href="v4.html">separate section</a>.</p>
341354

342355
<h3>Version 3</h3>
343356

doc/issue_reporting.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<a href="faq.htm">FAQ</a> &nbsp;&nbsp;
3131
<a href="release_history.html">Releases</a> &nbsp;&nbsp;
3232
<a href="portability_guide.htm">Portability</a> &nbsp;&nbsp;
33+
<a href="v4.html">V4</a> &nbsp;&nbsp;
3334
<a href="v3.html">V3 Intro</a> &nbsp;&nbsp;
3435
<a href="v3_design.html">V3 Design</a> &nbsp;&nbsp;
3536
<a href="deprecated.html">Deprecated</a> &nbsp;&nbsp;

doc/portability_guide.htm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ <h1>
2525
<a href="faq.htm">FAQ</a> &nbsp;&nbsp;
2626
<a href="release_history.html">Releases</a> &nbsp;&nbsp;
2727
<a href="portability_guide.htm">Portability</a> &nbsp;&nbsp;
28+
<a href="v4.html">V4</a> &nbsp;&nbsp;
2829
<a href="v3.html">V3 Intro</a> &nbsp;&nbsp;
2930
<a href="v3_design.html">V3 Design</a> &nbsp;&nbsp;
3031
<a href="deprecated.html">Deprecated</a> &nbsp;&nbsp;

doc/reference.html

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
<img src="../../../boost.png" alt="boost.png (6897 bytes)" align="middle" width="300" height="86" border="0"></a></td>
2727
<td align="middle">
2828
<font size="7">Filesystem Library<br>
29-
</font>
30-
<font size="6">Version 3</font></td>
29+
Version 4</font></td>
3130
</tr>
3231
</table>
3332

@@ -40,6 +39,7 @@
4039
<a href="faq.htm">FAQ</a> &nbsp;&nbsp;
4140
<a href="release_history.html">Releases</a> &nbsp;&nbsp;
4241
<a href="portability_guide.htm">Portability</a> &nbsp;&nbsp;
42+
<a href="v4.html">V4</a> &nbsp;&nbsp;
4343
<a href="v3.html">V3 Intro</a> &nbsp;&nbsp;
4444
<a href="v3_design.html">V3 Design</a> &nbsp;&nbsp;
4545
<a href="deprecated.html">Deprecated</a> &nbsp;&nbsp;
@@ -271,7 +271,7 @@ <h3>ISO/IEC 9945 conformance [fs.conform.9945]</h3>
271271
reasonable behavior, the implementation shall report an error in an
272272
implementation-defined manner.</p>
273273
<blockquote>
274-
<p>[<i>Note:</i> Such errors might be reported by an #error directive, a <code>
274+
<p>[<i>Note:</i> Such errors might be reported by an <code>#error</code> directive, a <code>
275275
static_assert</code>, a <code>filesystem_error</code> exception, a special
276276
return value, or some other manner. <i>—end note</i>]</p>
277277
</blockquote>
@@ -696,7 +696,7 @@ <h2><a name="Header-filesystem-synopsis">Header <code>&lt;boost/filesystem.hpp&g
696696

697697
bool lexicographical_compare(path::iterator first1, path::iterator last1,
698698
path::iterator first2, path::iterator last2);
699-
void swap(path&amp; lhs, path&amp; rhs);
699+
void swap(path&amp; lhs, path&amp; rhs) noexcept;
700700
std::size_t <a href="#hash_value">hash_value</a>(const path&amp; p);
701701

702702
bool operator==(const path&amp; lhs, const path&amp; rhs);
@@ -1122,7 +1122,7 @@ <h2><a name="class-path">Class <code>path</code> [class.path]</a></h2>
11221122
path&amp; <a href="#path-make_preferred">make_preferred</a>();
11231123
path&amp; <a href="#path-remove_filename">remove_filename</a>();
11241124
path&amp; <a href="#path-replace_extension">replace_extension</a>(const path&amp; new_extension = path());
1125-
void <a href="#path-swap">swap</a>(path&amp; rhs);
1125+
void <a href="#path-swap">swap</a>(path&amp; rhs) noexcept;
11261126

11271127
// lexical operations
11281128
path <a href="#lexically_normal">lexically_normal</a>() const;
@@ -1224,7 +1224,7 @@ <h4>Windows concerns</h4>
12241224

12251225
<p>Visual C++ at least through version 2012 does not employ C++11-style static
12261226
initialization locks, so the initialization of <code>path::codecvt()</code> can
1227-
race, either with itself or <code>path::imbue::()</code> if they are called from
1227+
race, either with itself or <code>path::imbue()</code> if they are called from
12281228
a different thread. A workaround is to call:</p>
12291229

12301230
<blockquote>
@@ -1714,14 +1714,16 @@ <h3> <a name="path-decomposition"> <code><font size="4">path</font></code> decom
17141714
<pre>path <a name="path-filename">filename</a>() const;</pre>
17151715

17161716
<blockquote>
1717-
<p><i>Returns:</i> <code>*this == <a href="#path-root_path">root_path</a>() ? path() : *--end()</code></p>
1717+
<p><i>Returns:</i> <b>v3:</b> <code>empty() ? path() : *--end()</code><br/>
1718+
<b>v4:</b> <code>*this == <a href="#path-root_path">root_path</a>() ? path() : *--end()</code></p>
17181719
<p>[<i>Example:</i></p>
17191720
<blockquote>
17201721

17211722
<pre>std::cout &lt;&lt; path(&quot;/foo/bar.txt&quot;).filename(); // outputs &quot;bar.txt&quot;
17221723
std::cout &lt;&lt; path(&quot;/foo/bar&quot;).filename(); // outputs &quot;bar&quot;
17231724
std::cout &lt;&lt; path(&quot;/foo/bar/&quot;).filename(); // outputs &quot;.&quot;
1724-
std::cout &lt;&lt; path(&quot;/&quot;).filename(); // outputs &quot;&quot;
1725+
std::cout &lt;&lt; path(&quot;/&quot;).filename(); // v3 outputs &quot;/&quot;
1726+
// v4 outputs &quot;&quot;
17251727
std::cout &lt;&lt; path(&quot;.&quot;).filename(); // outputs &quot;.&quot;
17261728
std::cout &lt;&lt; path(&quot;..&quot;).filename(); // outputs &quot;..&quot;</pre>
17271729

@@ -1736,14 +1738,15 @@ <h3> <a name="path-decomposition"> <code><font size="4">path</font></code> decom
17361738

17371739
<blockquote>
17381740
<p><i>Returns:</i> If <code>p.<a href="path-filename">filename</a>()</code> does not contain dots, consist solely of one
1739-
or to two dots, or contains exactly one dot as the initial character, returns <code>p.filename()</code>.
1741+
or to two dots, <i>[Since <b>v4</b>:</i> or contains exactly one dot as the initial character,<i>]</i> returns <code>p.filename()</code>.
17401742
Otherwise returns the substring of <code>p.filename()</code> starting at its beginning and
17411743
ending at the last dot (the dot is not included).</p>
17421744
<p>[<i>Example:</i></p>
17431745
<blockquote>
17441746

17451747
<pre>std::cout &lt;&lt; path(&quot;/foo/bar.txt&quot;).stem() &lt;&lt; '\n'; // outputs &quot;bar&quot;
1746-
std::cout &lt;&lt; path(&quot;.hidden&quot;).stem() &lt;&lt; '\n'; // outputs &quot;.hidden&quot;
1748+
std::cout &lt;&lt; path(&quot;.hidden&quot;).stem() &lt;&lt; '\n'; // v3 outputs &quot;&quot;
1749+
// v4 outputs &quot;.hidden&quot;
17471750
path p = &quot;foo.bar.baz.tar&quot;;
17481751
for (; !p.extension().empty(); p = p.stem())
17491752
std::cout &lt;&lt; p.extension() &lt;&lt; '\n';
@@ -2066,14 +2069,13 @@ <h3> <a name="path-non-member-functions"> <code><font size="4">path</font></code
20662069
relative</a></code>&nbsp; <i>—end note</i>]</p>
20672070
<p>[<i>Note:</i> If <a href="#normal-form">normalization</a> is needed to ensure consistent matching of elements, wrap
20682071
<code>p</code>, <code>base</code>, or both in calls <code>
2069-
<a href="#lex-normal">
2070-
lexically_normal()</a></code>. <i>—end note</i>]</p>
2072+
<a href="#lex-normal">lexically_normal</a>()</code>. <i>—end note</i>]</p>
20712073
</blockquote>
2072-
<pre>void swap( path&amp; lhs, path&amp; rhs )</pre>
2074+
<pre>void swap(path&amp; lhs, path&amp; rhs) noexcept;</pre>
20732075
<blockquote>
20742076
<p><i>Effects: </i><code>lhs.swap(rhs)</code>.</p>
20752077
</blockquote>
2076-
<pre>std::size_t <a name="hash_value">hash_value</a> (const path&amp; p);</pre>
2078+
<pre>std::size_t <a name="hash_value">hash_value</a>(const path&amp; p);</pre>
20772079
<blockquote>
20782080
<p><i>Returns:</i> A hash value for the path <code>p</code>. If
20792081
for two paths, <code>p1 == p2</code> then <code>hash_value(p1) == hash_value(p2)</code>.</p>

doc/relative_proposal.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<a href="faq.htm">FAQ</a> &nbsp;&nbsp;
3333
<a href="release_history.html">Releases</a> &nbsp;&nbsp;
3434
<a href="portability_guide.htm">Portability</a> &nbsp;&nbsp;
35+
<a href="v4.html">V4</a> &nbsp;&nbsp;
3536
<a href="v3.html">V3 Intro</a> &nbsp;&nbsp;
3637
<a href="v3_design.html">V3 Design</a> &nbsp;&nbsp;
3738
<a href="deprecated.html">Deprecated</a> &nbsp;&nbsp;

doc/release_history.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<a href="faq.htm">FAQ</a> &nbsp;&nbsp;
3232
<a href="release_history.html">Releases</a> &nbsp;&nbsp;
3333
<a href="portability_guide.htm">Portability</a> &nbsp;&nbsp;
34+
<a href="v4.html">V4</a> &nbsp;&nbsp;
3435
<a href="v3.html">V3 Intro</a> &nbsp;&nbsp;
3536
<a href="v3_design.html">V3 Design</a> &nbsp;&nbsp;
3637
<a href="deprecated.html">Deprecated</a> &nbsp;&nbsp;
@@ -40,6 +41,11 @@
4041

4142
<h2>1.77.0</h2>
4243
<ul>
44+
<li><b>Introducing Boost.Filesystem v4.</b> This new version of the library removes all deprecated features of v3 and also makes a number of breaking API changes intended to make Boost.Filesystem more compatible with std::filesystem introduced in C++17. The differences are described in the release notes and documentation using <b>v3</b> and <b>v4</b> tags and are also summarised in a <a href="v4.html">separate section</a>. Users can select Boost.Filesystem version by defining <code>BOOST_FILESYSTEM_VERSION</code> macro to either 3 or 4 when compiling their code. There is no need to separately compile Boost.Filesystem for each library version &mdash; a single binary supports both v3 and v4. Users should avoid using both v3 and v4 in the same application as this can lead to subtle bugs. Currently, v3 is the default. In a future release v4 will become the default, and eventually v3 will be removed. v4 is functional, but it is still a work in progress and there may be breaking API changes in the future.</li>
45+
<li><b>v4:</b> <code>path::filename</code>, <code>path::stem</code> and <code>path::extension</code> no longer consider root name or root directory of the path as a filename if the path only consists of those components. For example, on Windows <code>path("C:").filename()</code> used to return "C:" and <code>path("C:\").filename()</code> used to return "\" and both will return an empty path now. (<a href="https://github.com/boostorg/filesystem/issues/88">#88</a>, <a href="https://github.com/boostorg/filesystem/issues/194">#194</a>)</li>
46+
<li><b>v4:</b> <code>path::stem</code> and <code>path::extension</code> no longer treat a filename that starts with a dot and has no other dots as an extension. Filenames starting with a dot are commonly treated as filenames with an empty extension. The leading dot is used to indicate a hidden file on most UNIX-like systems. (<a href="https://github.com/boostorg/filesystem/issues/88">#88</a>)</li>
47+
<li><b>New:</b> Improved support for various path prefixes on Windows. Added support for local device prefix ("\\.\") and experimental support for NT path prefix ("\??\"). The prefixes will be included in the root name of a path. Note that using the prefixes with Boost.Filesystem v3 can lead to surprising results (e.g. <code>path("\\\\.\\").stem() == "\\\\"</code>). It is recommended to use the prefixes only with Boost.Filesystem v4.</li>
48+
<li>Reworked <code>path::lexically_normal</code> implementation to eliminate some cases of duplicate dot (".") elements in the normalized paths.</li>
4349
<li><b>New:</b> Added support for disabling usage of various system APIs at library build time. This can be useful when a certain API is detected as present by the library configuration scripts but must not be used for some reason (for example, when it is known to fail on the target system). See the description of <a href="index.htm#Macros">configuration macros</a> for more details.</li>
4450
<li><b>New:</b> Added <code>copy_options::synchronize_data</code> and <code>copy_options::synchronize</code> options for the <code>copy_file</code> operation. These options allow to synchronize the written data and attributes with the permanent storage. These options are expensive in terms of performance, but allow to ensure reliability of the copied data. Note that <code>copy_file</code> performed implicit data synchronization on POSIX systems since Boost.Filesystem 1.74.0. This release adds support for more platforms and disables data synchronization by default while allowing the caller to explicitly request it. (<a href="https://github.com/boostorg/filesystem/issues/186">#186</a>)</li>
4551
<li>Added handling of <code>EINTR</code> error code on POSIX systems for some system calls issued internally. In particular, <code>EINTR</code> could have been ignored on <code>close</code>, which on HP-UX would result in a leaked file descriptor.</li>
@@ -52,11 +58,7 @@ <h2>1.77.0</h2>
5258
<li>In <code>canonical</code>, added a limit for the maximum number of symlinks that can be resolved during the call. The limit is currently at least 40 symlinks.</li>
5359
<li>On Windows, <code>canonical</code> and <code>weakly_canonical</code> will now use <code>path::preferred_separator</code> for the root directory separator in the resulting paths. This fixes "file not found" errors caused by Windows API not handling generic separators in UNC paths and paths that start with the Win32 filesystem prefix ("\\?\"). (<a href="https://github.com/boostorg/filesystem/issues/87">#87</a>, <a href="https://github.com/boostorg/filesystem/issues/187">#187</a>)</li>
5460
<li><b>New:</b> Added <code>weakly_canonical</code> overloads taking <code>base</code> path as an argument.</li>
55-
<li><b>Breaking change:</b><code>path::filename</code>, <code>path::stem</code> and <code>path::extension</code> no longer consider root name or root directory of the path as a filename if the path only consists of those components. For example, on Windows <code>path("C:").filename()</code> used to return "C:" and <code>path("C:\").filename()</code> used to return "\" and both will return an empty path now. (<a href="https://github.com/boostorg/filesystem/issues/88">#88</a>, <a href="https://github.com/boostorg/filesystem/issues/194">#194</a>)</li>
56-
<li><b>Breaking change:</b><code>path::stem</code> and <code>path::extension</code> no longer treat a filename that starts with a dot and has no other dots as an extension. Filenames starting with a dot are commonly treated as filenames with an empty extension. The leading dot is used to indicate a hidden file on most UNIX-like systems. (<a href="https://github.com/boostorg/filesystem/issues/88">#88</a>)</li>
57-
<li><b>New:</b> Improved support for various path prefixes on Windows. Added support for local device prefix ("\\.\") and experimental support for NT path prefix ("\??\"). The prefixes will be included in the root name of a path.</li>
5861
<li>In <code>read_symlink</code> on Windows, corrected reparse point handling. The operation would return an empty path for some mount points (for example, created by <a href="https://www.box.com/">Box</a> cloud storage driver) and directory junction points that had empty print names. The new implementation now parses substitute name of the reparse point and attempts to reconstruct a Win32 path from it. (<a href="https://github.com/boostorg/filesystem/issues/187">#187</a>)</li>
59-
<li>Reworked <code>path::lexically_normal</code> implementation to eliminate some cases of duplicate dot (".") elements in the normalized paths.</li>
6062
<li>On Windows, file streams provided in <code>boost/filesystem/fstream.hpp</code> will use wide character paths on libc++ versions 7.0 and higher, when the standard library supports opening files with wide character paths. (<a href="https://github.com/boostorg/filesystem/issues/181">#181</a>)</li>
6163
<li>On Windows, creating symlinks should no longer require elevated privileges, if Windows is configured in <a href="https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development">Developer mode</a>.</li>
6264
</ul>

0 commit comments

Comments
 (0)