From: <bl...@us...> - 2003-04-01 08:26:32
|
Update of /cvsroot/cpptool/rfta/deplib/boostcvs/libs/filesystem/src In directory sc8-pr-cvs1:/tmp/cvs-serv17363/deplib/boostcvs/libs/filesystem/src Modified Files: exception.cpp operations_posix_windows.cpp path_posix_windows.cpp Log Message: * upgraded to the official boost 1.30 Index: exception.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/deplib/boostcvs/libs/filesystem/src/exception.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** exception.cpp 23 Oct 2002 20:22:55 -0000 1.1.1.1 --- exception.cpp 1 Apr 2003 08:25:50 -0000 1.2 *************** *** 1,5 **** // Exception implementation file -------------------------------------------// ! // < ----------------------------------------------------------------------- > // < Copyright © 2001 Dietmar Kühl, All Rights Reserved > // < > --- 1,6 ---- // Exception implementation file -------------------------------------------// ! // < ----------------------------------------------------------------------- > ! // < Copyright © 2002 Beman Dawes > // < Copyright © 2001 Dietmar Kühl, All Rights Reserved > // < > *************** *** 8,19 **** // < that the above copyright notice appears in all copies and that > // < both that copyright notice and this permission notice appear in > ! // < supporting documentation. Dietmar Kühl makes no representations about > // < the suitability of this software for any purpose. It is provided > // < "as is" without express or implied warranty. > // < ----------------------------------------------------------------------- > ! // Original author: Dietmar Kühl. Revised by Beman Dawes. ! ! // See http://www.boost.org for most recent version including documentation. //----------------------------------------------------------------------------// --- 9,18 ---- // < that the above copyright notice appears in all copies and that > // < both that copyright notice and this permission notice appear in > ! // < supporting documentation. The authors make no representations about > // < the suitability of this software for any purpose. It is provided > // < "as is" without express or implied warranty. > // < ----------------------------------------------------------------------- > ! // See http://www.boost.org/libs/filesystem for documentation. //----------------------------------------------------------------------------// *************** *** 22,26 **** #include <boost/filesystem/exception.hpp> ! #include <cerrno> #include <string> --- 21,27 ---- #include <boost/filesystem/exception.hpp> ! namespace fs = boost::filesystem; ! ! #include <cstring> // SGI MIPSpro compilers need this #include <string> *************** *** 29,37 **** # endif ! // BOOST_POSIX or BOOST_WINDOWS specify which API to use, not the current ! // operating system. GCC defaults to BOOST_POSIX; it doesn't predefine _WIN32. ! # if !defined( BOOST_WINDOWS ) && !defined( BOOST_POSIX ) ! # if defined(_WIN32) # define BOOST_WINDOWS # else --- 30,36 ---- # endif ! // BOOST_POSIX or BOOST_WINDOWS specify which API to use. # if !defined( BOOST_WINDOWS ) && !defined( BOOST_POSIX ) ! # if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__) # define BOOST_WINDOWS # else *************** *** 42,71 **** # if defined( BOOST_WINDOWS ) # include "windows.h" # endif //----------------------------------------------------------------------------// ! namespace boost { ! namespace filesystem { ! filesystem_error::filesystem_error( std::string const& msg ): ! std::runtime_error("filesystem error"), ! m_msg(msg), ! m_err(0) ! { ! } ! ! filesystem_error::filesystem_error( std::string const& msg, error_type ): ! std::runtime_error("filesystem error"), ! m_msg(msg), # ifdef BOOST_WINDOWS ! m_err( ::GetLastError() ) # else ! m_err(errno) // GCC 3.1 won't accept ::errno # endif { } filesystem_error::~filesystem_error() throw() --- 41,229 ---- # if defined( BOOST_WINDOWS ) # include "windows.h" + # else + # include <errno.h> // for POSIX error codes # endif //----------------------------------------------------------------------------// ! namespace { ! std::string system_message( int sys_err_code ) { + std::string str; + # ifdef BOOST_WINDOWS + LPVOID lpMsgBuf; + ::FormatMessageA( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + sys_err_code, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPSTR) &lpMsgBuf, + 0, + NULL + ); + str += static_cast<LPCSTR>(lpMsgBuf); + ::LocalFree( lpMsgBuf ); // free the buffer + while ( str.size() + && (str[str.size()-1] == '\n' || str[str.size()-1] == '\r') ) + str.erase( str.size()-1 ); + # else + str += std::strerror( errno ); + # endif + return str; + } ! struct ec_xlate { int sys_ec; fs::error_code ec; }; ! const ec_xlate ec_table[] = ! { # ifdef BOOST_WINDOWS ! { ERROR_ACCESS_DENIED, fs::security_error }, ! { ERROR_INVALID_ACCESS, fs::security_error }, ! { ERROR_SHARING_VIOLATION, fs::security_error }, ! { ERROR_LOCK_VIOLATION, fs::security_error }, ! { ERROR_LOCKED, fs::security_error }, ! { ERROR_NOACCESS, fs::security_error }, ! { ERROR_WRITE_PROTECT, fs::read_only_error }, ! { ERROR_NOT_READY, fs::io_error }, ! { ERROR_SEEK, fs::io_error }, ! { ERROR_READ_FAULT, fs::io_error }, ! { ERROR_WRITE_FAULT, fs::io_error }, ! { ERROR_CANTOPEN, fs::io_error }, ! { ERROR_CANTREAD, fs::io_error }, ! { ERROR_CANTWRITE, fs::io_error }, ! { ERROR_DIRECTORY, fs::path_error }, ! { ERROR_INVALID_NAME, fs::path_error }, ! { ERROR_FILE_NOT_FOUND, fs::not_found_error }, ! { ERROR_PATH_NOT_FOUND, fs::not_found_error }, ! { ERROR_DEV_NOT_EXIST, fs::not_found_error }, ! { ERROR_DEVICE_IN_USE, fs::busy_error }, ! { ERROR_OPEN_FILES, fs::busy_error }, ! { ERROR_BUSY_DRIVE, fs::busy_error }, ! { ERROR_BUSY, fs::busy_error }, ! { ERROR_FILE_EXISTS, fs::already_exists_error }, ! { ERROR_ALREADY_EXISTS, fs::already_exists_error }, ! { ERROR_DIR_NOT_EMPTY, fs::not_empty_error }, ! { ERROR_HANDLE_DISK_FULL, fs::out_of_space_error }, ! { ERROR_DISK_FULL, fs::out_of_space_error }, ! { ERROR_OUTOFMEMORY, fs::out_of_memory_error }, ! { ERROR_NOT_ENOUGH_MEMORY, fs::out_of_memory_error }, ! { ERROR_TOO_MANY_OPEN_FILES, fs::out_of_resource_error } # else ! { EACCES, fs::security_error }, ! { EROFS, fs::read_only_error }, ! { EIO, fs::io_error }, ! { ENAMETOOLONG, fs::path_error }, ! { ENOENT, fs::not_found_error }, ! { ENOTDIR, fs::not_directory_error }, ! { EAGAIN, fs::busy_error }, ! { EBUSY, fs::busy_error }, ! { ETXTBSY, fs::busy_error }, ! { EEXIST, fs::already_exists_error }, ! { ENOTEMPTY, fs::not_empty_error }, ! { EISDIR, fs::is_directory_error }, ! { ENOSPC, fs::out_of_space_error }, ! { ENOMEM, fs::out_of_memory_error }, ! { EMFILE, fs::out_of_resource_error } # endif + }; + + fs::error_code lookup_error( int sys_err_code ) + { + for ( const ec_xlate * cur = &ec_table[0]; + cur != ec_table + + sizeof(ec_table)/sizeof(ec_xlate); ++cur ) { + if ( sys_err_code == cur->sys_ec ) return cur->ec; } + return fs::system_error; // general system error code + } + + // These helper functions work for POSIX and Windows. For systems where + // path->native_file_string() != path->native_directory_string(), more + // care would be required to get the right form for the function involved. + + std::string other_error_prep( + const std::string & who, + const std::string & message ) + { + return who + ": " + message; + } + + std::string other_error_prep( + const std::string & who, + const fs::path & path1, + const std::string & message ) + { + return who + ": \"" + path1.native_file_string() + "\": " + message; + } + + std::string system_error_prep( + const std::string & who, + const fs::path & path1, + int sys_err_code ) + { + return who + ": \"" + path1.native_file_string() + "\": " + + system_message( sys_err_code ); + } + + std::string system_error_prep( + const std::string & who, + const fs::path & path1, + const fs::path & path2, + int sys_err_code ) + { + return who + ": \"" + path1.native_file_string() + + "\", \"" + path2.native_file_string() + "\": " + + system_message( sys_err_code ); + } + + } // unnamed namespace + + namespace boost + { + namespace filesystem + { + + // filesystem_error implementation -----------------------------------------// + + filesystem_error::filesystem_error( + const std::string & who, + const std::string & message ) + : std::runtime_error( + other_error_prep( who, message ).c_str() ), + m_sys_err(0), m_err(other_error), m_who(who) + {} + + filesystem_error::filesystem_error( + const std::string & who, + const path & path1, + const std::string & message ) + : std::runtime_error( + other_error_prep( who, path1, message ).c_str() ), + m_sys_err(0), m_err(other_error), m_who(who), m_path1(path1) + {} + + filesystem_error::filesystem_error( + const std::string & who, + const path & path1, + int sys_err_code ) + : std::runtime_error( + system_error_prep( who, path1, sys_err_code ).c_str() ), + m_sys_err(sys_err_code), m_err(lookup_error(sys_err_code)), + m_who(who), m_path1(path1) + {} + + filesystem_error::filesystem_error( + const std::string & who, + const path & path1, + const path & path2, + int sys_err_code ) + : std::runtime_error( + system_error_prep( who, path1, path2, sys_err_code ).c_str() ), + m_sys_err(sys_err_code), m_err(lookup_error(sys_err_code)), + m_who(who), m_path1(path1), m_path2(path2) + {} filesystem_error::~filesystem_error() throw() *************** *** 73,103 **** } ! char const* filesystem_error::what() const throw() { ! if (m_err) { ! m_msg += ": "; ! # ifdef BOOST_WINDOWS ! LPVOID lpMsgBuf; ! ::FormatMessageA( ! FORMAT_MESSAGE_ALLOCATE_BUFFER | ! FORMAT_MESSAGE_FROM_SYSTEM | ! FORMAT_MESSAGE_IGNORE_INSERTS, ! NULL, ! m_err, ! MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language ! (LPSTR) &lpMsgBuf, ! 0, ! NULL ! ); ! m_msg += static_cast<LPCSTR>(lpMsgBuf); ! LocalFree( lpMsgBuf ); // free the buffer ! # else ! m_msg += std::strerror(m_err); ! # endif ! m_err = 0; } ! return m_msg.c_str(); ! } } // namespace filesystem } // namespace boost --- 231,245 ---- } ! namespace detail { ! int system_error_code() // artifact of POSIX and WINDOWS error reporting { ! # ifdef BOOST_WINDOWS ! return ::GetLastError(); ! # else ! return errno; // GCC 3.1 won't accept ::errno ! # endif } ! } // namespace detail } // namespace filesystem } // namespace boost Index: operations_posix_windows.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/deplib/boostcvs/libs/filesystem/src/operations_posix_windows.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** operations_posix_windows.cpp 23 Oct 2002 20:22:58 -0000 1.1.1.1 --- operations_posix_windows.cpp 1 Apr 2003 08:25:50 -0000 1.2 *************** *** 14,18 **** // < ----------------------------------------------------------------------- > ! // See http://www.boost.org for most recent version including documentation. //----------------------------------------------------------------------------// --- 14,18 ---- // < ----------------------------------------------------------------------- > ! // See http://www.boost.org/libs/filesystem for documentation. //----------------------------------------------------------------------------// *************** *** 28,42 **** #include <boost/filesystem/operations.hpp> #include <boost/filesystem/exception.hpp> //#include <iostream> namespace fs = boost::filesystem; ! // BOOST_POSIX or BOOST_WINDOWS specify which API to use, not the current ! // operating system. GCC defaults to BOOST_POSIX; it doesn't predefine _WIN32. ! # if defined(BOOST_WINDOWS) || (!defined(BOOST_POSIX) && defined(_WIN32)) # include "windows.h" # else - # define BOOST_POSIX # include "sys/stat.h" # include "dirent.h" --- 28,55 ---- #include <boost/filesystem/operations.hpp> #include <boost/filesystem/exception.hpp> + #include <boost/scoped_array.hpp> + #include <boost/throw_exception.hpp> //#include <iostream> namespace fs = boost::filesystem; ! // BOOST_POSIX or BOOST_WINDOWS specify which API to use. ! # if !defined( BOOST_WINDOWS ) && !defined( BOOST_POSIX ) ! # if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__) ! # define BOOST_WINDOWS ! # else ! # define BOOST_POSIX ! # endif ! # endif ! # if defined(BOOST_WINDOWS) # include "windows.h" + + // For Windows, the xxxA form of various function names is used to avoid + // inadvertently getting wide forms of the functions. (The undecorated + // forms are actually macros, so can misfire if the user has various + // other macros defined. There was a bug report of this happening.) + # else # include "sys/stat.h" # include "dirent.h" *************** *** 76,80 **** inline const char * find_next_file( ! BOOST_HANDLE handle, BOOST_SYSTEM_DIRECTORY_TYPE & ) // Returns: if EOF 0, otherwise name // Throws: if system reports error --- 89,93 ---- inline const char * find_next_file( ! BOOST_HANDLE handle, const fs::path & ph, BOOST_SYSTEM_DIRECTORY_TYPE & ) // Returns: if EOF 0, otherwise name // Throws: if system reports error *************** *** 90,94 **** if ( errno != 0 ) { ! throw fs::filesystem_error( "directory_iterator ++() failure" ); } else { return 0; } // end reached --- 103,110 ---- if ( errno != 0 ) { ! boost::throw_exception( ! fs::filesystem_error( ! "boost::filesystem::directory_iterator::operator++", ! ph, errno ) ); } else { return 0; } // end reached *************** *** 100,104 **** # define BOOST_HANDLE HANDLE # define BOOST_INVALID_HANDLE_VALUE INVALID_HANDLE_VALUE ! # define BOOST_SYSTEM_DIRECTORY_TYPE WIN32_FIND_DATA inline const char * find_first_file( const char * dir, --- 116,120 ---- # define BOOST_HANDLE HANDLE # define BOOST_INVALID_HANDLE_VALUE INVALID_HANDLE_VALUE ! # define BOOST_SYSTEM_DIRECTORY_TYPE WIN32_FIND_DATAA inline const char * find_first_file( const char * dir, *************** *** 106,111 **** // Returns: 0 if error, otherwise name { std::string dirpath( std::string(dir) + "/*" ); ! return ( (handle = ::FindFirstFile( dirpath.c_str(), &data )) == BOOST_INVALID_HANDLE_VALUE ) ? 0 : data.cFileName; } --- 122,128 ---- // Returns: 0 if error, otherwise name { + // std::cout << "find_first_file " << dir << std::endl; std::string dirpath( std::string(dir) + "/*" ); ! return ( (handle = ::FindFirstFileA( dirpath.c_str(), &data )) == BOOST_INVALID_HANDLE_VALUE ) ? 0 : data.cFileName; } *************** *** 113,116 **** --- 130,134 ---- inline void find_close( BOOST_HANDLE handle ) { + // std::cout << "find_close" << std::endl; assert( handle != BOOST_INVALID_HANDLE_VALUE ); ::FindClose( handle ); *************** *** 118,131 **** inline const char * find_next_file( ! BOOST_HANDLE handle, BOOST_SYSTEM_DIRECTORY_TYPE & data ) // Returns: 0 if EOF, otherwise name // Throws: if system reports error { ! if ( ::FindNextFile( handle, &data ) == 0 ) { if ( ::GetLastError() != ERROR_NO_MORE_FILES ) { ! throw fs::filesystem_error( ! "directory_iterator ++() failure", fs::system_error ); } else { return 0; } // end reached --- 136,151 ---- inline const char * find_next_file( ! BOOST_HANDLE handle, const fs::path & ph, ! BOOST_SYSTEM_DIRECTORY_TYPE & data ) // Returns: 0 if EOF, otherwise name // Throws: if system reports error { ! if ( ::FindNextFileA( handle, &data ) == 0 ) { if ( ::GetLastError() != ERROR_NO_MORE_FILES ) { ! boost::throw_exception( fs::filesystem_error( ! "boost::filesystem::directory_iterator::operator++", ! ph.branch_path(), fs::detail::system_error_code() ) ); } else { return 0; } // end reached *************** *** 148,152 **** if ( fs::is_directory( ph ) ) { ! for ( boost::filesystem::directory_iterator itr( ph ); itr != end_itr; ++itr ) { --- 168,172 ---- if ( fs::is_directory( ph ) ) { ! for ( fs::directory_iterator itr( ph ); itr != end_itr; ++itr ) { *************** *** 164,190 **** namespace filesystem { - namespace detail - { - #ifdef BOOST_POSIX - const char * implementation_name() { return "POSIX"; } - #else - const char * implementation_name() { return "Windows"; } - #endif ! // directory_iterator_imp --------------------------------------------------// ! ! class directory_iterator_imp ! { ! public: ! path entry_path; ! BOOST_HANDLE handle; ! ~directory_iterator_imp() ! { ! if ( handle != BOOST_INVALID_HANDLE_VALUE ) find_close( handle ); ! } ! }; ! } // namespace detail // directory_iterator implementation ---------------------------------------// --- 184,201 ---- namespace filesystem { ! // dir_itr_imp -------------------------------------------------------------// ! class directory_iterator::dir_itr_imp ! { ! public: ! path entry_path; ! BOOST_HANDLE handle; ! ~dir_itr_imp() ! { ! if ( handle != BOOST_INVALID_HANDLE_VALUE ) find_close( handle ); ! } ! }; // directory_iterator implementation ---------------------------------------// *************** *** 195,246 **** directory_iterator::directory_iterator( const path & dir_path ) { ! base().imp.reset( new detail::directory_iterator_imp ); BOOST_SYSTEM_DIRECTORY_TYPE scratch; ! const char * name; ! if ( dir_path.is_null() ) ! base().imp->handle = BOOST_INVALID_HANDLE_VALUE; else ! name = find_first_file( dir_path.directory_path().c_str(), ! base().imp->handle, scratch ); // sets handle ! if ( base().imp->handle != BOOST_INVALID_HANDLE_VALUE ) { ! base().imp->entry_path = dir_path; ! base().imp->entry_path.m_path_append( name, path::nocheck ); ! while ( base().imp.get() ! && ( base().imp->entry_path.leaf() == "." ! || base().imp->entry_path.leaf() == ".." ) ) ! { operator++(); } } else { ! throw filesystem_error( std::string( ! "directory_iterator constructor failure: " ) ! + dir_path.directory_path().c_str(), system_error ); } } ! namespace detail { ! path const & directory_iterator_internals::deref() const { ! assert( imp.get() ); // fails if dereference end iterator ! return imp->entry_path; } ! ! void directory_iterator_internals::inc() { ! assert( imp.get() ); // fails on increment end iterator ! assert( imp->handle != BOOST_INVALID_HANDLE_VALUE ); // imp reality check ! ! BOOST_SYSTEM_DIRECTORY_TYPE scratch; ! const char * name; ! if ( (name = find_next_file( imp->handle, scratch )) != 0 ) ! { ! imp->entry_path.m_replace_leaf( name ); ! } ! else { ! imp.reset(); // make base() the end iterator ! } } } --- 206,256 ---- directory_iterator::directory_iterator( const path & dir_path ) { ! m_imp.reset( new dir_itr_imp ); BOOST_SYSTEM_DIRECTORY_TYPE scratch; ! const char * name = 0; // initialization quiets compiler warnings ! if ( dir_path.empty() ) ! m_imp->handle = BOOST_INVALID_HANDLE_VALUE; else ! name = find_first_file( dir_path.native_directory_string().c_str(), ! m_imp->handle, scratch ); // sets handle ! if ( m_imp->handle != BOOST_INVALID_HANDLE_VALUE ) { ! m_imp->entry_path = dir_path; ! m_imp->entry_path.m_path_append( name, path::nocheck ); ! while ( m_imp.get() ! && ( m_imp->entry_path.leaf() == "." ! || m_imp->entry_path.leaf() == ".." ) ) ! { operator++(); } } else { ! boost::throw_exception( filesystem_error( ! "boost::filesystem::directory_iterator constructor", ! dir_path, fs::detail::system_error_code() ) ); } } ! path const & directory_iterator::m_deref() const { ! assert( m_imp.get() ); // fails if dereference end iterator ! return m_imp->entry_path; ! } ! ! void directory_iterator::m_inc() ! { ! assert( m_imp.get() ); // fails on increment end iterator ! assert( m_imp->handle != BOOST_INVALID_HANDLE_VALUE ); // reality check ! ! BOOST_SYSTEM_DIRECTORY_TYPE scratch; ! const char * name; ! if ( (name = find_next_file( m_imp->handle, ! m_imp->entry_path, scratch )) != 0 ) { ! m_imp->entry_path.m_replace_leaf( name ); } ! else { ! m_imp.reset(); // make base() the end iterator } } *************** *** 252,258 **** # ifdef BOOST_POSIX struct stat path_stat; ! return ::stat( ph.file_path().c_str(), &path_stat ) == 0; # else ! return ::GetFileAttributes( ph.file_path().c_str() ) != 0xFFFFFFFF; # endif } --- 262,268 ---- # ifdef BOOST_POSIX struct stat path_stat; ! return ::stat( ph.string().c_str(), &path_stat ) == 0; # else ! return ::GetFileAttributesA( ph.string().c_str() ) != 0xFFFFFFFF; # endif } *************** *** 262,274 **** # ifdef BOOST_POSIX struct stat path_stat; ! if ( ::stat( ph.directory_path().c_str(), &path_stat ) != 0 ) ! throw filesystem_error( std::string("is_directory(): ") ! + ph.directory_path().c_str(), system_error ); return S_ISDIR( path_stat.st_mode ); # else ! DWORD attributes = ::GetFileAttributes( ph.directory_path().c_str() ); if ( attributes == 0xFFFFFFFF ) ! throw filesystem_error( std::string("is_directory(): ") ! + ph.directory_path().c_str(), system_error ); return (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0; # endif --- 272,286 ---- # ifdef BOOST_POSIX struct stat path_stat; ! if ( ::stat( ph.native_directory_string().c_str(), &path_stat ) != 0 ) ! boost::throw_exception( filesystem_error( ! "boost::filesystem::is_directory", ! ph, fs::detail::system_error_code() ) ); return S_ISDIR( path_stat.st_mode ); # else ! DWORD attributes = ::GetFileAttributesA( ph.native_directory_string().c_str() ); if ( attributes == 0xFFFFFFFF ) ! boost::throw_exception( filesystem_error( ! "boost::filesystem::is_directory", ! ph, fs::detail::system_error_code() ) ); return (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0; # endif *************** *** 279,285 **** # ifdef BOOST_POSIX struct stat path_stat; ! if ( ::stat( ph.file_path().c_str(), &path_stat ) != 0 ) ! throw filesystem_error( std::string("is_empty(): ") ! + ph.file_path().c_str(), system_error ); return S_ISDIR( path_stat.st_mode ) --- 291,298 ---- # ifdef BOOST_POSIX struct stat path_stat; ! if ( ::stat( ph.string().c_str(), &path_stat ) != 0 ) ! boost::throw_exception( filesystem_error( ! "boost::filesystem::is_empty", ! ph, fs::detail::system_error_code() ) ); return S_ISDIR( path_stat.st_mode ) *************** *** 288,295 **** # else WIN32_FILE_ATTRIBUTE_DATA fad; ! if ( !::GetFileAttributesEx( ph.file_path().c_str(), ::GetFileExInfoStandard, &fad ) ) ! throw filesystem_error( std::string("is_empty(): ") ! + ph.file_path().c_str(), system_error ); return ( fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) --- 301,309 ---- # else WIN32_FILE_ATTRIBUTE_DATA fad; ! if ( !::GetFileAttributesExA( ph.string().c_str(), ::GetFileExInfoStandard, &fad ) ) ! boost::throw_exception( filesystem_error( ! "boost::filesystem::is_empty", ! ph, fs::detail::system_error_code() ) ); return ( fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) *************** *** 302,339 **** { # ifdef BOOST_POSIX ! if ( ::mkdir( dir_path.directory_path().c_str(), S_IRWXU|S_IRWXG|S_IRWXO ) != 0 ) # else ! if ( !::CreateDirectory( dir_path.directory_path().c_str(), 0 ) ) # endif ! throw filesystem_error( std::string("create_directory(): ") ! + dir_path.directory_path().c_str(), system_error ); } ! void remove( const path & ph ) { if ( exists( ph ) ) { - if ( is_directory( ph ) ) - { # ifdef BOOST_POSIX ! if ( ::rmdir( ph.file_path().c_str() ) != 0 ) # else ! if ( !::RemoveDirectory( ph.file_path().c_str() ) ) ! # endif ! throw fs::filesystem_error( std::string("remove() on: ") ! + ph.file_path().c_str(), system_error ); } else { ! # ifdef BOOST_POSIX ! if ( ::remove( ph.file_path().c_str() ) != 0 ) ! # else ! if ( !::DeleteFile( ph.file_path().c_str() ) ) # endif ! throw fs::filesystem_error( std::string("remove() on: ") ! + ph.file_path().c_str(), system_error ); } } } --- 316,355 ---- { # ifdef BOOST_POSIX ! if ( ::mkdir( dir_path.native_directory_string().c_str(), S_IRWXU|S_IRWXG|S_IRWXO ) != 0 ) # else ! if ( !::CreateDirectoryA( dir_path.native_directory_string().c_str(), 0 ) ) # endif ! boost::throw_exception( filesystem_error( ! "boost::filesystem::create_directory", ! dir_path, fs::detail::system_error_code() ) ); } ! bool remove( const path & ph ) { if ( exists( ph ) ) { # ifdef BOOST_POSIX ! if ( ::remove( ph.string().c_str() ) != 0 ) ! { # else ! if ( is_directory( ph ) ) ! { ! if ( !::RemoveDirectoryA( ph.string().c_str() ) ) ! boost::throw_exception( filesystem_error( ! "boost::filesystem::remove", ! ph, fs::detail::system_error_code() ) ); } else { ! if ( !::DeleteFileA( ph.string().c_str() ) ) # endif ! boost::throw_exception( filesystem_error( ! "boost::filesystem::remove", ! ph, fs::detail::system_error_code() ) ); } + return true; } + return false; } *************** *** 348,357 **** # ifdef BOOST_POSIX if ( exists( new_path ) // POSIX is too permissive so must check ! || ::rename( old_path.file_path().c_str(), new_path.file_path().c_str() ) != 0 ) # else ! if ( !::MoveFile( old_path.file_path().c_str(), new_path.file_path().c_str() ) ) # endif ! throw filesystem_error( std::string("move_file(): ") ! + old_path.file_path().c_str() + ", " + new_path.file_path().c_str(), system_error ); } --- 364,374 ---- # ifdef BOOST_POSIX if ( exists( new_path ) // POSIX is too permissive so must check ! || ::rename( old_path.string().c_str(), new_path.string().c_str() ) != 0 ) # else ! if ( !::MoveFileA( old_path.string().c_str(), new_path.string().c_str() ) ) # endif ! boost::throw_exception( filesystem_error( ! "boost::filesystem::rename", ! old_path, new_path, fs::detail::system_error_code() ) ); } *************** *** 364,379 **** const std::size_t buf_sz = 32768; boost::scoped_array<char> buf( new char [buf_sz] ); ! int infile, outfile; ! if ( (infile = ::open( from_file_ph.file_path().c_str(), O_RDONLY )) < 0 ! || (outfile = ::open( to_file_ph.file_path().c_str(), O_WRONLY | O_CREAT | O_EXCL, S_IRWXU|S_IRWXG|S_IRWXO )) < 0 ) { if ( infile != 0 ) ::close( infile ); ! throw fs::filesystem_error( std::string("copy() files: ") ! + from_file_ph.file_path().c_str() ! + ", " + to_file_ph.file_path().c_str(), system_error ); } --- 381,396 ---- const std::size_t buf_sz = 32768; boost::scoped_array<char> buf( new char [buf_sz] ); ! int infile, outfile=0; // init quiets compiler warning ! if ( (infile = ::open( from_file_ph.string().c_str(), O_RDONLY )) < 0 ! || (outfile = ::open( to_file_ph.string().c_str(), O_WRONLY | O_CREAT | O_EXCL, S_IRWXU|S_IRWXG|S_IRWXO )) < 0 ) { if ( infile != 0 ) ::close( infile ); ! boost::throw_exception( filesystem_error( ! "boost::filesystem::copy_file", ! from_file_ph, to_file_ph, fs::detail::system_error_code() ) ); } *************** *** 387,423 **** if ( sz != 0 ) # else ! if ( !::CopyFile( from_file_ph.file_path().c_str(), ! to_file_ph.file_path().c_str(), /*fail_if_exists=*/true ) ) # endif ! throw fs::filesystem_error( std::string("copy() files: ") ! + from_file_ph.file_path().c_str() ! + ", " + to_file_ph.file_path().c_str(), system_error ); } ! const path & initial_directory() { ! static path init_dir; ! if ( init_dir.is_null() ) ! { ! # ifdef BOOST_POSIX ! long path_max = ::pathconf( ".", _PC_PATH_MAX ); ! if ( path_max == -1 ) ! throw filesystem_error( "initial_directory()" ); ! boost::scoped_array<char> ! buf( new char[static_cast<std::size_t>(path_max)] ); ! if ( ::getcwd( buf.get(), static_cast<std::size_t>(path_max) ) == 0 ) ! # else ! DWORD sz; ! if ( (sz = ::GetCurrentDirectory( 0, static_cast<char*>(0) )) == 0 ) ! throw filesystem_error( "initial_directory()" ); ! boost::scoped_array<char> buf( new char[sz] ); ! if ( ::GetCurrentDirectory( sz, buf.get() ) == 0 ) ! # endif ! { throw filesystem_error( "initial_directory()", system_error ); } ! init_dir = path( buf.get(), system_specific ); ! } ! return init_dir; } } // namespace filesystem } // namespace boost --- 404,483 ---- if ( sz != 0 ) # else ! if ( !::CopyFileA( from_file_ph.string().c_str(), ! to_file_ph.string().c_str(), /*fail_if_exists=*/true ) ) # endif ! boost::throw_exception( filesystem_error( ! "boost::filesystem::copy_file", ! from_file_ph, to_file_ph, fs::detail::system_error_code() ) ); } ! path current_path() { ! # ifdef BOOST_POSIX ! long path_max = ::pathconf( ".", _PC_PATH_MAX ); ! if ( path_max < 1 ) ! boost::throw_exception( ! filesystem_error( "boost::filesystem::current_path", ! "_PC_PATH_MAX < 1" ) ); ! boost::scoped_array<char> ! buf( new char[static_cast<std::size_t>(path_max)] ); ! if ( ::getcwd( buf.get(), static_cast<std::size_t>(path_max) ) == 0 ) ! # else ! DWORD sz; ! if ( (sz = ::GetCurrentDirectoryA( 0, static_cast<char*>(0) )) == 0 ) ! boost::throw_exception( ! filesystem_error( "boost::filesystem::current_path", ! "size is 0" ) ); ! boost::scoped_array<char> buf( new char[sz] ); ! if ( ::GetCurrentDirectoryA( sz, buf.get() ) == 0 ) ! # endif ! boost::throw_exception( ! filesystem_error( "boost::filesystem::current_path", path(), ! fs::detail::system_error_code() ) ); ! return path( buf.get(), native ); } + const path & initial_path() + { + static path init_path; + if ( init_path.empty() ) init_path = current_path(); + return init_path; + } + + path system_complete( const path & ph ) + { + # ifdef BOOST_WINDOWS + if ( ph.empty() ) return ph; + char buf[MAX_PATH]; + char * pfn; + std::size_t len = ::GetFullPathNameA( ph.string().c_str(), + sizeof(buf) , buf, &pfn ); + if ( !len ) + { boost::throw_exception( + filesystem_error( "boost::filesystem::system_complete", + ph, "size is 0" ) ); } + buf[len] = '\0'; + return path( buf, native ); + # else + return (ph.empty() || ph.is_complete()) + ? ph : current_path() / ph; + # endif + } + + path complete( const path & ph, const path & base ) + { + assert( base.is_complete() + && (ph.is_complete() || !ph.has_root_name()) ); // precondition + # ifdef BOOST_WINDOWS + if (ph.empty() || ph.is_complete()) return ph; + if ( !ph.has_root_name() ) + return ph.has_root_directory() + ? path( base.root_name(), native ) / ph + : base / ph; + return base / ph; + # else + return (ph.empty() || ph.is_complete()) ? ph : base / ph; + # endif + } } // namespace filesystem } // namespace boost Index: path_posix_windows.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/deplib/boostcvs/libs/filesystem/src/path_posix_windows.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** path_posix_windows.cpp 23 Oct 2002 20:22:58 -0000 1.1.1.1 --- path_posix_windows.cpp 1 Apr 2003 08:25:51 -0000 1.2 *************** *** 7,11 **** // suitability for any purpose. ! // See http://www.boost.org for most recent version including documentation. --- 7,11 ---- // suitability for any purpose. ! // See http://www.boost.org/libs/filesystem for documentation. *************** *** 20,28 **** //****************************************************************************// ! // BOOST_POSIX or BOOST_WINDOWS specify which API to use, not the current ! // operating system. GCC defaults to BOOST_POSIX; it doesn't predefine _WIN32. ! # if !defined( BOOST_WINDOWS ) && !defined( BOOST_POSIX ) ! # if defined(_WIN32) # define BOOST_WINDOWS # else --- 20,26 ---- //****************************************************************************// ! // BOOST_POSIX or BOOST_WINDOWS specify which API to use. # if !defined( BOOST_WINDOWS ) && !defined( BOOST_POSIX ) ! # if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__) # define BOOST_WINDOWS # else *************** *** 41,44 **** --- 39,44 ---- #endif + #include <boost/throw_exception.hpp> + #include <cstring> // SGI MIPSpro compilers need this #include <vector> #include <cassert> *************** *** 50,54 **** // POSIX & Windows cases: "", "/", "/foo", "foo", "foo/bar" // Windows only cases: "c:", "c:/", "c:foo", "c:/foo", ! // "prn:", "//share", "//share/foo" std::string::size_type leaf_pos( const std::string & str, --- 50,54 ---- // POSIX & Windows cases: "", "/", "/foo", "foo", "foo/bar" // Windows only cases: "c:", "c:/", "c:foo", "c:/foo", ! // "prn:", "//share", "//share/", "//share/foo" std::string::size_type leaf_pos( const std::string & str, *************** *** 56,69 **** // return 0 if str itself is leaf (or empty) { ! if ( (end_pos == 1 && str[0] == '/') ! # ifdef BOOST_WINDOWS ! || (end_pos > 1 // drive or device ! && (str[end_pos-1] == ':' || str[end_pos-2] == ':')) ! # endif ! ) return 0; ! std::string::size_type pos( str.find_last_of( '/', end_pos-1 ) ); # ifdef BOOST_WINDOWS ! if ( pos == std::string::npos ) pos = str.find_last_of( ':', end_pos-1 ); # endif --- 56,64 ---- // return 0 if str itself is leaf (or empty) { ! if ( end_pos && str[end_pos-1] == '/' ) return end_pos-1; ! std::string::size_type pos( str.find_last_of( '/', end_pos-1 ) ); # ifdef BOOST_WINDOWS ! if ( pos == std::string::npos ) pos = str.find_last_of( ':', end_pos-2 ); # endif *************** *** 99,104 **** { target += *itr++; - if ( itr == src.end() ) return; - if ( *itr == '/' ) { target += *itr++; } return; } --- 94,97 ---- *************** *** 137,141 **** // error checking functions --------------------------------------------// - bool generic_name( const std::string & name ) { --- 130,133 ---- *************** *** 157,162 **** { if ( !posix_name( ph.leaf() ) ) ! throw filesystem_error( "invalid posix name: \"" ! + ph.leaf() + "\"" ); return ph; } --- 149,156 ---- { if ( !posix_name( ph.leaf() ) ) ! boost::throw_exception( filesystem_error( ! "boost::filesystem::check_posix_leaf", ! ph, "invalid posix name: \"" ! + ph.leaf() + "\"" ) ); return ph; } *************** *** 175,179 **** } ! // path implementation -------------------------------------------------// path::path( const std::string & src ) --- 169,173 ---- } ! // path implementation -----------------------------------------------------// path::path( const std::string & src ) *************** *** 197,201 **** } ! path & path::operator <<=( const path & rhs ) { m_path_append( rhs.m_path, nocheck ); --- 191,195 ---- } ! path & path::operator /=( const path & rhs ) { m_path_append( rhs.m_path, nocheck ); *************** *** 215,243 **** std::string::const_iterator itr( src.begin() ); ! // system-specific-root like drive: or first slash of //share ! if ( context != generic ) { ! if ( *itr == '/' # ifdef BOOST_WINDOWS || (*itr == '\\' && context == platform) # endif ! ) { ++itr; m_path += '/'; } ! else if ( itr+1 != src.end() && *(itr+1) == ':' ) ! { m_path += *itr++; m_path += *itr++; } ! ! # ifdef BOOST_WINDOWS ! // "/" or second slash of //share ! if ( *itr == '/' || (*itr == '\\' && context == platform) ) ! { ++itr; m_path += '/';} ! # endif ! ! if ( itr == src.end() ) return; } ! // relative-path ::= element { "/" element } while ( itr != src.end() ) { // append '/' if needed ! if ( !is_null() // append '/' && *(m_path.end()-1) != ':' && *(m_path.end()-1) != '/' ) m_path += '/'; --- 209,263 ---- std::string::const_iterator itr( src.begin() ); ! // [root-filesystem] ! # ifdef BOOST_WINDOWS ! if ( context != generic && src.size() >= 2 ) { ! // drive or device ! if ( src[1] == ':' || src[src.size()-1] == ':' ) ! { ! for ( ; *itr != ':'; ++itr ) m_path += *itr; ! m_path += ':'; ! ++itr; ! } ! ! // share ! else if ( (*itr == '/' || (*itr == '\\' && context == platform)) ! && (*(itr+1) == '/' || (*(itr+1) == '\\' && context == platform)) ) ! { ! m_path += "//"; ! for ( itr += 2; ! itr != src.end() && *itr != '/' && *itr != '\\'; ! ++itr ) m_path += *itr; ! } ! } ! # endif ! ! // root directory [ "/" ] ! if ( itr != src.end() && (*itr == '/' # ifdef BOOST_WINDOWS || (*itr == '\\' && context == platform) # endif ! ) ) ! { ! ++itr; ! if ( m_path.size() == 0 ! # ifdef BOOST_WINDOWS ! || m_path[m_path.size()-1] == ':' // drive or device ! || ( // share ! m_path.size() > 2 ! && m_path[0] == '/' ! && m_path[1] == '/' ! && m_path.find( '/', 2 ) == std::string::npos ! ) ! # endif ! ) m_path += '/'; } ! // element { "/" element } [ "/" ] while ( itr != src.end() ) { + // append '/' if needed ! if ( !empty() && *(m_path.end()-1) != ':' && *(m_path.end()-1) != '/' ) m_path += '/'; *************** *** 278,282 **** ++itr; } // ".." ! else // name { std::string name; --- 298,302 ---- ++itr; } // ".." ! else // element is name { std::string name; *************** *** 291,296 **** if ( context == generic && !generic_name( name ) ) { ! throw filesystem_error( "invalid path name: \"" ! + src + "\"" ); } --- 311,317 ---- if ( context == generic && !generic_name( name ) ) { ! boost::throw_exception( filesystem_error( ! "boost::filesystem::path", ! "invalid name \"" + name + "\" in path: \"" + src + "\"" ) ); } *************** *** 299,313 **** if ( itr != src.end() ) ! { ! if ( !( (*itr == '/' ! # ifdef BOOST_WINDOWS ! || (context == platform && *itr == '\\') ! # endif ! ) && (itr+1) != src.end() ) ) ! { ! throw filesystem_error( "invalid path syntax: \"" ! + src + "\"" ); ! } ! ++itr; } --- 320,333 ---- if ( itr != src.end() ) ! { ! if ( *itr == '/' ! # ifdef BOOST_WINDOWS ! || (*itr == '\\' && context == platform) ! # endif ! ) ++itr; ! else ! boost::throw_exception( filesystem_error( ! "boost::filesystem::path", ! "invalid path syntax: \"" + src + "\"" ) ); } *************** *** 315,319 **** } ! const path::iterator path::begin() const { iterator itr; --- 335,359 ---- } ! // path conversion functions ------------------------------------------------// ! ! std::string path::native_file_string() const ! { ! # ifdef BOOST_WINDOWS ! std::string s( m_path ); ! for ( std::string::iterator itr( s.begin() ); ! itr != s.end(); ++itr ) ! if ( *itr == '/' ) *itr = '\\'; ! return s; ! # else ! return m_path; ! # endif ! } ! ! std::string path::native_directory_string() const ! { return native_file_string(); } ! ! // path decomposition functions ---------------------------------------------// ! ! path::iterator path::begin() const { iterator itr; *************** *** 330,362 **** } ! const std::string path::leaf() const { return m_path.substr( leaf_pos( m_path, m_path.size() ) ); } ! const path path::branch() const { ! std::string::size_type len( leaf_pos( m_path, m_path.size() ) ); ! ! if ( len > 1 // unless delimiter is part of root, don't include it # ifdef BOOST_WINDOWS ! && m_path[len-1] != ':' ! && m_path[len-2] != ':' # endif ! ) --len; ! return path( m_path.substr( 0, len ), system_specific ); } ! //bool path::is_absolute() const ! //{ ! // return ( m_path.size() ! // && m_path[0] == '/' ) // covers both "/" and "//share" ! // || ( m_path.size() > 2 ! // && m_path[1] == ':' ! // && m_path[2] == '/' ) // "c:/" ! // || ( m_path.size() > 3 ! // && m_path[m_path.size()-1] == ':' ); // "device:" ! //} namespace detail --- 370,524 ---- } ! std::string path::leaf() const { return m_path.substr( leaf_pos( m_path, m_path.size() ) ); } ! namespace detail { ! inline bool is_absolute_root( const std::string & s, ! std::string::size_type len ) ! { ! return ! len && s[len-1] == '/' ! && ! ( ! len == 1 // "/" ! # ifdef BOOST_WINDOWS ! || ( len > 1 ! && ( s[len-2] == ':' // drive or device ! || ( s[0] == '/' // share ! && s[1] == '/' ! && s.find( '/', 2 ) == len-1 ! ) ! ) ! ) ! # endif ! ); ! } ! } ! ! path path::branch_path() const ! { ! std::string::size_type end_pos( leaf_pos( m_path, m_path.size() ) ); ! ! // skip a '/' unless it is a root directory ! if ( end_pos && m_path[end_pos-1] == '/' ! && !detail::is_absolute_root( m_path, end_pos ) ) --end_pos; ! return path( m_path.substr( 0, end_pos ), native ); ! } ! ! path path::relative_path() const ! { ! std::string::size_type pos( 0 ); ! if ( m_path.size() && m_path[0] == '/' ) ! { pos = 1; # ifdef BOOST_WINDOWS ! if ( m_path.size()>1 && m_path[1] == '/' ) // share ! { ! if ( (pos = m_path.find( '/', 2 )) != std::string::npos ) ++pos; ! else return path(); ! } ! } ! else if ( (pos = m_path.find( ':' )) == std::string::npos ) pos = 0; ! else // has ':' ! { ! if ( ++pos < m_path.size() && m_path[pos] == '/' ) ++pos; # endif ! } ! return path( m_path.substr( pos ) ); ! } ! std::string path::root_name() const ! { ! # ifdef BOOST_WINDOWS ! std::string::size_type pos( m_path.find( ':' ) ); ! if ( pos != std::string::npos ) return m_path.substr( 0, pos+1 ); ! if ( m_path.size() > 2 && m_path[0] == '/' && m_path[1] == '/' ) ! { ! pos = m_path.find( '/', 2 ); ! return m_path.substr( 0, pos ); ! } ! # endif ! return std::string(); } ! std::string path::root_directory() const ! { ! return std::string( ! ( m_path.size() && m_path[0] == '/' ) // covers both "/" and "//share" ! # ifdef BOOST_WINDOWS ! || ( m_path.size() > 2 ! && m_path[1] == ':' ! && m_path[2] == '/' ) // "c:/" ! # endif ! ? "/" : "" ); ! } ! ! path path::root_path() const ! { ! return path( ! # ifdef BOOST_WINDOWS ! root_name(), native ) /= root_directory(); ! # else ! root_directory() ); ! # endif ! } ! ! // path query functions -----------------------------------------------------// ! ! bool path::is_complete() const ! { ! # ifdef BOOST_WINDOWS ! return m_path.size() > 2 ! && ( (m_path[1] == ':' && m_path[2] == '/') // "c:/" ! || (m_path[0] == '/' && m_path[1] == '/') // "//share" ! || m_path[m_path.size()-1] == ':' ); ! # else ! return m_path.size() && m_path[0] == '/'; ! # endif ! } ! ! bool path::has_root_path() const ! { ! return ( m_path.size() ! && m_path[0] == '/' ) // covers both "/" and "//share" ! # ifdef BOOST_WINDOWS ! || ( m_path.size() > 1 && m_path[1] == ':' ) // "c:" and "c:/" ! || ( m_path.size() > 3 ! && m_path[m_path.size()-1] == ':' ) // "device:" ! # endif ! ; ! } ! ! bool path::has_root_name() const ! { ! # ifdef BOOST_WINDOWS ! return m_path.size() > 1 ! && ( m_path[1] == ':' // "c:" ! || m_path[m_path.size()-1] == ':' // "prn:" ! || (m_path[0] == '/' && m_path[1] == '/') // "//share" ! ); ! # else ! return false; ! # endif ! } ! ! bool path::has_root_directory() const ! { ! return ( m_path.size() ! && m_path[0] == '/' ) // covers both "/" and "//share" ! # ifdef BOOST_WINDOWS ! || ( m_path.size() > 2 ! && m_path[1] == ':' && m_path[2] == '/' ) // "c:/" ! # endif ! ; ! } ! ! bool path::has_relative_path() const { return !relative_path().empty(); } ! bool path::has_branch_path() const { return !branch_path().empty(); } ! ! ! // path_itr_imp implementation ----------------------------------------------// namespace detail *************** *** 371,375 **** return; } ! if ( path_ptr->m_path[pos] == '/' ) ++pos; std::string::size_type end_pos( path_ptr->m_path.find( '/', pos ) ); if ( end_pos == std::string::npos ) end_pos = path_ptr->m_path.size(); --- 533,548 ---- return; } ! if ( path_ptr->m_path[pos] == '/' ) ! { ! # ifdef BOOST_WINDOWS ! if ( name[name.size()-1] == ':' // drive or device ! || (name[0] == '/' && name[1] == '/') ) // share ! { ! name = "/"; ! return; ! } ! # endif ! ++pos; ! } std::string::size_type end_pos( path_ptr->m_path.find( '/', pos ) ); if ( end_pos == std::string::npos ) end_pos = path_ptr->m_path.size(); *************** *** 381,391 **** assert( pos ); // detect decrement of begin std::string::size_type end_pos( pos ); ! if ( end_pos != path_ptr->m_path.size() ! && end_pos > 1 ! # ifdef BOOST_WINDOWS ! && path_ptr->m_path[end_pos-1] != ':' ! && path_ptr->m_path[end_pos-2] != ':' ! # endif ! ) --end_pos; pos = leaf_pos( path_ptr->m_path, end_pos ); name = path_ptr->m_path.substr( pos, end_pos - pos ); --- 554,561 ---- assert( pos ); // detect decrement of begin std::string::size_type end_pos( pos ); ! ! // skip a '/' unless it is a root directory ! if ( path_ptr->m_path[end_pos-1] == '/' ! && !detail::is_absolute_root( path_ptr->m_path, end_pos ) ) --end_pos; pos = leaf_pos( path_ptr->m_path, end_pos ); name = path_ptr->m_path.substr( pos, end_pos - pos ); |