Index: /trunk/boost/filesystem/operations.hpp =================================================================== --- /trunk/boost/filesystem/operations.hpp (revision 48192) +++ /trunk/boost/filesystem/operations.hpp (revision 48377) @@ -122,8 +122,4 @@ 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; @@ -235,5 +231,8 @@ template - unsigned long remove_all_aux( const Path & ph ); + bool remove_aux( const Path & ph, file_status f ); + + template + unsigned long remove_all_aux( const Path & ph, file_status f ); } // namespace detail @@ -475,17 +474,22 @@ } - BOOST_FS_FUNC(void) remove( const Path & ph, system::error_code & ec = detail::throws ) - { - system::error_code error( detail::remove_api(ph.external_file_string()) ); - if ( error && &ec == &detail::throws ) - boost::throw_exception( basic_filesystem_error( - "boost::filesystem::remove", ph, error ) ); - ec = error; + BOOST_FS_FUNC(bool) remove( const Path & ph ) + { + system::error_code ec; + file_status f = symlink_status( ph, ec ); + if ( ec ) + boost::throw_exception( basic_filesystem_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( + "boost::filesystem::remove_all", ph, ec ) ); + return exists( f ) ? detail::remove_all_aux( ph, f ) : 0; } @@ -713,6 +717,8 @@ { return create_symlink( to_ph, from_ph, ec ); } - inline void remove( const path & ph ) { remove( ph ); } - inline void remove( const wpath & ph ) { remove( ph ); } + inline bool remove( const path & ph ) + { return remove( ph ); } + inline bool remove( const wpath & ph ) + { return remove( ph ); } inline unsigned long remove_all( const path & ph ) @@ -763,18 +769,37 @@ { template - 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( + "boost::filesystem::remove", ph, ec ) ); + return true; + } + return false; + } + + template + unsigned long remove_all_aux( const Path & ph, file_status f ) { static const boost::filesystem::basic_directory_iterator 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 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( + "boost::filesystem:remove_all", ph, ec ) ); + count += remove_all_aux( itr->path(), fn ); } } - boost::filesystem::remove( ph ); + remove_aux( ph, f ); return count; } Index: /trunk/libs/filesystem/test/operations_test.cpp =================================================================== --- /trunk/libs/filesystem/test/operations_test.cpp (revision 47181) +++ /trunk/libs/filesystem/test/operations_test.cpp (revision 48377) @@ -777,8 +777,8 @@ 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 @@ -791,5 +791,5 @@ bad_remove_dir = dir; BOOST_CHECK( CHECK_EXCEPTION( bad_remove, ENOTEMPTY ) ); - fs::remove( d1 ); + BOOST_CHECK( fs::remove( d1 ) ); BOOST_CHECK( !fs::exists( d1 ) ); @@ -798,5 +798,5 @@ // 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 ) ); @@ -804,14 +804,14 @@ 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 ) ); @@ -820,12 +820,12 @@ 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 ) ); @@ -834,5 +834,5 @@ // 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, "" ); @@ -846,9 +846,9 @@ 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 ) ); } Index: /trunk/libs/filesystem/test/msvc/fstream_test/fstream_test.vcproj =================================================================== --- /trunk/libs/filesystem/test/msvc/fstream_test/fstream_test.vcproj (revision 46750) +++ /trunk/libs/filesystem/test/msvc/fstream_test/fstream_test.vcproj (revision 48377) @@ -87,5 +87,5 @@ @@ -164,4 +164,6 @@ Index: /trunk/libs/filesystem/test/msvc/operations_test/operations_test.vcproj =================================================================== --- /trunk/libs/filesystem/test/msvc/operations_test/operations_test.vcproj (revision 46750) +++ /trunk/libs/filesystem/test/msvc/operations_test/operations_test.vcproj (revision 48377) @@ -87,5 +87,5 @@ @@ -164,4 +164,6 @@ Index: /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 (revision 46750) +++ /trunk/libs/filesystem/test/msvc/large_file_support_test/large_file_support_test.vcproj (revision 48377) @@ -87,5 +87,5 @@ @@ -164,4 +164,6 @@ Index: /trunk/libs/filesystem/test/msvc/simple_ls/simple_ls.vcproj =================================================================== --- /trunk/libs/filesystem/test/msvc/simple_ls/simple_ls.vcproj (revision 46750) +++ /trunk/libs/filesystem/test/msvc/simple_ls/simple_ls.vcproj (revision 48377) @@ -87,4 +87,6 @@ @@ -162,4 +164,6 @@ Index: /trunk/libs/filesystem/test/msvc/wide_test/wide_test.vcproj =================================================================== --- /trunk/libs/filesystem/test/msvc/wide_test/wide_test.vcproj (revision 46750) +++ /trunk/libs/filesystem/test/msvc/wide_test/wide_test.vcproj (revision 48377) @@ -87,5 +87,5 @@ @@ -164,4 +164,6 @@ Index: /trunk/libs/filesystem/test/msvc/mbcopy/mbcopy.vcproj =================================================================== --- /trunk/libs/filesystem/test/msvc/mbcopy/mbcopy.vcproj (revision 46750) +++ /trunk/libs/filesystem/test/msvc/mbcopy/mbcopy.vcproj (revision 48377) @@ -87,4 +87,6 @@ @@ -162,4 +164,6 @@ Index: /trunk/libs/filesystem/test/msvc/convenience_test/convenience_test.vcproj =================================================================== --- /trunk/libs/filesystem/test/msvc/convenience_test/convenience_test.vcproj (revision 46750) +++ /trunk/libs/filesystem/test/msvc/convenience_test/convenience_test.vcproj (revision 48377) @@ -87,5 +87,5 @@ @@ -164,4 +164,6 @@ Index: /trunk/libs/filesystem/test/msvc/path_test/path_test.vcproj =================================================================== --- /trunk/libs/filesystem/test/msvc/path_test/path_test.vcproj (revision 46750) +++ /trunk/libs/filesystem/test/msvc/path_test/path_test.vcproj (revision 48377) @@ -87,5 +87,5 @@ @@ -164,4 +164,6 @@