6 #include "7zCompressionMode.h"
\r
7 #include "7zEncode.h"
\r
8 #include "7zHeader.h"
\r
11 #include "../../Common/OutBuffer.h"
\r
13 namespace NArchive {
\r
16 class CWriteBufferLoc
\r
22 CWriteBufferLoc(): _size(0), _pos(0) {}
\r
23 void Init(Byte *data, size_t size)
\r
29 void WriteBytes(const void *data, size_t size)
\r
31 if (size > _size - _pos)
\r
33 memcpy(_data + _pos, data, size);
\r
36 void WriteByte(Byte b)
\r
42 size_t GetPos() const { return _pos; }
\r
45 struct CHeaderOptions
\r
47 bool CompressMainHeader;
\r
53 CompressMainHeader(true),
\r
62 UInt64 _prefixHeaderPos;
\r
64 HRESULT WriteDirect(const void *data, UInt32 size);
\r
66 UInt64 GetPos() const;
\r
67 void WriteBytes(const void *data, size_t size);
\r
68 void WriteBytes(const CByteBuffer &data) { WriteBytes(data, data.GetCapacity()); }
\r
69 void WriteByte(Byte b);
\r
70 void WriteUInt32(UInt32 value);
\r
71 void WriteUInt64(UInt64 value);
\r
72 void WriteNumber(UInt64 value);
\r
73 void WriteID(UInt64 value) { WriteNumber(value); }
\r
75 void WriteFolder(const CFolder &folder);
\r
76 HRESULT WriteFileHeader(const CFileItem &itemInfo);
\r
77 void WriteBoolVector(const CBoolVector &boolVector);
\r
78 void WriteHashDigests(
\r
79 const CRecordVector<bool> &digestsDefined,
\r
80 const CRecordVector<UInt32> &hashDigests);
\r
84 const CRecordVector<UInt64> &packSizes,
\r
85 const CRecordVector<bool> &packCRCsDefined,
\r
86 const CRecordVector<UInt32> &packCRCs);
\r
88 void WriteUnpackInfo(const CObjectVector<CFolder> &folders);
\r
90 void WriteSubStreamsInfo(
\r
91 const CObjectVector<CFolder> &folders,
\r
92 const CRecordVector<CNum> &numUnpackStreamsInFolders,
\r
93 const CRecordVector<UInt64> &unpackSizes,
\r
94 const CRecordVector<bool> &digestsDefined,
\r
95 const CRecordVector<UInt32> &hashDigests);
\r
97 void SkipAlign(unsigned pos, unsigned alignSize);
\r
98 void WriteAlignedBoolHeader(const CBoolVector &v, int numDefined, Byte type, unsigned itemSize);
\r
99 void WriteUInt64DefVector(const CUInt64DefVector &v, Byte type);
\r
101 HRESULT EncodeStream(
\r
102 DECL_EXTERNAL_CODECS_LOC_VARS
\r
103 CEncoder &encoder, const CByteBuffer &data,
\r
104 CRecordVector<UInt64> &packSizes, CObjectVector<CFolder> &folders);
\r
106 const CArchiveDatabase &db,
\r
107 const CHeaderOptions &headerOptions,
\r
108 UInt64 &headerOffset);
\r
111 bool _writeToStream;
\r
114 COutBuffer _outByte;
\r
115 CWriteBufferLoc _outByte2;
\r
121 HRESULT WriteSignature();
\r
123 HRESULT WriteFinishSignature();
\r
125 HRESULT WriteStartHeader(const CStartHeader &h);
\r
127 HRESULT WriteFinishHeader(const CFinishHeader &h);
\r
129 CMyComPtr<IOutStream> Stream;
\r
132 COutArchive() { _outByte.Create(1 << 16); }
\r
133 CMyComPtr<ISequentialOutStream> SeqStream;
\r
134 HRESULT Create(ISequentialOutStream *stream, bool endMarker);
\r
136 HRESULT SkipPrefixArchiveHeader();
\r
137 HRESULT WriteDatabase(
\r
138 DECL_EXTERNAL_CODECS_LOC_VARS
\r
139 const CArchiveDatabase &db,
\r
140 const CCompressionMethodMode *options,
\r
141 const CHeaderOptions &headerOptions);
\r
144 static UInt32 GetVolHeadersSize(UInt64 dataSize, int nameLength = 0, bool props = false);
\r
145 static UInt64 GetVolPureSize(UInt64 volSize, int nameLength = 0, bool props = false);
\r