Re: [Boost-bugs] [Boost C++ Libraries] #2866: boost::filesystem::rename throw exception when target file exists, but documentation tell us that it must be replaced

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #2866: boost::filesystem::rename throw exception when target file exists, but documentation tell us that it must be replaced
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-11-17 22:46:40


#2866: boost::filesystem::rename throw exception when target file exists, but
documentation tell us that it must be replaced
--------------------------------+-------------------------------------------
 Reporter: t.kozlov@… | Owner: bemandawes
     Type: Bugs | Status: new
Milestone: Boost 1.41.0 | Component: filesystem
  Version: Boost 1.40.0 | Severity: Problem
 Keywords: |
--------------------------------+-------------------------------------------
Changes (by sean@…):

 * cc: sean@… (added)
  * version: Boost 1.38.0 => Boost 1.40.0
  * milestone: Boost 1.39.0 => Boost 1.41.0

Comment:

 Passing the call back to POSIX's rename(2) call should result in the
 desired outcome that matches the semantics of both POSIX's rename(2) call
 and boost::filesystem's documentation. The attached patch fixes this
 problem and changes the behavior of boost::filesystem::rename() to match
 that of rename(2). I believe that the Win32 API is doing the correct
 thing. The extra exists() checks should be removed from the POSIX
 versions according to the posix specification. POSIX rename(2) guarantees
 rename(2) to be atomic and the extra check creates a race condition that
 prevents boost's rename() from being used.

 Thanks in advance.

 http://www.opengroup.org/onlinepubs/000095399/functions/rename.html

 --- /tmp/operations.cpp 2009-11-17 14:40:39.000000000 -0800
 +++ contrib-
 Darwin-i386/boost-1.41.0.beta1.cmake1/libs/filesystem/src/operations.cpp
 2009-11-17 14:41:00.000000000 -0800
 @@ -1186,10 +1186,6 @@
        BOOST_FILESYSTEM_DECL error_code
        rename_api( const std::string & from, const std::string & to )
        {
 - // POSIX is too permissive so must check
 - error_code dummy;
 - if ( fs::exists( status_api( to, dummy ) ) )
 - return error_code( EEXIST, system_category );
          return error_code( std::rename( from.c_str(), to.c_str() ) != 0
            ? errno : 0, system_category );
        }

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/2866#comment:2>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:01 UTC