blob: 056d0d094dd3a48dcb3c10dfa3611dd13807e224 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
// ZipOut.h
#ifndef __ZIP_OUT_H
#define __ZIP_OUT_H
#include "../../../Common/MyCom.h"
#include "../../IStream.h"
#include "../../Common/OutBuffer.h"
#include "ZipItem.h"
namespace NArchive {
namespace NZip {
// can throw CSystemException and COutBufferException
class CItemOut: public CItem
{
public:
FILETIME Ntfs_MTime;
FILETIME Ntfs_ATime;
FILETIME Ntfs_CTime;
bool NtfsTimeIsDefined;
// It's possible that NtfsTime is not defined, but there is NtfsTime in Extra.
CItemOut(): NtfsTimeIsDefined(false) {}
};
class COutArchive
{
CMyComPtr<IOutStream> m_Stream;
COutBuffer m_OutBuffer;
UInt64 m_Base; // Base of arc (offset in output Stream)
UInt64 m_CurPos; // Curent position in archive (relative from m_Base)
UInt32 m_LocalFileHeaderSize;
UInt32 m_ExtraSize;
bool m_IsZip64;
void SeekToRelatPos(UInt64 offset);
void WriteBytes(const void *buffer, UInt32 size);
void Write8(Byte b);
void Write16(UInt16 val);
void Write32(UInt32 val);
void Write64(UInt64 val);
void WriteNtfsTime(const FILETIME &ft)
{
Write32(ft.dwLowDateTime);
Write32(ft.dwHighDateTime);
}
void WriteExtra(const CExtraBlock &extra);
void WriteCommonItemInfo(const CLocalItem &item, bool isZip64);
void WriteCentralHeader(const CItemOut &item);
void PrepareWriteCompressedDataZip64(unsigned fileNameLen, bool isZip64, bool aesEncryption);
public:
HRESULT Create(IOutStream *outStream);
void MoveCurPos(UInt64 distanceToMove);
UInt64 GetCurPos() const { return m_CurPos; }
void SeekToCurPos();
void PrepareWriteCompressedData(unsigned fileNameLen, UInt64 unPackSize, bool aesEncryption);
void PrepareWriteCompressedData2(unsigned fileNameLen, UInt64 unPackSize, UInt64 packSize, bool aesEncryption);
void WriteLocalHeader(const CLocalItem &item);
void WriteLocalHeader_And_SeekToNextFile(const CLocalItem &item)
{
WriteLocalHeader(item);
SeekToCurPos();
}
void WriteCentralDir(const CObjectVector<CItemOut> &items, const CByteBuffer *comment);
void CreateStreamForCompressing(IOutStream **outStream);
void CreateStreamForCopying(ISequentialOutStream **outStream);
};
}}
#endif
|