|
1 // fzipup.cpp |
|
2 // |
|
3 // Copyright (c) 2008 - 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "Eclipse Public License v1.0" |
|
6 // which accompanies this distribution, and is available |
|
7 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 // |
|
9 // Initial Contributors: |
|
10 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 #include <ezstream.h> |
|
14 #include <ezcompressor.h> |
|
15 #include <ezdecompressor.h> |
|
16 #include <ezfilebuffer.h> |
|
17 #include <f32file.h> |
|
18 #include "fzipup.h" |
|
19 |
|
20 const TInt KDefaultDiskNumber = 0; |
|
21 const TInt CZipEntry::iOffset = _FOFF(CZipEntry, iLink); |
|
22 const TUint16 KFZipVersion = 0x0014; |
|
23 TInt KWindowBits = -CEZCompressor::EMaxWBits; // negative value is an undocumented feature of our zlib implementation, ensuring we do not include the zlib header in the compressed data (which we must do for zip-file format support) |
|
24 const TInt KCompressedSizeRelativePosition = 18; // iCompressedSize is 18 bytes in from the current entry's LFH |
|
25 |
|
26 // |
|
27 // CBufferManager |
|
28 // |
|
29 CBufferManager *CBufferManager::NewLC(RFileReadStream& aInput, RFileWriteStream& aOutput, TInt aInputStreamBytes, TInt aBufferSize) |
|
30 { |
|
31 CBufferManager *bm = new (ELeave) CBufferManager(aInput, aOutput, aInputStreamBytes, aBufferSize); |
|
32 CleanupStack::PushL(bm); |
|
33 bm->ConstructL(); |
|
34 return bm; |
|
35 } |
|
36 |
|
37 CBufferManager::CBufferManager(RFileReadStream& aInput, RFileWriteStream& aOutput, TInt aInputStreamBytes, TInt aBufferSize) |
|
38 :iInput(aInput), iOutput(aOutput), iInputStreamBytes(aInputStreamBytes), iBufferSize(aBufferSize), iInputDescriptor(NULL,0), iOutputDescriptor(NULL,0) |
|
39 { |
|
40 } |
|
41 |
|
42 CBufferManager::~CBufferManager() |
|
43 { |
|
44 delete[] iInputBuffer; |
|
45 delete[] iOutputBuffer; |
|
46 } |
|
47 |
|
48 void CBufferManager::ConstructL() |
|
49 { |
|
50 if (iInputStreamBytes < iBufferSize) |
|
51 iBufferSize = iInputStreamBytes; |
|
52 if (iBufferSize <=0) |
|
53 { |
|
54 User::Leave(KErrUnderflow); |
|
55 } |
|
56 |
|
57 iInputBuffer = new (ELeave) TUint8[iBufferSize]; |
|
58 iOutputBuffer = new (ELeave) TUint8[iBufferSize]; |
|
59 |
|
60 iInputDescriptor.Set(iInputBuffer,0,iBufferSize); |
|
61 iOutputDescriptor.Set(iOutputBuffer,0,iBufferSize); |
|
62 |
|
63 iReadLength = iBufferSize; |
|
64 } |
|
65 |
|
66 void CBufferManager::InitializeL(CEZZStream &aZStream) |
|
67 { |
|
68 ReadInputL(); |
|
69 aZStream.SetInput(iInputDescriptor); |
|
70 aZStream.SetOutput(iOutputDescriptor); |
|
71 } |
|
72 |
|
73 void CBufferManager::NeedInputL(CEZZStream &aZStream) |
|
74 { |
|
75 ReadInputL(); |
|
76 aZStream.SetInput(iInputDescriptor); |
|
77 } |
|
78 |
|
79 void CBufferManager::NeedOutputL(CEZZStream &aZStream) |
|
80 { |
|
81 WriteOutputL(aZStream); |
|
82 aZStream.SetOutput(iOutputDescriptor); |
|
83 } |
|
84 |
|
85 void CBufferManager::FinalizeL(CEZZStream &aZStream) |
|
86 { |
|
87 WriteOutputL(aZStream); |
|
88 } |
|
89 |
|
90 void CBufferManager::ReadInputL() |
|
91 { |
|
92 iInput.ReadL(iInputDescriptor, iReadLength); |
|
93 iInputStreamBytes -= iReadLength; |
|
94 if (iInputStreamBytes < iBufferSize) |
|
95 { |
|
96 iReadLength = iInputStreamBytes; |
|
97 } |
|
98 if (iReadLength < 0) |
|
99 { |
|
100 User::Leave(KErrOverflow); |
|
101 } |
|
102 } |
|
103 |
|
104 void CBufferManager::WriteOutputL(CEZZStream& aZStream) |
|
105 { |
|
106 TPtrC8 od = aZStream.OutputDescriptor(); |
|
107 iOutput.WriteL(od); |
|
108 iBytesWritten += od.Size(); |
|
109 } |
|
110 |
|
111 // |
|
112 // CZipEntry |
|
113 // |
|
114 CZipEntry* CZipEntry::NewLC(RFs& aFs, const TDesC& aFilename, const TInt aUid) |
|
115 { |
|
116 CZipEntry* self = new (ELeave) CZipEntry(aFs, aUid); |
|
117 CleanupStack::PushL(self); |
|
118 self->ConstructL(aFilename); |
|
119 return self; |
|
120 } |
|
121 |
|
122 CZipEntry::CZipEntry(RFs& aFs, const TInt aUid): |
|
123 iFs(aFs), iUid(aUid) |
|
124 { |
|
125 iLFH.iCRC32 = crc32(iLFH.iCRC32, NULL, 0); |
|
126 } |
|
127 |
|
128 CZipEntry::~CZipEntry() |
|
129 { |
|
130 if (iFileData) |
|
131 delete iFileData; |
|
132 if (iInput.SubSessionHandle() > 0) |
|
133 iInput.Close(); |
|
134 } |
|
135 |
|
136 void CZipEntry::ConstructL(const TDesC& aFilename) |
|
137 { |
|
138 User::LeaveIfError(iInput.Open(iFs, aFilename, EFileRead | EFileShareReadersOnly)); |
|
139 |
|
140 // ensure aFileName is stored in accordance with zip file-format specification |
|
141 TFileName2 file(aFilename); |
|
142 if (file.HasDriveLetter()) |
|
143 { |
|
144 file.Delete(0, 3); // remove '<drive>:\' |
|
145 } |
|
146 if (file.HasLeadingSlash()) |
|
147 { |
|
148 file.Delete(0, 1); // remove '\' |
|
149 } |
|
150 iAsciiName.Copy(file); |
|
151 TUint8* ptr = const_cast<TUint8*> (iAsciiName.Ptr()); |
|
152 TInt count = 0; |
|
153 do |
|
154 { |
|
155 if (*ptr == '\\') |
|
156 { |
|
157 *ptr = '/'; |
|
158 } |
|
159 ptr++; |
|
160 } while (count++ < iAsciiName.Length()); |
|
161 |
|
162 // config. local file header |
|
163 iLFH.iSignature = KLocalHeaderSignature; |
|
164 iLFH.iVersionNeeded = KFZipVersion; |
|
165 iLFH.iFlags = 0x0002; // best (-exx/-ex) compression was used |
|
166 iLFH.iCompressionMethod = EDeflated; |
|
167 TTime time; |
|
168 User::LeaveIfError(iInput.Modified(time)); |
|
169 TDateTime td = time.DateTime(); |
|
170 TUint16 param1 = td.Year() - 1980; |
|
171 TUint16 param2 = td.Month() + 1; |
|
172 TUint16 param3 = td.Day() + 1; |
|
173 iLFH.iLastModifiedFileDate = (param1 << 9) | (param2 << 5) | param3; |
|
174 param1 = td.Hour() + 1; |
|
175 param2 = td.Minute() + 1; |
|
176 param3 = td.Second() + 1; |
|
177 iLFH.iLastModifiedFileTime = (param1 << 11) | (param2 << 5) | (param3 >> 1); |
|
178 TInt uSize = 0; |
|
179 User::LeaveIfError(iInput.Size(uSize)); |
|
180 if (uSize <= 0) |
|
181 { |
|
182 User::Leave(KErrAbort); |
|
183 } |
|
184 iLFH.iUncompressedSize = uSize; |
|
185 iLFH.iCompressedSize = uSize; // note: to be adjusted later once the compression is performed |
|
186 CalcCRCL(); |
|
187 iLFH.iFileNameLength = iAsciiName.Size(); |
|
188 iLFH.iExtraFieldLength = 0; |
|
189 |
|
190 // config. file header |
|
191 iFH.iSignature = KCentralDirectoryHeaderSignature; |
|
192 iFH.iMadeBy = KFZipVersion; |
|
193 iFH.iRequired = KFZipVersion; |
|
194 iFH.iFlags = iLFH.iFlags; |
|
195 iFH.iCompressionMethod = iLFH.iCompressionMethod; |
|
196 iFH.iLastModifiedFileTime = iLFH.iLastModifiedFileTime; |
|
197 iFH.iLastModifiedFileDate = iLFH.iLastModifiedFileDate; |
|
198 iFH.iCRC32 = iLFH.iCRC32; |
|
199 iFH.iCompressedSize = iLFH.iCompressedSize; // note: to be adjusted later once the compression is performed |
|
200 iFH.iUncompressedSize = iLFH.iUncompressedSize; |
|
201 iFH.iFileNameLength = iLFH.iFileNameLength; |
|
202 iFH.iExtraFieldLength = iLFH.iExtraFieldLength; |
|
203 iFH.iFileCommentLength = 0x0000; |
|
204 iFH.iDiskNumberStart = KDefaultDiskNumber; |
|
205 iFH.iInternalFileAttributes = 0x0001; |
|
206 iFH.iExternalFileAttributes = 0x00000020; // hardcoded to 'Archive' |
|
207 iFH.iLocalHeaderOffset = 0x00000000; // to be adjusted later (if necessary) |
|
208 } |
|
209 |
|
210 void CZipEntry::SetOffset(TUint32 aOffset) |
|
211 { |
|
212 iFH.iLocalHeaderOffset = aOffset; |
|
213 } |
|
214 |
|
215 TUint32 CZipEntry::ReturnOffset() |
|
216 { |
|
217 TUint32 result = iFH.iLocalHeaderOffset; // start with the offset of the LFH |
|
218 result += KLocalHeaderFixedLength; // add the size of the LFH itself |
|
219 result += iAsciiName.Size(); // add the size of the filename |
|
220 result += iLFH.iCompressedSize; // add any compressed data |
|
221 return result; |
|
222 } |
|
223 |
|
224 TUint32 CZipEntry::FileHeaderSize() |
|
225 { |
|
226 TUint32 result = KCentralDirectoryHeaderFixedLength; |
|
227 result += iAsciiName.Size(); |
|
228 return result; |
|
229 } |
|
230 |
|
231 // |
|
232 // CZipEntry::CalcCRCL |
|
233 // mem. efficient means of calculating the crc on uncompressed data |
|
234 // we require a maximum of KDefaultZipBufferLength heap space regardless size of data |
|
235 // |
|
236 void CZipEntry::CalcCRCL() |
|
237 { |
|
238 ASSERT(iInput.SubSessionHandle() > 0); |
|
239 TInt bytesRead = 0; |
|
240 TInt length = KDefaultZipBufferLength; // 32Kb |
|
241 if (iLFH.iUncompressedSize < KDefaultZipBufferLength) |
|
242 { |
|
243 length = iLFH.iUncompressedSize; |
|
244 } |
|
245 |
|
246 iLFH.iCRC32 = crc32(0, NULL, 0); |
|
247 HBufC8* crc = HBufC8::NewLC(length); |
|
248 TPtr8 crcPtr = crc->Des(); |
|
249 User::LeaveIfError(iInput.Seek(ESeekStart, bytesRead)); |
|
250 do |
|
251 { |
|
252 User::LeaveIfError(iInput.Read(crcPtr, length)); |
|
253 iLFH.iCRC32 = crc32(iLFH.iCRC32, crcPtr.Ptr(), length); |
|
254 bytesRead += length; |
|
255 if ((iLFH.iUncompressedSize - bytesRead) < KDefaultZipBufferLength) |
|
256 { |
|
257 length = iLFH.iUncompressedSize - bytesRead; |
|
258 } |
|
259 } while (length > 0); |
|
260 CleanupStack::PopAndDestroy(1); // crc |
|
261 } |
|
262 |
|
263 // |
|
264 // CZipItUp |
|
265 // |
|
266 CZipItUp* CZipItUp::NewLC(RFs& aFs, TDesC& aArchive) |
|
267 { |
|
268 CZipItUp* self = new (ELeave) CZipItUp(aFs, aArchive); |
|
269 CleanupStack::PushL(self); |
|
270 self->ConstructL(); |
|
271 return self; |
|
272 } |
|
273 |
|
274 CZipItUp::CZipItUp(RFs& aFs, TDesC& aArchive): |
|
275 iFs(aFs), iFileName(aArchive), iZipMemberLinkedList(CZipEntry::iOffset), iZipMemberLinkedListIter(iZipMemberLinkedList) |
|
276 { |
|
277 } |
|
278 |
|
279 CZipItUp::~CZipItUp() |
|
280 { |
|
281 if (iFile.SubSessionHandle() > 0) |
|
282 { |
|
283 iFile.Close(); |
|
284 } |
|
285 while (!iZipMemberLinkedList.IsEmpty()) |
|
286 { |
|
287 CZipEntry* entry = iZipMemberLinkedList.First(); |
|
288 iZipMemberLinkedList.Remove(*entry); |
|
289 delete entry; |
|
290 } |
|
291 iZipMemberLinkedList.Reset(); |
|
292 } |
|
293 |
|
294 void CZipItUp::ConstructL() |
|
295 { |
|
296 User::LeaveIfError(iFile.Create(iFs, iFileName, EFileStream | EFileShareExclusive)); |
|
297 } |
|
298 |
|
299 // |
|
300 // CZipItUp::AddFileL |
|
301 // |
|
302 void CZipItUp::AddFileL(const TDesC& aFile) |
|
303 { |
|
304 if (!DuplicateEntryL(aFile)) |
|
305 { |
|
306 // spawn a new zip entry, compress the file, add it to the list of zip file contained in the archive |
|
307 CZipEntry* zipEntry = CZipEntry::NewLC(iFs, aFile, ++iEntryUid); |
|
308 AddEntryL(*zipEntry); |
|
309 CleanupStack::Pop(zipEntry); |
|
310 } |
|
311 } |
|
312 |
|
313 // |
|
314 // CZipItUp::DuplicateEntryL |
|
315 // run a check against the zip archive's current entries (if any!) for duplicate files |
|
316 // return ETrue if a duplicate is found |
|
317 // |
|
318 TBool CZipItUp::DuplicateEntryL(const TDesC& aFile) |
|
319 { |
|
320 if (iZipMemberLinkedList.IsEmpty()) |
|
321 { |
|
322 return EFalse; |
|
323 } |
|
324 |
|
325 // turn aFile into a zip-file format filename |
|
326 TFileName2 file(aFile); |
|
327 if (file.HasDriveLetter()) |
|
328 { |
|
329 file.Delete(0, 3); // remove '<drive>:\' |
|
330 } |
|
331 if (file.HasLeadingSlash()) |
|
332 { |
|
333 file.Delete(0, 1); // remove '\' |
|
334 } |
|
335 TBuf8<KMaxFileName> ascii; |
|
336 ascii.Copy(file); |
|
337 TUint8* ptr = const_cast<TUint8*> (ascii.Ptr()); |
|
338 TInt count = 0; |
|
339 do |
|
340 { |
|
341 if (*ptr == '\\') |
|
342 { |
|
343 *ptr = '/'; |
|
344 } |
|
345 ptr++; |
|
346 } while (count++ < ascii.Length()); |
|
347 |
|
348 // iterate through zip archive entries looking for a duplicate |
|
349 iZipMemberLinkedListIter.SetToFirst(); |
|
350 CZipEntry* entry = iZipMemberLinkedListIter++; |
|
351 while (entry != NULL) |
|
352 { |
|
353 if (entry->iAsciiName == ascii) |
|
354 { |
|
355 return ETrue; |
|
356 } |
|
357 entry = iZipMemberLinkedListIter++; |
|
358 } |
|
359 return EFalse; |
|
360 } |
|
361 |
|
362 // |
|
363 // CZipItUp::AddEntryL |
|
364 // Add an entry to the zip archive. |
|
365 // |
|
366 void CZipItUp::AddEntryL(CZipEntry& aEntry) |
|
367 { |
|
368 // append the new entry to the queue |
|
369 if (!iZipMemberLinkedList.IsEmpty()) |
|
370 { |
|
371 // prior entries in the list therefore need to adjust this entry's local file header offset |
|
372 CZipEntry* lastEntry = iZipMemberLinkedList.Last(); |
|
373 User::LeaveIfNull(lastEntry); |
|
374 } |
|
375 iZipMemberLinkedList.AddLast(aEntry); |
|
376 } |
|
377 |
|
378 // |
|
379 // CZipItUp::CreateZipL |
|
380 // Creates the actual file, including all the previously compressed zip files in the archive |
|
381 // |
|
382 void CZipItUp::CreateZipL() |
|
383 { |
|
384 ASSERT(iFile.SubSessionHandle() > 0); |
|
385 if (iZipMemberLinkedList.IsEmpty()) |
|
386 { |
|
387 User::Leave(KErrGeneral); |
|
388 } |
|
389 RFileWriteStream stream(iFile); |
|
390 stream.PushL(); |
|
391 |
|
392 // initialise central directory header |
|
393 iCDT.iSignature = CZipArchive::KCentralDirectorySignature; |
|
394 iCDT.iDiskNumber = KDefaultDiskNumber; |
|
395 iCDT.iStartDiskNumber = KDefaultDiskNumber; |
|
396 iCDT.iLocalEntryCount = 0; |
|
397 iCDT.iTotalEntryCount = 0; |
|
398 iCDT.iSize = 0; |
|
399 iCDT.iCommentLength = 0; |
|
400 |
|
401 // iterate through each zip entry, appending local file header (LFH), file data (FD) to file |
|
402 iZipMemberLinkedListIter.SetToFirst(); |
|
403 CZipEntry* entry = iZipMemberLinkedListIter++; |
|
404 CZipEntry* prior = NULL; |
|
405 User::LeaveIfNull(entry); |
|
406 do |
|
407 { |
|
408 if (prior) |
|
409 { |
|
410 // adjust file header local offset if necessary |
|
411 entry->SetOffset(prior->ReturnOffset()); |
|
412 } |
|
413 |
|
414 // insert entry's Local File Header |
|
415 AppendLocalFileHeaderL(stream, *entry); |
|
416 |
|
417 // insert entry's File Data |
|
418 AppendCompressedDataL(stream, *entry); |
|
419 |
|
420 // adjust cdt parameters |
|
421 iCDT.iLocalEntryCount++; |
|
422 iCDT.iTotalEntryCount++; |
|
423 iCDT.iSize += entry->FileHeaderSize(); |
|
424 |
|
425 // move onto the next entry |
|
426 prior = entry; |
|
427 entry = iZipMemberLinkedListIter++; |
|
428 } while (entry != NULL); |
|
429 |
|
430 // adjust cdt offset parameter |
|
431 iCDT.iOffset = iZipMemberLinkedList.Last()->ReturnOffset(); |
|
432 |
|
433 // iterate through each zip entry, appending the central directory File Headers to file (these must go after LFH, FD entries) |
|
434 iZipMemberLinkedListIter.SetToFirst(); |
|
435 entry = iZipMemberLinkedListIter++; |
|
436 |
|
437 do |
|
438 { |
|
439 // central directory File Header |
|
440 AppendCentralDirectoryFileHeaderL(stream, *entry); |
|
441 |
|
442 // move onto the next entry |
|
443 entry = iZipMemberLinkedListIter++; |
|
444 } while (entry != NULL); |
|
445 |
|
446 // append the central directory trailer |
|
447 AppendCentralDirectoryTrailerL(stream); |
|
448 |
|
449 // commit the transaction |
|
450 stream.CommitL(); |
|
451 stream.Pop(); |
|
452 stream.Close(); |
|
453 |
|
454 // go back through & adjust compressed size values for each zip entry post-mortem |
|
455 ASSERT(iFile.SubSessionHandle() == 0); |
|
456 User::LeaveIfError(iFile.Open(iFs, iFileName, EFileWrite | EFileShareExclusive)); |
|
457 TInt pos = 0; |
|
458 const TInt remainder = 8; // CZipArchive::KLocalHeaderFixedLength - KCompressedSizeRelativePosition |
|
459 User::LeaveIfError(iFile.Seek(ESeekStart, pos)); |
|
460 iZipMemberLinkedListIter.SetToFirst(); |
|
461 entry = iZipMemberLinkedListIter++; |
|
462 do |
|
463 { |
|
464 pos += KCompressedSizeRelativePosition; // step to iCompressedSize location in the current entry's LFH |
|
465 TUint32 cs = entry->iLFH.iCompressedSize; |
|
466 TUint32 KMyByte = 0x000000FF; |
|
467 TInt bytecount = 0; |
|
468 TBuf8<8> compSize; |
|
469 do |
|
470 { |
|
471 TUint32 csChar((cs & KMyByte)); |
|
472 compSize.Append(csChar); |
|
473 cs >>= 8; |
|
474 } while (++bytecount < 4); // zip-file format allows us 4 bytes only for the compressed size value |
|
475 User::LeaveIfError(iFile.Write(pos, compSize)); |
|
476 pos += bytecount; // the 4 bytes we just wrote |
|
477 |
|
478 // step over remaing bytes to the beginning of the next entry's LFH |
|
479 pos += remainder; |
|
480 pos += entry->iAsciiName.Size(); |
|
481 pos += entry->iLFH.iCompressedSize; |
|
482 |
|
483 // we're now positioned at the next entry's LFH |
|
484 entry = iZipMemberLinkedListIter++; |
|
485 } while (entry != NULL); |
|
486 } |
|
487 |
|
488 void CZipItUp::AppendLocalFileHeaderL(RFileWriteStream& aStream, CZipEntry& aZipEntry) |
|
489 { |
|
490 aStream.WriteUint32L(aZipEntry.iLFH.iSignature); |
|
491 aStream.WriteUint16L(aZipEntry.iLFH.iVersionNeeded); |
|
492 aStream.WriteUint16L(aZipEntry.iLFH.iFlags); |
|
493 aStream.WriteUint16L(aZipEntry.iLFH.iCompressionMethod); |
|
494 aStream.WriteUint16L(aZipEntry.iLFH.iLastModifiedFileTime); |
|
495 aStream.WriteUint16L(aZipEntry.iLFH.iLastModifiedFileDate); |
|
496 aStream.WriteUint32L(aZipEntry.iLFH.iCRC32); |
|
497 aStream.WriteUint32L(aZipEntry.iLFH.iCompressedSize); |
|
498 aStream.WriteUint32L(aZipEntry.iLFH.iUncompressedSize); |
|
499 aStream.WriteUint16L(aZipEntry.iLFH.iFileNameLength); |
|
500 aStream.WriteUint16L(aZipEntry.iLFH.iExtraFieldLength); |
|
501 aStream.WriteL(aZipEntry.iAsciiName); |
|
502 } |
|
503 |
|
504 void CZipItUp::AppendCompressedDataL(RFileWriteStream& aStream, CZipEntry& aZipEntry) |
|
505 { |
|
506 // compress data & stream it to the zip archive (aStream) |
|
507 RFileReadStream inStream; |
|
508 inStream.Attach(aZipEntry.iInput); // note takes ownership of iInput subsession handle |
|
509 CBufferManager* fb = CBufferManager::NewLC(inStream, aStream, aZipEntry.iLFH.iUncompressedSize, KDefaultZipBufferLength); |
|
510 CEZCompressor* compressor = CEZCompressor::NewLC(*fb, CEZCompressor::EBestCompression, KWindowBits, CEZCompressor::EDefMemLevel, CEZCompressor::EDefaultStrategy); |
|
511 while (compressor->DeflateL()){/* do nothing */} |
|
512 |
|
513 // update the entry's LocalFileHeader and FileHeader |
|
514 aZipEntry.iLFH.iCompressedSize = fb->TotalBytesOut(); |
|
515 aZipEntry.iFH.iCompressedSize = aZipEntry.iLFH.iCompressedSize; |
|
516 |
|
517 // cleanup |
|
518 CleanupStack::PopAndDestroy(2, fb); // compressor, fb |
|
519 inStream.Close(); |
|
520 } |
|
521 |
|
522 void CZipItUp::AppendCentralDirectoryFileHeaderL(RFileWriteStream& aStream, CZipEntry& aEntry) |
|
523 { |
|
524 aStream.WriteUint32L(aEntry.iFH.iSignature); |
|
525 aStream.WriteUint16L(aEntry.iFH.iMadeBy); |
|
526 aStream.WriteUint16L(aEntry.iFH.iRequired); |
|
527 aStream.WriteUint16L(aEntry.iFH.iFlags); |
|
528 aStream.WriteUint16L(aEntry.iFH.iCompressionMethod); |
|
529 aStream.WriteUint16L(aEntry.iFH.iLastModifiedFileTime); |
|
530 aStream.WriteUint16L(aEntry.iFH.iLastModifiedFileDate); |
|
531 aStream.WriteUint32L(aEntry.iFH.iCRC32); |
|
532 aStream.WriteUint32L(aEntry.iFH.iCompressedSize); |
|
533 aStream.WriteUint32L(aEntry.iFH.iUncompressedSize); |
|
534 aStream.WriteUint16L(aEntry.iFH.iFileNameLength); |
|
535 aStream.WriteUint16L(aEntry.iFH.iExtraFieldLength); |
|
536 aStream.WriteUint16L(aEntry.iFH.iFileCommentLength); |
|
537 aStream.WriteUint16L(aEntry.iFH.iDiskNumberStart); |
|
538 aStream.WriteUint16L(aEntry.iFH.iInternalFileAttributes); |
|
539 aStream.WriteUint32L(aEntry.iFH.iExternalFileAttributes); |
|
540 aStream.WriteUint32L(aEntry.iFH.iLocalHeaderOffset); |
|
541 aStream.WriteL(aEntry.iAsciiName); |
|
542 } |
|
543 |
|
544 void CZipItUp::AppendCentralDirectoryTrailerL(RFileWriteStream& aStream) |
|
545 { |
|
546 aStream.WriteUint32L(iCDT.iSignature); |
|
547 aStream.WriteUint16L(iCDT.iDiskNumber); |
|
548 aStream.WriteUint16L(iCDT.iStartDiskNumber); |
|
549 aStream.WriteUint16L(iCDT.iLocalEntryCount); |
|
550 aStream.WriteUint16L(iCDT.iTotalEntryCount); |
|
551 aStream.WriteUint32L(iCDT.iSize); |
|
552 aStream.WriteUint32L(iCDT.iOffset); |
|
553 aStream.WriteUint16L(iCDT.iCommentLength); |
|
554 } |