diff options
Diffstat (limited to '')
-rw-r--r-- | CPP/7zip/Archive/7z/7zUpdate.cpp | 141 |
1 files changed, 136 insertions, 5 deletions
diff --git a/CPP/7zip/Archive/7z/7zUpdate.cpp b/CPP/7zip/Archive/7z/7zUpdate.cpp index b641d93..b6fd192 100644 --- a/CPP/7zip/Archive/7z/7zUpdate.cpp +++ b/CPP/7zip/Archive/7z/7zUpdate.cpp | |||
@@ -804,10 +804,20 @@ struct CAnalysis | |||
804 | bool ParseExe; | 804 | bool ParseExe; |
805 | bool ParseAll; | 805 | bool ParseAll; |
806 | 806 | ||
807 | /* | ||
808 | bool Need_ATime; | ||
809 | bool ATime_Defined; | ||
810 | FILETIME ATime; | ||
811 | */ | ||
812 | |||
807 | CAnalysis(): | 813 | CAnalysis(): |
808 | ParseWav(true), | 814 | ParseWav(true), |
809 | ParseExe(false), | 815 | ParseExe(false), |
810 | ParseAll(false) | 816 | ParseAll(false) |
817 | /* | ||
818 | , Need_ATime(false) | ||
819 | , ATime_Defined(false) | ||
820 | */ | ||
811 | {} | 821 | {} |
812 | 822 | ||
813 | HRESULT GetFilterGroup(UInt32 index, const CUpdateItem &ui, CFilterMode &filterMode); | 823 | HRESULT GetFilterGroup(UInt32 index, const CUpdateItem &ui, CFilterMode &filterMode); |
@@ -887,6 +897,18 @@ HRESULT CAnalysis::GetFilterGroup(UInt32 index, const CUpdateItem &ui, CFilterMo | |||
887 | HRESULT result = Callback->GetStream2(index, &stream, NUpdateNotifyOp::kAnalyze); | 897 | HRESULT result = Callback->GetStream2(index, &stream, NUpdateNotifyOp::kAnalyze); |
888 | if (result == S_OK && stream) | 898 | if (result == S_OK && stream) |
889 | { | 899 | { |
900 | /* | ||
901 | if (Need_ATime) | ||
902 | { | ||
903 | // access time could be changed in analysis pass | ||
904 | CMyComPtr<IStreamGetProps> getProps; | ||
905 | stream.QueryInterface(IID_IStreamGetProps, (void **)&getProps); | ||
906 | if (getProps) | ||
907 | if (getProps->GetProps(NULL, NULL, &ATime, NULL, NULL) == S_OK) | ||
908 | ATime_Defined = true; | ||
909 | } | ||
910 | */ | ||
911 | |||
890 | size_t size = kAnalysisBufSize; | 912 | size_t size = kAnalysisBufSize; |
891 | result = ReadStream(stream, Buffer, &size); | 913 | result = ReadStream(stream, Buffer, &size); |
892 | stream.Release(); | 914 | stream.Release(); |
@@ -1586,6 +1608,11 @@ HRESULT Update( | |||
1586 | CMyComPtr<IArchiveExtractCallbackMessage> extractCallback; | 1608 | CMyComPtr<IArchiveExtractCallbackMessage> extractCallback; |
1587 | updateCallback->QueryInterface(IID_IArchiveExtractCallbackMessage, (void **)&extractCallback); | 1609 | updateCallback->QueryInterface(IID_IArchiveExtractCallbackMessage, (void **)&extractCallback); |
1588 | 1610 | ||
1611 | /* | ||
1612 | CMyComPtr<IArchiveUpdateCallbackArcProp> reportArcProp; | ||
1613 | updateCallback->QueryInterface(IID_IArchiveUpdateCallbackArcProp, (void **)&reportArcProp); | ||
1614 | */ | ||
1615 | |||
1589 | // size_t totalSecureDataSize = (size_t)secureBlocks.GetTotalSizeInBytes(); | 1616 | // size_t totalSecureDataSize = (size_t)secureBlocks.GetTotalSizeInBytes(); |
1590 | 1617 | ||
1591 | /* | 1618 | /* |
@@ -1756,6 +1783,7 @@ HRESULT Update( | |||
1756 | 1783 | ||
1757 | { | 1784 | { |
1758 | CAnalysis analysis; | 1785 | CAnalysis analysis; |
1786 | // analysis.Need_ATime = options.Need_ATime; | ||
1759 | if (options.AnalysisLevel == 0) | 1787 | if (options.AnalysisLevel == 0) |
1760 | { | 1788 | { |
1761 | analysis.ParseWav = false; | 1789 | analysis.ParseWav = false; |
@@ -1790,7 +1818,15 @@ HRESULT Update( | |||
1790 | CFilterMode2 fm; | 1818 | CFilterMode2 fm; |
1791 | if (useFilters) | 1819 | if (useFilters) |
1792 | { | 1820 | { |
1821 | // analysis.ATime_Defined = false; | ||
1793 | RINOK(analysis.GetFilterGroup(i, ui, fm)); | 1822 | RINOK(analysis.GetFilterGroup(i, ui, fm)); |
1823 | /* | ||
1824 | if (analysis.ATime_Defined) | ||
1825 | { | ||
1826 | ui.ATime = FILETIME_To_UInt64(analysis.ATime); | ||
1827 | ui.ATime_WasReadByAnalysis = true; | ||
1828 | } | ||
1829 | */ | ||
1794 | } | 1830 | } |
1795 | fm.Encrypted = method.PasswordIsDefined; | 1831 | fm.Encrypted = method.PasswordIsDefined; |
1796 | 1832 | ||
@@ -2374,13 +2410,33 @@ HRESULT Update( | |||
2374 | 2410 | ||
2375 | RINOK(lps->SetCur()); | 2411 | RINOK(lps->SetCur()); |
2376 | 2412 | ||
2413 | /* | ||
2414 | const unsigned folderIndex = newDatabase.NumUnpackStreamsVector.Size(); | ||
2415 | |||
2416 | if (opCallback) | ||
2417 | { | ||
2418 | RINOK(opCallback->ReportOperation( | ||
2419 | NEventIndexType::kBlockIndex, (UInt32)folderIndex, | ||
2420 | NUpdateNotifyOp::kAdd)); | ||
2421 | } | ||
2422 | */ | ||
2423 | |||
2424 | |||
2377 | CFolderInStream *inStreamSpec = new CFolderInStream; | 2425 | CFolderInStream *inStreamSpec = new CFolderInStream; |
2378 | CMyComPtr<ISequentialInStream> solidInStream(inStreamSpec); | 2426 | CMyComPtr<ISequentialInStream> solidInStream(inStreamSpec); |
2427 | |||
2428 | // inStreamSpec->_reportArcProp = reportArcProp; | ||
2429 | |||
2430 | inStreamSpec->Need_CTime = options.Need_CTime; | ||
2431 | inStreamSpec->Need_ATime = options.Need_ATime; | ||
2432 | inStreamSpec->Need_MTime = options.Need_MTime; | ||
2433 | inStreamSpec->Need_Attrib = options.Need_Attrib; | ||
2434 | |||
2379 | inStreamSpec->Init(updateCallback, &indices[i], numSubFiles); | 2435 | inStreamSpec->Init(updateCallback, &indices[i], numSubFiles); |
2380 | 2436 | ||
2381 | unsigned startPackIndex = newDatabase.PackSizes.Size(); | 2437 | unsigned startPackIndex = newDatabase.PackSizes.Size(); |
2382 | UInt64 curFolderUnpackSize = totalSize; | 2438 | UInt64 curFolderUnpackSize = totalSize; |
2383 | // curFolderUnpackSize = (UInt64)(Int64)-1; | 2439 | // curFolderUnpackSize = (UInt64)(Int64)-1; // for debug |
2384 | 2440 | ||
2385 | RINOK(encoder.Encode( | 2441 | RINOK(encoder.Encode( |
2386 | EXTERNAL_CODECS_LOC_VARS | 2442 | EXTERNAL_CODECS_LOC_VARS |
@@ -2393,8 +2449,11 @@ HRESULT Update( | |||
2393 | if (!inStreamSpec->WasFinished()) | 2449 | if (!inStreamSpec->WasFinished()) |
2394 | return E_FAIL; | 2450 | return E_FAIL; |
2395 | 2451 | ||
2452 | UInt64 packSize = 0; | ||
2453 | // const UInt32 numStreams = newDatabase.PackSizes.Size() - startPackIndex; | ||
2396 | for (; startPackIndex < newDatabase.PackSizes.Size(); startPackIndex++) | 2454 | for (; startPackIndex < newDatabase.PackSizes.Size(); startPackIndex++) |
2397 | lps->OutSize += newDatabase.PackSizes[startPackIndex]; | 2455 | packSize += newDatabase.PackSizes[startPackIndex]; |
2456 | lps->OutSize += packSize; | ||
2398 | 2457 | ||
2399 | lps->InSize += curFolderUnpackSize; | 2458 | lps->InSize += curFolderUnpackSize; |
2400 | // for () | 2459 | // for () |
@@ -2403,7 +2462,9 @@ HRESULT Update( | |||
2403 | 2462 | ||
2404 | CNum numUnpackStreams = 0; | 2463 | CNum numUnpackStreams = 0; |
2405 | UInt64 skippedSize = 0; | 2464 | UInt64 skippedSize = 0; |
2406 | 2465 | UInt64 procSize = 0; | |
2466 | // unsigned numProcessedFiles = 0; | ||
2467 | |||
2407 | for (unsigned subIndex = 0; subIndex < numSubFiles; subIndex++) | 2468 | for (unsigned subIndex = 0; subIndex < numSubFiles; subIndex++) |
2408 | { | 2469 | { |
2409 | const CUpdateItem &ui = updateItems[indices[i + subIndex]]; | 2470 | const CUpdateItem &ui = updateItems[indices[i + subIndex]]; |
@@ -2429,14 +2490,16 @@ HRESULT Update( | |||
2429 | */ | 2490 | */ |
2430 | if (!inStreamSpec->Processed[subIndex]) | 2491 | if (!inStreamSpec->Processed[subIndex]) |
2431 | { | 2492 | { |
2493 | // we don't add file here | ||
2432 | skippedSize += ui.Size; | 2494 | skippedSize += ui.Size; |
2433 | continue; | 2495 | continue; // comment it for debug |
2434 | // file.Name += ".locked"; | 2496 | // name += ".locked"; // for debug |
2435 | } | 2497 | } |
2436 | 2498 | ||
2437 | file.Crc = inStreamSpec->CRCs[subIndex]; | 2499 | file.Crc = inStreamSpec->CRCs[subIndex]; |
2438 | file.Size = inStreamSpec->Sizes[subIndex]; | 2500 | file.Size = inStreamSpec->Sizes[subIndex]; |
2439 | 2501 | ||
2502 | procSize += file.Size; | ||
2440 | // if (file.Size >= 0) // test purposes | 2503 | // if (file.Size >= 0) // test purposes |
2441 | if (file.Size != 0) | 2504 | if (file.Size != 0) |
2442 | { | 2505 | { |
@@ -2450,6 +2513,23 @@ HRESULT Update( | |||
2450 | file.HasStream = false; | 2513 | file.HasStream = false; |
2451 | } | 2514 | } |
2452 | 2515 | ||
2516 | if (inStreamSpec->TimesDefined[subIndex]) | ||
2517 | { | ||
2518 | if (inStreamSpec->Need_CTime) | ||
2519 | { file2.CTimeDefined = true; file2.CTime = inStreamSpec->CTimes[subIndex]; } | ||
2520 | if (inStreamSpec->Need_ATime | ||
2521 | // && !ui.ATime_WasReadByAnalysis | ||
2522 | ) | ||
2523 | { file2.ATimeDefined = true; file2.ATime = inStreamSpec->ATimes[subIndex]; } | ||
2524 | if (inStreamSpec->Need_MTime) | ||
2525 | { file2.MTimeDefined = true; file2.MTime = inStreamSpec->MTimes[subIndex]; } | ||
2526 | if (inStreamSpec->Need_Attrib) | ||
2527 | { | ||
2528 | file2.AttribDefined = true; | ||
2529 | file2.Attrib = inStreamSpec->Attribs[subIndex]; | ||
2530 | } | ||
2531 | } | ||
2532 | |||
2453 | /* | 2533 | /* |
2454 | file.Parent = ui.ParentFolderIndex; | 2534 | file.Parent = ui.ParentFolderIndex; |
2455 | if (ui.TreeFolderIndex >= 0) | 2535 | if (ui.TreeFolderIndex >= 0) |
@@ -2457,9 +2537,22 @@ HRESULT Update( | |||
2457 | if (totalSecureDataSize != 0) | 2537 | if (totalSecureDataSize != 0) |
2458 | newDatabase.SecureIDs.Add(ui.SecureIndex); | 2538 | newDatabase.SecureIDs.Add(ui.SecureIndex); |
2459 | */ | 2539 | */ |
2540 | /* | ||
2541 | if (reportArcProp) | ||
2542 | { | ||
2543 | RINOK(ReportItemProps(reportArcProp, ui.IndexInClient, file.Size, | ||
2544 | file.CrcDefined ? &file.Crc : NULL)) | ||
2545 | } | ||
2546 | */ | ||
2547 | |||
2548 | // numProcessedFiles++; | ||
2460 | newDatabase.AddFile(file, file2, name); | 2549 | newDatabase.AddFile(file, file2, name); |
2461 | } | 2550 | } |
2462 | 2551 | ||
2552 | // it's optional check to ensure that sizes are correct | ||
2553 | if (procSize != curFolderUnpackSize) | ||
2554 | return E_FAIL; | ||
2555 | |||
2463 | // numUnpackStreams = 0 is very bad case for locked files | 2556 | // numUnpackStreams = 0 is very bad case for locked files |
2464 | // v3.13 doesn't understand it. | 2557 | // v3.13 doesn't understand it. |
2465 | newDatabase.NumUnpackStreamsVector.Add(numUnpackStreams); | 2558 | newDatabase.NumUnpackStreamsVector.Add(numUnpackStreams); |
@@ -2470,6 +2563,44 @@ HRESULT Update( | |||
2470 | complexity -= skippedSize; | 2563 | complexity -= skippedSize; |
2471 | RINOK(updateCallback->SetTotal(complexity)); | 2564 | RINOK(updateCallback->SetTotal(complexity)); |
2472 | } | 2565 | } |
2566 | |||
2567 | /* | ||
2568 | if (reportArcProp) | ||
2569 | { | ||
2570 | PROPVARIANT prop; | ||
2571 | prop.vt = VT_EMPTY; | ||
2572 | prop.wReserved1 = 0; | ||
2573 | { | ||
2574 | NWindows::NCOM::PropVarEm_Set_UInt32(&prop, numProcessedFiles); | ||
2575 | RINOK(reportArcProp->ReportProp( | ||
2576 | NEventIndexType::kBlockIndex, (UInt32)folderIndex, kpidNumSubFiles, &prop)); | ||
2577 | } | ||
2578 | { | ||
2579 | NWindows::NCOM::PropVarEm_Set_UInt64(&prop, curFolderUnpackSize); | ||
2580 | RINOK(reportArcProp->ReportProp( | ||
2581 | NEventIndexType::kBlockIndex, (UInt32)folderIndex, kpidSize, &prop)); | ||
2582 | } | ||
2583 | { | ||
2584 | NWindows::NCOM::PropVarEm_Set_UInt64(&prop, packSize); | ||
2585 | RINOK(reportArcProp->ReportProp( | ||
2586 | NEventIndexType::kBlockIndex, (UInt32)folderIndex, kpidPackSize, &prop)); | ||
2587 | } | ||
2588 | { | ||
2589 | NWindows::NCOM::PropVarEm_Set_UInt32(&prop, numStreams); | ||
2590 | RINOK(reportArcProp->ReportProp( | ||
2591 | NEventIndexType::kBlockIndex, (UInt32)folderIndex, kpidNumStreams, &prop)); | ||
2592 | } | ||
2593 | RINOK(reportArcProp->ReportFinished(NEventIndexType::kBlockIndex, (UInt32)folderIndex, NUpdate::NOperationResult::kOK)); | ||
2594 | } | ||
2595 | */ | ||
2596 | /* | ||
2597 | if (opCallback) | ||
2598 | { | ||
2599 | RINOK(opCallback->ReportOperation( | ||
2600 | NEventIndexType::kBlockIndex, (UInt32)folderIndex, | ||
2601 | NUpdateNotifyOp::kOpFinished)); | ||
2602 | } | ||
2603 | */ | ||
2473 | } | 2604 | } |
2474 | } | 2605 | } |
2475 | 2606 | ||