From: Christian P. <cp...@us...> - 2005-06-07 12:01:35
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21523/src/System Modified Files: CdRomDevice.linux.cpp File.common.cpp File.win32.cpp IOHandle.h IOHandle.posix.cpp Pipe.common.cpp Pipe.posix.cpp Process.common.cpp Process.posix.cpp StorageDevice.common.cpp Log Message: - Changed "unsigned long _handle" in I/O classes to "IOHandle* _handld" - Changed "unsigned long _handle" in Process class to "void* _handle" Index: File.common.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/File.common.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- File.common.cpp 30 Jan 2005 17:07:03 -0000 1.1 +++ File.common.cpp 7 Jun 2005 12:01:19 -0000 1.2 @@ -36,8 +36,7 @@ { if(f.valid()) { - IOHandle* h = new IOHandle(f.handle(), false); - _handle = (unsigned long)h; + _handle = new IOHandle(f.handle()->handle(), false); } } @@ -62,9 +61,8 @@ if(valid()) close(); - IOHandle* h = new IOHandle(name, amode, omode, smode); + _handle = new IOHandle(name, amode, omode, smode); - _handle = (unsigned long)h; IODevice::setAccess(amode); IODevice::setValid(true); IODevice::setEof(false); @@ -72,9 +70,8 @@ void File::_close() throw(IO::IOError) { - IOHandle* h = (IOHandle*)_handle; - h->close(); - delete h; + _handle->close(); + delete _handle; _handle = 0; IODevice::setAccess(None); @@ -83,8 +80,7 @@ size_t File::_read(char* buffer, size_t count) throw(IO::IOError) { - IOHandle* h = (IOHandle*)_handle; - size_t ret = h->read(buffer, count); + size_t ret = _handle->read(buffer, count); if(ret == 0 && !eof()) setEof(true); @@ -93,46 +89,39 @@ size_t File::_peek(char* buffer, size_t count) throw(IO::IOError) { - IOHandle* h = (IOHandle*)_handle; - return h->peek(buffer, count); + return _handle->peek(buffer, count); } size_t File::_write(const char* buffer, size_t count) throw(IO::IOError) { - IOHandle* h = (IOHandle*)_handle; - return h->write(buffer, count); + return _handle->write(buffer, count); } offset_t File::_seek(offset_t offset, SeekMode mode) throw(IO::IOError) { - IOHandle* h = (IOHandle*)_handle; - return h->seek(offset, mode); + return _handle->seek(offset, mode); } bool File::_isSeekable() const throw() { - IOHandle* h = (IOHandle*)_handle; - return h->isSeekable(); + return _handle->isSeekable(); } void File::_sync() const throw(IO::IOError) { - IOHandle* h = (IOHandle*)_handle; - h->sync(); + _handle->sync(); } offset_t File::_size() const throw(IO::IOError) { - IOHandle* h = (IOHandle*)_handle; - return h->size(); + return _handle->size(); } void File::resize(size_t sz) throw(IO::IOError) { sync(); - IOHandle* h = (IOHandle*)_handle; - h->resize(sz); + _handle->resize(sz); } File& File::operator=(const File& f) throw(IO::IOError) @@ -140,7 +129,7 @@ // strong exception guarantee... if(f.valid()) { - IOHandle* h = new IOHandle(f.handle(), false); + IOHandle* h = new IOHandle(f.handle()->handle(), false); if(valid()) { try @@ -155,7 +144,7 @@ } IODevice::operator=(f); - _handle = (unsigned long)h; + _handle = h; } else { @@ -175,9 +164,9 @@ return FileInfo(path); } -unsigned long File::handle() const throw() +IOHandle* File::handle() const throw() { - return ((IOHandle*)_handle)->handle(); + return _handle; } Index: Process.common.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/Process.common.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Process.common.cpp 31 Dec 2004 03:22:57 -0000 1.1 +++ Process.common.cpp 7 Jun 2005 12:01:19 -0000 1.2 @@ -25,13 +25,15 @@ namespace System { Process::Process(const Unicode::String& program, const ArgList& args) -: _handle((unsigned long)-1), _procIO(0), _state(Stopped), _program(program), +: _handle((void*)-1), _procIO(0), _state(Stopped), _program(program), _args(args) { } Process::~Process() throw() { + if(_procIO) + delete _procIO; } Process::State Process::state() const Index: File.win32.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/File.win32.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- File.win32.cpp 30 Jan 2005 17:07:03 -0000 1.1 +++ File.win32.cpp 7 Jun 2005 12:01:19 -0000 1.2 @@ -19,6 +19,7 @@ ***************************************************************************/ #include "pclasses/System/File.h" +#include <windows.h> namespace P { @@ -27,7 +28,7 @@ void File::unlink(const Unicode::String& path) throw(IO::IOError) { if(::DeleteFile(path.utf8().c_str()) == -1) - throw IO::IOError(errno, "Could not unlink file", P_SOURCEINFO); + throw IO::IOError(GetLastError(), "Could not unlink file", P_SOURCEINFO); } } // !namespace System Index: IOHandle.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/IOHandle.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- IOHandle.h 30 Jan 2005 17:07:03 -0000 1.1 +++ IOHandle.h 7 Jun 2005 12:01:19 -0000 1.2 @@ -29,11 +29,17 @@ namespace System { +#ifdef WIN32 +typedef HANDLE iohandle_t; +#else +typedef int iohandle_t; +#endif + //! Internal System I/O handle class IOHandle { public: IOHandle(const IOHandle& h) throw(IO::IOError); - IOHandle(unsigned long handle, bool takeOwnership) throw(IO::IOError); + IOHandle(iohandle_t h, bool takeOwnership) throw(IO::IOError); IOHandle(const Unicode::String& name, IO::IODevice::AccessMode amode, IO::IODevice::OpenMode omode = IO::IODevice::OpenCreate, IO::IODevice::ShareMode smode = IO::IODevice::AllowNone) @@ -62,10 +68,10 @@ void resize(size_t sz) throw(IO::IOError); //! Returns the native O/S handle - unsigned long handle() const throw(); + iohandle_t handle() const throw(); private: - unsigned long _handle; + iohandle_t _handle; }; } // !namespace System Index: Pipe.common.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/Pipe.common.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Pipe.common.cpp 30 Jan 2005 17:07:03 -0000 1.1 +++ Pipe.common.cpp 7 Jun 2005 12:01:19 -0000 1.2 @@ -25,13 +25,9 @@ namespace System { -Pipe::Pipe(unsigned long handle, bool readEnd) throw() -: IODevice(), _handle(0) +Pipe::Pipe(IOHandle* handle, bool readEnd) throw() +: IODevice(), _handle(handle) { - // takes ownership of the handle ... - IOHandle* h = new IOHandle(handle, true); - _handle = (unsigned long)h; - IODevice::setAccess(readEnd ? Read : Write); IODevice::setValid(true); IODevice::setEof(false); @@ -43,8 +39,7 @@ if(p.valid()) { // duplicates the handle ... - IOHandle* h = new IOHandle(p.handle(), false); - _handle = (unsigned long)h; + _handle = new IOHandle(p.handle()->handle(), false); } } @@ -58,9 +53,8 @@ void Pipe::_close() throw(IO::IOError) { - IOHandle* h = (IOHandle*)_handle; - h->close(); - delete h; + _handle->close(); + delete _handle; _handle = 0; IODevice::setAccess(None); @@ -69,14 +63,12 @@ size_t Pipe::_read(char* buffer, size_t count) throw(IO::IOError) { - IOHandle* h = (IOHandle*)_handle; - return h->read(buffer, count); + return _handle->read(buffer, count); } size_t Pipe::_write(const char* buffer, size_t count) throw(IO::IOError) { - IOHandle* h = (IOHandle*)_handle; - return h->write(buffer, count); + return _handle->write(buffer, count); } void Pipe::_sync() const throw(IO::IOError) @@ -91,7 +83,7 @@ { if(p.valid()) { - IOHandle* h = new IOHandle(p.handle(), false); + IOHandle* h = new IOHandle(p.handle()->handle(), false); if(valid()) { try @@ -106,7 +98,7 @@ } IODevice::operator=(p); - _handle = (unsigned long)h; + _handle = h; } else { @@ -121,9 +113,9 @@ return *this; } -unsigned long Pipe::handle() const throw() +IOHandle* Pipe::handle() const throw() { - return ((IOHandle*)_handle)->handle(); + return _handle; } } // !namespace System Index: CdRomDevice.linux.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/CdRomDevice.linux.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- CdRomDevice.linux.cpp 17 Feb 2005 14:28:08 -0000 1.6 +++ CdRomDevice.linux.cpp 7 Jun 2005 12:01:19 -0000 1.7 @@ -19,6 +19,8 @@ ***************************************************************************/ #include "pclasses/System/CdRomDevice.h" +#include "IOHandle.h" + #include <sys/ioctl.h> #include <linux/cdrom.h> #include <errno.h> @@ -55,7 +57,7 @@ { CdRomDevice::DriveCapability capability = CdRom; - int ret = ::ioctl((int)handle(), CDROM_GET_CAPABILITY, CDSL_CURRENT); + int ret = ::ioctl(handle()->handle(), CDROM_GET_CAPABILITY, CDSL_CURRENT); if(-1 == ret) { throw IO::IOError(errno, "ioctl CDROM_GET_CAPABILITY failed.", P_SOURCEINFO); } @@ -81,7 +83,7 @@ CdRomDevice::DriveStatus CdRomDevice::driveStatus() throw(IO::IOError) { - int ret = ::ioctl((int)handle(), CDROM_DRIVE_STATUS, CDSL_CURRENT); + int ret = ::ioctl(handle()->handle(), CDROM_DRIVE_STATUS, CDSL_CURRENT); if(ret == -1) throw IO::IOError(errno, "ioctl error on device", P_SOURCEINFO); @@ -111,7 +113,7 @@ CdRomDevice::DiscStatus CdRomDevice::discStatus() throw(IO::IOError) { - int ret = ::ioctl((int)handle(), CDROM_DISC_STATUS, CDSL_CURRENT); + int ret = ::ioctl(handle()->handle(), CDROM_DISC_STATUS, CDSL_CURRENT); if(ret == -1) throw IO::IOError(errno, "ioctl error on device", P_SOURCEINFO); @@ -158,7 +160,7 @@ msf.cdmsf_sec1 = endSec; msf.cdmsf_frame1 = endFrame; - int ret = ::ioctl((int)handle(), CDROMPLAYMSF, (void*)&msf); + int ret = ::ioctl(handle()->handle(), CDROMPLAYMSF, (void*)&msf); if(ret == -1) throw IO::IOError(errno, "ioctl error on device", P_SOURCEINFO); } @@ -177,14 +179,14 @@ void CdRomDevice::stop() throw(IO::IOError) { - int ret = ::ioctl((int)handle(), CDROMSTOP); + int ret = ::ioctl(handle()->handle(), CDROMSTOP); if(ret == -1) throw IO::IOError(errno, "ioctl error on device", P_SOURCEINFO); } bool CdRomDevice::mediaChanged() throw(IO::IOError) { // the return value indicates whether the media was changed. - int ret = ::ioctl((int)handle(), CDROM_MEDIA_CHANGED); + int ret = ::ioctl(handle()->handle(), CDROM_MEDIA_CHANGED); if(ret >= 0) return true; @@ -193,27 +195,27 @@ void CdRomDevice::eject() throw(IO::IOError) { - int ret = ::ioctl((int)handle(), CDROMEJECT); + int ret = ::ioctl(handle()->handle(), CDROMEJECT); if(ret == -1) throw IO::IOError(errno, "ioctl error on device", P_SOURCEINFO); } void CdRomDevice::closeTray() throw (IO::IOError) { - int ret = ::ioctl((int)handle(), CDROMEJECT); + int ret = ::ioctl(handle()->handle(), CDROMEJECT); if(ret == -1) throw IO::IOError(errno, "ioctl CDROMCLOSETRAY failed.", P_SOURCEINFO); } void CdRomDevice::pause() throw(IO::IOError) { - int ret = ::ioctl((int)handle(), CDROMPAUSE); + int ret = ::ioctl(handle()->handle(), CDROMPAUSE); if(ret == -1) throw IO::IOError(errno, "ioctl error on device", P_SOURCEINFO); } void CdRomDevice::resume() throw(IO::IOError) { - int ret = ::ioctl((int)handle(), CDROMRESUME); + int ret = ::ioctl(handle()->handle(), CDROMRESUME); if(ret == -1) throw IO::IOError(errno, "ioctl error on device", P_SOURCEINFO); } @@ -222,7 +224,7 @@ { struct cdrom_tochdr hdr; - int ret = ::ioctl((int)handle(), CDROMREADTOCHDR, (void*)&hdr); + int ret = ::ioctl(handle()->handle(), CDROMREADTOCHDR, (void*)&hdr); if(ret == -1) throw IO::IOError(errno, "ioctl error on device", P_SOURCEINFO); @@ -237,7 +239,7 @@ toc_entries[ti].cdte_track = track; toc_entries[ti].cdte_format = CDROM_LBA; - ret = ::ioctl((int)handle(), CDROMREADTOCENTRY, &toc_entries[ti++]); + ret = ::ioctl(handle()->handle(), CDROMREADTOCENTRY, &toc_entries[ti++]); if(ret == -1) throw IO::IOError(errno, "ioctl error on device", P_SOURCEINFO); } @@ -245,7 +247,7 @@ // read lead-out ... toc_entries[ti].cdte_track = CDROM_LEADOUT; toc_entries[ti].cdte_format = CDROM_LBA; - ret = ::ioctl((int)handle(), CDROMREADTOCENTRY, &toc_entries[ti++]); + ret = ::ioctl(handle()->handle(), CDROMREADTOCENTRY, &toc_entries[ti++]); if(ret == -1) throw IO::IOError(errno, "ioctl error on device", P_SOURCEINFO); Index: Process.posix.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/Process.posix.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Process.posix.cpp 23 Apr 2005 17:57:26 -0000 1.3 +++ Process.posix.cpp 7 Jun 2005 12:01:19 -0000 1.4 @@ -24,7 +24,8 @@ #include "pclasses/System/File.h" #include "pclasses/System/CriticalSection.h" -#include "../System/SignalListener.h" +#include "SignalListener.h" +#include "IOHandle.h" #include <sys/types.h> #include <sys/wait.h> @@ -40,6 +41,20 @@ namespace System { +inline void* pid2ptr(pid_t p) +{ + union { pid_t pid; void* ptr; } tmp; + tmp.pid = p; + return tmp.ptr; +} + +inline pid_t ptr2pid(void* p) +{ + union { pid_t pid; void* ptr; } tmp; + tmp.ptr = p; + return tmp.pid; +} + class ChildSignalHandler: public System::SignalListener { public: ChildSignalHandler() @@ -239,32 +254,34 @@ if(mode & RedirectStdErr) close(errfds[1]); - _handle = (unsigned long)child; + _handle = pid2ptr(child); if(mode) { - _procIO = new ProcessIO(Pipe(infds[1],false), - Pipe(outfds[0],true), - Pipe(errfds[0],true)); + _procIO = new ProcessIO(Pipe(new IOHandle(infds[1], true), false), + Pipe(new IOHandle(outfds[0], true), true), + Pipe(new IOHandle(errfds[0], true), true)); + } + else + { + close(infds[1]); + close(outfds[0]); + close(errfds[0]); } - - close(infds[1]); - close(outfds[0]); - close(errfds[0]); _state = Running; } void Process::stop() throw(SystemError) { - int ret = ::kill((pid_t)_handle, SIGTERM); + int ret = ::kill(ptr2pid(_handle), SIGTERM); if(ret == -1) throw SystemError(errno, "Could not stop process", P_SOURCEINFO); } void Process::kill() throw(SystemError) { - int ret = ::kill((pid_t)_handle, SIGKILL); + int ret = ::kill(ptr2pid(_handle), SIGKILL); if(ret == -1) throw SystemError(errno, "Could not kill process", P_SOURCEINFO); } @@ -272,7 +289,7 @@ bool Process::tryWait(int& exitCode) throw(SystemError) { int status = 0; - pid_t pid = waitpid((pid_t)_handle, &status, WNOHANG|WUNTRACED); + pid_t pid = waitpid(ptr2pid(_handle), &status, WNOHANG|WUNTRACED); if(pid == -1) throw SystemError(errno, "Could not wait for process", P_SOURCEINFO); else if(pid == 0) @@ -283,7 +300,7 @@ exitCode = WIFEXITED(status) ? WEXITSTATUS(status) : 127; _state = Stopped; - _handle = (unsigned long)-1; + _handle = (void*)-1; delete _procIO; _procIO = 0; @@ -299,7 +316,7 @@ int status = 0; Process_wait: - pid_t pid = waitpid((pid_t)_handle, &status, WUNTRACED); + pid_t pid = waitpid(ptr2pid(_handle), &status, WUNTRACED); if(pid == -1) { if(errno == EINTR) @@ -310,7 +327,7 @@ } _state = Stopped; - _handle = (unsigned long)-1; + _handle = (void*)-1; delete _procIO; _procIO = 0; Index: IOHandle.posix.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/IOHandle.posix.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- IOHandle.posix.cpp 30 Jan 2005 17:07:03 -0000 1.1 +++ IOHandle.posix.cpp 7 Jun 2005 12:01:19 -0000 1.2 @@ -31,6 +31,8 @@ namespace System { +#define INVALID_HANDLE -1 + int OpenMode2Flags(IO::IODevice::OpenMode omode) { int flags = 0; @@ -79,13 +81,13 @@ IOHandle::IOHandle(const IOHandle& h) throw(IO::IOError) { int handle = ::dup((int)h._handle); - if(handle == -1) + if(handle == INVALID_HANDLE) throw IO::IOError(errno, "Could not duplicate handle", P_SOURCEINFO); - _handle = (unsigned long)handle; + _handle = handle; } -IOHandle::IOHandle(unsigned long h, bool takeOwnership) throw(IO::IOError) +IOHandle::IOHandle(iohandle_t h, bool takeOwnership) throw(IO::IOError) { if(takeOwnership) { @@ -94,17 +96,17 @@ else { int handle = ::dup((int)h); - if(handle == -1) + if(handle == INVALID_HANDLE) throw IO::IOError(errno, "Could not duplicate handle", P_SOURCEINFO); - _handle = (unsigned long)handle; + _handle = handle; } } IOHandle::IOHandle(const Unicode::String& name, IO::IODevice::AccessMode amode, IO::IODevice::OpenMode omode, IO::IODevice::ShareMode smode) throw(IO::IOError) -: _handle((unsigned long)-1) +: _handle(INVALID_HANDLE) { int flags = OpenMode2Flags(omode) | AccessMode2Flags(amode); @@ -114,15 +116,15 @@ else handle = ::open(name.utf8().c_str(), flags); - if(handle == -1) + if(handle == INVALID_HANDLE) throw IO::IOError(errno, "Could not open handle", P_SOURCEINFO); - _handle = (unsigned long)handle; + _handle = handle; } IOHandle::~IOHandle() throw() { - if((int)_handle != -1) + if(_handle != INVALID_HANDLE) { try { close(); } catch(...) { } } @@ -130,10 +132,10 @@ void IOHandle::close() throw(IO::IOError) { - if(::close((int)_handle) == -1) + if(::close(_handle) == -1) throw IO::IOError(errno, "Could not close handle", P_SOURCEINFO); - _handle = (unsigned long)-1; + _handle = INVALID_HANDLE; } size_t IOHandle::read(char* buffer, size_t count) throw(IO::IOError) @@ -142,7 +144,7 @@ count = SSIZE_MAX; Handle_read: - ssize_t ret = ::read((int)_handle, (void*)buffer, count); + ssize_t ret = ::read(_handle, (void*)buffer, count); if(ret == -1) { if(errno == EINTR) @@ -160,7 +162,7 @@ count = SSIZE_MAX; Handle_write: - ssize_t ret = ::write((int)_handle, (const void*)buffer, count); + ssize_t ret = ::write(_handle, (const void*)buffer, count); if(ret == -1) { if(errno == EINTR) @@ -175,7 +177,7 @@ bool IOHandle::isSeekable() const throw() { struct stat buff; - int ret = fstat((int)_handle, &buff); + int ret = fstat(_handle, &buff); if(ret == 0) { if(S_ISREG(buff.st_mode) || S_ISBLK(buff.st_mode)) @@ -204,7 +206,7 @@ break; } - off_t ret = lseek((int)_handle, offset, whence); + off_t ret = lseek(_handle, offset, whence); if(ret == (off_t)-1) throw IO::IOError(errno, "Could not seek on handle", P_SOURCEINFO); @@ -217,7 +219,7 @@ count = SSIZE_MAX; Handle_peek: - ssize_t ret = ::read((int)_handle, (void*)buffer, count); + ssize_t ret = ::read(_handle, (void*)buffer, count); if(ret == -1) { if(errno == EINTR) @@ -232,7 +234,7 @@ void IOHandle::sync() const throw(IO::IOError) { - int ret = fsync((int)_handle); + int ret = fsync(_handle); if(ret == -1) throw IO::IOError(errno, "Could not sync handle", P_SOURCEINFO); } @@ -240,7 +242,7 @@ offset_t IOHandle::size() const throw(IO::IOError) { struct stat buff; - int ret = fstat((int)_handle, &buff); + int ret = fstat(_handle, &buff); if(ret == -1) throw IO::IOError(errno, "Could not stat file", P_SOURCEINFO); @@ -249,12 +251,12 @@ void IOHandle::resize(size_t sz) throw(IO::IOError) { - int ret = ftruncate((int)_handle, sz); + int ret = ftruncate(_handle, sz); if(ret == -1) throw IO::IOError(errno, "Could not truncate file", P_SOURCEINFO); } -unsigned long IOHandle::handle() const throw() +iohandle_t IOHandle::handle() const throw() { return _handle; } Index: StorageDevice.common.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/StorageDevice.common.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- StorageDevice.common.cpp 30 Jan 2005 17:17:00 -0000 1.1 +++ StorageDevice.common.cpp 7 Jun 2005 12:01:19 -0000 1.2 @@ -51,55 +51,55 @@ if(valid()) close(); - _handle = (unsigned long)new IOHandle(str, access, IO::IODevice::OpenFail, share); + _handle = new IOHandle(str, access, IO::IODevice::OpenFail, share); } void StorageDevice::_close() throw(IO::IOError) { - delete (IOHandle*)_handle; + delete _handle; _handle = 0; } size_t StorageDevice::_read(char* buffer, size_t count) throw(IO::IOError) { - return ((IOHandle*)_handle)->read(buffer, count); + return _handle->read(buffer, count); } size_t StorageDevice::_peek(char* buffer, size_t count) throw(IO::IOError) { - return ((IOHandle*)_handle)->peek(buffer, count); + return _handle->peek(buffer, count); } size_t StorageDevice::_write(const char* buffer, size_t count) throw(IO::IOError) { - return ((IOHandle*)_handle)->write(buffer, count); + return _handle->write(buffer, count); } offset_t StorageDevice::_seek(offset_t offset, SeekMode mode) throw(IO::IOError) { - return ((IOHandle*)_handle)->seek(offset, mode); + return _handle->seek(offset, mode); } bool StorageDevice::_isSeekable() const throw() { - return ((IOHandle*)_handle)->isSeekable(); + return _handle->isSeekable(); } void StorageDevice::_sync() const throw(IO::IOError) { - ((IOHandle*)_handle)->sync(); + _handle->sync(); } offset_t StorageDevice::_size() const throw(IO::IOError) { - return ((IOHandle*)_handle)->size(); + return _handle->size(); } -unsigned long StorageDevice::handle() const throw() +IOHandle* StorageDevice::handle() const throw() { - return ((IOHandle*)_handle)->handle(); + return _handle; } } // !namespace System Index: Pipe.posix.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/Pipe.posix.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- Pipe.posix.cpp 30 Jan 2005 17:07:03 -0000 1.9 +++ Pipe.posix.cpp 7 Jun 2005 12:01:19 -0000 1.10 @@ -35,8 +35,8 @@ if(::pipe(fds) == -1) throw IO::IOError(errno, "Could not create pipe", P_SOURCEINFO); - Pipe readPipe((unsigned long)fds[0], true); - Pipe writePipe((unsigned long)fds[1], false); + Pipe readPipe(new IOHandle(fds[0], true), true); + Pipe writePipe(new IOHandle(fds[1], true), false); return std::make_pair(readPipe, writePipe); } |