[Opalvoip-svn] SF.net SVN: opalvoip:[22997] ptlib/trunk/src/ptlib/common/pchannel.cxx
Brought to you by:
csoutheren,
rjongbloed
From: <rjo...@us...> - 2009-06-26 08:29:38
|
Revision: 22997 http://opalvoip.svn.sourceforge.net/opalvoip/?rev=22997&view=rev Author: rjongbloed Date: 2009-06-26 08:29:36 +0000 (Fri, 26 Jun 2009) Log Message: ----------- Added test for operations on a PFile when not open, relatively benign, but prevents an assert in the Microsoft Run Time debug version. Modified Paths: -------------- ptlib/trunk/src/ptlib/common/pchannel.cxx Modified: ptlib/trunk/src/ptlib/common/pchannel.cxx =================================================================== --- ptlib/trunk/src/ptlib/common/pchannel.cxx 2009-06-26 06:26:06 UTC (rev 22996) +++ ptlib/trunk/src/ptlib/common/pchannel.cxx 2009-06-26 08:29:36 UTC (rev 22997) @@ -909,6 +909,9 @@ PBoolean PFile::Read(void * buffer, PINDEX amount) { + if (!IsOpen()) + return SetErrorValues(NotOpen, EBADF); + flush(); #ifdef WOT_NO_FILESYSTEM lastReadCount = 0; @@ -921,6 +924,9 @@ PBoolean PFile::Write(const void * buffer, PINDEX amount) { + if (!IsOpen()) + return SetErrorValues(NotOpen, EBADF); + flush(); #ifdef WOT_NO_FILESYSTEM lastWriteCount = amount; @@ -941,6 +947,9 @@ off_t PFile::GetLength() const { + if (!IsOpen()) + return -1; + #ifdef WOT_NO_FILESYSTEM return 0; #else @@ -954,6 +963,9 @@ PBoolean PFile::IsEndOfFile() const { + if (!IsOpen()) + return true; + ((PFile *)this)->flush(); return GetPosition() >= GetLength(); } @@ -964,6 +976,9 @@ #ifdef WOT_NO_FILESYSTEM return PTrue; #else + if (!IsOpen()) + return SetErrorValues(NotOpen, EBADF); + return _lseek(GetHandle(), pos, origin) != (off_t)-1; #endif } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |