Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67067 - in trunk/libs/filesystem: v2/src v3/src v3/test
From: bdawes_at_[hidden]
Date: 2010-12-06 09:03:28


Author: bemandawes
Date: 2010-12-06 09:03:23 EST (Mon, 06 Dec 2010)
New Revision: 67067
URL: http://svn.boost.org/trac/boost/changeset/67067

Log:
Fix #4930, add V3 test case to detect any future regression
Text files modified:
   trunk/libs/filesystem/v2/src/v2_operations.cpp | 5 +++--
   trunk/libs/filesystem/v3/src/operations.cpp | 2 +-
   trunk/libs/filesystem/v3/test/operations_test.cpp | 4 ++++
   3 files changed, 8 insertions(+), 3 deletions(-)

Modified: trunk/libs/filesystem/v2/src/v2_operations.cpp
==============================================================================
--- trunk/libs/filesystem/v2/src/v2_operations.cpp (original)
+++ trunk/libs/filesystem/v2/src/v2_operations.cpp 2010-12-06 09:03:23 EST (Mon, 06 Dec 2010)
@@ -1215,8 +1215,9 @@
         if ( ::stat( from_file_ph.c_str(), &from_stat ) != 0 )
           { return error_code( errno, system_category() ); }
 
- int oflag = O_CREAT | O_WRONLY;
- if ( fail_if_exists ) oflag |= O_EXCL;
+ int oflag = O_CREAT | O_WRONLY | O_TRUNC;
+ if ( fail_if_exists )
+ oflag |= O_EXCL;
         if ( (outfile = ::open( to_file_ph.c_str(), oflag, from_stat.st_mode )) < 0 )
         {
           int open_errno = errno;

Modified: trunk/libs/filesystem/v3/src/operations.cpp
==============================================================================
--- trunk/libs/filesystem/v3/src/operations.cpp (original)
+++ trunk/libs/filesystem/v3/src/operations.cpp 2010-12-06 09:03:23 EST (Mon, 06 Dec 2010)
@@ -427,7 +427,7 @@
     if (::stat(from_p.c_str(), &from_stat)!= 0)
       { return false; }
 
- int oflag = O_CREAT | O_WRONLY;
+ int oflag = O_CREAT | O_WRONLY | O_TRUNC;
     if (fail_if_exists)
       oflag |= O_EXCL;
     if ((outfile = ::open(to_p.c_str(), oflag, from_stat.st_mode))< 0)

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-12-06 09:03:23 EST (Mon, 06 Dec 2010)
@@ -1187,10 +1187,14 @@
     catch (const fs::filesystem_error &) { copy_ex_ok = true; }
     BOOST_TEST(copy_ex_ok);
 
+ create_file(d1 / "f2", "1234567890");
+ BOOST_TEST_EQ(fs::file_size(d1 / "f2"), 10);
     copy_ex_ok = true;
     try { fs::copy_file(f1, d1 / "f2", fs::copy_option::overwrite_if_exists); }
     catch (const fs::filesystem_error &) { copy_ex_ok = false; }
     BOOST_TEST(copy_ex_ok);
+ BOOST_TEST_EQ(fs::file_size(d1 / "f2"), 7);
+ verify_file(d1 / "f2", "file-f1");
   }
 
  // symlink_status_tests -------------------------------------------------------------//


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