|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r59158 - in sandbox/filesystem-v3: boost/filesystem libs/filesystem/doc libs/filesystem/src libs/filesystem/test
From: bdawes_at_[hidden]
Date: 2010-01-20 12:47:47
Author: bemandawes
Date: 2010-01-20 12:47:46 EST (Wed, 20 Jan 2010)
New Revision: 59158
URL: http://svn.boost.org/trac/boost/changeset/59158
Log:
Change path::absolute to modifier, deprecate complete
Text files modified:
sandbox/filesystem-v3/boost/filesystem/operations.hpp | 16 +---
sandbox/filesystem-v3/boost/filesystem/path.hpp | 21 ++----
sandbox/filesystem-v3/libs/filesystem/doc/reference.html | 118 +++++++++++++++++++--------------------
sandbox/filesystem-v3/libs/filesystem/doc/v3.html | 45 +++++++-------
sandbox/filesystem-v3/libs/filesystem/src/operations.cpp | 16 -----
sandbox/filesystem-v3/libs/filesystem/src/path.cpp | 112 ++++++++++++++++++++++---------------
sandbox/filesystem-v3/libs/filesystem/test/operations_test.cpp | 17 +----
sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp | 9 +-
8 files changed, 166 insertions(+), 188 deletions(-)
Modified: sandbox/filesystem-v3/boost/filesystem/operations.hpp
==============================================================================
--- sandbox/filesystem-v3/boost/filesystem/operations.hpp (original)
+++ sandbox/filesystem-v3/boost/filesystem/operations.hpp 2010-01-20 12:47:46 EST (Wed, 20 Jan 2010)
@@ -126,8 +126,6 @@
BOOST_FILESYSTEM_DECL
file_status symlink_status(const path& p, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
- path complete(const path& p, const path& base);
- BOOST_FILESYSTEM_DECL
bool is_empty(const path& p, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
path initial_path(system::error_code* ec=0);
@@ -248,23 +246,19 @@
// //
//--------------------------------------------------------------------------------------//
+# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
inline
path complete(const path& p)
{
- path base (detail::initial_path(0));
- return detail::complete(p, base);
+ return path(p).absolute(detail::initial_path(0));
}
inline
- path complete(const path& p, system::error_code& ec)
+ path complete(const path& p, const path& base)
{
- path base (detail::initial_path(&ec));
- if (ec) return path();
- return detail::complete(p, base);
+ return path(p).absolute(base);
}
-
- inline
- path complete(const path& p, const path& base) {return detail::complete(p, base);}
+# endif
inline
void copy(const path& from, const path& to) {detail::copy(from, to);}
Modified: sandbox/filesystem-v3/boost/filesystem/path.hpp
==============================================================================
--- sandbox/filesystem-v3/boost/filesystem/path.hpp (original)
+++ sandbox/filesystem-v3/boost/filesystem/path.hpp 2010-01-20 12:47:46 EST (Wed, 20 Jan 2010)
@@ -199,18 +199,17 @@
// ----- modifiers -----
+ path& absolute(const path& base);
void clear() { m_pathname.clear(); }
- void swap(path& rhs) { m_pathname.swap(rhs.m_pathname); }
+ path& preferred()
+# ifdef BOOST_POSIX_PATH
+ { return *this; } // POSIX no effect
+# else // BOOST_WINDOWS_PATH
+ ; // change slashes to backslashes
+# endif
path& remove_filename();
path& replace_extension(const path& new_extension = path());
-
-# ifdef BOOST_POSIX_API
- path& preferred() { return *this; } // POSIX m_pathname already localized
-
-# else // BOOST_WINDOWS_API
- path& preferred(); // change slashes to backslashes
-
-# endif
+ void swap(path& rhs) { m_pathname.swap(rhs.m_pathname); }
// ----- observers -----
@@ -271,10 +270,6 @@
# endif
- // ----- composition -----
-
- path absolute(const path& base) const;
-
// ----- decomposition -----
path root_path() const;
Modified: sandbox/filesystem-v3/libs/filesystem/doc/reference.html
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/doc/reference.html (original)
+++ sandbox/filesystem-v3/libs/filesystem/doc/reference.html 2010-01-20 12:47:46 EST (Wed, 20 Jan 2010)
@@ -20,8 +20,7 @@
<td width="633" align="middle">
<font size="7">Filesystem Library<br>
</font>
- <font size="6">Version 3</font><font size="7"><br>
- </font></td>
+ <font size="6">Version 3</font></td>
</tr>
</table>
@@ -85,7 +84,6 @@
<td width="33%" valign="top">
<a href="#Operational-functions">
Operational functions</a><br>
-   complete<br>
  copy_file<br>
  create_directories<br>
  create_directory<br>
@@ -525,11 +523,12 @@
path& operator/=(Source const& source);
// modifiers
+ path& absolute(const path& base);
void clear();
- void swap(path& rhs);
+ path& preferred(); // POSIX: no effect. Windows: convert slashes to backslashes
path& remove_filename();
path& replace_extension(const path& new_extension = path());
- path& preferred(); // POSIX: no effect. Windows: convert slashes to backslashes
+ void swap(path& rhs);
// native format observers
const string_type& native() const; // native format, encoding
@@ -775,19 +774,57 @@
<h3> <a name="path-modifiers"> <code>
<font size="4">path</font></code> modifiers</a></h3>
+<pre>path& absolute(const path& base);</pre>
+ <blockquote>
+ <p><i>Preconditions:</i> <code>
+ (has_root_name() || base.has_root_name() || path("/").is_absolute()) && (has_root_directory()
+ || base.has_root_directory())</code> is true.</p>
+ <p><i>Effects:</i> Makes <code>pathname</code> absolute by applying the following rules:</p>
+ <table border="1" cellpadding="5" cellspacing="0" bordercolor="#111111" style="border-collapse: collapse">
+ <tr>
+ <td align="center"> </td>
+ <td align="center"><i><b><code>has_root_directory()</code></b></i></td>
+ <td align="center"><i><b><code>!has_root_directory()</code></b></i></td>
+ </tr>
+ <tr>
+ <td align="center"><i><b><code>has_root_name()</code></b></i></td>
+ <td align="center">No change</td>
+ <td align="center"><code>root_name() / base.root_directory()<br>
+ / base.relative_path() / relative_path()</code></td>
+ </tr>
+ <tr>
+ <td align="center"><i><b><code>!has_root_name()</code></b></i></td>
+ <td align="center"><code>base.root_name()<br>
+ / pathname</code></td>
+ <td align="center"><code>base / pathname</code></td>
+ </tr>
+ </table>
+ <p><i>Postconditions:</i> <code>
+ is_absolute()</code> is true.</p>
+ <p><i>Returns:</i> <code>*this</code>.</p>
+ <p>[<i><a name="complete_note">Note</a>:</i> When portable behavior is
+ required, use <i>absolute()</i>. When operating system dependent behavior is
+ required, use <i>system_complete()</i>.</p>
+ <p>Portable behavior is useful when dealing with paths created
+ internally within a program, particularly if the program should exhibit the
+ same behavior on all operating systems.</p>
+ <p>Operating system dependent behavior is useful when dealing with
+ paths supplied by user input, reported to program users, or when such behavior
+ is expected by program users. <i>--
+ end note</i>]</p>
+</blockquote>
<pre>void clear();</pre>
<blockquote>
<p><i>Postcondition:</i> <code>this->empty()</code> is true.</p>
</blockquote>
-<pre><code><span style="background-color: #FFFFFF">void swap( path& rhs );</span></code></pre>
+<pre>path& preferred();</pre>
<blockquote>
- <p><i><span style="background-color: #FFFFFF">Effects:</span></i><span style="background-color: #FFFFFF">
- Swaps the contents of the two paths.</span></p>
- <p><i><span style="background-color: #FFFFFF">Throws: </span></i>
- <span style="background-color: #FFFFFF">nothing.</span></p>
- <p><i><span style="background-color: #FFFFFF">Complexity: </span></i>
- <span style="background-color: #FFFFFF">constant time.</span></p>
+ <p><i>Effects:</i> The contained pathname is converted to the preferred native
+ format. [<i>Note:</i> On Windows, the effect is to replace slashes with
+ backslashes. On POSIX, there is no effect. <i>-- end note</i>]</p>
+ <p><i>Returns:</i> <code>*this</code></p>
</blockquote>
+
<pre>path& remove_filename();</pre>
<blockquote>
<p><i>Returns: </i>As if, <code>*this = parent_path();</code></p>
@@ -805,12 +842,14 @@
<code>new_extension</code>.</p>
<p><i>Returns:</i> <code>*this</code></p>
</blockquote>
-<pre>path& preferred();</pre>
+<pre><code><span style="background-color: #FFFFFF">void swap(path& rhs);</span></code></pre>
<blockquote>
- <p><i>Effects:</i> The contained pathname is converted to the preferred native
- format. [<i>Note:</i> On Windows, the effect is to replace slashes with
- backslashes. On POSIX, there is no effect. <i>-- end note</i>]</p>
- <p><i>Returns:</i> <code>*this</code></p>
+ <p><i><span style="background-color: #FFFFFF">Effects:</span></i><span style="background-color: #FFFFFF">
+ Swaps the contents of the two paths.</span></p>
+ <p><i><span style="background-color: #FFFFFF">Throws: </span></i>
+ <span style="background-color: #FFFFFF">nothing.</span></p>
+ <p><i><span style="background-color: #FFFFFF">Complexity: </span></i>
+ <span style="background-color: #FFFFFF">constant time.</span></p>
</blockquote>
<h3> <a name="path-native-format-observers"><code><font size="4">path</font></code>
@@ -1774,49 +1813,6 @@
that any filesystem operational function, no matter how apparently innocuous, may encounter
an error. See Error reporting. <i>-- end note</i>]</p>
<h4><a name="Function-specifications">Operational function specifications</a></h4>
-<pre>path <a name="complete">complete</a>(const path& p, const path& base, system::error_code& ec);</pre>
- <p><i>Effects:</i> Composes an absolute path from <code>p</code> and <code>base</code>,
- using the following rules:</p>
- <table border="1" cellpadding="5" cellspacing="0" bordercolor="#111111" style="border-collapse: collapse">
- <tr>
- <td align="center"> </td>
- <td align="center"><b><code>p.has_root_directory()</code></b></td>
- <td align="center"><b><code>!p.has_root_directory()</code></b></td>
- </tr>
- <tr>
- <td align="center"><b><code>p.has_root_name()</code></b></td>
- <td align="center"><code>p</code></td>
- <td align="center">precondition failure</td>
- </tr>
- <tr>
- <td align="center"><b><code>!p.has_root_name()</code></b></td>
- <td align="center"><code>base.root_name()<br>
- / p</code></td>
- <td align="center"><code>base / p</code></td>
- </tr>
- </table>
- <p><i>Postconditions:</i> For the returned path, <code>rp,</code> <code>
- rp.is_absolute()</code> is true.</p>
- <p><i>Returns:</i> The composed path.</p>
- <p><i><span style="background-color: #FFFF00">Throws: </span> </i> <code>
- <span style="background-color: #FFFF00">filesystem_error</span></code><span style="background-color: #FFFF00"> if
- </span> <code>
- <span style="background-color: #FFFF00">!(base.is_absolute() && (p.is_absolute() || !p.has_root_name()))</span></code></p>
- <p>[<i><a name="complete_note">Note</a>:</i> When portable behavior is
- required, use <i>complete()</i>. When operating system dependent behavior is
- required, use <i>system_complete()</i>.</p>
- <p>Portable behavior is useful when dealing with paths created
- internally within a program, particularly if the program should exhibit the
- same behavior on all operating systems.</p>
- <p>Operating system dependent behavior is useful when dealing with
- paths supplied by user input, reported to program users, or when such behavior
- is expected by program users. <i>--
- end note</i>]</p>
-<pre>path complete(const path& p, system::error_code& ec);</pre>
-<blockquote>
-<p><i>Returns:</i> <code>path(p, initial_path(), ec)</code>.</p>
-<p><i><span style="background-color: #FFFF00">Throws: </span> </i> </p>
-</blockquote>
<pre>void copy_file(const path& from, const path& to);</pre>
<blockquote>
<p><i>Effects: </i><code>copy_file(from, to,
@@ -3189,7 +3185,7 @@
<p>Distributed under the Boost Software License, Version 1.0. See
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>
<p>Revised
-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->18 January 2010<!--webbot bot="Timestamp" endspan i-checksum="32149" --></p>
+<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->20 January 2010<!--webbot bot="Timestamp" endspan i-checksum="32134" --></p>
</body>
Modified: sandbox/filesystem-v3/libs/filesystem/doc/v3.html
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/doc/v3.html (original)
+++ sandbox/filesystem-v3/libs/filesystem/doc/v3.html 2010-01-20 12:47:46 EST (Wed, 20 Jan 2010)
@@ -43,10 +43,21 @@
supported. This is a major simplification of the path abstraction,
particularly for functions that take path arguments.<br>
</li>
- <li>Support for error reporting via <code>error_code</code> is now uniform
- throughout the library.<br>
- </li>
- <li>New or improved operational functions include:<br>
+ <li>New class path members include:<br>
+ <ul>
+ <li><code>has_stem()</code></li>
+ <li><code>has_extension()</code></li>
+ <li><code>is_absolute()</code>. This renames <code>is_complete()</code>, which
+ is now deprecated.</li>
+ <li><code>is_relative()</code></li>
+ <li><code>absolute()</code>. This replaces the operations function <code>
+ complete()</code>, which is now deprecated.</li>
+ <li><code>preferred()<br>
+ </code></li>
+</ul>
+
+ </li>
+ <li>New or improved operations functions include:<br>
<ul>
<li><code>create_symlink()</code> now supported on both POSIX and Windows.</li>
<li><code>read_symlink()</code> function added. Supported on both POSIX and
@@ -58,26 +69,16 @@
</li>
</ul>
</li>
- <li>New class path members include:<br>
- <ul>
- <li><code>has_stem()</code></li>
- <li><code>has_extension()</code></li>
- <li><code>is_relative()<br>
- </code></li>
-</ul>
-
- </li>
- <li>Other changes:<br>
- <ul>
- <li>The preferred name for <code>path</code> member <code>is_complete()</code>
- is now <code>is_absolute()</code>. Use of <code>is_complete()</code> is
- deprecated.</li>
-</ul>
-
- </li>
+ <li>Support for error reporting via <code>error_code</code> is now uniform
+ throughout the operations functions.<br>
+ </li>
</ul>
<h2>Breaking changes</h2>
+
+<p>To ease the transition, Versions 2 and 3 will both included in the next
+several Boost releases. Version 2 will be the default version for one release
+cycle, and then Version 3 will become the default version.</p>
<h3>Class <code>path</code></h3>
<ul>
<li>Class template <code>basic_path</code> and its specializations are gone.
@@ -110,7 +111,7 @@
<p>Distributed under the Boost Software License, Version 1.0. See
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>
<p>Revised
-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->08 January 2010<!--webbot bot="Timestamp" endspan i-checksum="32148" --></p>
+<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->20 January 2010<!--webbot bot="Timestamp" endspan i-checksum="32134" --></p>
</body>
Modified: sandbox/filesystem-v3/libs/filesystem/src/operations.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/src/operations.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/src/operations.cpp 2010-01-20 12:47:46 EST (Wed, 20 Jan 2010)
@@ -585,22 +585,6 @@
}
BOOST_FILESYSTEM_DECL
- path complete(const path& p, const path& base)
- {
- if (p.empty() || base.empty())
- return p;
- if (p.has_root_name())
- {
- return p.has_root_directory()
- ? p
- : p.root_name()/ base.root_directory()/ base.relative_path()/ p.relative_path();
- }
- return p.has_root_directory()
- ? base.root_name()/ p
- : base / p;
- }
-
- BOOST_FILESYSTEM_DECL
void copy(const path& from, const path& to, system::error_code* ec)
{
file_status s(symlink_status(from, *ec));
Modified: sandbox/filesystem-v3/libs/filesystem/src/path.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/src/path.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/src/path.cpp 2010-01-20 12:47:46 EST (Wed, 20 Jan 2010)
@@ -175,17 +175,6 @@
return tmp.wstring();
}
- path & path::preferred()
- {
- for (string_type::iterator it = m_pathname.begin();
- it != m_pathname.end(); ++it)
- {
- if (*it == L'/')
- *it = L'\\';
- }
- return *this;
- }
-
# endif // BOOST_WINDOWS_PATH
// m_append_separator_if_needed ----------------------------------------------------//
@@ -218,16 +207,14 @@
)) { m_pathname.erase(sep_pos, 1); } // erase the added separator
}
- // composition ---------------------------------------------------------------------//
+ // modifiers -----------------------------------------------------------------------//
- path path::absolute(const path& base) const
+ path& path::absolute(const path& base)
{
// store expensive to compute values that are needed multiple times
path this_root_name (root_name());
path base_root_name (base.root_name());
-# ifdef BOOST_WINDOWS_PATH
path this_root_directory (root_directory());
-# endif
# ifndef BOOST_WINDOWS_PATH
BOOST_ASSERT(!this_root_name.empty() || !base_root_name.empty());
@@ -235,17 +222,70 @@
BOOST_ASSERT(!this_root_directory.empty() || base.has_root_directory());
- if (empty())
- return base;
+ if (m_pathname.empty())
+ m_pathname = base.m_pathname;
+
+ else if (!this_root_name.empty()) // has_root_name
+ {
+ if (this_root_directory.empty()) // !root_directory()
+ {
+ path tmp (this_root_name / base.root_directory()
+ / base.relative_path() / relative_path());
+ m_pathname.swap(tmp.m_pathname);
+ }
+ // else is_absolute() so do nothing at all
+ }
+
+ else if (has_root_directory())
+ {
+# ifdef BOOST_POSIX_PATH
+ if (base_root_name.empty() return *this;
+# endif
+ path tmp (base_root_name / m_pathname);
+ m_pathname.swap(tmp.m_pathname);
+ }
+
+ else
+ {
+ path tmp (base / m_pathname);
+ m_pathname.swap(tmp.m_pathname);
+ }
+
+ return *this;
+ }
+
+# ifdef BOOST_WINDOWS_PATH
+ path & path::preferred()
+ {
+ for (string_type::iterator it = m_pathname.begin();
+ it != m_pathname.end(); ++it)
+ {
+ if (*it == L'/')
+ *it = L'\\';
+ }
+ return *this;
+ }
+# endif
+
+ path& path::remove_filename()
+ {
+ m_pathname.erase(m_parent_path_end());
+ return *this;
+ }
+
+ path & path::replace_extension(const path & source)
+ {
+ // erase existing extension if any
+ size_type pos(m_pathname.rfind(dot));
+ if (pos != string_type::npos)
+ m_pathname.erase(pos);
+
+ // append source extension if any
+ pos = source.m_pathname.rfind(dot);
+ if (pos != string_type::npos)
+ m_pathname += source.c_str() + pos;
- if (!this_root_name.empty()) // has_root_name
- return has_root_directory()
- ? m_pathname
- : this_root_name / base.root_directory() / base.relative_path() / relative_path();
-
- return has_root_directory()
- ? base.root_name() / m_pathname
- : base / m_pathname;
+ return *this;
}
// decomposition -------------------------------------------------------------------//
@@ -327,12 +367,6 @@
: path(m_pathname.c_str(), m_pathname.c_str() + end_pos);
}
- path& path::remove_filename()
- {
- m_pathname.erase(m_parent_path_end());
- return *this;
- }
-
path path::filename() const
{
size_type pos(filename_pos(m_pathname, m_pathname.size()));
@@ -364,22 +398,6 @@
: path(name.m_pathname.c_str() + pos);
}
- path & path::replace_extension(const path & source)
- {
- // erase existing extension if any
- size_type pos(m_pathname.rfind(dot));
- if (pos != string_type::npos)
- m_pathname.erase(pos);
-
- // append source extension if any
- pos = source.m_pathname.rfind(dot);
- if (pos != string_type::npos)
- m_pathname += source.c_str() + pos;
-
- return *this;
- }
-
-
// m_normalize ----------------------------------------------------------------------//
path& path::m_normalize()
Modified: sandbox/filesystem-v3/libs/filesystem/test/operations_test.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/operations_test.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/operations_test.cpp 2010-01-20 12:47:46 EST (Wed, 20 Jan 2010)
@@ -1062,10 +1062,10 @@
std::string s2(fs::initial_path().root_path().string()+"foo");
BOOST_TEST_EQ(s1, s2);
- BOOST_TEST(fs::complete(fs::path("c:/")).string()
- == "c:/");
- BOOST_TEST(fs::complete(fs::path("c:/foo")).string()
- == "c:/foo");
+ BOOST_TEST(fs::path("x:/").absolute(fs::initial_path()).string()
+ == "x:/");
+ BOOST_TEST(fs::path("x:/foo").absolute(fs::initial_path()).string()
+ == "x:/foo");
BOOST_TEST(fs::system_complete(fs::path(fs::initial_path().root_name()))
== fs::initial_path());
@@ -1105,15 +1105,6 @@
BOOST_TEST(fs::current_path().is_absolute());
BOOST_TEST(fs::initial_path().string()
== fs::current_path().string());
-
- BOOST_TEST(fs::complete("").empty());
- fs::path px1 = fs::complete("/");
- fs::path px2 = fs::initial_path().root_path();
- BOOST_TEST(px1 == px2);
- BOOST_TEST(fs::complete("foo") == fs::initial_path().string()+"/foo");
- BOOST_TEST(fs::complete("/foo") == fs::initial_path().root_path().string()+"foo");
- BOOST_TEST(fs::complete("foo", fs::path("//net/bar"))
- == "//net/bar/foo");
}
// space_tests ---------------------------------------------------------------------//
Modified: sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp 2010-01-20 12:47:46 EST (Wed, 20 Jan 2010)
@@ -436,11 +436,11 @@
CHECK(++it == p3.end());
}
- // test_compositions ---------------------------------------------------------------//
+ // test_modifiers ------------------------------------------------------------------//
- void test_compositions()
+ void test_modifiers()
{
- std::cout << "testing compositions..." << std::endl;
+ std::cout << "testing modifiers..." << std::endl;
// CHECK(path("").absolute("") == ""); // should assert
// CHECK(path("").absolute("foo") == ""); // should assert
@@ -810,13 +810,12 @@
test_constructors();
test_assignments();
test_appends();
+ test_modifiers();
test_observers();
test_relationals();
test_inserter_and_extractor();
test_other_non_members();
- //test_modifiers();
test_iterators();
- test_compositions();
test_decompositions();
test_queries();
test_imbue_locale();
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk