Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
04ebf437
Kaydet (Commit)
04ebf437
authored
Eki 07, 2014
tarafından
Matúš Kukan
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
package: ZipOutputStream: prefix members
Change-Id: I9cc21ba87484560ec0db5424800dd67f80e00540
üst
3d8f0598
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
126 additions
and
133 deletions
+126
-133
ZipOutputStream.hxx
package/inc/ZipOutputStream.hxx
+9
-14
ZipOutputStream.cxx
package/source/zipapi/ZipOutputStream.cxx
+117
-119
No files found.
package/inc/ZipOutputStream.hxx
Dosyayı görüntüle @
04ebf437
...
@@ -20,7 +20,6 @@
...
@@ -20,7 +20,6 @@
#define INCLUDED_PACKAGE_INC_ZIPOUTPUTSTREAM_HXX
#define INCLUDED_PACKAGE_INC_ZIPOUTPUTSTREAM_HXX
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/xml/crypto/XCipherContext.hpp>
#include <com/sun/star/xml/crypto/XCipherContext.hpp>
#include <com/sun/star/xml/crypto/XDigestContext.hpp>
#include <com/sun/star/xml/crypto/XDigestContext.hpp>
...
@@ -33,32 +32,28 @@
...
@@ -33,32 +32,28 @@
struct
ZipEntry
;
struct
ZipEntry
;
class
ZipPackageStream
;
class
ZipPackageStream
;
namespace
rtl
{
template
<
class
T
>
class
Reference
;
}
class
ZipOutputStream
class
ZipOutputStream
{
{
protected
:
protected
:
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
uno
::
XComponentContext
>
m_xContext
;
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
uno
::
XComponentContext
>
m_xContext
;
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
io
::
XOutputStream
>
xStream
;
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
io
::
XOutputStream
>
m_
xStream
;
::
std
::
vector
<
ZipEntry
*
>
aZipList
;
::
std
::
vector
<
ZipEntry
*
>
m_
aZipList
;
::
com
::
sun
::
star
::
uno
::
Sequence
<
sal_Int8
>
m_aDeflateBuffer
;
::
com
::
sun
::
star
::
uno
::
Sequence
<
sal_Int8
>
m_aDeflateBuffer
;
OUString
sComment
;
OUString
m_
sComment
;
ZipUtils
::
Deflater
aDeflater
;
ZipUtils
::
Deflater
m_
aDeflater
;
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
xml
::
crypto
::
XCipherContext
>
m_xCipherContext
;
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
xml
::
crypto
::
XCipherContext
>
m_xCipherContext
;
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
xml
::
crypto
::
XDigestContext
>
m_xDigestContext
;
::
com
::
sun
::
star
::
uno
::
Reference
<
::
com
::
sun
::
star
::
xml
::
crypto
::
XDigestContext
>
m_xDigestContext
;
CRC32
aCRC
;
CRC32
m_
aCRC
;
ByteChucker
aChucker
;
ByteChucker
m_
aChucker
;
ZipEntry
*
pCurrentEntry
;
ZipEntry
*
m_
pCurrentEntry
;
sal_Int16
nMethod
,
nLevel
,
m
nDigested
;
sal_Int16
m_nMethod
,
m_nLevel
,
m_
nDigested
;
bool
bFinished
,
bEncryptCurrentEntry
;
bool
m_bFinished
,
m_
bEncryptCurrentEntry
;
ZipPackageStream
*
m_pCurrentStream
;
ZipPackageStream
*
m_pCurrentStream
;
public
:
public
:
...
...
package/source/zipapi/ZipOutputStream.cxx
Dosyayı görüntüle @
04ebf437
...
@@ -33,8 +33,6 @@
...
@@ -33,8 +33,6 @@
using
namespace
com
::
sun
::
star
;
using
namespace
com
::
sun
::
star
;
using
namespace
com
::
sun
::
star
::
io
;
using
namespace
com
::
sun
::
star
::
io
;
using
namespace
com
::
sun
::
star
::
uno
;
using
namespace
com
::
sun
::
star
::
uno
;
using
namespace
com
::
sun
::
star
::
packages
;
using
namespace
com
::
sun
::
star
::
packages
::
zip
;
using
namespace
com
::
sun
::
star
::
packages
::
zip
::
ZipConstants
;
using
namespace
com
::
sun
::
star
::
packages
::
zip
::
ZipConstants
;
/** This class is used to write Zip files
/** This class is used to write Zip files
...
@@ -42,35 +40,35 @@ using namespace com::sun::star::packages::zip::ZipConstants;
...
@@ -42,35 +40,35 @@ using namespace com::sun::star::packages::zip::ZipConstants;
ZipOutputStream
::
ZipOutputStream
(
const
uno
::
Reference
<
uno
::
XComponentContext
>&
rxContext
,
ZipOutputStream
::
ZipOutputStream
(
const
uno
::
Reference
<
uno
::
XComponentContext
>&
rxContext
,
const
uno
::
Reference
<
XOutputStream
>
&
xOStream
)
const
uno
::
Reference
<
XOutputStream
>
&
xOStream
)
:
m_xContext
(
rxContext
)
:
m_xContext
(
rxContext
)
,
xStream
(
xOStream
)
,
m_
xStream
(
xOStream
)
,
m_aDeflateBuffer
(
n_ConstBufferSize
)
,
m_aDeflateBuffer
(
n_ConstBufferSize
)
,
aDeflater
(
DEFAULT_COMPRESSION
,
true
)
,
m_
aDeflater
(
DEFAULT_COMPRESSION
,
true
)
,
aChucker
(
xOStream
)
,
m_
aChucker
(
xOStream
)
,
pCurrentEntry
(
NULL
)
,
m_
pCurrentEntry
(
NULL
)
,
nMethod
(
DEFLATED
)
,
m_
nMethod
(
DEFLATED
)
,
nLevel
(
0
)
,
m_
nLevel
(
0
)
,
mnDigested
(
0
)
,
m
_
nDigested
(
0
)
,
bFinished
(
false
)
,
m_
bFinished
(
false
)
,
bEncryptCurrentEntry
(
false
)
,
m_
bEncryptCurrentEntry
(
false
)
,
m_pCurrentStream
(
NULL
)
,
m_pCurrentStream
(
NULL
)
{
{
}
}
ZipOutputStream
::~
ZipOutputStream
(
void
)
ZipOutputStream
::~
ZipOutputStream
(
void
)
{
{
for
(
sal_Int32
i
=
0
,
nEnd
=
aZipList
.
size
();
i
<
nEnd
;
i
++
)
for
(
sal_Int32
i
=
0
,
nEnd
=
m_
aZipList
.
size
();
i
<
nEnd
;
i
++
)
delete
aZipList
[
i
];
delete
m_
aZipList
[
i
];
}
}
void
SAL_CALL
ZipOutputStream
::
setMethod
(
sal_Int32
nNewMethod
)
void
SAL_CALL
ZipOutputStream
::
setMethod
(
sal_Int32
nNewMethod
)
throw
(
RuntimeException
)
throw
(
RuntimeException
)
{
{
nMethod
=
static_cast
<
sal_Int16
>
(
nNewMethod
);
m_
nMethod
=
static_cast
<
sal_Int16
>
(
nNewMethod
);
}
}
void
SAL_CALL
ZipOutputStream
::
setLevel
(
sal_Int32
nNewLevel
)
void
SAL_CALL
ZipOutputStream
::
setLevel
(
sal_Int32
nNewLevel
)
throw
(
RuntimeException
)
throw
(
RuntimeException
)
{
{
aDeflater
.
setLevel
(
nNewLevel
);
m_
aDeflater
.
setLevel
(
nNewLevel
);
}
}
void
SAL_CALL
ZipOutputStream
::
putNextEntry
(
ZipEntry
&
rEntry
,
void
SAL_CALL
ZipOutputStream
::
putNextEntry
(
ZipEntry
&
rEntry
,
...
@@ -78,12 +76,12 @@ void SAL_CALL ZipOutputStream::putNextEntry( ZipEntry& rEntry,
...
@@ -78,12 +76,12 @@ void SAL_CALL ZipOutputStream::putNextEntry( ZipEntry& rEntry,
bool
bEncrypt
)
bool
bEncrypt
)
throw
(
IOException
,
RuntimeException
)
throw
(
IOException
,
RuntimeException
)
{
{
if
(
pCurrentEntry
!=
NULL
)
if
(
m_
pCurrentEntry
!=
NULL
)
closeEntry
();
closeEntry
();
if
(
rEntry
.
nTime
==
-
1
)
if
(
rEntry
.
nTime
==
-
1
)
rEntry
.
nTime
=
getCurrentDosTime
();
rEntry
.
nTime
=
getCurrentDosTime
();
if
(
rEntry
.
nMethod
==
-
1
)
if
(
rEntry
.
nMethod
==
-
1
)
rEntry
.
nMethod
=
nMethod
;
rEntry
.
nMethod
=
m_
nMethod
;
rEntry
.
nVersion
=
20
;
rEntry
.
nVersion
=
20
;
rEntry
.
nFlag
=
1
<<
11
;
rEntry
.
nFlag
=
1
<<
11
;
if
(
rEntry
.
nSize
==
-
1
||
rEntry
.
nCompressedSize
==
-
1
||
if
(
rEntry
.
nSize
==
-
1
||
rEntry
.
nCompressedSize
==
-
1
||
...
@@ -95,61 +93,61 @@ void SAL_CALL ZipOutputStream::putNextEntry( ZipEntry& rEntry,
...
@@ -95,61 +93,61 @@ void SAL_CALL ZipOutputStream::putNextEntry( ZipEntry& rEntry,
if
(
bEncrypt
)
if
(
bEncrypt
)
{
{
bEncryptCurrentEntry
=
true
;
m_
bEncryptCurrentEntry
=
true
;
m_xCipherContext
=
ZipFile
::
StaticGetCipher
(
m_xContext
,
pStream
->
GetEncryptionData
(),
true
);
m_xCipherContext
=
ZipFile
::
StaticGetCipher
(
m_xContext
,
pStream
->
GetEncryptionData
(),
true
);
m_xDigestContext
=
ZipFile
::
StaticGetDigestContextForChecksum
(
m_xContext
,
pStream
->
GetEncryptionData
()
);
m_xDigestContext
=
ZipFile
::
StaticGetDigestContextForChecksum
(
m_xContext
,
pStream
->
GetEncryptionData
()
);
mnDigested
=
0
;
m
_
nDigested
=
0
;
rEntry
.
nFlag
|=
1
<<
4
;
rEntry
.
nFlag
|=
1
<<
4
;
m_pCurrentStream
=
pStream
;
m_pCurrentStream
=
pStream
;
}
}
sal_Int32
nLOCLength
=
writeLOC
(
rEntry
);
sal_Int32
nLOCLength
=
writeLOC
(
rEntry
);
rEntry
.
nOffset
=
aChucker
.
GetPosition
()
-
nLOCLength
;
rEntry
.
nOffset
=
m_
aChucker
.
GetPosition
()
-
nLOCLength
;
aZipList
.
push_back
(
&
rEntry
);
m_
aZipList
.
push_back
(
&
rEntry
);
pCurrentEntry
=
&
rEntry
;
m_
pCurrentEntry
=
&
rEntry
;
}
}
void
SAL_CALL
ZipOutputStream
::
closeEntry
(
)
void
SAL_CALL
ZipOutputStream
::
closeEntry
(
)
throw
(
IOException
,
RuntimeException
)
throw
(
IOException
,
RuntimeException
)
{
{
ZipEntry
*
pEntry
=
pCurrentEntry
;
ZipEntry
*
pEntry
=
m_
pCurrentEntry
;
if
(
pEntry
)
if
(
pEntry
)
{
{
switch
(
pEntry
->
nMethod
)
switch
(
pEntry
->
nMethod
)
{
{
case
DEFLATED
:
case
DEFLATED
:
aDeflater
.
finish
();
m_
aDeflater
.
finish
();
while
(
!
aDeflater
.
finished
())
while
(
!
m_
aDeflater
.
finished
())
doDeflate
();
doDeflate
();
if
((
pEntry
->
nFlag
&
8
)
==
0
)
if
((
pEntry
->
nFlag
&
8
)
==
0
)
{
{
if
(
pEntry
->
nSize
!=
aDeflater
.
getTotalIn
())
if
(
pEntry
->
nSize
!=
m_
aDeflater
.
getTotalIn
())
{
{
OSL_FAIL
(
"Invalid entry size"
);
OSL_FAIL
(
"Invalid entry size"
);
}
}
if
(
pEntry
->
nCompressedSize
!=
aDeflater
.
getTotalOut
())
if
(
pEntry
->
nCompressedSize
!=
m_
aDeflater
.
getTotalOut
())
{
{
// Different compression strategies make the merit of this
// Different compression strategies make the merit of this
// test somewhat dubious
// test somewhat dubious
pEntry
->
nCompressedSize
=
aDeflater
.
getTotalOut
();
pEntry
->
nCompressedSize
=
m_
aDeflater
.
getTotalOut
();
}
}
if
(
pEntry
->
nCrc
!=
aCRC
.
getValue
())
if
(
pEntry
->
nCrc
!=
m_
aCRC
.
getValue
())
{
{
OSL_FAIL
(
"Invalid entry CRC-32"
);
OSL_FAIL
(
"Invalid entry CRC-32"
);
}
}
}
}
else
else
{
{
if
(
!
bEncryptCurrentEntry
)
if
(
!
m_
bEncryptCurrentEntry
)
{
{
pEntry
->
nSize
=
aDeflater
.
getTotalIn
();
pEntry
->
nSize
=
m_
aDeflater
.
getTotalIn
();
pEntry
->
nCompressedSize
=
aDeflater
.
getTotalOut
();
pEntry
->
nCompressedSize
=
m_
aDeflater
.
getTotalOut
();
}
}
pEntry
->
nCrc
=
aCRC
.
getValue
();
pEntry
->
nCrc
=
m_
aCRC
.
getValue
();
writeEXT
(
*
pEntry
);
writeEXT
(
*
pEntry
);
}
}
aDeflater
.
reset
();
m_
aDeflater
.
reset
();
aCRC
.
reset
();
m_
aCRC
.
reset
();
break
;
break
;
case
STORED
:
case
STORED
:
if
(
!
((
pEntry
->
nFlag
&
8
)
==
0
))
if
(
!
((
pEntry
->
nFlag
&
8
)
==
0
))
...
@@ -160,9 +158,9 @@ void SAL_CALL ZipOutputStream::closeEntry( )
...
@@ -160,9 +158,9 @@ void SAL_CALL ZipOutputStream::closeEntry( )
break
;
break
;
}
}
if
(
bEncryptCurrentEntry
)
if
(
m_
bEncryptCurrentEntry
)
{
{
bEncryptCurrentEntry
=
false
;
m_
bEncryptCurrentEntry
=
false
;
m_xCipherContext
.
clear
();
m_xCipherContext
.
clear
();
...
@@ -176,7 +174,7 @@ void SAL_CALL ZipOutputStream::closeEntry( )
...
@@ -176,7 +174,7 @@ void SAL_CALL ZipOutputStream::closeEntry( )
if
(
m_pCurrentStream
)
if
(
m_pCurrentStream
)
m_pCurrentStream
->
setDigest
(
aDigestSeq
);
m_pCurrentStream
->
setDigest
(
aDigestSeq
);
}
}
pCurrentEntry
=
NULL
;
m_
pCurrentEntry
=
NULL
;
m_pCurrentStream
=
NULL
;
m_pCurrentStream
=
NULL
;
}
}
}
}
...
@@ -184,22 +182,22 @@ void SAL_CALL ZipOutputStream::closeEntry( )
...
@@ -184,22 +182,22 @@ void SAL_CALL ZipOutputStream::closeEntry( )
void
SAL_CALL
ZipOutputStream
::
write
(
const
Sequence
<
sal_Int8
>&
rBuffer
,
sal_Int32
nNewOffset
,
sal_Int32
nNewLength
)
void
SAL_CALL
ZipOutputStream
::
write
(
const
Sequence
<
sal_Int8
>&
rBuffer
,
sal_Int32
nNewOffset
,
sal_Int32
nNewLength
)
throw
(
IOException
,
RuntimeException
)
throw
(
IOException
,
RuntimeException
)
{
{
switch
(
pCurrentEntry
->
nMethod
)
switch
(
m_
pCurrentEntry
->
nMethod
)
{
{
case
DEFLATED
:
case
DEFLATED
:
if
(
!
aDeflater
.
finished
())
if
(
!
m_
aDeflater
.
finished
())
{
{
aDeflater
.
setInputSegment
(
rBuffer
,
nNewOffset
,
nNewLength
);
m_
aDeflater
.
setInputSegment
(
rBuffer
,
nNewOffset
,
nNewLength
);
while
(
!
aDeflater
.
needsInput
())
while
(
!
m_
aDeflater
.
needsInput
())
doDeflate
();
doDeflate
();
if
(
!
bEncryptCurrentEntry
)
if
(
!
m_
bEncryptCurrentEntry
)
aCRC
.
updateSegment
(
rBuffer
,
nNewOffset
,
nNewLength
);
m_
aCRC
.
updateSegment
(
rBuffer
,
nNewOffset
,
nNewLength
);
}
}
break
;
break
;
case
STORED
:
case
STORED
:
{
{
Sequence
<
sal_Int8
>
aTmpBuffer
(
rBuffer
.
getConstArray
(),
nNewLength
);
Sequence
<
sal_Int8
>
aTmpBuffer
(
rBuffer
.
getConstArray
(),
nNewLength
);
aChucker
.
WriteBytes
(
aTmpBuffer
);
m_
aChucker
.
WriteBytes
(
aTmpBuffer
);
}
}
break
;
break
;
}
}
...
@@ -209,84 +207,84 @@ void SAL_CALL ZipOutputStream::rawWrite( Sequence< sal_Int8 >& rBuffer, sal_Int3
...
@@ -209,84 +207,84 @@ void SAL_CALL ZipOutputStream::rawWrite( Sequence< sal_Int8 >& rBuffer, sal_Int3
throw
(
IOException
,
RuntimeException
)
throw
(
IOException
,
RuntimeException
)
{
{
Sequence
<
sal_Int8
>
aTmpBuffer
(
rBuffer
.
getConstArray
(),
nNewLength
);
Sequence
<
sal_Int8
>
aTmpBuffer
(
rBuffer
.
getConstArray
(),
nNewLength
);
aChucker
.
WriteBytes
(
aTmpBuffer
);
m_
aChucker
.
WriteBytes
(
aTmpBuffer
);
}
}
void
SAL_CALL
ZipOutputStream
::
rawCloseEntry
(
)
void
SAL_CALL
ZipOutputStream
::
rawCloseEntry
(
)
throw
(
IOException
,
RuntimeException
)
throw
(
IOException
,
RuntimeException
)
{
{
if
(
pCurrentEntry
->
nMethod
==
DEFLATED
&&
(
pCurrentEntry
->
nFlag
&
8
)
)
if
(
m_pCurrentEntry
->
nMethod
==
DEFLATED
&&
(
m_
pCurrentEntry
->
nFlag
&
8
)
)
writeEXT
(
*
pCurrentEntry
);
writeEXT
(
*
m_
pCurrentEntry
);
pCurrentEntry
=
NULL
;
m_
pCurrentEntry
=
NULL
;
}
}
void
SAL_CALL
ZipOutputStream
::
finish
(
)
void
SAL_CALL
ZipOutputStream
::
finish
(
)
throw
(
IOException
,
RuntimeException
)
throw
(
IOException
,
RuntimeException
)
{
{
if
(
bFinished
)
if
(
m_
bFinished
)
return
;
return
;
if
(
pCurrentEntry
!=
NULL
)
if
(
m_
pCurrentEntry
!=
NULL
)
closeEntry
();
closeEntry
();
if
(
aZipList
.
size
()
<
1
)
if
(
m_
aZipList
.
size
()
<
1
)
OSL_FAIL
(
"Zip file must have at least one entry!
\n
"
);
OSL_FAIL
(
"Zip file must have at least one entry!
\n
"
);
sal_Int32
nOffset
=
static_cast
<
sal_Int32
>
(
aChucker
.
GetPosition
());
sal_Int32
nOffset
=
static_cast
<
sal_Int32
>
(
m_
aChucker
.
GetPosition
());
for
(
sal_Int32
i
=
0
,
nEnd
=
aZipList
.
size
();
i
<
nEnd
;
i
++
)
for
(
sal_Int32
i
=
0
,
nEnd
=
m_
aZipList
.
size
();
i
<
nEnd
;
i
++
)
writeCEN
(
*
aZipList
[
i
]
);
writeCEN
(
*
m_
aZipList
[
i
]
);
writeEND
(
nOffset
,
static_cast
<
sal_Int32
>
(
aChucker
.
GetPosition
())
-
nOffset
);
writeEND
(
nOffset
,
static_cast
<
sal_Int32
>
(
m_
aChucker
.
GetPosition
())
-
nOffset
);
bFinished
=
true
;
m_
bFinished
=
true
;
xStream
->
flush
();
m_
xStream
->
flush
();
}
}
void
ZipOutputStream
::
doDeflate
()
void
ZipOutputStream
::
doDeflate
()
{
{
sal_Int32
nLength
=
aDeflater
.
doDeflateSegment
(
m_aDeflateBuffer
,
0
,
m_aDeflateBuffer
.
getLength
());
sal_Int32
nLength
=
m_
aDeflater
.
doDeflateSegment
(
m_aDeflateBuffer
,
0
,
m_aDeflateBuffer
.
getLength
());
if
(
nLength
>
0
)
if
(
nLength
>
0
)
{
{
uno
::
Sequence
<
sal_Int8
>
aTmpBuffer
(
m_aDeflateBuffer
.
getConstArray
(),
nLength
);
uno
::
Sequence
<
sal_Int8
>
aTmpBuffer
(
m_aDeflateBuffer
.
getConstArray
(),
nLength
);
if
(
bEncryptCurrentEntry
&&
m_xDigestContext
.
is
()
&&
m_xCipherContext
.
is
()
)
if
(
m_
bEncryptCurrentEntry
&&
m_xDigestContext
.
is
()
&&
m_xCipherContext
.
is
()
)
{
{
// Need to update our digest before encryption...
// Need to update our digest before encryption...
sal_Int32
nDiff
=
n_ConstDigestLength
-
mnDigested
;
sal_Int32
nDiff
=
n_ConstDigestLength
-
m
_
nDigested
;
if
(
nDiff
)
if
(
nDiff
)
{
{
sal_Int32
nEat
=
::
std
::
min
(
nLength
,
nDiff
);
sal_Int32
nEat
=
::
std
::
min
(
nLength
,
nDiff
);
uno
::
Sequence
<
sal_Int8
>
aTmpSeq
(
aTmpBuffer
.
getConstArray
(),
nEat
);
uno
::
Sequence
<
sal_Int8
>
aTmpSeq
(
aTmpBuffer
.
getConstArray
(),
nEat
);
m_xDigestContext
->
updateDigest
(
aTmpSeq
);
m_xDigestContext
->
updateDigest
(
aTmpSeq
);
m
nDigested
=
m
nDigested
+
static_cast
<
sal_Int16
>
(
nEat
);
m
_nDigested
=
m_
nDigested
+
static_cast
<
sal_Int16
>
(
nEat
);
}
}
// FIXME64: uno::Sequence not 64bit safe.
// FIXME64: uno::Sequence not 64bit safe.
uno
::
Sequence
<
sal_Int8
>
aEncryptionBuffer
=
m_xCipherContext
->
convertWithCipherContext
(
aTmpBuffer
);
uno
::
Sequence
<
sal_Int8
>
aEncryptionBuffer
=
m_xCipherContext
->
convertWithCipherContext
(
aTmpBuffer
);
aChucker
.
WriteBytes
(
aEncryptionBuffer
);
m_
aChucker
.
WriteBytes
(
aEncryptionBuffer
);
// the sizes as well as checksum for encrypted streams is calculated here
// the sizes as well as checksum for encrypted streams is calculated here
pCurrentEntry
->
nCompressedSize
+=
aEncryptionBuffer
.
getLength
();
m_
pCurrentEntry
->
nCompressedSize
+=
aEncryptionBuffer
.
getLength
();
pCurrentEntry
->
nSize
=
pCurrentEntry
->
nCompressedSize
;
m_pCurrentEntry
->
nSize
=
m_
pCurrentEntry
->
nCompressedSize
;
aCRC
.
update
(
aEncryptionBuffer
);
m_
aCRC
.
update
(
aEncryptionBuffer
);
}
}
else
else
{
{
aChucker
.
WriteBytes
(
aTmpBuffer
);
m_
aChucker
.
WriteBytes
(
aTmpBuffer
);
}
}
}
}
if
(
aDeflater
.
finished
()
&&
bEncryptCurrentEntry
&&
m_xDigestContext
.
is
()
&&
m_xCipherContext
.
is
()
)
if
(
m_aDeflater
.
finished
()
&&
m_
bEncryptCurrentEntry
&&
m_xDigestContext
.
is
()
&&
m_xCipherContext
.
is
()
)
{
{
// FIXME64: sequence not 64bit safe.
// FIXME64: sequence not 64bit safe.
uno
::
Sequence
<
sal_Int8
>
aEncryptionBuffer
=
m_xCipherContext
->
finalizeCipherContextAndDispose
();
uno
::
Sequence
<
sal_Int8
>
aEncryptionBuffer
=
m_xCipherContext
->
finalizeCipherContextAndDispose
();
if
(
aEncryptionBuffer
.
getLength
()
)
if
(
aEncryptionBuffer
.
getLength
()
)
{
{
aChucker
.
WriteBytes
(
aEncryptionBuffer
);
m_
aChucker
.
WriteBytes
(
aEncryptionBuffer
);
// the sizes as well as checksum for encrypted streams is calculated hier
// the sizes as well as checksum for encrypted streams is calculated hier
pCurrentEntry
->
nCompressedSize
+=
aEncryptionBuffer
.
getLength
();
m_
pCurrentEntry
->
nCompressedSize
+=
aEncryptionBuffer
.
getLength
();
pCurrentEntry
->
nSize
=
pCurrentEntry
->
nCompressedSize
;
m_pCurrentEntry
->
nSize
=
m_
pCurrentEntry
->
nCompressedSize
;
aCRC
.
update
(
aEncryptionBuffer
);
m_
aCRC
.
update
(
aEncryptionBuffer
);
}
}
}
}
}
}
...
@@ -294,14 +292,14 @@ void ZipOutputStream::doDeflate()
...
@@ -294,14 +292,14 @@ void ZipOutputStream::doDeflate()
void
ZipOutputStream
::
writeEND
(
sal_uInt32
nOffset
,
sal_uInt32
nLength
)
void
ZipOutputStream
::
writeEND
(
sal_uInt32
nOffset
,
sal_uInt32
nLength
)
throw
(
IOException
,
RuntimeException
)
throw
(
IOException
,
RuntimeException
)
{
{
aChucker
<<
ENDSIG
;
m_
aChucker
<<
ENDSIG
;
aChucker
<<
static_cast
<
sal_Int16
>
(
0
);
m_
aChucker
<<
static_cast
<
sal_Int16
>
(
0
);
aChucker
<<
static_cast
<
sal_Int16
>
(
0
);
m_
aChucker
<<
static_cast
<
sal_Int16
>
(
0
);
aChucker
<<
static_cast
<
sal_Int16
>
(
aZipList
.
size
()
);
m_aChucker
<<
static_cast
<
sal_Int16
>
(
m_
aZipList
.
size
()
);
aChucker
<<
static_cast
<
sal_Int16
>
(
aZipList
.
size
()
);
m_aChucker
<<
static_cast
<
sal_Int16
>
(
m_
aZipList
.
size
()
);
aChucker
<<
nLength
;
m_
aChucker
<<
nLength
;
aChucker
<<
nOffset
;
m_
aChucker
<<
nOffset
;
aChucker
<<
static_cast
<
sal_Int16
>
(
0
);
m_
aChucker
<<
static_cast
<
sal_Int16
>
(
0
);
}
}
static
sal_uInt32
getTruncated
(
sal_Int64
nNum
,
bool
*
pIsTruncated
)
static
sal_uInt32
getTruncated
(
sal_Int64
nNum
,
bool
*
pIsTruncated
)
...
@@ -324,35 +322,35 @@ void ZipOutputStream::writeCEN( const ZipEntry &rEntry )
...
@@ -324,35 +322,35 @@ void ZipOutputStream::writeCEN( const ZipEntry &rEntry )
OString
sUTF8Name
=
OUStringToOString
(
rEntry
.
sPath
,
RTL_TEXTENCODING_UTF8
);
OString
sUTF8Name
=
OUStringToOString
(
rEntry
.
sPath
,
RTL_TEXTENCODING_UTF8
);
sal_Int16
nNameLength
=
static_cast
<
sal_Int16
>
(
sUTF8Name
.
getLength
()
);
sal_Int16
nNameLength
=
static_cast
<
sal_Int16
>
(
sUTF8Name
.
getLength
()
);
aChucker
<<
CENSIG
;
m_
aChucker
<<
CENSIG
;
aChucker
<<
rEntry
.
nVersion
;
m_
aChucker
<<
rEntry
.
nVersion
;
aChucker
<<
rEntry
.
nVersion
;
m_
aChucker
<<
rEntry
.
nVersion
;
if
(
rEntry
.
nFlag
&
(
1
<<
4
)
)
if
(
rEntry
.
nFlag
&
(
1
<<
4
)
)
{
{
// If it's an encrypted entry, we pretend its stored plain text
// If it's an encrypted entry, we pretend its stored plain text
ZipEntry
*
pEntry
=
const_cast
<
ZipEntry
*
>
(
&
rEntry
);
ZipEntry
*
pEntry
=
const_cast
<
ZipEntry
*
>
(
&
rEntry
);
pEntry
->
nFlag
&=
~
(
1
<<
4
);
pEntry
->
nFlag
&=
~
(
1
<<
4
);
aChucker
<<
rEntry
.
nFlag
;
m_
aChucker
<<
rEntry
.
nFlag
;
aChucker
<<
static_cast
<
sal_Int16
>
(
STORED
);
m_
aChucker
<<
static_cast
<
sal_Int16
>
(
STORED
);
}
}
else
else
{
{
aChucker
<<
rEntry
.
nFlag
;
m_
aChucker
<<
rEntry
.
nFlag
;
aChucker
<<
rEntry
.
nMethod
;
m_
aChucker
<<
rEntry
.
nMethod
;
}
}
bool
bWrite64Header
=
false
;
bool
bWrite64Header
=
false
;
aChucker
<<
static_cast
<
sal_uInt32
>
(
rEntry
.
nTime
);
m_
aChucker
<<
static_cast
<
sal_uInt32
>
(
rEntry
.
nTime
);
aChucker
<<
static_cast
<
sal_uInt32
>
(
rEntry
.
nCrc
);
m_
aChucker
<<
static_cast
<
sal_uInt32
>
(
rEntry
.
nCrc
);
aChucker
<<
getTruncated
(
rEntry
.
nCompressedSize
,
&
bWrite64Header
);
m_
aChucker
<<
getTruncated
(
rEntry
.
nCompressedSize
,
&
bWrite64Header
);
aChucker
<<
getTruncated
(
rEntry
.
nSize
,
&
bWrite64Header
);
m_
aChucker
<<
getTruncated
(
rEntry
.
nSize
,
&
bWrite64Header
);
aChucker
<<
nNameLength
;
m_
aChucker
<<
nNameLength
;
aChucker
<<
static_cast
<
sal_Int16
>
(
0
);
m_
aChucker
<<
static_cast
<
sal_Int16
>
(
0
);
aChucker
<<
static_cast
<
sal_Int16
>
(
0
);
m_
aChucker
<<
static_cast
<
sal_Int16
>
(
0
);
aChucker
<<
static_cast
<
sal_Int16
>
(
0
);
m_
aChucker
<<
static_cast
<
sal_Int16
>
(
0
);
aChucker
<<
static_cast
<
sal_Int16
>
(
0
);
m_
aChucker
<<
static_cast
<
sal_Int16
>
(
0
);
aChucker
<<
static_cast
<
sal_Int32
>
(
0
);
m_
aChucker
<<
static_cast
<
sal_Int32
>
(
0
);
aChucker
<<
getTruncated
(
rEntry
.
nOffset
,
&
bWrite64Header
);
m_
aChucker
<<
getTruncated
(
rEntry
.
nOffset
,
&
bWrite64Header
);
if
(
bWrite64Header
)
if
(
bWrite64Header
)
{
{
...
@@ -363,17 +361,17 @@ void ZipOutputStream::writeCEN( const ZipEntry &rEntry )
...
@@ -363,17 +361,17 @@ void ZipOutputStream::writeCEN( const ZipEntry &rEntry )
}
}
Sequence
<
sal_Int8
>
aSequence
(
(
sal_Int8
*
)
sUTF8Name
.
getStr
(),
sUTF8Name
.
getLength
()
);
Sequence
<
sal_Int8
>
aSequence
(
(
sal_Int8
*
)
sUTF8Name
.
getStr
(),
sUTF8Name
.
getLength
()
);
aChucker
.
WriteBytes
(
aSequence
);
m_
aChucker
.
WriteBytes
(
aSequence
);
}
}
void
ZipOutputStream
::
writeEXT
(
const
ZipEntry
&
rEntry
)
void
ZipOutputStream
::
writeEXT
(
const
ZipEntry
&
rEntry
)
throw
(
IOException
,
RuntimeException
)
throw
(
IOException
,
RuntimeException
)
{
{
bool
bWrite64Header
=
false
;
bool
bWrite64Header
=
false
;
aChucker
<<
EXTSIG
;
m_
aChucker
<<
EXTSIG
;
aChucker
<<
static_cast
<
sal_uInt32
>
(
rEntry
.
nCrc
);
m_
aChucker
<<
static_cast
<
sal_uInt32
>
(
rEntry
.
nCrc
);
aChucker
<<
getTruncated
(
rEntry
.
nCompressedSize
,
&
bWrite64Header
);
m_
aChucker
<<
getTruncated
(
rEntry
.
nCompressedSize
,
&
bWrite64Header
);
aChucker
<<
getTruncated
(
rEntry
.
nSize
,
&
bWrite64Header
);
m_
aChucker
<<
getTruncated
(
rEntry
.
nSize
,
&
bWrite64Header
);
if
(
bWrite64Header
)
if
(
bWrite64Header
)
{
{
...
@@ -393,40 +391,40 @@ sal_Int32 ZipOutputStream::writeLOC( const ZipEntry &rEntry )
...
@@ -393,40 +391,40 @@ sal_Int32 ZipOutputStream::writeLOC( const ZipEntry &rEntry )
OString
sUTF8Name
=
OUStringToOString
(
rEntry
.
sPath
,
RTL_TEXTENCODING_UTF8
);
OString
sUTF8Name
=
OUStringToOString
(
rEntry
.
sPath
,
RTL_TEXTENCODING_UTF8
);
sal_Int16
nNameLength
=
static_cast
<
sal_Int16
>
(
sUTF8Name
.
getLength
()
);
sal_Int16
nNameLength
=
static_cast
<
sal_Int16
>
(
sUTF8Name
.
getLength
()
);
aChucker
<<
LOCSIG
;
m_
aChucker
<<
LOCSIG
;
aChucker
<<
rEntry
.
nVersion
;
m_
aChucker
<<
rEntry
.
nVersion
;
if
(
rEntry
.
nFlag
&
(
1
<<
4
)
)
if
(
rEntry
.
nFlag
&
(
1
<<
4
)
)
{
{
// If it's an encrypted entry, we pretend its stored plain text
// If it's an encrypted entry, we pretend its stored plain text
sal_Int16
nTmpFlag
=
rEntry
.
nFlag
;
sal_Int16
nTmpFlag
=
rEntry
.
nFlag
;
nTmpFlag
&=
~
(
1
<<
4
);
nTmpFlag
&=
~
(
1
<<
4
);
aChucker
<<
nTmpFlag
;
m_
aChucker
<<
nTmpFlag
;
aChucker
<<
static_cast
<
sal_Int16
>
(
STORED
);
m_
aChucker
<<
static_cast
<
sal_Int16
>
(
STORED
);
}
}
else
else
{
{
aChucker
<<
rEntry
.
nFlag
;
m_
aChucker
<<
rEntry
.
nFlag
;
aChucker
<<
rEntry
.
nMethod
;
m_
aChucker
<<
rEntry
.
nMethod
;
}
}
bool
bWrite64Header
=
false
;
bool
bWrite64Header
=
false
;
aChucker
<<
static_cast
<
sal_uInt32
>
(
rEntry
.
nTime
);
m_
aChucker
<<
static_cast
<
sal_uInt32
>
(
rEntry
.
nTime
);
if
((
rEntry
.
nFlag
&
8
)
==
8
)
if
((
rEntry
.
nFlag
&
8
)
==
8
)
{
{
aChucker
<<
static_cast
<
sal_Int32
>
(
0
);
m_
aChucker
<<
static_cast
<
sal_Int32
>
(
0
);
aChucker
<<
static_cast
<
sal_Int32
>
(
0
);
m_
aChucker
<<
static_cast
<
sal_Int32
>
(
0
);
aChucker
<<
static_cast
<
sal_Int32
>
(
0
);
m_
aChucker
<<
static_cast
<
sal_Int32
>
(
0
);
}
}
else
else
{
{
aChucker
<<
static_cast
<
sal_uInt32
>
(
rEntry
.
nCrc
);
m_
aChucker
<<
static_cast
<
sal_uInt32
>
(
rEntry
.
nCrc
);
aChucker
<<
getTruncated
(
rEntry
.
nCompressedSize
,
&
bWrite64Header
);
m_
aChucker
<<
getTruncated
(
rEntry
.
nCompressedSize
,
&
bWrite64Header
);
aChucker
<<
getTruncated
(
rEntry
.
nSize
,
&
bWrite64Header
);
m_
aChucker
<<
getTruncated
(
rEntry
.
nSize
,
&
bWrite64Header
);
}
}
aChucker
<<
nNameLength
;
m_
aChucker
<<
nNameLength
;
aChucker
<<
static_cast
<
sal_Int16
>
(
0
);
m_
aChucker
<<
static_cast
<
sal_Int16
>
(
0
);
if
(
bWrite64Header
)
if
(
bWrite64Header
)
{
{
...
@@ -437,7 +435,7 @@ sal_Int32 ZipOutputStream::writeLOC( const ZipEntry &rEntry )
...
@@ -437,7 +435,7 @@ sal_Int32 ZipOutputStream::writeLOC( const ZipEntry &rEntry )
}
}
Sequence
<
sal_Int8
>
aSequence
(
(
sal_Int8
*
)
sUTF8Name
.
getStr
(),
sUTF8Name
.
getLength
()
);
Sequence
<
sal_Int8
>
aSequence
(
(
sal_Int8
*
)
sUTF8Name
.
getStr
(),
sUTF8Name
.
getLength
()
);
aChucker
.
WriteBytes
(
aSequence
);
m_
aChucker
.
WriteBytes
(
aSequence
);
return
LOCHDR
+
nNameLength
;
return
LOCHDR
+
nNameLength
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment