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
36 #define THROW_WHERE ""
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");
87 uno::Reference< io::XInputStream > SAL_CALL
94 return uno::Reference< io::XInputStream >( this );
98 uno::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 );
141 if(
m_aFile.
read( aData.getArray(), sal_uInt64(nBytesToRead), nrc )
142 != osl::FileBase::E_None)
146 if (nrc != static_cast<sal_uInt64>(nBytesToRead))
148 return static_cast<sal_Int32
>(nrc);
154 sal_Int32 nBytesToRead )
160 if(
m_aFile.
read( pData, sal_uInt64(nBytesToRead), nrc )
161 != osl::FileBase::E_None)
165 return static_cast<sal_Int32
>(nrc);
177 uno::Sequence< sal_Int8 >& aData,
178 sal_Int32 nMaxBytesToRead )
180 return readBytes( aData,nMaxBytesToRead );
187 m_aFile.
setPos( osl_Pos_Current, sal_uInt64( nBytesToSkip ) );
202 sal_uInt32
length = aData.getLength();
205 sal_uInt64 nWrittenBytes(0);
206 const sal_Int8*
p = aData.getConstArray();
207 if(osl::FileBase::E_None !=
m_aFile.
write(static_cast<void const *>(p),sal_uInt64(length),nWrittenBytes) ||
208 nWrittenBytes != length )
221 if( err != osl::FileBase::E_None ) {
223 ex.Message =
"could not close file";
234 std::scoped_lock aGuard(
m_aMutex );
245 std::scoped_lock aGuard(
m_aMutex );
257 throw lang::IllegalArgumentException(
THROW_WHERE, uno::Reference< uno::XInterface >(), 0 );
258 if( osl::FileBase::E_None !=
m_aFile.
setPos( osl_Pos_Absolut, sal_uInt64( location ) ) )
269 return sal_Int64( uPos );
278 return sal_Int64( uEndPos );
291 throw io::IOException(
292 "could not synchronize file to disc",
293 static_cast< OWeakObject * >(
this));
sal_Int32 SAL_CALL available() override
virtual void SAL_CALL waitForCompletion() override
::osl::FileBase::RC getSize(sal_uInt64 &rSize)
::osl::FileBase::RC close()
void SAL_CALL skipBytes(sal_Int32 nBytesToSkip) override
void SAL_CALL closeOutput() override
void SAL_CALL seek(sal_Int64 location) override
sal_Int32 SAL_CALL readBytes(css::uno::Sequence< sal_Int8 > &aData, sal_Int32 nBytesToRead) override
void SAL_CALL closeInput() override
::osl::FileBase::RC getPos(sal_uInt64 &uPos)
void SAL_CALL writeBytes(const css::uno::Sequence< sal_Int8 > &aData) override
sal_Int64 SAL_CALL getLength() override
void SAL_CALL flush() override
virtual void SAL_CALL truncate() override
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &_rIdentifier) override
sal_Int64 SAL_CALL getPosition() override
::osl::FileBase::RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64 &rBytesWritten)
::osl::FileBase::RC setPos(sal_uInt32 uHow, sal_Int64 uPos)
sal_Int32 SAL_CALL readSomeBytes(css::uno::Sequence< sal_Int8 > &aData, sal_Int32 nMaxBytesToRead) override
sal_Int32 m_nMinorErrorCode
::osl::FileBase::RC setSize(sal_uInt64 uSize)
bool m_bOutputStreamCalled
bool m_bInputStreamCalled
virtual ~XStream_impl() override
virtual css::uno::Reference< css::io::XOutputStream > SAL_CALL getOutputStream() override
::osl::FileBase::RC open(sal_uInt32 uFlags)
::osl::FileBase::RC sync() const
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getInputStream() override
#define TASKHANDLER_NO_ERROR
::osl::FileBase::RC read(void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64 &rBytesRead)
XStream_impl(const OUString &aUncPath, bool bLock)
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
#define TASKHANDLING_OPEN_FOR_STREAM
bool m_bDetectedRangeSegmentation false