summaryrefslogtreecommitdiff
path: root/package/source/zipapi/ByteGrabber.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'package/source/zipapi/ByteGrabber.cxx')
-rw-r--r--package/source/zipapi/ByteGrabber.cxx21
1 files changed, 21 insertions, 0 deletions
diff --git a/package/source/zipapi/ByteGrabber.cxx b/package/source/zipapi/ByteGrabber.cxx
index 7e8433d77837..84cd6465f7bf 100644
--- a/package/source/zipapi/ByteGrabber.cxx
+++ b/package/source/zipapi/ByteGrabber.cxx
@@ -51,8 +51,10 @@ ByteGrabber::ByteGrabber(uno::Reference < io::XInputStream > xIstream)
ByteGrabber::~ByteGrabber()
{
}
+
void ByteGrabber::setInputStream (uno::Reference < io::XInputStream > xNewStream)
{
+ ::osl::MutexGuard aGuard( m_aMutex );
xStream = xNewStream;
xSeek = uno::Reference < io::XSeekable > (xNewStream, uno::UNO_QUERY);
}
@@ -62,6 +64,7 @@ sal_Int32 SAL_CALL ByteGrabber::readBytes( uno::Sequence< sal_Int8 >& aData,
sal_Int32 nBytesToRead )
throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
{
+ ::osl::MutexGuard aGuard( m_aMutex );
return xStream->readBytes(aData, nBytesToRead );
}
@@ -69,6 +72,7 @@ sal_Int32 SAL_CALL ByteGrabber::readBytes( uno::Sequence< sal_Int8 >& aData,
sal_Int64 SAL_CALL ByteGrabber::seek( sal_Int64 location )
throw(lang::IllegalArgumentException, io::IOException, uno::RuntimeException)
{
+ ::osl::MutexGuard aGuard( m_aMutex );
if (xSeek.is() )
{
sal_Int64 nLen = xSeek->getLength();
@@ -82,32 +86,40 @@ sal_Int64 SAL_CALL ByteGrabber::seek( sal_Int64 location )
else
throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
+
sal_Int64 SAL_CALL ByteGrabber::getPosition( )
throw(io::IOException, uno::RuntimeException)
{
+ ::osl::MutexGuard aGuard( m_aMutex );
if (xSeek.is() )
return xSeek->getPosition();
else
throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
+
sal_Int64 SAL_CALL ByteGrabber::getLength( )
throw(io::IOException, uno::RuntimeException)
{
+ ::osl::MutexGuard aGuard( m_aMutex );
if (xSeek.is() )
return xSeek->getLength();
else
throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
+
ByteGrabber& ByteGrabber::operator >> (sal_Int8& rInt8)
{
+ ::osl::MutexGuard aGuard( m_aMutex );
if (xStream->readBytes(aSequence,1) != 1)
rInt8 = 0;
else
rInt8 = aSequence[0] & 0xFF;
return *this;
}
+
ByteGrabber& ByteGrabber::operator >> (sal_Int16& rInt16)
{
+ ::osl::MutexGuard aGuard( m_aMutex );
if (xStream->readBytes ( aSequence, 2) != 2)
rInt16 = 0;
else
@@ -119,8 +131,11 @@ ByteGrabber& ByteGrabber::operator >> (sal_Int16& rInt16)
}
return *this;
}
+
ByteGrabber& ByteGrabber::operator >> (sal_Int32& rInt32)
{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
if (xStream->readBytes(aSequence, 4) != 4)
rInt32 = 0;
else
@@ -137,6 +152,8 @@ ByteGrabber& ByteGrabber::operator >> (sal_Int32& rInt32)
ByteGrabber& ByteGrabber::operator >> (sal_uInt8& rInt8)
{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
if (xStream->readBytes(aSequence,1) != 1)
rInt8 = 0;
else
@@ -145,6 +162,8 @@ ByteGrabber& ByteGrabber::operator >> (sal_uInt8& rInt8)
}
ByteGrabber& ByteGrabber::operator >> (sal_uInt16& rInt16)
{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
if (xStream->readBytes(aSequence, 2) != 2)
rInt16 = 0;
else
@@ -158,6 +177,8 @@ ByteGrabber& ByteGrabber::operator >> (sal_uInt16& rInt16)
}
ByteGrabber& ByteGrabber::operator >> (sal_uInt32& ruInt32)
{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
if (xStream->readBytes(aSequence, 4) != 4)
ruInt32 = 0;
else