Boost logo

Boost-Commit :

From: bdawes_at_[hidden]
Date: 2007-08-24 17:35:51


Author: bemandawes
Date: 2007-08-24 17:35:46 EDT (Fri, 24 Aug 2007)
New Revision: 38912
URL: http://svn.boost.org/trac/boost/changeset/38912

Log:
Add current_path() setter, !#800, change form of some includes in response to bug report !#600
Removed:
   branches/libs/filesystem/boost/filesystem/cerrno.hpp
Text files modified:
   branches/c++0x/boost/boost/cerrno.hpp | 14 +--
   branches/libs/filesystem/boost/filesystem/convenience.hpp | 9 +-
   branches/libs/filesystem/boost/filesystem/operations.hpp | 13 +++
   branches/libs/filesystem/boost/filesystem/path.hpp | 2
   branches/libs/filesystem/filesystem/src/operations.cpp | 158 +++++++++++++++++++++++----------------
   branches/libs/filesystem/filesystem/src/path.cpp | 6
   branches/libs/filesystem/filesystem/test/operations_test.cpp | 58 ++++++++------
   branches/libs/filesystem/filesystem/test/path_test.cpp | 2
   8 files changed, 156 insertions(+), 106 deletions(-)

Modified: branches/c++0x/boost/boost/cerrno.hpp
==============================================================================
--- branches/c++0x/boost/boost/cerrno.hpp (original)
+++ branches/c++0x/boost/boost/cerrno.hpp 2007-08-24 17:35:46 EDT (Fri, 24 Aug 2007)
@@ -1,14 +1,14 @@
-// Boost Filesystem cerrno.hpp header --------------------------------------//
+// Boost cerrno.hpp header -------------------------------------------------//
 
-// © Copyright Beman Dawes 2005.
+// Copyright Beman Dawes 2005.
 // Use, modification, and distribution is subject to the Boost Software
 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-// See library home page at http://www.boost.org/libs/filesystem
+// See library home page at http://www.boost.org/libs/system
 
-#ifndef BOOST_FILESYSTEM_CERRNO_HPP
-#define BOOST_FILESYSTEM_CERRNO_HPP
+#ifndef BOOST_CERRNO_HPP
+#define BOOST_CERRNO_HPP
 
 #include <cerrno>
 
@@ -190,8 +190,4 @@
 #define EILSEQ 9945
 #endif
 
-#define EBADHANDLE 9998 // bad handle
-#define EOTHER 9999 // Other error not translatable
- // to a POSIX errno value
-
 #endif // include guard

Deleted: branches/libs/filesystem/boost/filesystem/cerrno.hpp
==============================================================================
--- branches/libs/filesystem/boost/filesystem/cerrno.hpp 2007-08-24 17:35:46 EDT (Fri, 24 Aug 2007)
+++ (empty file)
@@ -1,23 +0,0 @@
-// Boost Filesystem cerrno.hpp header --------------------------------------//
-
-// Copyright Beman Dawes 2005.
-// Use, modification, and distribution is subject to the Boost Software
-// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-// See library home page at http://www.boost.org/libs/filesystem
-
-#ifndef BOOST_FILESYSTEM_CERRNO_HPP
-#define BOOST_FILESYSTEM_CERRNO_HPP
-
-#include <cerrno>
-
-#if defined __BORLANDC__
-#define ENOSYS 9997
-#endif
-
-#define EBADHANDLE 9998 // bad handle
-#define EOTHER 9999 // Other error not translatable
- // to a POSIX errno value
-
-#endif // include guard

Modified: branches/libs/filesystem/boost/filesystem/convenience.hpp
==============================================================================
--- branches/libs/filesystem/boost/filesystem/convenience.hpp (original)
+++ branches/libs/filesystem/boost/filesystem/convenience.hpp 2007-08-24 17:35:46 EDT (Fri, 24 Aug 2007)
@@ -1,7 +1,7 @@
 // boost/filesystem/convenience.hpp ----------------------------------------//
 
-// © Copyright Beman Dawes, 2002-2005
-// © Copyright Vladimir Prus, 2002
+// Copyright Beman Dawes, 2002-2005
+// Copyright Vladimir Prus, 2002
 // Use, modification, and distribution is subject to the Boost Software
 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
@@ -14,7 +14,7 @@
 #define BOOST_FILESYSTEM_CONVENIENCE_HPP
 
 #include <boost/filesystem/operations.hpp>
-#include <boost/cerrno.hpp>
+#include <boost/system/error_code.hpp>
 #include <vector>
 #include <stack>
 
@@ -45,7 +45,8 @@
            if ( !ph.empty() && !is_directory(ph) )
                boost::throw_exception( basic_filesystem_error<Path>(
                  "boost::filesystem::create_directories", ph,
- boost::system::error_code(EEXIST, boost::system::errno_ecat) ) );
+ boost::system::make_error_code(
+ boost::system::posix::file_exists ) ) );
            return false;
          }
 

Modified: branches/libs/filesystem/boost/filesystem/operations.hpp
==============================================================================
--- branches/libs/filesystem/boost/filesystem/operations.hpp (original)
+++ branches/libs/filesystem/boost/filesystem/operations.hpp 2007-08-24 17:35:46 EDT (Fri, 24 Aug 2007)
@@ -160,6 +160,8 @@
         last_write_time_api( const std::string & ph, std::time_t new_value );
       BOOST_FILESYSTEM_DECL system::error_code
         get_current_path_api( std::string & ph );
+ BOOST_FILESYSTEM_DECL system::error_code
+ set_current_path_api( const std::string & ph );
       BOOST_FILESYSTEM_DECL query_pair
         create_directory_api( const std::string & ph );
       BOOST_FILESYSTEM_DECL system::error_code
@@ -200,6 +202,8 @@
         last_write_time_api( const std::wstring & ph, std::time_t new_value );
       BOOST_FILESYSTEM_DECL system::error_code
         get_current_path_api( std::wstring & ph );
+ BOOST_FILESYSTEM_DECL system::error_code
+ set_current_path_api( const std::wstring & ph );
       BOOST_FILESYSTEM_DECL query_pair
         create_directory_api( const std::wstring & ph );
 # ifdef BOOST_FS_HARD_LINK
@@ -506,6 +510,15 @@
     }
 
     template< class Path >
+ void current_path( const Path & ph )
+ {
+ system::error_code ec( detail::set_current_path_api( ph.string() ) );
+ if ( ec )
+ boost::throw_exception( basic_filesystem_error<Path>(
+ "boost::filesystem::current_path", ph, ec ) );
+ }
+
+ template< class Path >
     const Path & initial_path()
     {
       static Path init_path;

Modified: branches/libs/filesystem/boost/filesystem/path.hpp
==============================================================================
--- branches/libs/filesystem/boost/filesystem/path.hpp (original)
+++ branches/libs/filesystem/boost/filesystem/path.hpp 2007-08-24 17:35:46 EDT (Fri, 24 Aug 2007)
@@ -1,6 +1,6 @@
 // boost/filesystem/path.hpp -----------------------------------------------//
 
-// Copyright Beman Dawes 2002-2005
+// Copyright Beman Dawes 2002-2005
 
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Modified: branches/libs/filesystem/filesystem/src/operations.cpp
==============================================================================
--- branches/libs/filesystem/filesystem/src/operations.cpp (original)
+++ branches/libs/filesystem/filesystem/src/operations.cpp 2007-08-24 17:35:46 EDT (Fri, 24 Aug 2007)
@@ -42,18 +42,17 @@
 
 namespace fs = boost::filesystem;
 using boost::system::error_code;
-using boost::system::errno_ecat;
-using boost::system::native_ecat;
+using boost::system::system_category;
 
 # if defined(BOOST_WINDOWS_API)
-# include "windows.h"
+# include <windows.h>
 # if defined(__BORLANDC__) || defined(__MWERKS__)
 # if defined(__BORLANDC__)
         using std::time_t;
 # endif
-# include "utime.h"
+# include <utime.h>
 # else
-# include "sys/utime.h"
+# include <sys/utime.h>
 # endif
 
 # else // BOOST_POSIX_API
@@ -67,10 +66,10 @@
 # define BOOST_STATVFS statfs
 # define BOOST_STATVFS_F_FRSIZE static_cast<boost::uintmax_t>( vfs.f_bsize )
 # endif
-# include "dirent.h"
-# include "unistd.h"
-# include "fcntl.h"
-# include "utime.h"
+# include <dirent.h>
+# include <unistd.h>
+# include <fcntl.h>
+# include <utime.h>
 # endif
 
 // BOOST_FILESYSTEM_STATUS_CACHE enables file_status cache in
@@ -143,6 +142,9 @@
   inline DWORD get_current_directory( DWORD sz, wchar_t * buf )
     { return ::GetCurrentDirectoryW( sz, buf ); }
 
+ inline bool set_current_directory( const wchar_t * buf )
+ { return ::SetCurrentDirectoryW( buf ) != 0 ; }
+
   inline bool get_free_disk_space( const std::wstring & ph,
     PULARGE_INTEGER avail, PULARGE_INTEGER total, PULARGE_INTEGER free )
     { return ::GetDiskFreeSpaceExW( ph.c_str(), avail, total, free ) != 0; }
@@ -178,7 +180,7 @@
     DWORD attr( get_file_attributes( ph.c_str() ) );
     if ( attr == 0xFFFFFFFF )
     {
- ec = error_code( ::GetLastError(), native_ecat );
+ ec = error_code( ::GetLastError(), system_category );
       if ((ec.value() == ERROR_FILE_NOT_FOUND)
         || (ec.value() == ERROR_PATH_NOT_FOUND)
         || (ec.value() == ERROR_INVALID_NAME) // "tools/jam/src/:sys:stat.h", "//foo"
@@ -206,7 +208,7 @@
   {
     WIN32_FILE_ATTRIBUTE_DATA fad;
     if ( get_file_attributes_ex( ph.c_str(), fad ) == 0 )
- return std::make_pair( error_code( ::GetLastError(), native_ecat ), false );
+ return std::make_pair( error_code( ::GetLastError(), system_category ), false );
     return std::make_pair( error_code(),
       ( fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
         ? is_empty_directory( ph )
@@ -276,14 +278,14 @@
         { return std::make_pair( error_code(), false ); }
       assert( p1.handle == INVALID_HANDLE_VALUE
         && p2.handle == INVALID_HANDLE_VALUE );
- { return std::make_pair( error_code( error1, errno_ecat), false ); }
+ { return std::make_pair( error_code( error1, system_category), false ); }
     }
     // at this point, both handles are known to be valid
     BY_HANDLE_FILE_INFORMATION info1, info2;
     if ( !::GetFileInformationByHandle( p1.handle, &info1 ) )
- { return std::make_pair( error_code( ::GetLastError(), native_ecat ), false ); }
+ { return std::make_pair( error_code( ::GetLastError(), system_category ), false ); }
     if ( !::GetFileInformationByHandle( p2.handle, &info2 ) )
- { return std::make_pair( error_code( ::GetLastError(), native_ecat ), false ); }
+ { return std::make_pair( error_code( ::GetLastError(), system_category ), false ); }
     // In theory, volume serial numbers are sufficient to distinguish between
     // devices, but in practice VSN's are sometimes duplicated, so last write
     // time and file size are also checked.
@@ -306,9 +308,9 @@
     WIN32_FILE_ATTRIBUTE_DATA fad;
     // by now, intmax_t is 64-bits on all Windows compilers
     if ( get_file_attributes_ex( ph.c_str(), fad ) == 0 )
- return std::make_pair( error_code( ::GetLastError(), native_ecat ), 0 );
+ return std::make_pair( error_code( ::GetLastError(), system_category ), 0 );
     if ( (fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) !=0 )
- return std::make_pair( error_code( ERROR_FILE_NOT_FOUND, native_ecat), 0 );
+ return std::make_pair( error_code( ERROR_FILE_NOT_FOUND, system_category), 0 );
     return std::make_pair( error_code(),
       (static_cast<boost::uintmax_t>(fad.nFileSizeHigh)
         << (sizeof(fad.nFileSizeLow)*8))
@@ -340,7 +342,7 @@
     }
     else
     {
- result.first = error_code( ::GetLastError(), native_ecat );
+ result.first = error_code( ::GetLastError(), system_category );
       result.second.capacity = result.second.free
         = result.second.available = 0;
     }
@@ -361,11 +363,22 @@
     typedef typename String::value_type value_type;
     boost::scoped_array<value_type> buf( new value_type[sz] );
     if ( get_current_directory( sz, buf.get() ) == 0 )
- return error_code( ::GetLastError(), native_ecat );
+ return error_code( ::GetLastError(), system_category );
     ph = buf.get();
     return error_code();
   }
 
+ inline bool set_current_directory( const char * buf )
+ { return ::SetCurrentDirectoryA( buf ) != 0; }
+
+ template< class String >
+ error_code
+ set_current_path_template( const String & ph )
+ {
+ return error_code( set_current_directory( ph.c_str() )
+ ? 0 : ::GetLastError(), system_category );
+ }
+
   inline std::size_t get_full_path_name(
     const std::string & ph, std::size_t len, char * buf, char ** p )
   {
@@ -384,13 +397,13 @@
     typename String::value_type * pfn;
     std::size_t len = get_full_path_name( ph,
       buf_size , buf, &pfn );
- if ( len == 0 ) return error_code( ::GetLastError(), native_ecat );
+ if ( len == 0 ) return error_code( ::GetLastError(), system_category );
     if ( len > buf_size )
     {
       typedef typename String::value_type value_type;
       boost::scoped_array<value_type> big_buf( new value_type[len] );
       if ( (len=get_full_path_name( ph, len , big_buf.get(), &pfn ))
- == 0 ) return error_code( ::GetLastError(), native_ecat );
+ == 0 ) return error_code( ::GetLastError(), system_category );
       big_buf[len] = '\0';
       target = big_buf.get();
       return error_code();
@@ -409,9 +422,9 @@
         FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
         OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0 ) );
     if ( hw.handle == INVALID_HANDLE_VALUE )
- return error_code( ::GetLastError(), native_ecat );
+ return error_code( ::GetLastError(), system_category );
     return error_code( ::GetFileTime( hw.handle, 0, 0, &last_write_time ) != 0
- ? 0 : ::GetLastError(), native_ecat );
+ ? 0 : ::GetLastError(), system_category );
   }
 
   template<class String>
@@ -423,9 +436,9 @@
         FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
         OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0 ) );
     if ( hw.handle == INVALID_HANDLE_VALUE )
- return error_code( ::GetLastError(), native_ecat );
+ return error_code( ::GetLastError(), system_category );
     return error_code( ::SetFileTime( hw.handle, 0, 0, &last_write_time ) != 0
- ? 0 : ::GetLastError(), native_ecat );
+ ? 0 : ::GetLastError(), system_category );
   }
 
   // these constants come from inspecting some Microsoft sample code
@@ -490,11 +503,11 @@
     if ( fs::is_directory( sf ) )
     {
       if ( !remove_directory( ph ) )
- return error_code(::GetLastError(), native_ecat);
+ return error_code(::GetLastError(), system_category);
     }
     else
     {
- if ( !delete_file( ph ) ) return error_code(::GetLastError(), native_ecat);
+ if ( !delete_file( ph ) ) return error_code(::GetLastError(), system_category);
     }
     return error_code();
   }
@@ -508,7 +521,7 @@
   {
     error_code error, dummy;
     if ( create_directory( dir_ph ) ) return std::make_pair( error, true );
- error = error_code( ::GetLastError(), native_ecat );
+ error = error_code( ::GetLastError(), system_category );
     // an error here may simply mean the postcondition is already met
     if ( error.value() == ERROR_ALREADY_EXISTS
       && fs::is_directory( fs::detail::status_api( dir_ph, dummy ) ) )
@@ -529,7 +542,7 @@
     const String & from_ph )
   {
     return error_code( create_hard_link( to_ph.c_str(), from_ph.c_str() )
- ? 0 : ::GetLastError(), native_ecat );
+ ? 0 : ::GetLastError(), system_category );
   }
 #endif
 
@@ -548,9 +561,9 @@
       BOOST_FILESYSTEM_DECL error_code not_found_error()
       {
 # ifdef BOOST_WINDOWS_API
- return error_code(ERROR_PATH_NOT_FOUND, native_ecat);
+ return error_code(ERROR_PATH_NOT_FOUND, system_category);
 # else
- return error_code(ENOENT, errno_ecat);
+ return error_code(ENOENT, system_category);
 # endif
       }
 
@@ -601,6 +614,11 @@
       get_current_path_api( std::wstring & ph )
         { return get_current_path_template( ph ); }
 
+ BOOST_FILESYSTEM_DECL
+ error_code
+ set_current_path_api( const std::wstring & ph )
+ { return set_current_path_template( ph ); }
+
       BOOST_FILESYSTEM_DECL error_code
         get_full_path_name_api( const std::wstring & ph, std::wstring & target )
          { return get_full_path_name_template( ph, target ); }
@@ -627,7 +645,7 @@
       BOOST_FILESYSTEM_DECL error_code
       create_symlink_api( const std::wstring & to_ph,
         const std::wstring & from_ph )
- { return error_code( ERROR_NOT_SUPPORTED, native_ecat ); }
+ { return error_code( ERROR_NOT_SUPPORTED, system_category ); }
 
       BOOST_FILESYSTEM_DECL error_code
       remove_api( const std::wstring & ph ) { return remove_template( ph ); }
@@ -636,14 +654,14 @@
       rename_api( const std::wstring & from, const std::wstring & to )
       {
         return error_code( ::MoveFileW( from.c_str(), to.c_str() )
- ? 0 : ::GetLastError(), native_ecat );
+ ? 0 : ::GetLastError(), system_category );
       }
 
       BOOST_FILESYSTEM_DECL error_code
       copy_file_api( const std::wstring & from, const std::wstring & to )
       {
         return error_code( ::CopyFileW( from.c_str(), to.c_str(), /*fail_if_exists=*/true )
- ? 0 : ::GetLastError(), native_ecat );
+ ? 0 : ::GetLastError(), system_category );
       }
 
       BOOST_FILESYSTEM_DECL bool create_file_api( const std::wstring & ph,
@@ -719,7 +737,7 @@
         {
           handle = 0;
           return error_code( ::GetLastError() == ERROR_FILE_NOT_FOUND
- ? 0 : ::GetLastError(), native_ecat );
+ ? 0 : ::GetLastError(), system_category );
         }
         target = data.cFileName;
         if ( data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
@@ -737,7 +755,7 @@
         {
           int error = ::GetLastError();
           dir_itr_close( handle );
- return error_code( error == ERROR_NO_MORE_FILES ? 0 : error, native_ecat );
+ return error_code( error == ERROR_NO_MORE_FILES ? 0 : error, system_category );
         }
         target = data.cFileName;
         if ( data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
@@ -774,6 +792,11 @@
       get_current_path_api( std::string & ph )
         { return get_current_path_template( ph ); }
 
+ BOOST_FILESYSTEM_DECL
+ error_code
+ set_current_path_api( const std::string & ph )
+ { return set_current_path_template( ph ); }
+
       BOOST_FILESYSTEM_DECL error_code
         get_full_path_name_api( const std::string & ph, std::string & target )
          { return get_full_path_name_template( ph, target ); }
@@ -802,7 +825,7 @@
       BOOST_FILESYSTEM_DECL error_code
       create_symlink_api( const std::string & to_ph,
         const std::string & from_ph )
- { return error_code( ERROR_NOT_SUPPORTED, native_ecat ); }
+ { return error_code( ERROR_NOT_SUPPORTED, system_category ); }
 
       BOOST_FILESYSTEM_DECL error_code
       remove_api( const std::string & ph ) { return remove_template( ph ); }
@@ -811,14 +834,14 @@
       rename_api( const std::string & from, const std::string & to )
       {
         return error_code( ::MoveFileA( from.c_str(), to.c_str() )
- ? 0 : ::GetLastError(), native_ecat );
+ ? 0 : ::GetLastError(), system_category );
       }
 
       BOOST_FILESYSTEM_DECL error_code
       copy_file_api( const std::string & from, const std::string & to )
       {
         return error_code( ::CopyFileA( from.c_str(), to.c_str(), /*fail_if_exists=*/true )
- ? 0 : ::GetLastError(), native_ecat );
+ ? 0 : ::GetLastError(), system_category );
       }
 
       BOOST_FILESYSTEM_DECL error_code
@@ -840,7 +863,7 @@
         {
           handle = 0;
           return error_code( ::GetLastError() == ERROR_FILE_NOT_FOUND
- ? 0 : ::GetLastError(), native_ecat );
+ ? 0 : ::GetLastError(), system_category );
         }
         target = data.cFileName;
         if ( data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
@@ -856,7 +879,7 @@
         {
           bool ok = ::FindClose( handle ) != 0;
           handle = 0;
- return error_code( ok ? 0 : ::GetLastError(), native_ecat );
+ return error_code( ok ? 0 : ::GetLastError(), system_category );
         }
         return error_code();
       }
@@ -870,7 +893,7 @@
         {
           int error = ::GetLastError();
           dir_itr_close( handle );
- return error_code( error == ERROR_NO_MORE_FILES ? 0 : error, native_ecat );
+ return error_code( error == ERROR_NO_MORE_FILES ? 0 : error, system_category );
         }
         target = data.cFileName;
         if ( data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
@@ -892,7 +915,7 @@
             ec = error_code();
             return fs::file_status( fs::file_not_found );
           }
- ec = error_code( errno, errno_ecat );
+ ec = error_code( errno, system_category );
           return fs::file_status( fs::status_unknown );
         }
         ec = error_code();
@@ -922,7 +945,7 @@
             ec = error_code();
             return fs::file_status( fs::file_not_found );
           }
- ec = error_code( errno, errno_ecat );
+ ec = error_code( errno, system_category );
           return fs::file_status( fs::status_unknown );
         }
         ec = error_code();
@@ -957,7 +980,7 @@
       {
         struct stat path_stat;
         if ( (::stat( ph.c_str(), &path_stat )) != 0 )
- return std::make_pair( error_code( errno, errno_ecat ), false );
+ return std::make_pair( error_code( errno, system_category ), false );
         return std::make_pair( error_code(), S_ISDIR( path_stat.st_mode )
           ? is_empty_directory( ph )
           : path_stat.st_size == 0 );
@@ -971,7 +994,7 @@
         struct stat s1;
         int e1( ::stat( ph1.c_str(), &s1 ) );
         if ( e1 != 0 || e2 != 0 )
- return std::make_pair( error_code( e1 != 0 && e2 != 0 ? errno : 0, errno_ecat ), false );
+ return std::make_pair( error_code( e1 != 0 && e2 != 0 ? errno : 0, system_category ), false );
         // at this point, both stats are known to be valid
         return std::make_pair( error_code(),
             s1.st_dev == s2.st_dev
@@ -988,9 +1011,9 @@
       {
         struct stat path_stat;
         if ( ::stat( ph.c_str(), &path_stat ) != 0 )
- return std::make_pair( error_code( errno, errno_ecat ), 0 );
+ return std::make_pair( error_code( errno, system_category ), 0 );
         if ( !S_ISREG( path_stat.st_mode ) )
- return std::make_pair( error_code( EPERM, errno_ecat ), 0 );
+ return std::make_pair( error_code( EPERM, system_category ), 0 );
         return std::make_pair( error_code(),
           static_cast<boost::uintmax_t>(path_stat.st_size) );
       }
@@ -1002,7 +1025,7 @@
         space_pair result;
         if ( ::BOOST_STATVFS( ph.c_str(), &vfs ) != 0 )
         {
- result.first = error_code( errno, errno_ecat );
+ result.first = error_code( errno, system_category );
           result.second.capacity = result.second.free
             = result.second.available = 0;
         }
@@ -1024,7 +1047,7 @@
       {
         struct stat path_stat;
         if ( ::stat( ph.c_str(), &path_stat ) != 0 )
- return std::make_pair( error_code( errno, errno_ecat ), 0 );
+ return std::make_pair( error_code( errno, system_category ), 0 );
         return std::make_pair( error_code(), path_stat.st_mtime );
       }
 
@@ -1033,11 +1056,11 @@
       {
         struct stat path_stat;
         if ( ::stat( ph.c_str(), &path_stat ) != 0 )
- return error_code( errno, errno_ecat );
+ return error_code( errno, system_category );
         ::utimbuf buf;
         buf.actime = path_stat.st_atime; // utime() updates access time too:-(
         buf.modtime = new_value;
- return error_code( ::utime( ph.c_str(), &buf ) != 0 ? errno : 0, errno_ecat );
+ return error_code( ::utime( ph.c_str(), &buf ) != 0 ? errno : 0, system_category );
       }
 
       BOOST_FILESYSTEM_DECL error_code
@@ -1054,7 +1077,7 @@
 # if defined(__MSL__) && (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__))
               && errno != 0
 # endif
- ) return error_code( errno, errno_ecat );
+ ) return error_code( errno, system_category );
           }
           else
           {
@@ -1065,6 +1088,13 @@
         return error_code();
       }
 
+ BOOST_FILESYSTEM_DECL error_code
+ set_current_path_api( std::string & ph )
+ {
+ return error_code( ::chdir( ph.string().c_str()
+ ? errno : 0, system_category );
+ }
+
       BOOST_FILESYSTEM_DECL fs::detail::query_pair
       create_directory_api( const std::string & ph )
       {
@@ -1074,7 +1104,7 @@
         error_code dummy;
         if ( ec != EEXIST
           || !fs::is_directory( status_api( ph, dummy ) ) )
- { return std::make_pair( error_code( ec, errno_ecat ), false ); }
+ { return std::make_pair( error_code( ec, system_category ), false ); }
         return std::make_pair( error_code(), false );
       }
 
@@ -1083,7 +1113,7 @@
           const std::string & from_ph )
       {
         return error_code( ::link( to_ph.c_str(), from_ph.c_str() ) == 0
- ? 0 : errno, errno_ecat );
+ ? 0 : errno, system_category );
       }
 
       BOOST_FILESYSTEM_DECL error_code
@@ -1091,7 +1121,7 @@
           const std::string & from_ph )
       {
         return error_code( ::symlink( to_ph.c_str(), from_ph.c_str() ) == 0
- ? 0 : errno, errno_ecat );
+ ? 0 : errno, system_category );
       }
 
       BOOST_FILESYSTEM_DECL error_code
@@ -1116,7 +1146,7 @@
           // shall fail and set errno to EEXIST or ENOTEMPTY."
           // Linux uses ENOTEMPTY, Solaris uses EEXIST.
           if ( error == EEXIST ) error = ENOTEMPTY;
- return error_code( error, errno_ecat );
+ return error_code( error, system_category );
         }
         return error_code();
       }
@@ -1127,9 +1157,9 @@
         // POSIX is too permissive so must check
         error_code dummy;
         if ( fs::exists( status_api( to, dummy ) ) )
- return error_code( EEXIST, errno_ecat );
+ return error_code( EEXIST, system_category );
         return error_code( std::rename( from.c_str(), to.c_str() ) != 0
- ? errno : 0, errno_ecat );
+ ? errno : 0, system_category );
       }
 
       BOOST_FILESYSTEM_DECL error_code
@@ -1149,7 +1179,7 @@
                                 from_stat.st_mode )) < 0 )
         {
           if ( infile >= 0 ) ::close( infile );
- return error_code( errno, errno_ecat );
+ return error_code( errno, system_category );
         }
 
         ssize_t sz, sz_read=1, sz_write;
@@ -1174,7 +1204,7 @@
         if ( ::close( infile) < 0 ) sz_read = -1;
         if ( ::close( outfile) < 0 ) sz_read = -1;
 
- return error_code( sz_read < 0 ? errno : 0, errno_ecat );
+ return error_code( sz_read < 0 ? errno : 0, system_category );
       }
 
       BOOST_FILESYSTEM_DECL error_code
@@ -1184,10 +1214,10 @@
       {
         static const std::string dummy_first_name( "." );
         if ( (handle = ::opendir( dir.c_str() )) == 0 )
- return error_code( errno, errno_ecat );
+ return error_code( errno, system_category );
         target = dummy_first_name;
         long pc_name_max( ::pathconf( dir.c_str(), _PC_NAME_MAX ) );
- if ( pc_name_max == -1L ) return error_code( errno, errno_ecat );
+ if ( pc_name_max == -1L ) return error_code( errno, system_category );
         dirent de;
         buffer = std::malloc( (sizeof(dirent) - sizeof(de.d_name))
           + static_cast<std::size_t>( pc_name_max ) + 1 );
@@ -1202,7 +1232,7 @@
         if ( handle == 0 ) return error_code();
         DIR * h( static_cast<DIR*>(handle) );
         handle = 0;
- return error_code( ::closedir( h ) == 0 ? 0 : errno, errno_ecat );
+ return error_code( ::closedir( h ) == 0 ? 0 : errno, system_category );
       }
 
       // warning: the only dirent member updated is d_name
@@ -1238,7 +1268,7 @@
         dirent * result;
         int return_code;
         if ( (return_code = readdir_r_simulator( static_cast<DIR*>(handle),
- entry, &result )) != 0 ) return error_code( errno, errno_ecat );
+ entry, &result )) != 0 ) return error_code( errno, system_category );
         if ( result == 0 ) return dir_itr_close( handle, buffer );
         target = entry->d_name;
 # ifdef BOOST_FILESYSTEM_STATUS_CACHE

Modified: branches/libs/filesystem/filesystem/src/path.cpp
==============================================================================
--- branches/libs/filesystem/filesystem/src/path.cpp (original)
+++ branches/libs/filesystem/filesystem/src/path.cpp 2007-08-24 17:35:46 EDT (Fri, 24 Aug 2007)
@@ -62,7 +62,7 @@
       if ( locked ) boost::throw_exception(
         wfilesystem_error(
           "boost::filesystem::wpath_traits::imbue() after lockdown",
- system::error_code(EOTHER, system::errno_ecat) ) );
+ system::make_error_code( system::posix::not_supported ) ) );
       imbue( new_loc, std::nothrow );
     }
     
@@ -86,7 +86,7 @@
         work.get()+work_size, to_next ) != std::codecvt_base::ok )
         boost::throw_exception( boost::filesystem::wfilesystem_error(
           "boost::filesystem::wpath::to_external conversion error",
- ph, system::error_code( EINVAL, system::errno_ecat ) ) );
+ ph, system::posix::invalid_argument ) );
       *to_next = '\0';
       return external_string_type( work.get() );
     }
@@ -105,7 +105,7 @@
         work.get()+work_size, to_next ) != std::codecvt_base::ok )
         boost::throw_exception( boost::filesystem::wfilesystem_error(
           "boost::filesystem::wpath::to_internal conversion error",
- system::error_code( EINVAL, system::errno_ecat ) ) );
+ system::posix::invalid_argument ) );
       *to_next = L'\0';
       return internal_string_type( work.get() );
     }

Modified: branches/libs/filesystem/filesystem/test/operations_test.cpp
==============================================================================
--- branches/libs/filesystem/filesystem/test/operations_test.cpp (original)
+++ branches/libs/filesystem/filesystem/test/operations_test.cpp 2007-08-24 17:35:46 EDT (Fri, 24 Aug 2007)
@@ -26,7 +26,7 @@
 
 using boost::bind;
 using boost::system::error_code;
-using boost::system::errno_ecat;
+using boost::system::system_category;
 using boost::system::system_error;
 
 #include <fstream>
@@ -71,7 +71,7 @@
     std::ofstream f( ph.file_string().c_str() );
     if ( !f )
       throw fs::filesystem_error( "operations_test create_file",
- ph, error_code(errno, errno_ecat) );
+ ph, error_code(errno, system_category) );
     if ( !contents.empty() ) f << contents;
   }
 
@@ -80,7 +80,7 @@
     std::ifstream f( ph.file_string().c_str() );
     if ( !f )
       throw fs::filesystem_error( "operations_test verify_file",
- ph, error_code(errno, errno_ecat) );
+ ph, error_code(errno, system_category) );
     std::string contents;
     f >> contents;
     if ( contents != expected )
@@ -101,10 +101,10 @@
         std::cout << "\n" << ex.what() << "\n";
       }
       if ( en == 0
- || en == ex.code().to_errno() ) return true;
+ || en == ex.code().default_error_condition().value() ) return true;
       std::cout
         << "\nWarning: line " << line
- << " exception reports iso() " << ex.code().to_errno()
+ << " exception reports default_error_condition().value() " << ex.code().default_error_condition().value()
         << ", should be " << en
         << "\n value() is " << ex.code().value()
         << std::endl;
@@ -160,7 +160,7 @@
       if ( report_throws ) std::cout << x.what() << std::endl;
       if ( platform == "Windows" )
         BOOST_CHECK( std::strcmp( x.what(),
- "boost::filesystem::create_directory: The system cannot find the path specified." ) == 0 );
+ "boost::filesystem::create_directory: The system cannot find the path specified" ) == 0 );
     }
     BOOST_CHECK( exception_thrown );
 
@@ -176,7 +176,7 @@
       if ( platform == "Windows" )
       {
         bool ok ( std::strcmp( x.what(),
- "boost::filesystem::create_directory: The system cannot find the path specified.: \"no-such-dir\\foo\\bar\"" ) == 0 );
+ "boost::filesystem::create_directory: The system cannot find the path specified: \"no-such-dir\\foo\\bar\"" ) == 0 );
         BOOST_CHECK( ok );
       }
     }
@@ -194,7 +194,7 @@
       if ( platform == "Windows" )
       {
         bool ok ( std::strcmp( x.what(),
- "boost::filesystem::create_directory: The system cannot find the path specified.: \"no-such-dir\\foo\\bar\"" ) == 0 );
+ "boost::filesystem::create_directory: The system cannot find the path specified: \"no-such-dir\\foo\\bar\"" ) == 0 );
         BOOST_CHECK( ok );
       }
     }
@@ -325,26 +325,12 @@
   {
     BOOST_CHECK( ex.path1().string() == " no-way, Jose" );
   }
-
- BOOST_CHECK( fs::create_directory( dir ) );
-
   // several functions give unreasonable results if uintmax_t isn't 64-bits
   std::cout << "sizeof(boost::uintmax_t) = " << sizeof(boost::uintmax_t) << '\n';
   BOOST_CHECK( sizeof( boost::uintmax_t ) >= 8 );
 
- // make some reasonable assuptions for testing purposes
- fs::space_info spi( fs::space( dir ) );
- BOOST_CHECK( spi.capacity > 1000000 );
- BOOST_CHECK( spi.free > 1000 );
- BOOST_CHECK( spi.capacity > spi.free );
- BOOST_CHECK( spi.free >= spi.available );
-
- // it is convenient to display space, but older VC++ versions choke
-# if !defined(BOOST_MSVC) || _MSC_VER >= 1300 // 1300 == VC++ 7.0
- std::cout << " capacity = " << spi.capacity << '\n';
- std::cout << " free = " << spi.free << '\n';
- std::cout << "available = " << spi.available << '\n';
-# endif
+ // create a directory, then check it for consistency
+ BOOST_CHECK( fs::create_directory( dir ) );
 
   BOOST_CHECK( fs::exists( dir ) );
   BOOST_CHECK( BOOST_FS_IS_EMPTY( dir ) );
@@ -359,6 +345,30 @@
   BOOST_CHECK( !fs::is_other( stat ) );
   BOOST_CHECK( !fs::is_symlink( stat ) );
 
+ // set the current directory, then check it for consistency
+ fs::path original_dir = fs::current_path<fs::path>();
+ BOOST_CHECK( dir != original_dir );
+ fs::current_path( dir );
+ BOOST_CHECK( fs::current_path<fs::path>() == dir );
+ BOOST_CHECK( fs::current_path<fs::path>() != original_dir );
+ fs::current_path( original_dir );
+ 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_CHECK( spi.capacity > 1000000 );
+ BOOST_CHECK( spi.free > 1000 );
+ BOOST_CHECK( spi.capacity > spi.free );
+ BOOST_CHECK( spi.free >= spi.available );
+
+ // it is convenient to display space, but older VC++ versions choke
+# if !defined(BOOST_MSVC) || _MSC_VER >= 1300 // 1300 == VC++ 7.0
+ std::cout << " capacity = " << spi.capacity << '\n';
+ std::cout << " free = " << spi.free << '\n';
+ std::cout << "available = " << spi.available << '\n';
+# endif
+
   if ( platform == "Windows" )
     BOOST_CHECK( CHECK_EXCEPTION( bind( BOOST_BND(fs::file_size), dir ),
       ENOENT ) );

Modified: branches/libs/filesystem/filesystem/test/path_test.cpp
==============================================================================
--- branches/libs/filesystem/filesystem/test/path_test.cpp (original)
+++ branches/libs/filesystem/filesystem/test/path_test.cpp 2007-08-24 17:35:46 EDT (Fri, 24 Aug 2007)
@@ -180,7 +180,7 @@
   void exception_tests()
   {
     const std::string str_1("string-1");
- boost::system::error_code ec( 12345, boost::system::errno_ecat);
+ boost::system::error_code ec( 12345, boost::system::system_category);
     try { throw fs::filesystem_error( str_1, ec ); }
     catch ( const fs::filesystem_error & ex )
     {


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