diff --git a/mailnews/base/util/nsMsgFileStream.cpp b/mailnews/base/util/nsMsgFileStream.cpp index f680f62a5d..3be942db2e 100644 --- a/mailnews/base/util/nsMsgFileStream.cpp +++ b/mailnews/base/util/nsMsgFileStream.cpp @@ -30,6 +30,7 @@ ErrorAccordingToNSPR() nsMsgFileStream::nsMsgFileStream() { mFileDesc = nsnull; + mSeekedToEnd = PR_FALSE; } nsMsgFileStream::~nsMsgFileStream() @@ -50,11 +51,17 @@ nsMsgFileStream::Seek(PRInt32 whence, PRInt64 offset) { if (mFileDesc == nsnull) return NS_BASE_STREAM_CLOSED; - + + PRBool seekingToEnd = whence == PR_SEEK_END && offset == 0; + if (seekingToEnd && mSeekedToEnd) + return NS_OK; + PRInt64 cnt = PR_Seek64(mFileDesc, offset, (PRSeekWhence)whence); if (cnt == PRInt64(-1)) { return ErrorAccordingToNSPR(); } + + mSeekedToEnd = seekingToEnd; return NS_OK; } diff --git a/mailnews/base/util/nsMsgFileStream.h b/mailnews/base/util/nsMsgFileStream.h index e72a832e8c..2e27bc6047 100644 --- a/mailnews/base/util/nsMsgFileStream.h +++ b/mailnews/base/util/nsMsgFileStream.h @@ -11,15 +11,15 @@ public: ~nsMsgFileStream(); NS_DECL_ISUPPORTS - + NS_IMETHOD Available(PRUint32 *_retval); NS_IMETHOD Read(char * aBuf, PRUint32 aCount, PRUint32 *_retval); NS_IMETHOD ReadSegments(nsWriteSegmentFun aWriter, void * aClosure, PRUint32 aCount, PRUint32 *_retval); NS_DECL_NSIOUTPUTSTREAM NS_DECL_NSISEEKABLESTREAM - + nsresult InitWithFile(nsILocalFile *localFile); protected: PRFileDesc *mFileDesc; + PRBool mSeekedToEnd; }; -