231
232
throwError("ARCH0004", lMsg.str().c_str());
234
else if(lAttrName.getLocalName() == "options"){
235
theOptions = lAttr.getStringValue();
235
else if(lAttrName.getLocalName() == "compression"){
236
theCompression = lAttr.getStringValue();
238
theCompression.begin(),
239
theCompression.end(),
240
theCompression.begin(), ::toupper);
276
280
ArchiveFunction::ArchiveOptions::setValues(struct archive* aArchive)
278
theAlgorithm = ArchiveFunction::compressionName(archive_compression(aArchive));
282
theCompression = ArchiveFunction::compressionName(
283
archive_compression(aArchive));
279
284
theFormat = ArchiveFunction::formatName(archive_format(aArchive));
280
theCompressionLevel = archive_compression(aArchive);
293
297
Item lOptionName;
294
298
lOption.getNodeName(lOptionName);
296
if (lOptionName.getLocalName() == "algorithm")
300
if (lOptionName.getLocalName() == "compression")
298
theAlgorithm = getAttributeValue(lOption);
302
theCompression = lOption.getStringValue().c_str();
304
theCompression.begin(),
305
theCompression.end(),
306
theCompression.begin(), ::toupper);
300
308
else if (lOptionName.getLocalName() == "format")
302
theFormat = getAttributeValue(lOption);
304
else if (lOptionName.getLocalName() == "compression")
306
std::string lTmp = getAttributeValue(lOption);
307
theCompressionLevel = atoi(lTmp.c_str());
310
theFormat = lOption.getStringValue().c_str();
314
theFormat.begin(), ::toupper);
330
337
ArchiveFunction::ArchiveCompressor::setOptions(const ArchiveOptions& aOptions)
339
theOptions = aOptions;
332
341
int lFormatCode = formatCode(aOptions.getFormat().c_str());
333
342
int lErr = archive_write_set_format(theArchive, lFormatCode);
334
343
ArchiveFunction::checkForError(lErr, 0, theArchive);
336
int lCompressionCode = compressionCode(aOptions.getAlgorithm().c_str());
345
int lCompressionCode = compressionCode(aOptions.getCompression().c_str());
337
346
setArchiveCompression(theArchive, lCompressionCode);
339
348
lErr = archive_write_open(
564
572
archive_entry_set_perm(theEntry, 0644);
565
573
archive_entry_set_size(theEntry, lFileSize);
575
if (theOptions.getFormat() == "ZIP")
578
std::string lNextCompString;
579
if (aEntry.getCompression().length() > 0)
581
lNextCompString = aEntry.getCompression().c_str();
582
lNextComp = compressionCode(lNextCompString);
583
#ifndef ZORBA_LIBARCHIVE_HAVE_SET_COMPRESSION
584
std::ostringstream lMsg;
585
lMsg << lNextCompString << ": setting different compression algorithms for each entry is not supported by the used version of libarchive";
586
throwError("ARCH0099", lMsg.str().c_str());
591
lNextCompString = theOptions.getCompression();
592
lNextComp = compressionCode(lNextCompString);
594
if (lNextComp < ZORBA_ARCHIVE_COMPRESSION_DEFLATE)
596
std::ostringstream lMsg;
597
lMsg << lNextCompString << ": compression algorithm not supported for ZIP format (required: deflate, store)";
598
throwError("ARCH0002", lMsg.str().c_str());
601
#ifdef ZORBA_LIBARCHIVE_HAVE_SET_COMPRESSION
602
setArchiveCompression(theArchive, lNextComp);
567
606
archive_write_header(theArchive, theEntry);
569
if(strlen(aEntry.getOptions().c_str())>0){
570
lErr = archive_write_set_options(theArchive, aEntry.getOptions().c_str());
571
checkForError(lErr, NULL, theArchive);
574
608
char lBuf[ZORBA_ARCHIVE_MAX_READ_BUF];
575
609
while (lStream->good())
678
712
case ARCHIVE_COMPRESSION_NONE: return "NONE";
713
case ZORBA_ARCHIVE_COMPRESSION_DEFLATE: return "DEFLATE";
714
case ZORBA_ARCHIVE_COMPRESSION_STORE: return "STORE";
679
715
case ARCHIVE_COMPRESSION_GZIP: return "GZIP";
680
716
case ARCHIVE_COMPRESSION_BZIP2: return "BZIP2";
681
717
case ARCHIVE_COMPRESSION_COMPRESS: return "COMPRESS";
828
#ifdef ZORBA_LIBARCHIVE_HAVE_SET_COMPRESSION
829
case ZORBA_ARCHIVE_COMPRESSION_STORE:
830
lErr = archive_write_zip_set_compression_store(a); break;
831
case ZORBA_ARCHIVE_COMPRESSION_DEFLATE:
832
case ARCHIVE_COMPRESSION_NONE:
833
lErr = archive_write_zip_set_compression_deflate(a); break;
835
case ZORBA_ARCHIVE_COMPRESSION_STORE:
836
archive_write_set_option(a, "zip", "compression", "store");
838
case ZORBA_ARCHIVE_COMPRESSION_DEFLATE:
839
archive_write_set_option(a, "zip", "compression", "deflate");
784
841
case ARCHIVE_COMPRESSION_NONE:
785
842
lErr = archive_write_set_compression_none(a); break;
786
844
case ARCHIVE_COMPRESSION_GZIP:
787
845
lErr = archive_write_set_compression_gzip(a); break;
788
846
case ARCHIVE_COMPRESSION_BZIP2:
1057
1115
* or are not in a list (ArchiveEntrySet)
1058
1116
******************************************************************************/
1059
1117
struct archive_entry*
1060
ExtractFunction::ExtractItemSequence::ExtractIterator::lookForHeader(bool aMatch, ArchiveOptions* aOptions)
1118
ExtractFunction::ExtractItemSequence::ExtractIterator::lookForHeader(
1120
ArchiveOptions* aOptions)
1062
1122
struct archive_entry *lEntry = 0;
1346
1406
std::string lFormat =
1347
1407
ArchiveFunction::formatName(archive_format(theArchive));
1348
std::string lAlgorithm =
1408
std::string lCompression =
1349
1409
ArchiveFunction::compressionName(archive_compression(theArchive));
1351
1411
if (lFormat == "ZIP")
1353
lAlgorithm = "DEFLATE";
1413
lCompression = "DEFLATE";
1356
1416
zorba::Item lUntypedQName = theFactory->createQName(
1363
1423
zorba::Item lFormatQName = theFactory->createQName(
1364
1424
ArchiveModule::getModuleURI(), "format");
1366
zorba::Item lAlgorithmQName = theFactory->createQName(
1367
ArchiveModule::getModuleURI(), "algorithm");
1369
zorba::Item lValueQName = theFactory->createQName("", "value");
1426
zorba::Item lCompressionQName = theFactory->createQName(
1427
ArchiveModule::getModuleURI(), "compression");
1371
1429
zorba::Item lNoParent;
1372
1430
aRes = theFactory->createElementNode(
1377
1435
aRes, lFormatQName, lTmpQName, true, false, NsBindings());
1379
1437
lTmpQName = lUntypedQName;
1380
zorba::Item lAlgorithmItem = theFactory->createElementNode(
1381
aRes, lAlgorithmQName, lTmpQName, true, false, NsBindings());
1383
zorba::Item lTmpItem = theFactory->createString(lFormat);
1385
lTmpQName = lUntypedQName;
1386
theFactory->createAttributeNode(
1387
lFormatItem, lValueQName, lTmpQName, lTmpItem);
1389
lTmpItem = theFactory->createString(lAlgorithm);
1391
lTmpQName = lUntypedQName;
1392
theFactory->createAttributeNode(
1393
lAlgorithmItem, lValueQName, lTmpQName, lTmpItem);
1438
zorba::Item lCompressionItem = theFactory->createElementNode(
1439
aRes, lCompressionQName, lTmpQName, true, false, NsBindings());
1441
theFactory->createTextNode(lFormatItem, lFormat);
1442
theFactory->createTextNode(lCompressionItem, lCompression);