--- operations.hpp.orig	2008-05-30 14:33:15.000000000 +0300
+++ operations.hpp	2008-05-30 14:48:26.000000000 +0300
@@ -226,7 +226,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
 
@@ -456,25 +459,24 @@
 
     BOOST_FS_FUNC(bool) remove( const Path & ph )
     {
-      if ( exists( ph )
-        || is_symlink( ph ) ) // handle dangling symbolic links
-        // note that the POSIX behavior for symbolic links is what we want;
-        // the link rather than what it points to is deleted. Windows behavior
-        // doesn't matter; is_symlink() is always false on Windows.
-      {
-        system::error_code ec( detail::remove_api( ph.external_file_string() ) );
-        if ( ec )
-          boost::throw_exception( basic_filesystem_error<Path>(
-            "boost::filesystem::remove", ph, ec ) );
-        return true;
-      }
-      return false;
+      system::error_code ec;
+      file_status f = symlink_status( ph, ec );
+      if ( ec )
+	boost::throw_exception( basic_filesystem_error<Path>(
+	"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 )
@@ -745,20 +747,41 @@
     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;
       }
 
