From: Christian P. <cp...@us...> - 2004-12-27 07:04:57
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10557/src/System Modified Files: Directory.posix.cpp Log Message: Moved to std::list, fixed change(), current(), create() and remove(). Index: Directory.posix.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/Directory.posix.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Directory.posix.cpp 24 Dec 2004 16:50:49 -0000 1.1 +++ Directory.posix.cpp 27 Dec 2004 07:04:49 -0000 1.2 @@ -29,21 +29,11 @@ namespace P { namespace System { - + Directory::Directory(const Unicode::String& path) throw(IO::IOError) : _path(path) { - /*@fixme DIR* d = opendir(_path.utf8()); - if(!d) - throw IOError(errno, "Could not open directory", P_SOURCEINFO); - - _handle = (unsigned long)d;*/ -} - -Directory::Directory(const std::string& path) throw(IO::IOError) -: _path(path.c_str()) -{ - DIR* d = opendir(path.c_str()); + DIR* d = opendir(path.utf8().c_str()); if(!d) throw IO::IOError(errno, "Could not open directory", P_SOURCEINFO); @@ -67,7 +57,7 @@ struct dirent* de; while((de = readdir((DIR*)_handle))) - _entries.append(Unicode::String(de->d_name)); + _entries.push_back(Unicode::String(de->d_name)); } Directory::Iterator Directory::begin() const @@ -92,23 +82,22 @@ void Directory::change(const Unicode::String& path) throw(IO::IOError) { - /*@fixme if(chdir(path.utf8()) == -1) - throw IO::IOError(errno, "Could not change working directory", P_SOURCEINFO);*/ + if(chdir(path.utf8().c_str()) == -1) + throw IO::IOError(errno, "Could not change working directory", P_SOURCEINFO); } void Directory::create(const Unicode::String& path) throw(IO::IOError) { - /*@fixme if(mkdir(path.utf8(), 0777) == -1) - throw IO::IOError(errno, "Could not change working directory", P_SOURCEINFO); */ + if(mkdir(path.utf8().c_str(), 0777) == -1) + throw IO::IOError(errno, "Could not change working directory", P_SOURCEINFO); } void Directory::remove(const Unicode::String& path) throw(IO::IOError) { - /*@fixme if(rmdir(path.utf8()) == -1) - throw IO::IOError(errno, "Could not remove directory", P_SOURCEINFO); */ + if(rmdir(path.utf8().c_str()) == -1) + throw IO::IOError(errno, "Could not remove directory", P_SOURCEINFO); } - } // !namespace System } // !namespace P |