From: Christian P. <cp...@us...> - 2005-06-16 13:07:24
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26832/src/System Modified Files: Path.posix.cpp Log Message: - Added some trace messages Index: Path.posix.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/Path.posix.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Path.posix.cpp 7 May 2005 13:20:38 -0000 1.1 +++ Path.posix.cpp 16 Jun 2005 13:07:16 -0000 1.2 @@ -18,6 +18,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include "pclasses/Trace.h" #include "pclasses/System/Path.h" #include <errno.h> @@ -36,6 +37,8 @@ _path = path.substr(0,path.size()-1); else _path = path; + + P_TRACE(Path) << " Path('" << path << "') -> '" << _path << "'"; } Path::~Path() @@ -47,20 +50,30 @@ Unicode::String::size_type slashat = _path.find_last_of(separator()); + Unicode::String ret; + if(slashat == Unicode::String::npos || slashat == 0) - return _path; + ret = _path; + else + ret = _path.substr(0, slashat); - return _path.substr(0, slashat); + P_TRACE(Path) << "dirName() = '" << ret << "'"; + return ret; } Unicode::String Path::absDirName() const throw(SystemError) { char* absDirName = realpath(dirName().utf8().c_str(), 0); if(!absDirName) + { + P_TRACE(Path) << "absDirName() -> error=" << errno; throw SystemError(errno, "Could not resolve real path", P_SOURCEINFO); + } Unicode::String res = Unicode::String::fromUtf8(absDirName); free(absDirName); + + P_TRACE(Path) << "absDirName() = '" << res << "'"; return res; } @@ -69,10 +82,15 @@ Unicode::String::size_type slashat = _path.find_last_of(separator()); + Unicode::String ret; + if(slashat == Unicode::String::npos) - return _path; + ret = _path; + else + ret = _path.substr(slashat + 1); - return _path.substr(slashat + 1); + P_TRACE(Path) << "baseName() = '" << ret << "'"; + return ret; } Unicode::String Path::path() const throw() @@ -84,10 +102,15 @@ { char* absPath = realpath(_path.utf8().c_str(), 0); if(!absPath) + { + P_TRACE(Path) << "absPath() -> error=" << errno; throw SystemError(errno, "Could not resolve real path", P_SOURCEINFO); + } Unicode::String res = Unicode::String::fromUtf8(absPath); free(absPath); + + P_TRACE(Path) << "absPath() = '" << res << "'"; return res; } |