summaryrefslogtreecommitdiff
path: root/ucb/source
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-08-17 13:19:54 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-08-27 09:10:04 +0200
commita6ad198d097fb4a503c8d5831d484ff46721134b (patch)
treee82ca01e800c5f50ce8db7bd8eb610790ee13c8d /ucb/source
parent03b31a8ad48e3b8a9e54203ff3856702557757b5 (diff)
tdf#158556 use more comphelper::ByteReader
which avoids a ton of temporary uno::Sequence being created Change-Id: I237bb69395f692bb0272ca0daec05b81af828e01 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171968 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Jenkins
Diffstat (limited to 'ucb/source')
-rw-r--r--ucb/source/ucp/file/filinpstr.cxx18
-rw-r--r--ucb/source/ucp/file/filinpstr.hxx7
2 files changed, 23 insertions, 2 deletions
diff --git a/ucb/source/ucp/file/filinpstr.cxx b/ucb/source/ucp/file/filinpstr.cxx
index 70e80e384d2b..33cbf32d1df6 100644
--- a/ucb/source/ucp/file/filinpstr.cxx
+++ b/ucb/source/ucp/file/filinpstr.cxx
@@ -99,6 +99,24 @@ XInputStream_impl::readBytes(
return static_cast<sal_Int32>(nrc);
}
+sal_Int32
+XInputStream_impl::readSomeBytes(
+ sal_Int8* aData,
+ sal_Int32 nBytesToRead )
+{
+ if( ! m_nIsOpen ) throw io::IOException( THROW_WHERE );
+
+ //TODO! translate memory exhaustion (if it were detectable...) into
+ // io::BufferSizeExceededException
+
+ sal_uInt64 nrc(0);
+ if(m_aFile.read( aData, sal_uInt64(nBytesToRead),nrc )
+ != osl::FileBase::E_None)
+ throw io::IOException( THROW_WHERE );
+
+ return static_cast<sal_Int32>(nrc);
+}
+
sal_Int32 SAL_CALL
XInputStream_impl::readSomeBytes(
uno::Sequence< sal_Int8 >& aData,
diff --git a/ucb/source/ucp/file/filinpstr.hxx b/ucb/source/ucp/file/filinpstr.hxx
index f62fe4741170..d43cd2871bd6 100644
--- a/ucb/source/ucp/file/filinpstr.hxx
+++ b/ucb/source/ucp/file/filinpstr.hxx
@@ -22,7 +22,7 @@
#include <cppuhelper/implbase.hxx>
#include <com/sun/star/io/XSeekable.hpp>
#include <com/sun/star/io/XInputStream.hpp>
-
+#include <comphelper/bytereader.hxx>
#include "filrec.hxx"
enum class TaskHandlerErr;
@@ -32,7 +32,8 @@ namespace fileaccess {
class TaskManager;
class XInputStream_impl final
- : public cppu::WeakImplHelper<css::io::XInputStream, css::io::XSeekable>
+ : public cppu::WeakImplHelper<css::io::XInputStream, css::io::XSeekable>,
+ public comphelper::ByteReader
{
public:
@@ -75,6 +76,8 @@ namespace fileaccess {
virtual sal_Int64 SAL_CALL
getLength() override;
+ virtual sal_Int32 readSomeBytes(sal_Int8* aData, sal_Int32 nBytesToRead) override;
+
private:
bool m_nIsOpen;