22#include <com/sun/star/io/BufferSizeExceededException.hpp>
23#include <com/sun/star/io/IOException.hpp>
24#include <com/sun/star/lang/IllegalArgumentException.hpp>
25#include <com/sun/star/uno/RuntimeException.hpp>
26#include <osl/diagnose.h>
33#if OSL_DEBUG_LEVEL > 0
34#define THROW_WHERE SAL_WHERE
45XStream_impl::XStream_impl(
const OUString& aUncPath,
bool bLock )
46 : m_bInputStreamCalled( false ),
47 m_bOutputStreamCalled( false ),
52 sal_uInt32 nFlags = ( osl_File_OpenFlag_Read | osl_File_OpenFlag_Write );
54 nFlags |= osl_File_OpenFlag_NoLock;
57 if(
err != osl::FileBase::E_None )
76 catch (
const io::IOException&)
78 OSL_FAIL(
"unexpected situation");
80 catch (
const uno::RuntimeException&)
82 OSL_FAIL(
"unexpected situation");
87uno::Reference< io::XInputStream > SAL_CALL
94 return uno::Reference< io::XInputStream >(
this );
98uno::Reference< io::XOutputStream > SAL_CALL
102 std::scoped_lock aGuard(
m_aMutex );
105 return uno::Reference< io::XOutputStream >(
this );
114 if (osl::FileBase::E_None !=
m_aFile.
setPos(osl_Pos_Absolut,sal_uInt64(0)))
124 uno::Sequence< sal_Int8 >& aData,
125 sal_Int32 nBytesToRead )
132 aData.realloc(nBytesToRead);
134 catch (
const std::bad_alloc&)
137 throw io::BufferSizeExceededException(
THROW_WHERE );
142 != osl::FileBase::E_None)
146 if (nrc !=
static_cast<sal_uInt64
>(nBytesToRead))
148 return static_cast<sal_Int32
>(nrc);
154 sal_Int32 nBytesToRead )
161 != osl::FileBase::E_None)
165 return static_cast<sal_Int32
>(nrc);
170 uno::Sequence< sal_Int8 >& aData,
171 sal_Int32 nMaxBytesToRead )
173 return readBytes( aData,nMaxBytesToRead );
180 m_aFile.
setPos( osl_Pos_Current, sal_uInt64( nBytesToSkip ) );
198 sal_uInt64 nWrittenBytes(0);
200 if(osl::FileBase::E_None !=
m_aFile.
write(
static_cast<void const *
>(
p),sal_uInt64(
length),nWrittenBytes) ||
214 if(
err != osl::FileBase::E_None ) {
216 ex.Message =
"could not close file";
227 std::scoped_lock aGuard(
m_aMutex );
238 std::scoped_lock aGuard(
m_aMutex );
250 throw lang::IllegalArgumentException(
THROW_WHERE, uno::Reference< uno::XInterface >(), 0 );
251 if( osl::FileBase::E_None !=
m_aFile.
setPos( osl_Pos_Absolut, sal_uInt64( location ) ) )
262 return sal_Int64( uPos );
271 return sal_Int64( uEndPos );
284 throw io::IOException(
285 "could not synchronize file to disc",
::osl::FileBase::RC close()
::osl::FileBase::RC setSize(sal_uInt64 uSize)
::osl::FileBase::RC getPos(sal_uInt64 &uPos)
::osl::FileBase::RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64 &rBytesWritten)
::osl::FileBase::RC read(void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64 &rBytesRead)
::osl::FileBase::RC setPos(sal_uInt32 uHow, sal_Int64 uPos)
::osl::FileBase::RC sync() const
::osl::FileBase::RC getSize(sal_uInt64 &rSize)
::osl::FileBase::RC open(sal_uInt32 uFlags)
void SAL_CALL closeInput() override
virtual ~XStream_impl() override
sal_Int64 SAL_CALL getLength() override
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getInputStream() override
void SAL_CALL seek(sal_Int64 location) override
void SAL_CALL writeBytes(const css::uno::Sequence< sal_Int8 > &aData) override
bool m_bInputStreamCalled
sal_Int32 m_nMinorErrorCode
void SAL_CALL flush() override
sal_Int64 SAL_CALL getPosition() override
sal_Int32 SAL_CALL readBytes(css::uno::Sequence< sal_Int8 > &aData, sal_Int32 nBytesToRead) override
virtual css::uno::Reference< css::io::XOutputStream > SAL_CALL getOutputStream() override
void SAL_CALL skipBytes(sal_Int32 nBytesToSkip) override
bool m_bOutputStreamCalled
void SAL_CALL closeOutput() override
sal_Int32 SAL_CALL available() override
sal_Int32 SAL_CALL readSomeBytes(css::uno::Sequence< sal_Int8 > &aData, sal_Int32 nMaxBytesToRead) override
virtual void SAL_CALL waitForCompletion() override
virtual void SAL_CALL truncate() override
#define TASKHANDLER_NO_ERROR
#define TASKHANDLING_OPEN_FOR_STREAM
std::unique_ptr< sal_Int32[]> pData
constexpr OUStringLiteral aData