Boost logo

Boost-Commit :

From: bdawes_at_[hidden]
Date: 2007-11-12 21:54:33


Author: bemandawes
Date: 2007-11-12 21:54:32 EST (Mon, 12 Nov 2007)
New Revision: 41052
URL: http://svn.boost.org/trac/boost/changeset/41052

Log:
Add tests for, and fix, current_path overloading.
Text files modified:
   trunk/boost/filesystem/operations.hpp | 13 +++++++++----
   trunk/libs/filesystem/test/operations_test.cpp | 7 +++++++
   2 files changed, 16 insertions(+), 4 deletions(-)

Modified: trunk/boost/filesystem/operations.hpp
==============================================================================
--- trunk/boost/filesystem/operations.hpp (original)
+++ trunk/boost/filesystem/operations.hpp 2007-11-12 21:54:32 EST (Mon, 12 Nov 2007)
@@ -510,10 +510,10 @@
       return Path( Path::traits_type::to_internal( ph ) );
     }
 
- template< class Path >
- void current_path( const Path & ph )
+ BOOST_FS_FUNC(void) current_path( const Path & ph )
     {
- system::error_code ec( detail::set_current_path_api( ph.string() ) );
+ system::error_code ec( detail::set_current_path_api(
+ ph.external_directory_string() ) );
       if ( ec )
           boost::throw_exception( basic_filesystem_error<Path>(
             "boost::filesystem::current_path", ph, ec ) );
@@ -735,7 +735,12 @@
     inline void last_write_time( const wpath & ph, const std::time_t new_time )
       { last_write_time<wpath>( ph, new_time ); }
 
-# endif // BOOST_FILESYSTEM_NARROW_ONLY
+ inline void current_path( const path & ph )
+ { current_path<path>( ph ); }
+ inline void current_path( const wpath & ph )
+ { current_path<wpath>( ph ); }
+
+# endif // ifndef BOOST_FILESYSTEM_NARROW_ONLY
 
     namespace detail
     {

Modified: trunk/libs/filesystem/test/operations_test.cpp
==============================================================================
--- trunk/libs/filesystem/test/operations_test.cpp (original)
+++ trunk/libs/filesystem/test/operations_test.cpp 2007-11-12 21:54:32 EST (Mon, 12 Nov 2007)
@@ -411,6 +411,13 @@
   fs::current_path( original_dir );
   BOOST_CHECK( fs::current_path<fs::path>() == original_dir );
   BOOST_CHECK( fs::current_path<fs::path>() != dir );
+ // make sure the overloads work
+ fs::current_path( dir.string().c_str() );
+ BOOST_CHECK( fs::current_path<fs::path>() == dir );
+ BOOST_CHECK( fs::current_path<fs::path>() != original_dir );
+ fs::current_path( original_dir.string() );
+ BOOST_CHECK( fs::current_path<fs::path>() == original_dir );
+ BOOST_CHECK( fs::current_path<fs::path>() != dir );
 
   // make some reasonable assuptions for testing purposes
   fs::space_info spi( fs::space( dir ) );


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