summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorMartin Gallwey <mtg@openoffice.org>2001-04-19 13:13:40 +0000
committerMartin Gallwey <mtg@openoffice.org>2001-04-19 13:13:40 +0000
commit4b6f310cd73211d81110280d61db27df234cdca7 (patch)
tree50e3ea467e4140e9b0a1c32cae52e120ce526c76 /package
parent2b7c5da331c5573dac2cab9ac5e3a2ed097cb60f (diff)
misc code clean ups
Diffstat (limited to 'package')
-rw-r--r--package/source/zipapi/ByteChucker.cxx5
-rw-r--r--package/source/zipapi/CRC32.cxx7
-rw-r--r--package/source/zipapi/Deflater.cxx19
-rw-r--r--package/source/zipapi/EntryInputStream.cxx204
-rw-r--r--package/source/zipapi/Inflater.cxx18
-rw-r--r--package/source/zipapi/ZipEnumeration.cxx10
-rw-r--r--package/source/zipapi/ZipFile.cxx46
-rw-r--r--package/source/zipapi/ZipOutputStream.cxx64
-rw-r--r--package/source/zipapi/makefile.mk17
9 files changed, 145 insertions, 245 deletions
diff --git a/package/source/zipapi/ByteChucker.cxx b/package/source/zipapi/ByteChucker.cxx
index 78f9301ba074..ae21ecd67c61 100644
--- a/package/source/zipapi/ByteChucker.cxx
+++ b/package/source/zipapi/ByteChucker.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ByteChucker.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: mtg $ $Date: 2000-12-20 12:36:37 $
+ * last change: $Author: mtg $ $Date: 2001-04-19 14:13:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,6 +61,7 @@
#ifndef _BYTE_CHUCKER_HXX_
#include "ByteChucker.hxx"
#endif
+#include <memory.h> //for memcpy
using namespace ::com::sun::star;
diff --git a/package/source/zipapi/CRC32.cxx b/package/source/zipapi/CRC32.cxx
index 63ac06237619..b99229132133 100644
--- a/package/source/zipapi/CRC32.cxx
+++ b/package/source/zipapi/CRC32.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: CRC32.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: mtg $ $Date: 2000-12-19 21:55:39 $
+ * last change: $Author: mtg $ $Date: 2001-04-19 14:13:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,6 +61,9 @@
#ifndef _CRC32_HXX
#include "CRC32.hxx"
#endif
+#ifndef _ZLIB_H
+#include <external/zlib/zlib.h>
+#endif
using namespace rtl;
using namespace com::sun::star;
diff --git a/package/source/zipapi/Deflater.cxx b/package/source/zipapi/Deflater.cxx
index ed0ad4d8fe9a..0bc472fee918 100644
--- a/package/source/zipapi/Deflater.cxx
+++ b/package/source/zipapi/Deflater.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: Deflater.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: mtg $ $Date: 2001-03-16 17:11:42 $
+ * last change: $Author: mtg $ $Date: 2001-04-19 14:13:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,11 +59,18 @@
*
************************************************************************/
#ifndef _DEFLATER_HXX_
-#include "Deflater.hxx"
+#include <Deflater.hxx>
#endif
-
-#include <iostream.h>
-#include <string.h>
+#ifndef _ZLIB_H
+#include <external/zlib/zlib.h>
+#endif
+#ifndef _VOS_DIAGNOSE_H_
+#include <vos/diagnose.hxx>
+#endif
+#ifndef _COM_SUN_STAR_PACKAGES_ZIPCONSTANTS_HPP_
+#include <com/sun/star/packages/ZipConstants.hpp>
+#endif
+#include <string.h> // for memset
using namespace com::sun::star::packages::ZipConstants;
using namespace com::sun::star;
diff --git a/package/source/zipapi/EntryInputStream.cxx b/package/source/zipapi/EntryInputStream.cxx
index 7c1fae574b11..efb893439bb6 100644
--- a/package/source/zipapi/EntryInputStream.cxx
+++ b/package/source/zipapi/EntryInputStream.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: EntryInputStream.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: mtg $ $Date: 2001-03-16 17:11:42 $
+ * last change: $Author: mtg $ $Date: 2001-04-19 14:13:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,10 +61,10 @@
#ifndef _ENTRY_INPUT_STREAM_HXX
#include "EntryInputStream.hxx"
#endif
-
-#ifndef _COM_SUN_STAR_PACKAGE_ZIPCONSTANTS_HPP_
+#ifndef _COM_SUN_STAR_PACKAGES_ZIPCONSTANTS_HPP_
#include <com/sun/star/packages/ZipConstants.hpp>
#endif
+#include <memory.h> // for memcpy
using namespace rtl;
using namespace com::sun::star;
@@ -79,111 +79,74 @@ 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, sal_Int64 nUncompressedSize, sal_Bool bIsDeflated)
+EntryInputStream::EntryInputStream( uno::Reference < io::XInputStream > xNewInput,
+ sal_Int64 nNewBegin,
+ sal_Int64 nNewEnd,
+ sal_Int64 nNewUncompressedSize,
+ sal_Bool bIsDeflated)
: xStream( xNewInput )
, xSeek( xNewInput, uno::UNO_QUERY )
-, nCompBegin( nNewBegin )
-, nCompCurrent( nNewBegin )
-, nCompEnd( nNewEnd )
-, nBegin( 0 )
+, nBegin( nNewBegin )
+, nEnd ( nNewEnd )
, nCurrent( 0 )
-, nEnd(nUncompressedSize)
+, nUncompressedSize (nNewUncompressedSize)
, aSequence ( 0 )
, bReachEOF ( sal_False )
+, bHaveInMemory ( sal_False )
, aInflater( sal_True )
-, aBuffer( static_cast < sal_Int32 > (nUncompressedSize) )
+, aBuffer( 0 )
, bDeflated ( bIsDeflated )
{
- if (bDeflated)
- {
- aSequence.realloc( static_cast < sal_Int32 > (nNewEnd - nNewBegin) );
- xSeek->seek(nNewBegin);
- xStream->readBytes(aSequence, static_cast < sal_Int32 > (nNewEnd - nNewBegin));
- aInflater.setInputSegment(aSequence, 0, static_cast < sal_Int32 > (nNewEnd - nNewBegin) );
- aInflater.doInflate(aBuffer);
- aInflater.end();
- aSequence.realloc( 0 );
- }
- else
+}
+void EntryInputStream::readIntoMemory()
+{
+ if (!bHaveInMemory)
{
- xSeek->seek(nNewBegin);
- xStream->readBytes(aBuffer, static_cast < sal_Int32 > (nUncompressedSize));
+ aBuffer.realloc ( static_cast < sal_Int32 > ( nUncompressedSize ) );
+ if (bDeflated)
+ {
+ sal_Int32 nSize = static_cast < sal_Int32 > (nEnd - nBegin );
+ aSequence.realloc( nSize );
+ xSeek->seek(nBegin);
+ xStream->readBytes(aSequence, nSize );
+ aInflater.setInputSegment(aSequence, 0, nSize );
+ aInflater.doInflate(aBuffer);
+ aInflater.end();
+ aSequence.realloc( 0 );
+ }
+ else
+ {
+ xSeek->seek(nBegin);
+ xStream->readBytes(aBuffer, static_cast < sal_Int32 > (nUncompressedSize));
+ }
+ bHaveInMemory = sal_True;
}
}
-
EntryInputStream::~EntryInputStream( void )
{
}
-/*
-void EntryInputStream::fill(void)
-{
- sal_Int64 nLength, nBytesToRead = aSequence.getLength();
- if (nBytesToRead + nCompCurrent> nCompEnd)
- nBytesToRead = nCompEnd - nCompCurrent;
- if (xSeek.is())
- xSeek->seek( nCompCurrent );
- else
- throw io::IOException();
- nLength = xStream->readBytes(aSequence, static_cast < sal_Int32> (nBytesToRead));
- aInflater.setInputSegment(aSequence, 0, static_cast < sal_Int32> (nLength));
-}
-*/
+
sal_Int32 SAL_CALL EntryInputStream::readBytes( uno::Sequence< sal_Int8 >& aData,
sal_Int32 nBytesToRead )
throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
{
if (nBytesToRead <0)
throw io::BufferSizeExceededException(::rtl::OUString(), *this);
-
- if (nBytesToRead + nCurrent > nEnd)
- nBytesToRead = static_cast < sal_Int32> (nEnd - nCurrent);
+ if (!bHaveInMemory)
+ readIntoMemory();
+ if (nBytesToRead + nCurrent > nUncompressedSize)
+ nBytesToRead = static_cast < sal_Int32> (nUncompressedSize - nCurrent);
aData.realloc( nBytesToRead );
memcpy(aData.getArray(), aBuffer.getConstArray() + nCurrent, nBytesToRead);
nCurrent+=nBytesToRead;
return nBytesToRead;
- /*
- if (!bDeflated)
- {
- if (xSeek.is())
- xSeek->seek( nCompCurrent );
- sal_Int32 nRead = xStream->readBytes(aData, nBytesToRead );
- nCompCurrent+=nRead;
- return nRead;
- }
-
- while ( (n = aInflater.doInflate(aData)) == 0)
- {
- if (aInflater.finished() || aInflater.needsDictionary())
- {
- bReachEOF = sal_True;
- return -1;
- }
- if (aInflater.needsInput())
- fill();
- }
- nCurrent+=n;
- return n;
- //return xStream->readBytes(aData, nBytesToRead );
- */
}
sal_Int32 SAL_CALL EntryInputStream::readSomeBytes( uno::Sequence< sal_Int8 >& aData,
sal_Int32 nMaxBytesToRead )
throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
{
- /*
- if (nMaxBytesToRead + nCompCurrent > nEnd)
- {
- if (nCurrent > nEnd)
- return 0;
- nMaxBytesToRead = nEnd - nCurrent;
- }
- if (xSeek.is())
- xSeek->seek( nCurrent );
- else
- throw (io::IOException());
- */
return readBytes( aData, nMaxBytesToRead );
}
void SAL_CALL EntryInputStream::skipBytes( sal_Int32 nBytesToSkip )
@@ -191,52 +154,16 @@ void SAL_CALL EntryInputStream::skipBytes( sal_Int32 nBytesToSkip )
{
if (nBytesToSkip < 0)
throw io::BufferSizeExceededException(::rtl::OUString(), *this);
- if (nBytesToSkip + nCurrent > nEnd )
- nBytesToSkip = static_cast < sal_Int32 > (nEnd - nCurrent);
+
+ if (nBytesToSkip + nCurrent > nUncompressedSize )
+ nBytesToSkip = static_cast < sal_Int32 > (nUncompressedSize - nCurrent);
nCurrent+=nBytesToSkip;
-/*
- if (!bDeflated)
- {
- if (nBytesToSkip + nCompCurrent> nCompEnd)
- {
- if (nCurrent> nCompEnd)
- return;
- nBytesToSkip = nCompEnd - nCompCurrent;
- }
- nCompCurrent+=nBytesToSkip;
- }
- else
- {
- sal_Int32 nTotal = 0;
- uno::Sequence < sal_Int8 > aTmpSequence ( 1024 );
- while ( nTotal < nBytesToSkip )
- {
- sal_Int32 nNewLength, nLength = nBytesToSkip - nTotal;
- if ( nLength > aTmpSequence.getLength())
- nLength = aTmpSequence.getLength();
- nNewLength = readSomeBytes(aTmpSequence, nLength);
- if (nNewLength < nLength)
- {
- bReachEOF = sal_True;
- break;
- }
- nTotal +=nNewLength;
- }
- nCurrent+=nBytesToSkip;
- }
-*/
}
sal_Int32 SAL_CALL EntryInputStream::available( )
throw(io::NotConnectedException, io::IOException, uno::RuntimeException)
{
- return aBuffer.getLength() - static_cast < sal_Int32> (nCurrent);
- /*
- if (!bDeflated)
- return nCompEnd - nCompCurrent;
- else
- return nEnd - nCurrent;
- */
+ return static_cast < sal_Int32 > (nUncompressedSize - nCurrent);
}
void SAL_CALL EntryInputStream::closeInput( )
throw(io::NotConnectedException, io::IOException, uno::RuntimeException)
@@ -246,54 +173,19 @@ void SAL_CALL EntryInputStream::closeInput( )
void SAL_CALL EntryInputStream::seek( sal_Int64 location )
throw(lang::IllegalArgumentException, io::IOException, uno::RuntimeException)
{
- if (location > aBuffer.getLength())
- location = aBuffer.getLength();
+ if (location > nUncompressedSize)
+ location = nUncompressedSize;
if (location <0)
location = 0;
nCurrent = location;
- /*
- if (!bDeflated)
- {
- if (location < nCompBegin)
- location = nCompBegin;
- if (location > nCompEnd)
- location = nCompEnd;
- nCompCurrent = location;
- return;
- }
- else
- {
- if (location == 0)
- nCurrent = nCompCurrent = 0;
- else if (location > nCurrent)
- skipBytes(location - nCurrent);
- else
- {
- nCurrent = 0;
- skipBytes(location);
- }
- }
- */
}
sal_Int64 SAL_CALL EntryInputStream::getPosition( )
throw(io::IOException, uno::RuntimeException)
{
return nCurrent;
- /*
- if (!bDeflated)
- return nCompCurrent;
- else
- return nCurrent;
- */
}
sal_Int64 SAL_CALL EntryInputStream::getLength( )
throw(io::IOException, uno::RuntimeException)
{
- return aBuffer.getLength();
- /*
- if (!bDeflated)
- return nCompEnd - nCompBegin;
- else
- return nEnd - nBegin;
- */
+ return nUncompressedSize;
}
diff --git a/package/source/zipapi/Inflater.cxx b/package/source/zipapi/Inflater.cxx
index 8e1c311e054a..e58067a6ee38 100644
--- a/package/source/zipapi/Inflater.cxx
+++ b/package/source/zipapi/Inflater.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: Inflater.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: mtg $ $Date: 2001-03-07 19:24:15 $
+ * last change: $Author: mtg $ $Date: 2001-04-19 14:13:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,11 +59,19 @@
*
************************************************************************/
#ifndef _INFLATER_HXX_
-#include "Inflater.hxx"
+#include <Inflater.hxx>
#endif
+#ifndef _ZLIB_H
+#include <external/zlib/zlib.h>
+#endif
+#ifndef _VOS_DIAGNOSE_H_
+#include <vos/diagnose.hxx>
+#endif
+#ifndef _COM_SUN_STAR_PACKAGES_ZIPCONSTANTS_HPP_
+#include <com/sun/star/packages/ZipConstants.hpp>
+#endif
+#include <string.h> // for memset
-#include <iostream.h>
-#include <string.h>
/** Provides general purpose decompression using the ZLIB library */
void Inflater::init (sal_Bool bNowrap)
diff --git a/package/source/zipapi/ZipEnumeration.cxx b/package/source/zipapi/ZipEnumeration.cxx
index 7d0b3a804413..e5c373d4a6c4 100644
--- a/package/source/zipapi/ZipEnumeration.cxx
+++ b/package/source/zipapi/ZipEnumeration.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipEnumeration.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: mtg $ $Date: 2001-03-16 17:11:42 $
+ * last change: $Author: mtg $ $Date: 2001-04-19 14:13:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,14 +59,12 @@
*
************************************************************************/
#ifndef _ZIP_ENUMERATION_HXX
-#include "ZipEnumeration.hxx"
+#include <ZipEnumeration.hxx>
#endif
-
-#ifndef _COM_SUN_STAR_PACKAGE_ZIPCONSTANTS_HPP_
+#ifndef _COM_SUN_STAR_PACKAGES_ZIPCONSTANTS_HPP_
#include <com/sun/star/packages/ZipConstants.hpp>
#endif
-#include <iostream.h>
using namespace rtl;
using namespace com::sun::star;
diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx
index d06c291452c3..23c45905011a 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipFile.cxx,v $
*
- * $Revision: 1.18 $
+ * $Revision: 1.19 $
*
- * last change: $Author: mtg $ $Date: 2001-03-16 17:11:42 $
+ * last change: $Author: mtg $ $Date: 2001-04-19 14:13:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,8 +59,21 @@
*
************************************************************************/
#ifndef _ZIP_FILE_HXX
-#include "ZipFile.hxx"
+#include <ZipFile.hxx>
#endif
+#ifndef _ENTRY_INPUT_STREAM_HXX
+#include <EntryInputStream.hxx>
+#endif
+#ifndef _ZIP_ENUMERATION_HXX
+#include <ZipEnumeration.hxx>
+#endif
+#ifndef _VOS_DIAGNOSE_H_
+#include <vos/diagnose.hxx>
+#endif
+#ifndef _COM_SUN_STAR_PACKAGES_ZIPCONSTANTS_HPP_
+#include <com/sun/star/packages/ZipConstants.hpp>
+#endif
+#include <vector>
using namespace rtl;
@@ -84,6 +97,7 @@ void ZipFile::setInputStream ( uno::Reference < io::XInputStream > xNewStream )
aGrabber.setInputStream ( xStream );
}
+/*
void ZipFile::updateFromManList(std::vector < ManifestEntry * > &rManList)
{
sal_Int32 i=0, nSize = rManList.size();
@@ -97,7 +111,7 @@ void ZipFile::updateFromManList(std::vector < ManifestEntry * > &rManList)
aEntries[pEntry->sName] = *pEntry;
}
}
-
+*/
ZipFile::~ZipFile()
{
aEntries.clear();
@@ -169,13 +183,15 @@ sal_Bool SAL_CALL ZipFile::hasByName( const ::rtl::OUString& aName )
uno::Reference< io::XInputStream > SAL_CALL ZipFile::getInputStream( const packages::ZipEntry& rEntry )
throw(io::IOException, packages::ZipException, uno::RuntimeException)
{
- sal_Int64 nEnd = rEntry.nCompressedSize == 0 ? rEntry.nSize : rEntry.nCompressedSize;
+ sal_Int64 nSize = rEntry.nMethod == DEFLATED ? rEntry.nCompressedSize : rEntry.nSize;
if (rEntry.nOffset <= 0)
readLOC(rEntry);
- sal_Int64 nBegin = rEntry.nOffset;
- nEnd +=nBegin;
-
- uno::Reference< io::XInputStream > xStreamRef = new EntryInputStream(xStream, nBegin, nEnd, 1024, rEntry.nSize, rEntry.nMethod == DEFLATED );
+ uno::Reference< io::XInputStream > xStreamRef =
+ new EntryInputStream(xStream,
+ rEntry.nOffset,
+ rEntry.nOffset + nSize,
+ rEntry.nSize,
+ rEntry.nMethod == DEFLATED );
return xStreamRef;
}
@@ -225,15 +241,17 @@ sal_uInt32 SAL_CALL ZipFile::getHeader(const packages::ZipEntry& rEntry)
}
uno::Reference< io::XInputStream > SAL_CALL ZipFile::getRawStream( const packages::ZipEntry& rEntry )
- throw(io::IOException, packages::ZipException, uno::RuntimeException)
+ throw(io::IOException, packages::ZipException, uno::RuntimeException)
{
sal_Int64 nSize = rEntry.nMethod == DEFLATED ? rEntry.nCompressedSize : rEntry.nSize;
-
if (rEntry.nOffset <= 0)
readLOC(rEntry);
- sal_Int64 nBegin = rEntry.nOffset;
-
- uno::Reference< io::XInputStream > xStreamRef = new EntryInputStream(xStream, nBegin, nSize+nBegin, 1024, nSize, sal_False);
+ uno::Reference< io::XInputStream > xStreamRef =
+ new EntryInputStream(xStream,
+ rEntry.nOffset,
+ rEntry.nOffset + nSize,
+ nSize,
+ sal_False );
return xStreamRef;
}
diff --git a/package/source/zipapi/ZipOutputStream.cxx b/package/source/zipapi/ZipOutputStream.cxx
index ed64ef3a0854..d8078ca0dcbf 100644
--- a/package/source/zipapi/ZipOutputStream.cxx
+++ b/package/source/zipapi/ZipOutputStream.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipOutputStream.cxx,v $
*
- * $Revision: 1.23 $
+ * $Revision: 1.24 $
*
- * last change: $Author: mtg $ $Date: 2001-03-16 17:11:42 $
+ * last change: $Author: mtg $ $Date: 2001-04-19 14:13:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,9 +59,14 @@
*
************************************************************************/
#ifndef _ZIP_OUTPUT_STREAM_HXX
-#include "ZipOutputStream.hxx"
+#include <ZipOutputStream.hxx>
+#endif
+#ifndef _VOS_DIAGNOSE_H_
+#include <vos/diagnose.hxx>
+#endif
+#ifndef _COM_SUN_STAR_PACKAGES_ZIPCONSTANTS_HPP_
+#include <com/sun/star/packages/ZipConstants.hpp>
#endif
-
#include <time.h>
#include <utime.h>
@@ -84,6 +89,8 @@ ZipOutputStream::ZipOutputStream( uno::Reference < io::XOutputStream > &xOStream
ZipOutputStream::~ZipOutputStream( void )
{
+ for (sal_Int32 i = 0, nEnd = aZipList.size(); i < nEnd; i++)
+ delete aZipList[i];
}
void SAL_CALL ZipOutputStream::setComment( const ::rtl::OUString& rComment )
@@ -123,7 +130,7 @@ void SAL_CALL ZipOutputStream::putNextEntry( const packages::ZipEntry& rEntry )
pNonConstEntry->nOffset = static_cast < sal_Int32 > (aChucker.getPosition());
writeLOC(rEntry);
- aZipList.push_back(pNonConstEntry);
+ aZipList.push_back( pNonConstEntry );
pCurrentEntry=pNonConstEntry;
}
void SAL_CALL ZipOutputStream::close( )
@@ -265,8 +272,8 @@ void SAL_CALL ZipOutputStream::finish( )
VOS_DEBUG_ONLY("Zip file must have at least one entry!\n");
}
sal_Int32 nOffset= static_cast < sal_Int32 > (aChucker.getPosition());
- for (int i =0, nEnd = aZipList.size(); i < nEnd; i++)
- writeCEN(*aZipList[i]);
+ for (sal_Int32 i =0, nEnd = aZipList.size(); i < nEnd; i++)
+ writeCEN( *aZipList[i] );
writeEND( nOffset, static_cast < sal_Int32 > (aChucker.getPosition()) - nOffset);
bFinished = sal_True;
}
@@ -286,19 +293,12 @@ void ZipOutputStream::doDeflate()
void ZipOutputStream::writeEND(sal_uInt32 nOffset, sal_uInt32 nLength)
throw(io::IOException, uno::RuntimeException)
{
- sal_Int16 i=0, nCommentLength = static_cast < sal_Int16 > (sComment.getLength());
+ sal_Int16 nCommentLength = static_cast < sal_Int16 > (sComment.getLength());
uno::Sequence < sal_Int8 > aSequence (nCommentLength);
sal_Int8 *pArray = aSequence.getArray();
- sal_Int16 nOldLength = nCommentLength;
- if (nOldLength != nCommentLength)
- {
- nOldLength = nCommentLength;
- aSequence.realloc (nOldLength);
- pArray = aSequence.getArray();
- }
const sal_Unicode *pChar = sComment.getStr();
- for ( ; i < nCommentLength; i++)
+ for ( sal_Int16 i = 0; i < nCommentLength; i++)
{
VOS_ENSURE (pChar[i] <127, "Non US ASCII character in zipfile comment!");
*(pArray+i) = static_cast < const sal_Int8 > (pChar[i]);
@@ -320,10 +320,6 @@ void ZipOutputStream::writeCEN( const packages::ZipEntry &rEntry )
sal_Int16 nNameLength = static_cast < sal_Int16 > ( rEntry.sName.getLength() ) ,
nCommentLength = static_cast < sal_Int16 > ( rEntry.sComment.getLength() ) ,
nExtraLength = static_cast < sal_Int16 > ( rEntry.extra.getLength() );
- sal_Int16 i = 0;
- uno::Sequence < sal_Int8 > aSequence (nNameLength);
- sal_Int8 *pArray = aSequence.getArray();
- sal_Int16 nOldLength=0;
aChucker << CENSIG;
aChucker << rEntry.nVersion;
@@ -350,13 +346,10 @@ void ZipOutputStream::writeCEN( const packages::ZipEntry &rEntry )
aChucker.seek(nCurrent);
*/
const sal_Unicode *pChar = rEntry.sName.getStr();
- if (nOldLength != nNameLength)
- {
- nOldLength = nNameLength;
- aSequence.realloc(nOldLength);
- pArray = aSequence.getArray();
- }
- for ( ; i < nNameLength; i++)
+ uno::Sequence < sal_Int8 > aSequence (nNameLength);
+ sal_Int8 *pArray = aSequence.getArray();
+
+ for ( sal_Int16 i = 0; i < nNameLength; i++)
{
VOS_ENSURE (pChar[i] <127, "Non US ASCII character in zipentry name!");
*(pArray+i) = static_cast < const sal_Int8 > (pChar[i]);
@@ -367,10 +360,9 @@ void ZipOutputStream::writeCEN( const packages::ZipEntry &rEntry )
aChucker.writeBytes( rEntry.extra);
if (nCommentLength)
{
- if (nOldLength != nCommentLength)
+ if (nNameLength != nCommentLength)
{
- nOldLength = nCommentLength;
- aSequence.realloc (nOldLength);
+ aSequence.realloc (nCommentLength);
pArray = aSequence.getArray();
}
for (i=0, pChar = rEntry.sComment.getStr(); i < nCommentLength; i++)
@@ -394,17 +386,9 @@ void ZipOutputStream::writeLOC( const packages::ZipEntry &rEntry )
throw(io::IOException, uno::RuntimeException)
{
sal_Int16 nNameLength = static_cast < sal_Int16 > (rEntry.sName.getLength());
-
- sal_Int16 nOldLength=nNameLength;
uno::Sequence < sal_Int8 > aSequence(nNameLength);
sal_Int8 *pArray = aSequence.getArray();
- if ( nNameLength != nOldLength)
- {
- nOldLength = nNameLength;
- aSequence.realloc(nOldLength);
- pArray = aSequence.getArray();
- }
- sal_Int16 i=0;
+
aChucker << LOCSIG;
aChucker << rEntry.nVersion;
aChucker << rEntry.nFlag;
@@ -426,7 +410,7 @@ void ZipOutputStream::writeLOC( const packages::ZipEntry &rEntry )
aChucker << static_cast <sal_Int16 > ( rEntry.extra.getLength());
const sal_Unicode *pChar = rEntry.sName.getStr();
- for ( ; i < nNameLength; i++)
+ for ( sal_Int16 i = 0; i < nNameLength; i++)
{
VOS_ENSURE (pChar[i] <127, "Non US ASCII character in zipentry name!");
*(pArray+i) = static_cast < const sal_Int8 > (pChar[i]);
diff --git a/package/source/zipapi/makefile.mk b/package/source/zipapi/makefile.mk
index 304fc5ef9e38..5bda73ee2225 100644
--- a/package/source/zipapi/makefile.mk
+++ b/package/source/zipapi/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.6 $
+# $Revision: 1.7 $
#
-# last change: $Author: mtg $ $Date: 2001-03-16 17:11:42 $
+# last change: $Author: mtg $ $Date: 2001-04-19 14:13:40 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -105,18 +105,7 @@ UNOTYPES=\
com.sun.star.packages.XZipOutputStream \
com.sun.star.packages.ZipConstants \
com.sun.star.packages.ZipEntry \
- com.sun.star.packages.ZipException \
- com.sun.star.io.XSeekable \
- com.sun.star.io.XOutputStream \
- com.sun.star.lang.XInitialization \
- com.sun.star.container.XHierarchicalNameAccess \
- com.sun.star.lang.XSingleServiceFactory \
- com.sun.star.util.XChangesBatch \
- com.sun.star.container.XEnumeration \
- com.sun.star.container.XNamed \
- com.sun.star.container.XNameContainer \
- com.sun.star.container.XEnumerationAccess \
- com.sun.star.io.XActiveDataSink
+ com.sun.star.packages.ZipException
# --- Targets ------------------------------------------------------