summaryrefslogtreecommitdiffstats
path: root/package/source
diff options
context:
space:
mode:
authorMartin Gallwey <mtg@openoffice.org>2000-11-16 10:55:52 +0000
committerMartin Gallwey <mtg@openoffice.org>2000-11-16 10:55:52 +0000
commit05ac3fe285dd77e0fc636af6ea5f6fea568a9d1d (patch)
tree0aee68eedcc2c1ab7d7e4484c1a0a87bf6922f6c /package/source
parentInitial revision. This version is at best 50% functional, and contains (diff)
downloadcore-05ac3fe285dd77e0fc636af6ea5f6fea568a9d1d.tar.gz
core-05ac3fe285dd77e0fc636af6ea5f6fea568a9d1d.zip
Added 50% functional generic package implementation and added support
for un-deflated streams to EntryInputStream. This will require further work RSN.
Diffstat (limited to 'package/source')
-rw-r--r--package/source/zipapi/CRC32.cxx6
-rw-r--r--package/source/zipapi/EntryInputStream.cxx20
-rw-r--r--package/source/zipapi/ZipFile.cxx6
-rw-r--r--package/source/zipapi/ZipOutputStream.cxx22
4 files changed, 36 insertions, 18 deletions
diff --git a/package/source/zipapi/CRC32.cxx b/package/source/zipapi/CRC32.cxx
index bca9154af66f..ca866f761fc5 100644
--- a/package/source/zipapi/CRC32.cxx
+++ b/package/source/zipapi/CRC32.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: CRC32.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mtg $ $Date: 2000-11-13 13:38:01 $
+ * last change: $Author: mtg $ $Date: 2000-11-16 11:55:52 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -81,7 +81,7 @@ void CRC32::reset()
}
sal_Int32 CRC32::getValue()
{
- return (sal_Int32) nCRC & 0xFFFFFFFFL;
+ return nCRC & 0xFFFFFFFFL;
}
/** Update CRC32 with specified byte
*/
diff --git a/package/source/zipapi/EntryInputStream.cxx b/package/source/zipapi/EntryInputStream.cxx
index a2f65288a7ef..66150d97c16d 100644
--- a/package/source/zipapi/EntryInputStream.cxx
+++ b/package/source/zipapi/EntryInputStream.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: EntryInputStream.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mtg $ $Date: 2000-11-13 13:38:01 $
+ * last change: $Author: mtg $ $Date: 2000-11-16 11:55:52 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -80,13 +80,15 @@ using namespace com::sun::star;
* seek to it before performing any reads.
*/
-EntryInputStream::EntryInputStream( uno::Reference < io::XInputStream > xNewInput, sal_Int64 nNewBegin, sal_Int64 nNewEnd, sal_Int32 nNewBufferSize)
+EntryInputStream::EntryInputStream( uno::Reference < io::XInputStream > xNewInput, sal_Int64 nNewBegin, sal_Int64 nNewEnd, sal_Int32 nNewBufferSize, sal_Bool bNewDeflated)
: xStream(xNewInput)
, xSeek(xNewInput, uno::UNO_QUERY)
, nBegin(nNewBegin)
, nCurrent(nNewBegin)
, nEnd(nNewEnd)
, aSequence ( nNewBufferSize )
+, bDeflated ( bNewDeflated )
+, bReachEOF ( sal_False )
, aInflater( sal_True )
, nLength(0)
{
@@ -114,6 +116,16 @@ sal_Int32 SAL_CALL EntryInputStream::readBytes( uno::Sequence< sal_Int8 >& aData
sal_Int32 n;
if (nBytesToRead <=0)
return 0;
+ if (nBytesToRead + nCurrent > nEnd)
+ {
+ if (nCurrent > nEnd)
+ return 0;
+ nBytesToRead = nEnd - nCurrent;
+ }
+
+ if (!bDeflated)
+ return xStream->readBytes(aData, nBytesToRead );
+
while ( (n = aInflater.doInflate(aData)) == 0)
{
if (aInflater.finished() || aInflater.needsDictionary())
@@ -141,7 +153,7 @@ sal_Int32 SAL_CALL EntryInputStream::readSomeBytes( uno::Sequence< sal_Int8 >& a
xSeek->seek( nCurrent );
else
throw (io::IOException());
- return xStream->readSomeBytes( aData, nMaxBytesToRead );
+ return readBytes( aData, nMaxBytesToRead );
}
void SAL_CALL EntryInputStream::skipBytes( sal_Int32 nBytesToSkip )
throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx
index 3d4d9335fd08..cd8a7aea0eeb 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipFile.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mtg $ $Date: 2000-11-13 13:38:01 $
+ * last change: $Author: mtg $ $Date: 2000-11-16 11:55:52 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -211,7 +211,7 @@ uno::Reference< io::XInputStream> ZipFile::getInputStream(const package::ZipEntr
sal_Int64 nBegin = rEntry.nOffset;
nEnd +=nBegin;
- uno::Reference< io::XInputStream > xStreamRef = new EntryInputStream(xStream, nBegin, nEnd, 1024);
+ uno::Reference< io::XInputStream > xStreamRef = new EntryInputStream(xStream, nBegin, nEnd, 1024, rEntry.nMethod == DEFLATED);
return xStreamRef;
}
sal_Bool ZipFile::readLOC(const package::ZipEntry &rEntry)
diff --git a/package/source/zipapi/ZipOutputStream.cxx b/package/source/zipapi/ZipOutputStream.cxx
index fa5e8ac5b2d8..a1766937b0f7 100644
--- a/package/source/zipapi/ZipOutputStream.cxx
+++ b/package/source/zipapi/ZipOutputStream.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipOutputStream.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mtg $ $Date: 2000-11-13 13:38:01 $
+ * last change: $Author: mtg $ $Date: 2000-11-16 11:55:52 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -119,10 +119,10 @@ void SAL_CALL ZipOutputStream::putNextEntry( const package::ZipEntry& rEntry )
case DEFLATED:
if (pNonConstEntry->nSize == -1 || pNonConstEntry->nCompressedSize == -1 ||
pNonConstEntry->nCrc == -1)
- pNonConstEntry->nFlag = 8;
+ pNonConstEntry->nFlag |= 8;
else if (pNonConstEntry->nSize != -1 && pNonConstEntry->nCompressedSize != -1 &&
pNonConstEntry->nCrc != -1)
- pNonConstEntry->nFlag=0;
+ pNonConstEntry->nFlag &= 8;
pNonConstEntry->nVersion = 20;
break;
case STORED:
@@ -131,12 +131,12 @@ void SAL_CALL ZipOutputStream::putNextEntry( const package::ZipEntry& rEntry )
else if (pNonConstEntry->nCompressedSize == -1)
pNonConstEntry->nCompressedSize = pNonConstEntry->nSize;
pNonConstEntry->nVersion = 10;
- pNonConstEntry->nFlag = 0;
+ pNonConstEntry->nFlag &= 8;
break;
}
pNonConstEntry->nOffset = aChucker.getPosition();
writeLOC(rEntry);
- aZipList.push_back(pNonConstEntry);
+ aZipList.push_back(*pNonConstEntry);
pCurrentEntry=pNonConstEntry;
}
void SAL_CALL ZipOutputStream::close( )
@@ -185,7 +185,13 @@ void SAL_CALL ZipOutputStream::closeEntry( )
aDeflater.reset();
break;
case STORED:
- if (pEntry->nCrc != aCRC.getValue())
+ {
+ sal_uInt32 na= pEntry->nCrc;
+ sal_uInt32 nb = aCRC.getValue();
+ int i=0;
+ }
+
+ if (static_cast < sal_uInt32 > (pEntry->nCrc) != static_cast <sal_uInt32> (aCRC.getValue()))
{
// boom
DBG_ERROR("Invalid entry crc32");
@@ -234,7 +240,7 @@ void SAL_CALL ZipOutputStream::finish( )
}
sal_Int32 nOffset= aChucker.getPosition();
for (int i =0, nEnd = aZipList.size(); i < nEnd; i++)
- writeCEN(*aZipList[i]);
+ writeCEN(aZipList[i]);
writeEND( nOffset, aChucker.getPosition() - nOffset);
bFinished = sal_True;
}