[Cpptool-cvs] rfta/deplib/boostcvs/libs/filesystem/src convenience.cpp,1.1,1.2 exception.cpp,1.2,1.3
From: <bl...@us...> - 2003-05-10 15:17:35
|
Update of /cvsroot/cpptool/rfta/deplib/boostcvs/libs/filesystem/src In directory sc8-pr-cvs1:/tmp/cvs-serv22050/libs/filesystem/src Modified Files: convenience.cpp exception.cpp Log Message: * updated to the current boost cvs (2003/05/10) Index: convenience.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/deplib/boostcvs/libs/filesystem/src/convenience.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** convenience.cpp 5 Apr 2003 11:23:23 -0000 1.1 --- convenience.cpp 10 May 2003 15:17:32 -0000 1.2 *************** *** 29,32 **** --- 29,57 ---- } + std::string extension(const path& ph) + { + std::string leaf = ph.leaf(); + + std::string::size_type n = leaf.rfind('.'); + if (n != std::string::npos) + return leaf.substr(n); + else + return std::string(); + } + + std::string basename(const path& ph) + { + std::string leaf = ph.leaf(); + + std::string::size_type n = leaf.rfind('.'); + return leaf.substr(0, n); + } + + path change_extension(const path& ph, const std::string& new_extension) + { + return ph.branch_path() / (basename(ph) + new_extension); + } + + } // namespace filesystem } // namespace boost Index: exception.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/deplib/boostcvs/libs/filesystem/src/exception.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** exception.cpp 1 Apr 2003 08:25:50 -0000 1.2 --- exception.cpp 10 May 2003 15:17:32 -0000 1.3 *************** *** 180,183 **** --- 180,186 ---- } + const fs::path empty_path; + const std::string empty_string; + const char * no_context_msg = "filesystem_error"; } // unnamed namespace *************** *** 186,189 **** --- 189,204 ---- namespace filesystem { + // filesystem_error m_imp class --------------------------------------------// + // see www.boost.org/more/error_handling.html for implemenation rationale + + class filesystem_error::m_imp + { + public: + std::string m_who; + path m_path1; + path m_path2; + std::string m_what; + }; + // filesystem_error implementation -----------------------------------------// *************** *** 192,199 **** 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( --- 207,220 ---- const std::string & who, const std::string & message ) ! : m_sys_err(0), m_err(other_error) ! { ! try ! { ! m_imp_ptr.reset( new m_imp ); ! m_imp_ptr->m_who = who; ! m_imp_ptr->m_what = other_error_prep( who, message ); ! } ! catch (...) { m_imp_ptr.reset(); } ! } filesystem_error::filesystem_error( *************** *** 201,208 **** 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( --- 222,236 ---- const path & path1, const std::string & message ) ! : m_sys_err(0), m_err(other_error) ! { ! try ! { ! m_imp_ptr.reset( new m_imp ); ! m_imp_ptr->m_who = who; ! m_imp_ptr->m_what = other_error_prep( who, path1, message ); ! m_imp_ptr->m_path1 = path1; ! } ! catch (...) { m_imp_ptr.reset(); } ! } filesystem_error::filesystem_error( *************** *** 210,218 **** 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( --- 238,252 ---- const path & path1, int sys_err_code ) ! : m_sys_err(sys_err_code), m_err(lookup_error(sys_err_code)) ! { ! try ! { ! m_imp_ptr.reset( new m_imp ); ! m_imp_ptr->m_who = who; ! m_imp_ptr->m_what = system_error_prep( who, path1, sys_err_code ); ! m_imp_ptr->m_path1 = path1; ! } ! catch (...) { m_imp_ptr.reset(); } ! } filesystem_error::filesystem_error( *************** *** 221,232 **** 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() { } --- 255,294 ---- const path & path2, int sys_err_code ) ! : m_sys_err(sys_err_code), m_err(lookup_error(sys_err_code)) ! { ! try ! { ! m_imp_ptr.reset( new m_imp ); ! m_imp_ptr->m_who = who; ! m_imp_ptr->m_what = system_error_prep( who, path1, path2, sys_err_code ); ! m_imp_ptr->m_path1 = path1; ! m_imp_ptr->m_path2 = path2; ! } ! catch (...) { m_imp_ptr.reset(); } ! } filesystem_error::~filesystem_error() throw() { + } + + const std::string & filesystem_error::who() const + { + return m_imp_ptr.get() == 0 ? empty_string : m_imp_ptr->m_who; + } + + const path & filesystem_error::path1() const + { + return m_imp_ptr.get() == 0 ? empty_path : m_imp_ptr->m_path1; + } + + const path & filesystem_error::path2() const + { + return m_imp_ptr.get() == 0 ? empty_path : m_imp_ptr->m_path2; + } + + const char * filesystem_error::what() const throw() + { + return m_imp_ptr.get() == 0 ? empty_string.c_str() + : m_imp_ptr->m_what.c_str(); } |