22#include <com/sun/star/io/BufferSizeExceededException.hpp>
23#include <com/sun/star/io/NotConnectedException.hpp>
26#include <osl/file.hxx>
49 throw css::io::NotConnectedException(OUString(),
static_cast<css::uno::XWeak*
>(
this));
52 throw css::io::BufferSizeExceededException(OUString(),
static_cast<css::uno::XWeak*
>(
this));
54 aData.realloc(nBytesToRead);
59 FileBase::RC eError =
m_pFile->read(
static_cast<void*
>(
aData.getArray()), nBytesToRead, nRead);
60 if (eError != FileBase::E_None)
61 throw css::io::BufferSizeExceededException(OUString(),
static_cast<css::uno::XWeak*
>(
this));
65 aData.realloc( sal::static_int_cast< sal_Int32 >(nRead) );
67 return sal::static_int_cast< sal_Int32 >(nRead);
73 throw css::io::NotConnectedException(OUString(),
static_cast<css::uno::XWeak*
>(
this));
75 if (nMaxBytesToRead < 0)
76 throw css::io::BufferSizeExceededException(OUString(),
static_cast<css::uno::XWeak*
>(
this));
85 throw css::io::NotConnectedException(OUString(),
static_cast<css::uno::XWeak*
>(
this));
87 sal_uInt64 nCurrentPos;
88 FileBase::RC eError =
m_pFile->getPos(nCurrentPos);
89 if (eError != FileBase::E_None)
90 throw css::io::NotConnectedException(OUString(),
static_cast<css::uno::XWeak*
>(
this));
92 sal_uInt64 nNewPos = nCurrentPos + nBytesToSkip;
93 eError =
m_pFile->setPos(osl_Pos_Absolut, nNewPos);
94 if (eError != FileBase::E_None)
95 throw css::io::NotConnectedException(OUString(),
static_cast<css::uno::XWeak*
>(
this));
100 std::scoped_lock aGuard(
m_aMutex );
102 throw css::io::NotConnectedException(OUString(),
static_cast<css::uno::XWeak*
>(
this));
106 if (eError != FileBase::E_None)
107 throw css::io::NotConnectedException(OUString(),
static_cast<css::uno::XWeak*
>(
this));
109 eError =
m_pFile->setPos(osl_Pos_End, 0);
110 if (eError != FileBase::E_None)
111 throw css::io::NotConnectedException(OUString(),
static_cast<css::uno::XWeak*
>(
this));
113 sal_uInt64 nAvailable;
114 eError =
m_pFile->getPos(nAvailable);
115 if (eError != FileBase::E_None)
116 throw css::io::NotConnectedException(OUString(),
static_cast<css::uno::XWeak*
>(
this));
118 nAvailable = nAvailable -
nPos;
120 if (eError != FileBase::E_None)
121 throw css::io::NotConnectedException(OUString(),
static_cast<css::uno::XWeak*
>(
this));
129 throw css::io::NotConnectedException(OUString(),
static_cast<css::uno::XWeak*
>(
this));
149 FileBase::RC eError =
rFile.write(
aData.getConstArray(),
aData.getLength(), nWritten);
150 if (eError != FileBase::E_None
151 || nWritten != sal::static_int_cast< sal_uInt32 >(
aData.getLength()))
153 throw css::io::BufferSizeExceededException(OUString(),
static_cast<css::uno::XWeak*
>(
this));
virtual void SAL_CALL flush() override
virtual ~OSLOutputStreamWrapper() override
virtual void SAL_CALL closeOutput() override
virtual void SAL_CALL writeBytes(const css::uno::Sequence< sal_Int8 > &aData) override
COMPHELPER_DLLPUBLIC OSLOutputStreamWrapper(::osl::File &_rFile)
std::unique_ptr< ::osl::File > m_pFile
constexpr OUStringLiteral aData
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)