|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r63524 - in trunk: boost/filesystem/v3 libs/filesystem/v3/doc libs/filesystem/v3/src libs/filesystem/v3/test
From: bdawes_at_[hidden]
Date: 2010-07-02 14:57:37
Author: bemandawes
Date: 2010-07-02 13:04:20 EDT (Fri, 02 Jul 2010)
New Revision: 63524
URL: http://svn.boost.org/trac/boost/changeset/63524
Log:
Revert to absolute() being an operations free function, and provide semantics for the Windows case where the base argument was not absolute.
Text files modified:
trunk/boost/filesystem/v3/operations.hpp | 15 ++++++
trunk/boost/filesystem/v3/path.hpp | 1
trunk/libs/filesystem/v3/doc/deprecated.html | 25 +++++++++--
trunk/libs/filesystem/v3/doc/reference.html | 80 ++++++++++++++++++--------------------
trunk/libs/filesystem/v3/doc/v3.html | 8 ++-
trunk/libs/filesystem/v3/src/operations.cpp | 20 +++++++++
trunk/libs/filesystem/v3/src/path.cpp | 45 ---------------------
trunk/libs/filesystem/v3/test/operations_test.cpp | 84 ++++++++++++++++++++++++++++++++++++---
trunk/libs/filesystem/v3/test/path_test.cpp | 50 -----------------------
trunk/libs/filesystem/v3/test/path_unit_test.cpp | 14 ------
10 files changed, 173 insertions(+), 169 deletions(-)
Modified: trunk/boost/filesystem/v3/operations.hpp
==============================================================================
--- trunk/boost/filesystem/v3/operations.hpp (original)
+++ trunk/boost/filesystem/v3/operations.hpp 2010-07-02 13:04:20 EDT (Fri, 02 Jul 2010)
@@ -246,18 +246,28 @@
// in alphabetical order, unless otherwise noted //
// //
//--------------------------------------------------------------------------------------//
+
+ // forward declarations
+ path current_path(); // fwd declaration
+# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
+ path initial_path();
+# endif
+
+ BOOST_FILESYSTEM_DECL
+ path absolute(const path& p, const path& base=current_path());
+ // If base.is_absolute(), throws nothing. Thus no need for ec argument
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
inline
path complete(const path& p)
{
- return path(p).make_absolute(detail::initial_path(0));
+ return absolute(p, initial_path());
}
inline
path complete(const path& p, const path& base)
{
- return path(p).make_absolute(base);
+ return absolute(p, base);
}
# endif
@@ -919,6 +929,7 @@
{
namespace filesystem
{
+ using filesystem3::absolute;
using filesystem3::block_file;
using filesystem3::character_file;
using filesystem3::copy_file;
Modified: trunk/boost/filesystem/v3/path.hpp
==============================================================================
--- trunk/boost/filesystem/v3/path.hpp (original)
+++ trunk/boost/filesystem/v3/path.hpp 2010-07-02 13:04:20 EDT (Fri, 02 Jul 2010)
@@ -226,7 +226,6 @@
// ----- modifiers -----
void clear() { m_pathname.clear(); }
- path& make_absolute(const path& base);
path& make_preferred()
# ifdef BOOST_POSIX_API
{ return *this; } // POSIX no effect
Modified: trunk/libs/filesystem/v3/doc/deprecated.html
==============================================================================
--- trunk/libs/filesystem/v3/doc/deprecated.html (original)
+++ trunk/libs/filesystem/v3/doc/deprecated.html 2010-07-02 13:04:20 EDT (Fri, 02 Jul 2010)
@@ -229,7 +229,7 @@
<td style="font-size: 10pt" valign="top">
<code>path.hpp</code></td>
<td style="font-size: 10pt" valign="top">
- <code>typedef basic_path<std::string, path_traits> path;</code></td>
+ <code>typedef basic_path<std::string, path_traits> path</code></td>
<td style="font-size: 10pt" valign="top">
✔</td>
<td style="font-size: 10pt" valign="top">
@@ -239,12 +239,12 @@
<td style="font-size: 10pt" valign="top">
<code>path.hpp</code></td>
<td style="font-size: 10pt" valign="top">
- <code>typedef basic_path<std::wstring, wpath_traits> wpath;</code></td>
+ <code>typedef basic_path<std::wstring, wpath_traits> wpath</code></td>
<td style="font-size: 10pt" valign="top">
✔</td>
<td style="font-size: 10pt" valign="top">
<i>Removed; use </i><code>class path</code><i> instead. Workaround provides
- </i><code>typedef path wpath;</code></td>
+ </i><code>typedef path wpath</code></td>
</tr>
<tr>
<td style="font-size: 10pt" valign="top">
@@ -260,11 +260,26 @@
<td style="font-size: 10pt" valign="top">
<code>operations.hpp</code></td>
<td style="font-size: 10pt" valign="top">
+ <p dir="ltr"><code>template <class Path><br>
+ Path complete(const Path& p,<br>
+ const Path& base=<br>
+ initial_path<Path>())</code></td>
+ <td style="font-size: 10pt" valign="top">
+ ✔</td>
+ <td style="font-size: 10pt" valign="top">
+ <p dir="ltr"><code>path absolute(const path& p, const path& base=<br>
+ current_path())</code></td>
+ </tr>
+ <tr>
+ <td style="font-size: 10pt" valign="top">
+ <code>operations.hpp</code></td>
+ <td style="font-size: 10pt" valign="top">
<code>is_regular(file_status f)</code></td>
<td style="font-size: 10pt" valign="top">
✔</td>
<td style="font-size: 10pt" valign="top">
- <code>is_regular_file( file_status f )</code></td>
+ <p dir="ltr">
+ <code>is_regular_file(file_status f)</code></td>
</tr>
<tr>
<td style="font-size: 10pt" valign="top">
@@ -358,7 +373,7 @@
<hr>
<p>Revised
-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->01 July, 2010<!--webbot bot="Timestamp" endspan i-checksum="21054" --></p>
+<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->02 July, 2010<!--webbot bot="Timestamp" endspan i-checksum="21056" --></p>
<p>© Copyright Beman Dawes, 2002-2005, 2010</p>
<p> Use, modification, and distribution are subject to the Boost Software
Modified: trunk/libs/filesystem/v3/doc/reference.html
==============================================================================
--- trunk/libs/filesystem/v3/doc/reference.html (original)
+++ trunk/libs/filesystem/v3/doc/reference.html 2010-07-02 13:04:20 EDT (Fri, 02 Jul 2010)
@@ -88,7 +88,8 @@
<td width="33%" valign="top">
<a href="#Operational-functions">
Operational functions</a><br>
-   copy_file<br>
+   absolute<br>
+ copy_file<br>
  create_directories<br>
  create_directory<br>
  create_hard_link<br>
@@ -334,7 +335,9 @@
// operational functions
-</span> void copy_file(const path& from, const path& to);
+</span> path absolute(const path& p, const path& base=current_path());
+
+ void copy_file(const path& from, const path& to);
void copy_file(const path& from, const path& to, system::error_code& ec);
void copy_file(const path& from, const path& to, BOOST_SCOPED_ENUM(copy_option) option);
void copy_file(const path& from, const path& to, BOOST_SCOPED_ENUM(copy_option) option,
@@ -525,7 +528,7 @@
// modifiers
void clear();
- path& make_absolute(const path& base);
+ path& make_absolute(const path& base);
path& make_preferred(); // POSIX: no effect. Windows: convert slashes to backslashes
path& remove_filename();
path& replace_extension(const path& new_extension = path());
@@ -780,45 +783,6 @@
<blockquote>
<p><i>Postcondition:</i> <code>this->empty()</code> is true.</p>
</blockquote>
-<pre>path& <a name="path-make_absolute">make_absolute</a>(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>m_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>path& <a name="path-make_preferred">make_preferred</a>();</pre>
<blockquote>
<p><i>Effects:</i> The contained pathname is converted to the preferred native
@@ -1866,6 +1830,38 @@
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="absolute">absolute</a>(const path& p, const path& base=current_path());</pre>
+ <blockquote>
+ <p><i>Returns:</i> If <code>p.is_empty() || p.is_absolute()</code>, returns
+ <code>p</code>. Otherwise returns a path composed according to to the
+ following table</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>return p</code></td>
+ <td align="center"><code>return p.root_name() /
+ absolute(base).root_directory()<br>
+ / absolute(base).relative_path() / p.relative_path()</code></td>
+ </tr>
+ <tr>
+ <td align="center"><b><code>!p.has_root_name()</code></b></td>
+ <td align="center"><code>return absolute(base).root_name()<br>
+ / p</code></td>
+ <td align="center"><code>return absolute(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><a name="complete_note">Note</a>:</i> On POSIX-like systems, the return
+ is effectively <code>p.is_empty() || p.is_absolute() ? p : absolute(base) / p</code> <i>--
+ end note</i>]</p>
+ <p><i>Throws:</i> If <code>base.is_absolute()</code> is true, throws nothing.</p>
+</blockquote>
<pre>void copy_file(const path& from, const path& to);</pre>
<blockquote>
<p><i>Effects: </i><code>copy_file(from, to,
Modified: trunk/libs/filesystem/v3/doc/v3.html
==============================================================================
--- trunk/libs/filesystem/v3/doc/v3.html (original)
+++ trunk/libs/filesystem/v3/doc/v3.html 2010-07-02 13:04:20 EDT (Fri, 02 Jul 2010)
@@ -56,8 +56,6 @@
<li><code>is_absolute()</code>. This renames <code>is_complete()</code>, which
is now deprecated.</li>
<li><code>is_relative()</code></li>
- <li><code>make_absolute()</code>. This replaces the operations function <code>
- complete()</code>, which is now deprecated.</li>
<li><code>make_preferred()<br>
</code></li>
</ul>
@@ -65,6 +63,10 @@
</li>
<li>New or improved operations functions include:<br>
<ul>
+ <li><code>absolute()</code>. This replaces the operations function <code>
+ complete()</code>, which is now deprecated. Semantics are now provided for a
+ Windows corner case where the <code>base</code> argument was not an absolute
+ path. Previously this resulted in an exception being thrown.</li>
<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
Windows. Used to read the contents of a symlink itself.</li>
@@ -142,7 +144,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 -->04 June 2010<!--webbot bot="Timestamp" endspan i-checksum="17550" --></p>
+<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->02 July 2010<!--webbot bot="Timestamp" endspan i-checksum="18762" --></p>
</body>
Modified: trunk/libs/filesystem/v3/src/operations.cpp
==============================================================================
--- trunk/libs/filesystem/v3/src/operations.cpp (original)
+++ trunk/libs/filesystem/v3/src/operations.cpp 2010-07-02 13:04:20 EDT (Fri, 02 Jul 2010)
@@ -579,6 +579,26 @@
{
namespace filesystem3
{
+
+ BOOST_FILESYSTEM_DECL
+ path absolute(const path& p, const path& base)
+ {
+ if ( p.empty() || p.is_absolute() )
+ return p;
+ // recursively calling absolute is sub-optimal, but is simple
+ path abs_base(base.is_absolute() ? base : absolute(base));
+# ifdef BOOST_WINDOWS_API
+ if (p.has_root_directory())
+ return abs_base.root_name() / p;
+ // !p.has_root_directory
+ if (p.has_root_name())
+ return p.root_name()
+ / abs_base.root_directory() / abs_base.relative_path() / p.relative_path();
+ // !p.has_root_name()
+# endif
+ return abs_base / p;
+ }
+
namespace detail
{
BOOST_FILESYSTEM_DECL bool possible_large_file_size_support()
Modified: trunk/libs/filesystem/v3/src/path.cpp
==============================================================================
--- trunk/libs/filesystem/v3/src/path.cpp (original)
+++ trunk/libs/filesystem/v3/src/path.cpp 2010-07-02 13:04:20 EDT (Fri, 02 Jul 2010)
@@ -206,51 +206,6 @@
// modifiers -----------------------------------------------------------------------//
- path& path::make_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());
- path this_root_directory (root_directory());
-
-# ifdef BOOST_WINDOWS_API
- BOOST_ASSERT(!this_root_name.empty() || !base_root_name.empty());
-# endif
-
- BOOST_ASSERT(!this_root_directory.empty() || base.has_root_directory());
-
- 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_API
- 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_API
path & path::make_preferred()
{
Modified: trunk/libs/filesystem/v3/test/operations_test.cpp
==============================================================================
--- trunk/libs/filesystem/v3/test/operations_test.cpp (original)
+++ trunk/libs/filesystem/v3/test/operations_test.cpp 2010-07-02 13:04:20 EDT (Fri, 02 Jul 2010)
@@ -949,7 +949,7 @@
BOOST_TEST(fs::remove(link2));
BOOST_TEST(!fs::exists(link));
BOOST_TEST(!fs::exists(link2));
- BOOST_TEST(!fs::is_symlink(link));
+ BOOST_TEST(!fs::is_symlink(link));
// remove() symbolic link to file
fs::path file_ph = "link_target";
@@ -973,7 +973,81 @@
BOOST_TEST(!fs::exists(file_ph));
}
- // copy_file_tests -----------------------------------------------------------------//
+ // absolute_tests -----------------------------------------------------------------//
+
+ void absolute_tests()
+ {
+ std::cout << "absolute_tests..." << std::endl;
+
+ BOOST_TEST(fs::absolute("").empty());
+ BOOST_TEST_EQ(fs::absolute(fs::current_path() / "foo/bar"), fs::current_path() / "foo/bar");
+ BOOST_TEST_EQ(fs::absolute("foo"), fs::current_path() / "foo");
+ BOOST_TEST_EQ(fs::absolute("foo", fs::current_path()), fs::current_path() / "foo");
+ BOOST_TEST_EQ(fs::absolute("bar", "foo"), fs::current_path() / "foo" / "bar");
+ BOOST_TEST_EQ(fs::absolute("/foo"), fs::current_path().root_name().string() + "/foo");
+
+# ifdef BOOST_WINDOWS_API
+ BOOST_TEST_EQ(fs::absolute("a:foo", "b:/bar"), "a:/bar/foo");
+# endif
+
+ // these tests were moved from elsewhere, so may duplicate some of the above tests
+
+ // p.empty()
+ BOOST_TEST_EQ(fs::absolute(fs::path(), "//foo/bar"), "");
+ if (platform == "Windows")
+ {
+ BOOST_TEST_EQ(fs::absolute(fs::path(), "a:/bar"), "");
+ }
+
+ // p.has_root_name()
+ // p.has_root_directory()
+ BOOST_TEST_EQ(fs::absolute(fs::path("//foo/bar"), "//uvw/xyz"), "//foo/bar");
+ if (platform == "Windows")
+ {
+ BOOST_TEST_EQ(fs::absolute(fs::path("a:/bar"), "b:/xyz"), "a:/bar");
+ }
+ // !p.has_root_directory()
+ BOOST_TEST_EQ(fs::absolute(fs::path("//net"), "//xyz/"), "//net/");
+ BOOST_TEST_EQ(fs::absolute(fs::path("//net"), "//xyz/abc"), "//net/abc");
+ BOOST_TEST_EQ(fs::absolute(fs::path("//net"), "//xyz/abc/def"), "//net/abc/def");
+ if (platform == "Windows")
+ {
+ BOOST_TEST_EQ(fs::absolute(fs::path("a:"), "b:/"), "a:/");
+ BOOST_TEST_EQ(fs::absolute(fs::path("a:"),"b:/abc"), "a:/abc");
+ BOOST_TEST_EQ(fs::absolute(fs::path("a:"),"b:/abc/def"), "a:/abc/def");
+ BOOST_TEST_EQ(fs::absolute(fs::path("a:foo"), "b:/"), "a:/foo");
+ BOOST_TEST_EQ(fs::absolute(fs::path("a:foo"), "b:/abc"), "a:/abc/foo");
+ BOOST_TEST_EQ(fs::absolute(fs::path("a:foo"), "b:/abc/def"), "a:/abc/def/foo");
+ BOOST_TEST_EQ(fs::absolute(fs::path("a:foo/bar"), "b:/"), "a:/foo/bar");
+ BOOST_TEST_EQ(fs::absolute(fs::path("a:foo/bar"), "b:/abc"), "a:/abc/foo/bar");
+ BOOST_TEST_EQ(fs::absolute(fs::path("a:foo/bar"), "b:/abc/def"), "a:/abc/def/foo/bar");
+ }
+ // !p.has_root_name()
+ // p.has_root_directory()
+ BOOST_TEST_EQ(fs::absolute(fs::path("/"), "//xyz/"), "//xyz/");
+ BOOST_TEST_EQ(fs::absolute(fs::path("/"), "//xyz/abc"), "//xyz/");
+ BOOST_TEST_EQ(fs::absolute(fs::path("/foo"), "//xyz/"), "//xyz/foo");
+ BOOST_TEST_EQ(fs::absolute(fs::path("/foo"), "//xyz/abc"), "//xyz/foo");
+ // !p.has_root_directory()
+ BOOST_TEST_EQ(fs::absolute(fs::path("foo"), "//xyz/abc"), "//xyz/abc/foo");
+ BOOST_TEST_EQ(fs::absolute(fs::path("foo/bar"), "//xyz/abc"), "//xyz/abc/foo/bar");
+ BOOST_TEST_EQ(fs::absolute(fs::path("."), "//xyz/abc"), "//xyz/abc/.");
+ BOOST_TEST_EQ(fs::absolute(fs::path(".."), "//xyz/abc"), "//xyz/abc/..");
+ BOOST_TEST_EQ(fs::absolute(fs::path("./foo"), "//xyz/abc"), "//xyz/abc/./foo");
+ BOOST_TEST_EQ(fs::absolute(fs::path("../foo"), "//xyz/abc"), "//xyz/abc/../foo");
+ if (platform == "POSIX")
+ {
+ BOOST_TEST_EQ(fs::absolute(fs::path("foo"), "/abc"), "/abc/foo");
+ BOOST_TEST_EQ(fs::absolute(fs::path("foo/bar"), "/abc"), "/abc/foo/bar");
+ BOOST_TEST_EQ(fs::absolute(fs::path("."), "/abc"), "/abc/.");
+ BOOST_TEST_EQ(fs::absolute(fs::path(".."), "/abc"), "/abc/..");
+ BOOST_TEST_EQ(fs::absolute(fs::path("./foo"), "/abc"), "/abc/./foo");
+ BOOST_TEST_EQ(fs::absolute(fs::path("../foo"), "/abc"), "/abc/../foo");
+ }
+
+ }
+
+ // copy_file_tests -----------------------------------------------------------------//
void copy_file_tests(const fs::path& file_ph, const fs::path& d1)
{
@@ -1077,11 +1151,6 @@
std::string s2(init_path.root_path().string()+"foo");
BOOST_TEST_EQ(s1, s2);
- BOOST_TEST(fs::path("x:/").make_absolute(init_path).string()
- == "x:/");
- BOOST_TEST(fs::path("x:/foo").make_absolute(init_path).string()
- == "x:/foo");
-
BOOST_TEST(fs::system_complete(fs::path(init_path.root_name()))
== init_path);
BOOST_TEST(fs::system_complete(fs::path(init_path.root_name().string()
@@ -1276,6 +1345,7 @@
create_hard_link_tests();
create_symlink_tests();
resize_file_tests();
+ absolute_tests();
copy_file_tests(file_ph, d1);
rename_tests();
remove_tests(dir);
Modified: trunk/libs/filesystem/v3/test/path_test.cpp
==============================================================================
--- trunk/libs/filesystem/v3/test/path_test.cpp (original)
+++ trunk/libs/filesystem/v3/test/path_test.cpp 2010-07-02 13:04:20 EDT (Fri, 02 Jul 2010)
@@ -1214,56 +1214,6 @@
{
std::cout << "composition_tests..." << std::endl;
- // these are white box tests constructed with knowledge of execution paths
-
- // *this.empty()
- BOOST_TEST_EQ(path().make_absolute("//foo/bar"), "//foo/bar");
- if (platform == "Windows")
- BOOST_TEST_EQ(path().make_absolute("a:/bar"), "a:/bar");
-
- // *this.has_root_name()
- // *this.has_root_directory()
- BOOST_TEST_EQ(path("//foo/bar").make_absolute("//uvw/xyz"), "//foo/bar");
- if (platform == "Windows")
- BOOST_TEST_EQ(path("a:/bar").make_absolute("b:/xyz"), "a:/bar");
- // !*this.has_root_directory()
- BOOST_TEST_EQ(path("//net").make_absolute("//xyz/"), "//net/");
- BOOST_TEST_EQ(path("//net").make_absolute("//xyz/abc"), "//net/abc");
- BOOST_TEST_EQ(path("//net").make_absolute("//xyz/abc/def"), "//net/abc/def");
- if (platform == "Windows")
- {
- BOOST_TEST_EQ(path("a:").make_absolute("b:/"), "a:/");
- BOOST_TEST_EQ(path("a:").make_absolute("b:/abc"), "a:/abc");
- BOOST_TEST_EQ(path("a:").make_absolute("b:/abc/def"), "a:/abc/def");
- BOOST_TEST_EQ(path("a:foo").make_absolute("b:/"), "a:/foo");
- BOOST_TEST_EQ(path("a:foo").make_absolute("b:/abc"), "a:/abc/foo");
- BOOST_TEST_EQ(path("a:foo").make_absolute("b:/abc/def"), "a:/abc/def/foo");
- BOOST_TEST_EQ(path("a:foo/bar").make_absolute("b:/"), "a:/foo/bar");
- BOOST_TEST_EQ(path("a:foo/bar").make_absolute("b:/abc"), "a:/abc/foo/bar");
- BOOST_TEST_EQ(path("a:foo/bar").make_absolute("b:/abc/def"), "a:/abc/def/foo/bar");
- }
- // !*this.has_root_name()
- // *this.has_root_directory()
- BOOST_TEST_EQ(path("/").make_absolute("//xyz/"), "//xyz/");
- BOOST_TEST_EQ(path("/").make_absolute("//xyz/abc"), "//xyz/");
- BOOST_TEST_EQ(path("/foo").make_absolute("//xyz/"), "//xyz/foo");
- BOOST_TEST_EQ(path("/foo").make_absolute("//xyz/abc"), "//xyz/foo");
- // !*this.has_root_directory()
- BOOST_TEST_EQ(path("foo").make_absolute("//xyz/abc"), "//xyz/abc/foo");
- BOOST_TEST_EQ(path("foo/bar").make_absolute("//xyz/abc"), "//xyz/abc/foo/bar");
- BOOST_TEST_EQ(path(".").make_absolute("//xyz/abc"), "//xyz/abc/.");
- BOOST_TEST_EQ(path("..").make_absolute("//xyz/abc"), "//xyz/abc/..");
- BOOST_TEST_EQ(path("./foo").make_absolute("//xyz/abc"), "//xyz/abc/./foo");
- BOOST_TEST_EQ(path("../foo").make_absolute("//xyz/abc"), "//xyz/abc/../foo");
- if (platform == "POSIX")
- {
- BOOST_TEST_EQ(path("foo").make_absolute("/abc"), "/abc/foo");
- BOOST_TEST_EQ(path("foo/bar").make_absolute("/abc"), "/abc/foo/bar");
- BOOST_TEST_EQ(path(".").make_absolute("/abc"), "/abc/.");
- BOOST_TEST_EQ(path("..").make_absolute("/abc"), "/abc/..");
- BOOST_TEST_EQ(path("./foo").make_absolute("/abc"), "/abc/./foo");
- BOOST_TEST_EQ(path("../foo").make_absolute("/abc"), "/abc/../foo");
- }
}
// construction_tests ---------------------------------------------------------------//
Modified: trunk/libs/filesystem/v3/test/path_unit_test.cpp
==============================================================================
--- trunk/libs/filesystem/v3/test/path_unit_test.cpp (original)
+++ trunk/libs/filesystem/v3/test/path_unit_test.cpp 2010-07-02 13:04:20 EDT (Fri, 02 Jul 2010)
@@ -517,20 +517,6 @@
{
std::cout << "testing modifiers..." << std::endl;
-// CHECK(path("").make_absolute("") == ""); // should assert
-// CHECK(path("").make_absolute("foo") == ""); // should assert
-
-# ifdef BOOST_WINDOWS_API
- CHECK(path("baa").make_absolute("c:/") == "c:/baa");
- CHECK(path("/baa").make_absolute("c:/foo").string() == path("c:/baa").string());
- CHECK(path("baa/baz").make_absolute("c:/foo/bar").string()
- == path("c:/foo/bar\\baa/baz").string());
-# else
- CHECK(path("baa").make_absolute("/") == "/baa");
- CHECK(path("/baa").make_absolute("/foo").string() == path("/baa").string());
- CHECK(path("baa/baz").make_absolute("/foo/bar").string()
- == path("/foo/bar/baa/baz").string());
-# endif
}
// test_decompositions -------------------------------------------------------------//
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