From: Christian P. <cp...@us...> - 2005-06-07 12:15:57
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28530/src/System Modified Files: Directory.posix.cpp Directory.win32.cpp Log Message: - Changed Directory::_handle from "unsigned long" to "void*" Index: Directory.posix.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/Directory.posix.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Directory.posix.cpp 27 May 2005 15:28:34 -0000 1.4 +++ Directory.posix.cpp 7 Jun 2005 12:15:45 -0000 1.5 @@ -37,7 +37,7 @@ if(!d) throw IO::IOError(errno, "Could not open directory", P_SOURCEINFO); - _handle = (unsigned long)d; + _handle = (void*)d; reload(); } Index: Directory.win32.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/Directory.win32.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Directory.win32.cpp 24 Jan 2005 09:57:28 -0000 1.1 +++ Directory.win32.cpp 7 Jun 2005 12:15:46 -0000 1.2 @@ -26,14 +26,14 @@ namespace System { Directory::Directory(const Unicode::String& path) throw(IO::IOError) -: _path(path), _handle(INVALID_HANDLE_VALUE) +: _path(path), _handle((void*)INVALID_HANDLE_VALUE) { reload(); } Directory::~Directory() throw() { - if(_handle != INVALID_HANDLE_VALUE) + if(_handle != (void*)INVALID_HANDLE_VALUE) FindClose((HANDLE)_handle); } @@ -82,25 +82,16 @@ Unicode::String Directory::current() throw(IO::IOError) { - size_t cwdSize = PATH_MAX; - char* cwd = new char[PATH_MAX]; + DWORD reqdSize = GetCurrentDirectory(0, 0); + char* cwd = new char[reqdSize + 1]; -getCurrentDirectory: - DWORD ret = GetCurrentDirectory(cwdSize, cwd); - if(ret == 0) - { - if(ret > cwdSize) - { - delete[] cwd; - cwdSize += cwdSize; - cwd = new char[cwdSize]; - goto getCurrentDirectory; - } - - throw IO::IOError(errno, "Could not get current working directroy", P_SOURCEINFO); - } + DWORD cwdRet = GetCurrentDirectory(cwdSize, cwd); + if(cwdRet == 0) + throw IO::IOError(GetLastError(), "Could not get current working directroy", P_SOURCEINFO); - return Unicode::String(cwd); + Unicode::String retStr(cwd); + delete[] cwd; + return retStr; } void Directory::change(const Unicode::String& path) throw(IO::IOError) |