|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r65765 - in trunk: boost/filesystem/v3 libs/filesystem/v3/doc libs/filesystem/v3/src libs/filesystem/v3/test
From: bdawes_at_[hidden]
Date: 2010-10-05 12:55:20
Author: bemandawes
Date: 2010-10-05 12:55:19 EDT (Tue, 05 Oct 2010)
New Revision: 65765
URL: http://svn.boost.org/trac/boost/changeset/65765
Log:
Fix #4799. The same bug occurred in three places. One of these may have been the source of reported problems with remove_all. Several other problems in documentation and tests were also found and will be addressed separately.
Text files modified:
trunk/boost/filesystem/v3/operations.hpp | 9 +++++----
trunk/libs/filesystem/v3/doc/reference.html | 29 +++++++++++++++++++++++------
trunk/libs/filesystem/v3/src/operations.cpp | 40 ++++++++++++++--------------------------
trunk/libs/filesystem/v3/test/operations_test.cpp | 35 +++++++++++++++++++++++++++++++++++
trunk/libs/filesystem/v3/test/operations_unit_test.cpp | 6 ++++++
5 files changed, 83 insertions(+), 36 deletions(-)
Modified: trunk/boost/filesystem/v3/operations.hpp
==============================================================================
--- trunk/boost/filesystem/v3/operations.hpp (original)
+++ trunk/boost/filesystem/v3/operations.hpp 2010-10-05 12:55:19 EDT (Tue, 05 Oct 2010)
@@ -145,7 +145,7 @@
BOOST_SCOPED_ENUM(copy_option) option, // See ticket #2925
system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
- void copy_symlink(const path& from, const path& to, system::error_code* ec=0);
+ void copy_symlink(const path& existing_symlink, const path& new_symlink, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
bool create_directories(const path& p, system::error_code* ec=0);
BOOST_FILESYSTEM_DECL
@@ -304,11 +304,11 @@
void copy_file(const path& from, const path& to, system::error_code& ec)
{detail::copy_file(from, to, copy_option::fail_if_exists, &ec);}
inline
- void copy_symlink(const path& from, const path& to) {detail::copy_symlink(from, to);}
+ void copy_symlink(const path& existing_symlink, const path& new_symlink) {detail::copy_symlink(existing_symlink, new_symlink);}
inline
- void copy_symlink(const path& from, const path& to, system::error_code& ec)
- {detail::copy_symlink(from, to, &ec);}
+ void copy_symlink(const path& existing_symlink, const path& new_symlink, system::error_code& ec)
+ {detail::copy_symlink(existing_symlink, new_symlink, &ec);}
inline
bool create_directories(const path& p) {return detail::create_directories(p);}
@@ -938,6 +938,7 @@
using filesystem3::absolute;
using filesystem3::block_file;
using filesystem3::character_file;
+// using filesystem3::copy;
using filesystem3::copy_file;
using filesystem3::copy_option;
using filesystem3::copy_symlink;
Modified: trunk/libs/filesystem/v3/doc/reference.html
==============================================================================
--- trunk/libs/filesystem/v3/doc/reference.html (original)
+++ trunk/libs/filesystem/v3/doc/reference.html 2010-10-05 12:55:19 EDT (Tue, 05 Oct 2010)
@@ -337,23 +337,35 @@
</span> path absolute(const path& p, const path& base=current_path());
+ void copy(const path& from, const path& to);
+ void copy(const path& from, const path& to, system::error_code& ec);
+
+ void copy_directory(const path& from, const path& to);
+ void copy_directory(const path& from, const path& to, system::error_code& ec);
+
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,
system::error_code& ec);
+ void copy_symlink(const path& existing_symlink, const path& new_symlink);
+ void copy_symlink(const path& existing_symlink, const path& new_symlink, system::error_code& ec);
+
bool create_directories(const path& p);
bool create_directories(const path& p, system::error_code& ec);
bool create_directory(const path& p);
bool create_directory(const path& p, system::error_code& ec);
- void create_hard_link(const path& to, const path& from);
- void create_hard_link(const path& to, const path& from, system::error_code& ec);
+<span style="background-color: #FFFFFF"> void create_directory_symlink(const path& to, const path& </span>new_symlink<span style="background-color: #FFFFFF">);
+ void create_directory_symlink(const path& to, const path& </span>new_symlink, system::error_code& ec<span style="background-color: #FFFFFF">);
+</span>
+ void create_hard_link(const path& to, const path& new_hard_link);
+ void create_hard_link(const path& to, const path& new_hard_link, system::error_code& ec);
-<span style="background-color: #FFFFFF"> void create_symlink(const path& to, const path& from);
- void create_symlink(const path& to, const path& from</span>, system::error_code& ec<span style="background-color: #FFFFFF">);
+<span style="background-color: #FFFFFF"> void create_symlink(const path& to, const path& </span>new_symlink<span style="background-color: #FFFFFF">);
+ void create_symlink(const path& to, const path& </span>new_symlink, system::error_code& ec<span style="background-color: #FFFFFF">);
</span> path current_path();
path current_path(system::error_code& ec);
@@ -368,7 +380,9 @@
bool equivalent(const path& p1, const path& p2, system::error_code& ec);
<span style="background-color: #FFFFFF; ">uintmax_t</span> file_size(const path& p);
- <span style="background-color: #FFFFFF; ">uintmax_t</span> file_size(const path& p, system::error_code& ec);
+ <span style="background-color: #FFFFFF; ">uintmax_t</span> file_size(const path& p, system::error_code& ec);</pre>
+<pre> uintmax_t hard_link_count(const path& p);
+ uintmax_t hard_link_count(const path& p, system::error_code& ec);
bool is_directory(file_status s);
bool is_directory(const path& p);
@@ -406,6 +420,9 @@
void rename(const path& from, const path& to);
void rename(const path& from, const path& to, system::error_code& ec);
+ void resize_file(const path& p, uintmax_t size);
+ void resize_file(const path& p, uintmax_t size, system::error_code& ec);
+
<span style="background-color: #FFFFFF"> space_info space(const path& p);
<a href="#space_info">space_info</a> <a href="#space">space</a>(const path& p</span>, system::error_code& ec<span style="background-color: #FFFFFF">);
</span><span style="background-color: #FFFF00">
@@ -3052,7 +3069,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 -->02 July 2010<!--webbot bot="Timestamp" endspan i-checksum="18762" --></p>
+<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->05 October 2010<!--webbot bot="Timestamp" endspan i-checksum="32123" --></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-10-05 12:55:19 EDT (Tue, 05 Oct 2010)
@@ -373,7 +373,7 @@
itr != end_dir_itr; ++itr)
{
fs::file_status tmp_sym_stat = fs::symlink_status(itr->path(), *ec);
- if (ec != 0 && ec)
+ if (ec != 0 && *ec)
return count;
count += remove_all_aux(itr->path(), tmp_sym_stat, ec);
}
@@ -659,7 +659,7 @@
void copy(const path& from, const path& to, system::error_code* ec)
{
file_status s(symlink_status(from, *ec));
- if (ec != 0 && ec)return;
+ if (ec != 0 && *ec) return;
if(is_symlink(s))
{
@@ -703,32 +703,20 @@
}
BOOST_FILESYSTEM_DECL
- void copy_symlink(const path& from, const path& to, system::error_code* ec)
+ void copy_symlink(const path& existing_symlink, const path& new_symlink,
+ system::error_code* ec)
{
-# ifdef BOOST_POSIX_API
- path p(read_symlink(from, ec));
- if (ec != 0 && ec) return;
- create_symlink(p, to, ec);
-
-# elif _WIN32_WINNT < 0x0600 // SDK earlier than Vista and Server 2008
- error(true, error_code(BOOST_ERROR_NOT_SUPPORTED, system_category()), to, from, ec,
+# if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0600
+ error(true, error_code(BOOST_ERROR_NOT_SUPPORTED, system_category()),
+ new_symlink, existing_symlink, ec,
"boost::filesystem::copy_symlink");
-# else // modern Windows
-
- // see if actually supported by Windows runtime dll
- if (error(!create_symbolic_link_api,
- error_code(BOOST_ERROR_NOT_SUPPORTED, system_category()),
- to, from, ec,
- "boost::filesystem3::copy_symlink"))
- return;
-
- // preconditions met, so attempt the copy
- error(!::CopyFileExW(from.c_str(), to.c_str(), 0, 0, 0,
- COPY_FILE_COPY_SYMLINK | COPY_FILE_FAIL_IF_EXISTS), to, from, ec,
- "boost::filesystem3::copy_symlink");
-# endif
+# else // modern Windows or BOOST_POSIX_API
+ path p(read_symlink(existing_symlink, ec));
+ if (ec != 0 && *ec) return;
+ create_symlink(p, new_symlink, ec);
+# endif
}
BOOST_FILESYSTEM_DECL
@@ -842,12 +830,12 @@
if (error(!create_symbolic_link_api,
error_code(BOOST_ERROR_NOT_SUPPORTED, system_category()),
to, from, ec,
- "boost::filesystem::create_directory_symlink"))
+ "boost::filesystem::create_symlink"))
return;
# endif
error(!BOOST_CREATE_SYMBOLIC_LINK(from.c_str(), to.c_str(), 0),
- to, from, ec, "boost::filesystem::create_directory_symlink");
+ to, from, ec, "boost::filesystem::create_symlink");
# endif
}
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-10-05 12:55:19 EDT (Tue, 05 Oct 2010)
@@ -1087,6 +1087,39 @@
BOOST_TEST(copy_ex_ok);
}
+ // copy_symlink_tests ---------------------------------------------------------------//
+
+ void copy_symlink_tests(const fs::path& file_ph, const fs::path& d1)
+ {
+ std::cout << "copy_symlink_tests..." << std::endl;
+
+ BOOST_TEST(fs::exists(file_ph));
+ BOOST_TEST(fs::exists(d1));
+ fs::path sym1(d1 / "symlink1");
+ fs::remove(sym1); // remove possible residue from prior testing
+ fs::create_symlink(file_ph, sym1);
+ BOOST_TEST(fs::exists(sym1));
+ BOOST_TEST(fs::is_symlink(sym1));
+ fs::path sym2(d1 / "symlink2");
+ fs::copy_symlink(sym1, sym2);
+ BOOST_TEST(fs::exists(sym2));
+ BOOST_TEST(fs::is_symlink(sym2));
+ //fs::path sym3(d1 / "symlink3");
+ //fs::copy(sym1, sym3);
+ //BOOST_TEST(fs::exists(sym3));
+ //BOOST_TEST(fs::is_symlink(sym3));
+
+ bool copy_ex_ok = false;
+ try { fs::copy_symlink("no-such-file", "new-symlink1"); }
+ catch (const fs::filesystem_error &) { copy_ex_ok = true; }
+ BOOST_TEST(copy_ex_ok);
+
+ copy_ex_ok = false;
+ try { fs::copy_symlink(file_ph, "new-symlink2"); } // should fail; file_ph not symlink
+ catch (const fs::filesystem_error &) { copy_ex_ok = true; }
+ BOOST_TEST(copy_ex_ok);
+ }
+
// write_time_tests ----------------------------------------------------------------//
void write_time_tests(const fs::path& dir)
@@ -1353,6 +1386,8 @@
resize_file_tests();
absolute_tests();
copy_file_tests(file_ph, d1);
+ if (create_symlink_ok) // only if symlinks supported
+ copy_symlink_tests(file_ph, d1);
rename_tests();
remove_tests(dir);
if (create_symlink_ok) // only if symlinks supported
Modified: trunk/libs/filesystem/v3/test/operations_unit_test.cpp
==============================================================================
--- trunk/libs/filesystem/v3/test/operations_unit_test.cpp (original)
+++ trunk/libs/filesystem/v3/test/operations_unit_test.cpp 2010-10-05 12:55:19 EDT (Tue, 05 Oct 2010)
@@ -7,6 +7,12 @@
// Library home page: http://www.boost.org/libs/filesystem
+// ------------------------------------------------------------------------------------//
+
+// This program is misnamed - it is really a smoke test rather than a unit_test
+
+// ------------------------------------------------------------------------------------//
+
#define BOOST_FILESYSTEM_VERSION 3
#include <boost/config.hpp>
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