summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-07-16 22:15:49 +0100
committerCaolán McNamara <caolanm@redhat.com>2011-07-18 12:21:26 +0100
commit5f2acb17260ee3c874412ba79bc966292100bccc (patch)
tree824224d22426ef8f583effae9b8a6d64884b7c83 /tools
parente689ed9b937213225f9d8c7f57d324041eff7f4b (diff)
add a SvStream::remainingSize
Diffstat (limited to 'tools')
-rw-r--r--tools/inc/tools/stream.hxx2
-rw-r--r--tools/source/stream/stream.cxx12
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()