diff options
-rw-r--r-- | tools/inc/tools/stream.hxx | 2 | ||||
-rw-r--r-- | tools/source/stream/stream.cxx | 12 |
2 files changed, 14 insertions, 0 deletions
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() |