From 5f2acb17260ee3c874412ba79bc966292100bccc Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sat, 16 Jul 2011 22:15:49 +0100 Subject: add a SvStream::remainingSize --- tools/inc/tools/stream.hxx | 2 ++ tools/source/stream/stream.cxx | 12 ++++++++++++ 2 files changed, 14 insertions(+) (limited to 'tools') diff --git a/tools/inc/tools/stream.hxx b/tools/inc/tools/stream.hxx index 71cae4e0e3f2..dc097b8c563f 100644 --- a/tools/inc/tools/stream.hxx +++ b/tools/inc/tools/stream.hxx @@ -390,6 +390,8 @@ public: sal_Size Seek( sal_Size nPos ); sal_Size SeekRel( sal_sSize nPos ); sal_Size Tell() const { return nBufFilePos+nBufActualPos; } + //length between current (Tell()) pos and end of stream + sal_Size remainingSize(); void Flush(); sal_Bool IsEof() const { return bIsEof; } // next Tell() <= nSize diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index 242f9bb04dc1..2917776e6212 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -1797,6 +1797,18 @@ sal_Size SvStream::Seek( sal_Size nFilePos ) return nBufFilePos + nBufActualPos; } +//probably not as inefficient as it looks seeing as STREAM_SEEK_TO_END in the +//Seek backends is nomally special cased feel free to make this virtual and add +//good implementations for SvFileStream etc +sal_Size SvStream::remainingSize() +{ + sal_Size nCurr = Tell(); + sal_Size nEnd = Seek(STREAM_SEEK_TO_END); + sal_Size nMaxAvailable = nEnd-nCurr; + Seek(nCurr); + return nMaxAvailable; +} + /************************************************************************* |* |* Stream::Flush() -- cgit v1.2.3