Boost logo

Boost-Commit :

From: bdawes_at_[hidden]
Date: 2008-08-25 11:35:35


Author: bemandawes
Date: 2008-08-25 11:35:34 EDT (Mon, 25 Aug 2008)
New Revision: 48377
URL: http://svn.boost.org/trac/boost/changeset/48377

Log:
Revert 'remove' changes inadvertently committed by 47006. Fully apply ticket #1972 'remove' fixes.
Text files modified:
   trunk/boost/filesystem/operations.hpp | 63 +++++++++++++++++++++++++++------------
   trunk/libs/filesystem/test/msvc/convenience_test/convenience_test.vcproj | 4 +
   trunk/libs/filesystem/test/msvc/fstream_test/fstream_test.vcproj | 4 +
   trunk/libs/filesystem/test/msvc/large_file_support_test/large_file_support_test.vcproj | 4 +
   trunk/libs/filesystem/test/msvc/mbcopy/mbcopy.vcproj | 4 ++
   trunk/libs/filesystem/test/msvc/operations_test/operations_test.vcproj | 4 +
   trunk/libs/filesystem/test/msvc/path_test/path_test.vcproj | 4 +
   trunk/libs/filesystem/test/msvc/simple_ls/simple_ls.vcproj | 4 ++
   trunk/libs/filesystem/test/msvc/wide_test/wide_test.vcproj | 4 +
   trunk/libs/filesystem/test/operations_test.cpp | 30 +++++++++---------
   10 files changed, 85 insertions(+), 40 deletions(-)

Modified: trunk/boost/filesystem/operations.hpp
==============================================================================
--- trunk/boost/filesystem/operations.hpp (original)
+++ trunk/boost/filesystem/operations.hpp 2008-08-25 11:35:34 EDT (Mon, 25 Aug 2008)
@@ -121,10 +121,6 @@
 
     namespace detail
     {
- // singular object used only as a tag; thus initialization and
- // thread-safety are not issues
- BOOST_FILESYSTEM_DECL extern system::error_code throws;
-
       typedef std::pair< system::error_code, bool >
         query_pair;
 
@@ -234,7 +230,10 @@
 # endif
 
       template<class Path>
- unsigned long remove_all_aux( const Path & ph );
+ bool remove_aux( const Path & ph, file_status f );
+
+ template<class Path>
+ unsigned long remove_all_aux( const Path & ph, file_status f );
 
     } // namespace detail
 
@@ -474,19 +473,24 @@
       return ec;
     }
 
- BOOST_FS_FUNC(void) remove( const Path & ph, system::error_code & ec = detail::throws )
+ BOOST_FS_FUNC(bool) remove( const Path & ph )
     {
- system::error_code error( detail::remove_api(ph.external_file_string()) );
- if ( error && &ec == &detail::throws )
+ system::error_code ec;
+ file_status f = symlink_status( ph, ec );
+ if ( ec )
         boost::throw_exception( basic_filesystem_error<Path>(
- "boost::filesystem::remove", ph, error ) );
- ec = error;
+ "boost::filesystem::remove", ph, ec ) );
+ return detail::remove_aux( ph, f );
     }
 
     BOOST_FS_FUNC(unsigned long) remove_all( const Path & ph )
     {
- return exists( ph )|| is_symlink( ph )
- ? detail::remove_all_aux( ph ) : 0;
+ system::error_code ec;
+ file_status f = symlink_status( ph, ec );
+ if ( ec )
+ boost::throw_exception( basic_filesystem_error<Path>(
+ "boost::filesystem::remove_all", ph, ec ) );
+ return exists( f ) ? detail::remove_all_aux( ph, f ) : 0;
     }
 
     BOOST_FS_FUNC(void) rename( const Path & from_path, const Path & to_path )
@@ -712,8 +716,10 @@
       const wpath & from_ph, system::error_code & ec )
       { return create_symlink<wpath>( to_ph, from_ph, ec ); }
 
- inline void remove( const path & ph ) { remove<path>( ph ); }
- inline void remove( const wpath & ph ) { remove<wpath>( ph ); }
+ inline bool remove( const path & ph )
+ { return remove<path>( ph ); }
+ inline bool remove( const wpath & ph )
+ { return remove<wpath>( ph ); }
 
     inline unsigned long remove_all( const path & ph )
       { return remove_all<path>( ph ); }
@@ -762,20 +768,39 @@
     namespace detail
     {
       template<class Path>
- unsigned long remove_all_aux( const Path & ph )
+ bool remove_aux( const Path & ph, file_status f )
+ {
+ if ( exists( f ) )
+ {
+ system::error_code ec = remove_api( ph.external_file_string() );
+ if ( ec )
+ boost::throw_exception( basic_filesystem_error<Path>(
+ "boost::filesystem::remove", ph, ec ) );
+ return true;
+ }
+ return false;
+ }
+
+ template<class Path>
+ unsigned long remove_all_aux( const Path & ph, file_status f )
       {
         static const boost::filesystem::basic_directory_iterator<Path> end_itr;
         unsigned long count = 1;
- if ( !boost::filesystem::is_symlink( ph ) // don't recurse symbolic links
- && boost::filesystem::is_directory( ph ) )
+ if ( !boost::filesystem::is_symlink( f ) // don't recurse symbolic links
+ && boost::filesystem::is_directory( f ) )
         {
           for ( boost::filesystem::basic_directory_iterator<Path> itr( ph );
                 itr != end_itr; ++itr )
           {
- count += remove_all_aux( itr->path() );
+ boost::system::error_code ec;
+ boost::filesystem::file_status fn = boost::filesystem::symlink_status( itr->path(), ec );
+ if ( ec )
+ boost::throw_exception( basic_filesystem_error<Path>(
+ "boost::filesystem:remove_all", ph, ec ) );
+ count += remove_all_aux( itr->path(), fn );
           }
         }
- boost::filesystem::remove( ph );
+ remove_aux( ph, f );
         return count;
       }
 

Modified: trunk/libs/filesystem/test/msvc/convenience_test/convenience_test.vcproj
==============================================================================
--- trunk/libs/filesystem/test/msvc/convenience_test/convenience_test.vcproj (original)
+++ trunk/libs/filesystem/test/msvc/convenience_test/convenience_test.vcproj 2008-08-25 11:35:34 EDT (Mon, 25 Aug 2008)
@@ -86,7 +86,7 @@
                         />
                         <Tool
                                 Name="VCPostBuildEventTool"
- Description="Auto test run"
+ Description="run test"
                                 CommandLine="&quot;$(TargetDir)\$(TargetName).exe&quot; --result_code=no --report_level=no"
                         />
                 </Configuration>
@@ -163,6 +163,8 @@
                         />
                         <Tool
                                 Name="VCPostBuildEventTool"
+ Description="run test"
+ CommandLine="&quot;$(TargetDir)\$(TargetName).exe&quot; --result_code=no --report_level=no"
                         />
                 </Configuration>
         </Configurations>

Modified: trunk/libs/filesystem/test/msvc/fstream_test/fstream_test.vcproj
==============================================================================
--- trunk/libs/filesystem/test/msvc/fstream_test/fstream_test.vcproj (original)
+++ trunk/libs/filesystem/test/msvc/fstream_test/fstream_test.vcproj 2008-08-25 11:35:34 EDT (Mon, 25 Aug 2008)
@@ -86,7 +86,7 @@
                         />
                         <Tool
                                 Name="VCPostBuildEventTool"
- Description="Auto test run"
+ Description="run test"
                                 CommandLine="&quot;$(TargetDir)\$(TargetName).exe&quot; --result_code=no --report_level=no"
                         />
                 </Configuration>
@@ -163,6 +163,8 @@
                         />
                         <Tool
                                 Name="VCPostBuildEventTool"
+ Description="run test"
+ CommandLine="&quot;$(TargetDir)\$(TargetName).exe&quot; --result_code=no --report_level=no"
                         />
                 </Configuration>
         </Configurations>

Modified: trunk/libs/filesystem/test/msvc/large_file_support_test/large_file_support_test.vcproj
==============================================================================
--- trunk/libs/filesystem/test/msvc/large_file_support_test/large_file_support_test.vcproj (original)
+++ trunk/libs/filesystem/test/msvc/large_file_support_test/large_file_support_test.vcproj 2008-08-25 11:35:34 EDT (Mon, 25 Aug 2008)
@@ -86,7 +86,7 @@
                         />
                         <Tool
                                 Name="VCPostBuildEventTool"
- Description="Auto test run"
+ Description="run test"
                                 CommandLine="&quot;$(TargetDir)\$(TargetName).exe&quot; --result_code=no --report_level=no"
                         />
                 </Configuration>
@@ -163,6 +163,8 @@
                         />
                         <Tool
                                 Name="VCPostBuildEventTool"
+ Description="run test"
+ CommandLine="&quot;$(TargetDir)\$(TargetName).exe&quot; --result_code=no --report_level=no"
                         />
                 </Configuration>
         </Configurations>

Modified: trunk/libs/filesystem/test/msvc/mbcopy/mbcopy.vcproj
==============================================================================
--- trunk/libs/filesystem/test/msvc/mbcopy/mbcopy.vcproj (original)
+++ trunk/libs/filesystem/test/msvc/mbcopy/mbcopy.vcproj 2008-08-25 11:35:34 EDT (Mon, 25 Aug 2008)
@@ -86,6 +86,8 @@
                         />
                         <Tool
                                 Name="VCPostBuildEventTool"
+ Description="run test"
+ CommandLine="&quot;$(TargetDir)\$(TargetName).exe&quot; --result_code=no --report_level=no"
                         />
                 </Configuration>
                 <Configuration
@@ -161,6 +163,8 @@
                         />
                         <Tool
                                 Name="VCPostBuildEventTool"
+ Description="run test"
+ CommandLine="&quot;$(TargetDir)\$(TargetName).exe&quot; --result_code=no --report_level=no"
                         />
                 </Configuration>
         </Configurations>

Modified: trunk/libs/filesystem/test/msvc/operations_test/operations_test.vcproj
==============================================================================
--- trunk/libs/filesystem/test/msvc/operations_test/operations_test.vcproj (original)
+++ trunk/libs/filesystem/test/msvc/operations_test/operations_test.vcproj 2008-08-25 11:35:34 EDT (Mon, 25 Aug 2008)
@@ -86,7 +86,7 @@
                         />
                         <Tool
                                 Name="VCPostBuildEventTool"
- Description="Auto test run"
+ Description="run test"
                                 CommandLine="&quot;$(TargetDir)\$(TargetName).exe&quot; --result_code=no --report_level=no"
                         />
                 </Configuration>
@@ -163,6 +163,8 @@
                         />
                         <Tool
                                 Name="VCPostBuildEventTool"
+ Description="run test"
+ CommandLine="&quot;$(TargetDir)\$(TargetName).exe&quot; --result_code=no --report_level=no"
                         />
                 </Configuration>
         </Configurations>

Modified: trunk/libs/filesystem/test/msvc/path_test/path_test.vcproj
==============================================================================
--- trunk/libs/filesystem/test/msvc/path_test/path_test.vcproj (original)
+++ trunk/libs/filesystem/test/msvc/path_test/path_test.vcproj 2008-08-25 11:35:34 EDT (Mon, 25 Aug 2008)
@@ -86,7 +86,7 @@
                         />
                         <Tool
                                 Name="VCPostBuildEventTool"
- Description="Auto test run"
+ Description="run test"
                                 CommandLine="&quot;$(TargetDir)\$(TargetName).exe&quot; --result_code=no --report_level=no"
                         />
                 </Configuration>
@@ -163,6 +163,8 @@
                         />
                         <Tool
                                 Name="VCPostBuildEventTool"
+ Description="run test"
+ CommandLine="&quot;$(TargetDir)\$(TargetName).exe&quot; --result_code=no --report_level=no"
                         />
                 </Configuration>
         </Configurations>

Modified: trunk/libs/filesystem/test/msvc/simple_ls/simple_ls.vcproj
==============================================================================
--- trunk/libs/filesystem/test/msvc/simple_ls/simple_ls.vcproj (original)
+++ trunk/libs/filesystem/test/msvc/simple_ls/simple_ls.vcproj 2008-08-25 11:35:34 EDT (Mon, 25 Aug 2008)
@@ -86,6 +86,8 @@
                         />
                         <Tool
                                 Name="VCPostBuildEventTool"
+ Description=""
+ CommandLine=""
                         />
                 </Configuration>
                 <Configuration
@@ -161,6 +163,8 @@
                         />
                         <Tool
                                 Name="VCPostBuildEventTool"
+ Description=""
+ CommandLine=""
                         />
                 </Configuration>
         </Configurations>

Modified: trunk/libs/filesystem/test/msvc/wide_test/wide_test.vcproj
==============================================================================
--- trunk/libs/filesystem/test/msvc/wide_test/wide_test.vcproj (original)
+++ trunk/libs/filesystem/test/msvc/wide_test/wide_test.vcproj 2008-08-25 11:35:34 EDT (Mon, 25 Aug 2008)
@@ -86,7 +86,7 @@
                         />
                         <Tool
                                 Name="VCPostBuildEventTool"
- Description="Auto test run"
+ Description="run test"
                                 CommandLine="&quot;$(TargetDir)\$(TargetName).exe&quot; --result_code=no --report_level=no"
                         />
                 </Configuration>
@@ -163,6 +163,8 @@
                         />
                         <Tool
                                 Name="VCPostBuildEventTool"
+ Description="run test"
+ CommandLine="&quot;$(TargetDir)\$(TargetName).exe&quot; --result_code=no --report_level=no"
                         />
                 </Configuration>
         </Configurations>

Modified: trunk/libs/filesystem/test/operations_test.cpp
==============================================================================
--- trunk/libs/filesystem/test/operations_test.cpp (original)
+++ trunk/libs/filesystem/test/operations_test.cpp 2008-08-25 11:35:34 EDT (Mon, 25 Aug 2008)
@@ -776,10 +776,10 @@
   create_file( file_ph, "" );
   BOOST_CHECK( fs::exists( file_ph ) );
   BOOST_CHECK( !fs::is_directory( file_ph ) );
- fs::remove( file_ph );
+ BOOST_CHECK( fs::remove( file_ph ) );
   BOOST_CHECK( !fs::exists( file_ph ) );
- fs::remove( "no-such-file" );
- fs::remove( "no-such-directory/no-such-file" );
+ BOOST_CHECK( !fs::remove( "no-such-file" ) );
+ BOOST_CHECK( !fs::remove( "no-such-directory/no-such-file" ) );
 
   // remove() directory
   d1 = dir / "shortlife_dir";
@@ -790,50 +790,50 @@
   BOOST_CHECK( BOOST_FS_IS_EMPTY( d1 ) );
   bad_remove_dir = dir;
   BOOST_CHECK( CHECK_EXCEPTION( bad_remove, ENOTEMPTY ) );
- fs::remove( d1 );
+ BOOST_CHECK( fs::remove( d1 ) );
   BOOST_CHECK( !fs::exists( d1 ) );
 
   if ( create_symlink_ok ) // only if symlinks supported
   {
     // remove() dangling symbolic link
     fs::path link( "dangling_link" );
- fs::remove( link );
+ fs::remove( link ); // remove any residue from past tests
     BOOST_CHECK( !fs::is_symlink( link ) );
     BOOST_CHECK( !fs::exists( link ) );
     fs::create_symlink( "nowhere", link );
     BOOST_CHECK( !fs::exists( link ) );
     BOOST_CHECK( fs::is_symlink( link ) );
- fs::remove( link );
+ BOOST_CHECK( fs::remove( link ) );
     BOOST_CHECK( !fs::is_symlink( link ) );
 
     // remove() self-refering symbolic link
     link = "link_to_self";
- fs::remove( link );
+ fs::remove( link ); // remove any residue from past tests
     BOOST_CHECK( !fs::is_symlink( link ) );
     BOOST_CHECK( !fs::exists( link ) );
     fs::create_symlink( link, link );
- fs::remove( link );
+ BOOST_CHECK( fs::remove( link ) );
     BOOST_CHECK( !fs::exists( link ) );
     BOOST_CHECK( !fs::is_symlink( link ) );
 
     // remove() cyclic symbolic link
     link = "link_to_a";
     fs::path link2( "link_to_b" );
- fs::remove( link );
- fs::remove( link2 );
+ fs::remove( link ); // remove any residue from past tests
+ fs::remove( link2 ); // remove any residue from past tests
     BOOST_CHECK( !fs::is_symlink( link ) );
     BOOST_CHECK( !fs::exists( link ) );
     fs::create_symlink( link, link2 );
     fs::create_symlink( link2, link );
- fs::remove( link );
- fs::remove( link2 );
+ BOOST_CHECK( fs::remove( link ) );
+ BOOST_CHECK( fs::remove( link2 ) );
     BOOST_CHECK( !fs::exists( link ) );
     BOOST_CHECK( !fs::exists( link2 ) );
     BOOST_CHECK( !fs::is_symlink( link ) );
 
     // remove() symbolic link to file
     file_ph = "link_target";
- fs::remove( file_ph );
+ fs::remove( file_ph ); // remove any residue from past tests
     BOOST_CHECK( !fs::exists( file_ph ) );
     create_file( file_ph, "" );
     BOOST_CHECK( fs::exists( file_ph ) );
@@ -845,11 +845,11 @@
     BOOST_CHECK( !fs::is_directory( link ) );
     BOOST_CHECK( fs::is_regular_file( link ) );
     BOOST_CHECK( fs::is_symlink( link ) );
- fs::remove( link );
+ BOOST_CHECK( fs::remove( link ) );
     BOOST_CHECK( fs::exists( file_ph ) );
     BOOST_CHECK( !fs::exists( link ) );
     BOOST_CHECK( !fs::is_symlink( link ) );
- fs::remove( file_ph );
+ BOOST_CHECK( fs::remove( file_ph ) );
     BOOST_CHECK( !fs::exists( file_ph ) );
   }
 


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