This commit is contained in:
Igor Pavlov
2022-06-23 11:43:16 +01:00
committed by Kornel
parent c3529a41f5
commit ec44a8a070
1248 changed files with 15242 additions and 2443 deletions

0
CPP/7zip/7zip.mak Normal file → Executable file
View File

8
CPP/7zip/7zip_gcc.mak Normal file → Executable file
View File

@@ -382,6 +382,8 @@ $O/VirtThread.o: ../../Common/VirtThread.cpp
$(CXX) $(CXXFLAGS) $<
$O/ApfsHandler.o: ../../Archive/ApfsHandler.cpp
$(CXX) $(CXXFLAGS) $<
$O/ApmHandler.o: ../../Archive/ApmHandler.cpp
$(CXX) $(CXXFLAGS) $<
$O/ArchiveExports.o: ../../Archive/ArchiveExports.cpp
@@ -390,6 +392,8 @@ $O/ArHandler.o: ../../Archive/ArHandler.cpp
$(CXX) $(CXXFLAGS) $<
$O/ArjHandler.o: ../../Archive/ArjHandler.cpp
$(CXX) $(CXXFLAGS) $<
$O/AvbHandler.o: ../../Archive/AvbHandler.cpp
$(CXX) $(CXXFLAGS) $<
$O/Base64Handler.o: ../../Archive/Base64Handler.cpp
$(CXX) $(CXXFLAGS) $<
$O/Bz2Handler.o: ../../Archive/Bz2Handler.cpp
@@ -426,6 +430,8 @@ $O/HfsHandler.o: ../../Archive/HfsHandler.cpp
$(CXX) $(CXXFLAGS) $<
$O/IhexHandler.o: ../../Archive/IhexHandler.cpp
$(CXX) $(CXXFLAGS) $<
$O/LpHandler.o: ../../Archive/LpHandler.cpp
$(CXX) $(CXXFLAGS) $<
$O/LzhHandler.o: ../../Archive/LzhHandler.cpp
$(CXX) $(CXXFLAGS) $<
$O/LzmaHandler.o: ../../Archive/LzmaHandler.cpp
@@ -448,6 +454,8 @@ $O/QcowHandler.o: ../../Archive/QcowHandler.cpp
$(CXX) $(CXXFLAGS) $<
$O/RpmHandler.o: ../../Archive/RpmHandler.cpp
$(CXX) $(CXXFLAGS) $<
$O/SparseHandler.o: ../../Archive/SparseHandler.cpp
$(CXX) $(CXXFLAGS) $<
$O/SplitHandler.o: ../../Archive/SplitHandler.cpp
$(CXX) $(CXXFLAGS) $<
$O/SquashfsHandler.o: ../../Archive/SquashfsHandler.cpp

0
CPP/7zip/Aes.mak Normal file → Executable file
View File

0
CPP/7zip/Archive/7z/7z.dsp Normal file → Executable file
View File

0
CPP/7zip/Archive/7z/7z.dsw Normal file → Executable file
View File

0
CPP/7zip/Archive/7z/7zCompressionMode.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/7z/7zCompressionMode.h Normal file → Executable file
View File

0
CPP/7zip/Archive/7z/7zDecode.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/7z/7zDecode.h Normal file → Executable file
View File

0
CPP/7zip/Archive/7z/7zEncode.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/7z/7zEncode.h Normal file → Executable file
View File

0
CPP/7zip/Archive/7z/7zExtract.cpp Normal file → Executable file
View File

123
CPP/7zip/Archive/7z/7zFolderInStream.cpp Normal file → Executable file
View File

@@ -2,6 +2,8 @@
#include "StdAfx.h"
#include "../../../Windows/TimeUtils.h"
#include "7zFolderInStream.h"
namespace NArchive {
@@ -13,17 +15,17 @@ void CFolderInStream::Init(IArchiveUpdateCallback *updateCallback,
_updateCallback = updateCallback;
_indexes = indexes;
_numFiles = numFiles;
_index = 0;
Processed.ClearAndReserve(numFiles);
CRCs.ClearAndReserve(numFiles);
Sizes.ClearAndReserve(numFiles);
_pos = 0;
_crc = CRC_INIT_VAL;
_size_Defined = false;
_size = 0;
if (Need_CTime) CTimes.ClearAndReserve(numFiles);
if (Need_ATime) ATimes.ClearAndReserve(numFiles);
if (Need_MTime) MTimes.ClearAndReserve(numFiles);
if (Need_Attrib) Attribs.ClearAndReserve(numFiles);
TimesDefined.ClearAndReserve(numFiles);
_stream.Release();
}
@@ -32,44 +34,101 @@ HRESULT CFolderInStream::OpenStream()
_pos = 0;
_crc = CRC_INIT_VAL;
_size_Defined = false;
_times_Defined = false;
_size = 0;
FILETIME_Clear(_cTime);
FILETIME_Clear(_aTime);
FILETIME_Clear(_mTime);
_attrib = 0;
while (_index < _numFiles)
while (Processed.Size() < _numFiles)
{
CMyComPtr<ISequentialInStream> stream;
HRESULT result = _updateCallback->GetStream(_indexes[_index], &stream);
if (result != S_OK)
{
if (result != S_FALSE)
return result;
}
const HRESULT result = _updateCallback->GetStream(_indexes[Processed.Size()], &stream);
if (result != S_OK && result != S_FALSE)
return result;
_stream = stream;
if (stream)
{
CMyComPtr<IStreamGetSize> streamGetSize;
stream.QueryInterface(IID_IStreamGetSize, &streamGetSize);
if (streamGetSize)
{
if (streamGetSize->GetSize(&_size) == S_OK)
_size_Defined = true;
CMyComPtr<IStreamGetProps> getProps;
stream.QueryInterface(IID_IStreamGetProps, (void **)&getProps);
if (getProps)
{
// access could be changed in first myx pass
if (getProps->GetProps(&_size,
Need_CTime ? &_cTime : NULL,
Need_ATime ? &_aTime : NULL,
Need_MTime ? &_mTime : NULL,
Need_Attrib ? &_attrib : NULL)
== S_OK)
{
_size_Defined = true;
_times_Defined = true;
}
return S_OK;
}
}
{
CMyComPtr<IStreamGetSize> streamGetSize;
stream.QueryInterface(IID_IStreamGetSize, &streamGetSize);
if (streamGetSize)
{
if (streamGetSize->GetSize(&_size) == S_OK)
_size_Defined = true;
}
return S_OK;
}
return S_OK;
}
_index++;
RINOK(_updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
AddFileInfo(result == S_OK);
RINOK(AddFileInfo(result == S_OK));
}
return S_OK;
}
void CFolderInStream::AddFileInfo(bool isProcessed)
static void AddFt(CRecordVector<UInt64> &vec, const FILETIME &ft)
{
Processed.Add(isProcessed);
Sizes.Add(_pos);
CRCs.Add(CRC_GET_DIGEST(_crc));
vec.AddInReserved(FILETIME_To_UInt64(ft));
}
/*
HRESULT ReportItemProps(IArchiveUpdateCallbackArcProp *reportArcProp,
UInt32 index, UInt64 size, const UInt32 *crc)
{
PROPVARIANT prop;
prop.vt = VT_EMPTY;
prop.wReserved1 = 0;
NWindows::NCOM::PropVarEm_Set_UInt64(&prop, size);
RINOK(reportArcProp->ReportProp(NEventIndexType::kOutArcIndex, index, kpidSize, &prop));
if (crc)
{
NWindows::NCOM::PropVarEm_Set_UInt32(&prop, *crc);
RINOK(reportArcProp->ReportProp(NEventIndexType::kOutArcIndex, index, kpidCRC, &prop));
}
return reportArcProp->ReportFinished(NEventIndexType::kOutArcIndex, index, NUpdate::NOperationResult::kOK);
}
*/
HRESULT CFolderInStream::AddFileInfo(bool isProcessed)
{
// const UInt32 index = _indexes[Processed.Size()];
Processed.AddInReserved(isProcessed);
Sizes.AddInReserved(_pos);
const UInt32 crc = CRC_GET_DIGEST(_crc);
CRCs.AddInReserved(crc);
TimesDefined.AddInReserved(_times_Defined);
if (Need_CTime) AddFt(CTimes, _cTime);
if (Need_ATime) AddFt(ATimes, _aTime);
if (Need_MTime) AddFt(MTimes, _mTime);
if (Need_Attrib) Attribs.AddInReserved(_attrib);
/*
if (isProcessed && _reportArcProp)
RINOK(ReportItemProps(_reportArcProp, index, _pos, &crc))
*/
return _updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK);
}
STDMETHODIMP CFolderInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
@@ -95,18 +154,10 @@ STDMETHODIMP CFolderInStream::Read(void *data, UInt32 size, UInt32 *processedSiz
}
_stream.Release();
_index++;
AddFileInfo(true);
_pos = 0;
_crc = CRC_INIT_VAL;
_size_Defined = false;
_size = 0;
RINOK(_updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
RINOK(AddFileInfo(true));
}
if (_index >= _numFiles)
if (Processed.Size() >= _numFiles)
break;
RINOK(OpenStream());
}

31
CPP/7zip/Archive/7z/7zFolderInStream.h Normal file → Executable file
View File

@@ -23,21 +23,37 @@ class CFolderInStream:
UInt64 _pos;
UInt32 _crc;
bool _size_Defined;
bool _times_Defined;
UInt64 _size;
FILETIME _cTime;
FILETIME _aTime;
FILETIME _mTime;
UInt32 _attrib;
const UInt32 *_indexes;
unsigned _numFiles;
unsigned _index;
const UInt32 *_indexes;
CMyComPtr<IArchiveUpdateCallback> _updateCallback;
HRESULT OpenStream();
void AddFileInfo(bool isProcessed);
HRESULT AddFileInfo(bool isProcessed);
public:
CRecordVector<bool> Processed;
CRecordVector<UInt32> CRCs;
CRecordVector<UInt64> Sizes;
CRecordVector<UInt64> CTimes;
CRecordVector<UInt64> ATimes;
CRecordVector<UInt64> MTimes;
CRecordVector<UInt32> Attribs;
CRecordVector<bool> TimesDefined;
bool Need_CTime;
bool Need_ATime;
bool Need_MTime;
bool Need_Attrib;
// CMyComPtr<IArchiveUpdateCallbackArcProp> _reportArcProp;
MY_UNKNOWN_IMP2(ISequentialInStream, ICompressGetSubStreamSize)
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
@@ -45,7 +61,7 @@ public:
void Init(IArchiveUpdateCallback *updateCallback, const UInt32 *indexes, unsigned numFiles);
bool WasFinished() const { return _index == _numFiles; }
bool WasFinished() const { return Processed.Size() == _numFiles; }
UInt64 GetFullSize() const
{
@@ -54,6 +70,13 @@ public:
size += Sizes[i];
return size;
}
CFolderInStream():
Need_CTime(false),
Need_ATime(false),
Need_MTime(false),
Need_Attrib(false)
{}
};
}}

2
CPP/7zip/Archive/7z/7zHandler.cpp Normal file → Executable file
View File

@@ -278,7 +278,7 @@ static void SetFileTimeProp_From_UInt64Def(PROPVARIANT *prop, const CUInt64DefVe
{
UInt64 value;
if (v.GetItem(index, value))
PropVarEm_Set_FileTime64(prop, value);
PropVarEm_Set_FileTime64_Prec(prop, value, k_PropVar_TimePrec_100ns);
}
bool CHandler::IsFolderEncrypted(CNum folderIndex) const

5
CPP/7zip/Archive/7z/7zHandler.h Normal file → Executable file
View File

@@ -49,9 +49,8 @@ public:
bool _encryptHeaders;
// bool _useParents; 9.26
CBoolPair Write_CTime;
CBoolPair Write_ATime;
CBoolPair Write_MTime;
CHandlerTimeOptions TimeOptions;
CBoolPair Write_Attrib;
bool _useMultiThreadMixer;

39
CPP/7zip/Archive/7z/7zHandlerOut.cpp Normal file → Executable file
View File

@@ -384,16 +384,16 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
CObjectVector<CUpdateItem> updateItems;
bool need_CTime = (Write_CTime.Def && Write_CTime.Val);
bool need_ATime = (Write_ATime.Def && Write_ATime.Val);
bool need_MTime = (Write_MTime.Def ? Write_MTime.Val : true);
bool need_CTime = (TimeOptions.Write_CTime.Def && TimeOptions.Write_CTime.Val);
bool need_ATime = (TimeOptions.Write_ATime.Def && TimeOptions.Write_ATime.Val);
bool need_MTime = (TimeOptions.Write_MTime.Def ? TimeOptions.Write_MTime.Val : true);
bool need_Attrib = (Write_Attrib.Def ? Write_Attrib.Val : true);
if (db && !db->Files.IsEmpty())
{
if (!Write_CTime.Def) need_CTime = !db->CTime.Defs.IsEmpty();
if (!Write_ATime.Def) need_ATime = !db->ATime.Defs.IsEmpty();
if (!Write_MTime.Def) need_MTime = !db->MTime.Defs.IsEmpty();
if (!TimeOptions.Write_CTime.Def) need_CTime = !db->CTime.Defs.IsEmpty();
if (!TimeOptions.Write_ATime.Def) need_ATime = !db->ATime.Defs.IsEmpty();
if (!TimeOptions.Write_MTime.Def) need_MTime = !db->MTime.Defs.IsEmpty();
if (!Write_Attrib.Def) need_Attrib = !db->Attrib.Defs.IsEmpty();
}
@@ -719,6 +719,11 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
int level = GetLevel();
CUpdateOptions options;
options.Need_CTime = need_CTime;
options.Need_ATime = need_ATime;
options.Need_MTime = need_MTime;
options.Need_Attrib = need_Attrib;
options.Method = &methodMode;
options.HeaderMethod = (_compressHeaders || encryptHeaders) ? &headerMethod : NULL;
options.UseFilters = (level != 0 && _autoFilter && !methodMode.Filter_was_Inserted);
@@ -817,9 +822,7 @@ void COutHandler::InitProps7z()
_encryptHeaders = false;
// _useParents = false;
Write_CTime.Init();
Write_ATime.Init();
Write_MTime.Init();
TimeOptions.Init();
Write_Attrib.Init();
_useMultiThreadMixer = true;
@@ -954,10 +957,20 @@ HRESULT COutHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &val
return S_OK;
}
if (name.IsEqualTo("tc")) return PROPVARIANT_to_BoolPair(value, Write_CTime);
if (name.IsEqualTo("ta")) return PROPVARIANT_to_BoolPair(value, Write_ATime);
if (name.IsEqualTo("tm")) return PROPVARIANT_to_BoolPair(value, Write_MTime);
{
bool processed;
RINOK(TimeOptions.Parse(name, value, processed));
if (processed)
{
if ( TimeOptions.Prec != (UInt32)(Int32)-1
&& TimeOptions.Prec != k_PropVar_TimePrec_0
&& TimeOptions.Prec != k_PropVar_TimePrec_HighPrec
&& TimeOptions.Prec != k_PropVar_TimePrec_100ns)
return E_INVALIDARG;
return S_OK;
}
}
if (name.IsEqualTo("tr")) return PROPVARIANT_to_BoolPair(value, Write_Attrib);
if (name.IsEqualTo("mtf")) return PROPVARIANT_to_bool(value, _useMultiThreadMixer);

0
CPP/7zip/Archive/7z/7zHeader.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/7z/7zHeader.h Normal file → Executable file
View File

0
CPP/7zip/Archive/7z/7zIn.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/7z/7zIn.h Normal file → Executable file
View File

0
CPP/7zip/Archive/7z/7zItem.h Normal file → Executable file
View File

0
CPP/7zip/Archive/7z/7zOut.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/7z/7zOut.h Normal file → Executable file
View File

0
CPP/7zip/Archive/7z/7zProperties.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/7z/7zProperties.h Normal file → Executable file
View File

10
CPP/7zip/Archive/7z/7zRegister.cpp Normal file → Executable file
View File

@@ -15,7 +15,13 @@ REGISTER_ARC_IO_DECREMENT_SIG(
"7z", "7z", NULL, 7,
k_Signature_Dec,
0,
NArcInfoFlags::kFindSignature,
NULL);
NArcInfoFlags::kFindSignature
| NArcInfoFlags::kCTime
| NArcInfoFlags::kATime
| NArcInfoFlags::kMTime
| NArcInfoFlags::kMTime_Default
, TIME_PREC_TO_ARC_FLAGS_MASK(NFileTimeType::kWindows)
| TIME_PREC_TO_ARC_FLAGS_TIME_DEFAULT(NFileTimeType::kWindows)
, NULL);
}}

0
CPP/7zip/Archive/7z/7zSpecStream.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/7z/7zSpecStream.h Normal file → Executable file
View File

141
CPP/7zip/Archive/7z/7zUpdate.cpp Normal file → Executable file
View File

@@ -804,10 +804,20 @@ struct CAnalysis
bool ParseExe;
bool ParseAll;
/*
bool Need_ATime;
bool ATime_Defined;
FILETIME ATime;
*/
CAnalysis():
ParseWav(true),
ParseExe(false),
ParseAll(false)
/*
, Need_ATime(false)
, ATime_Defined(false)
*/
{}
HRESULT GetFilterGroup(UInt32 index, const CUpdateItem &ui, CFilterMode &filterMode);
@@ -887,6 +897,18 @@ HRESULT CAnalysis::GetFilterGroup(UInt32 index, const CUpdateItem &ui, CFilterMo
HRESULT result = Callback->GetStream2(index, &stream, NUpdateNotifyOp::kAnalyze);
if (result == S_OK && stream)
{
/*
if (Need_ATime)
{
// access time could be changed in analysis pass
CMyComPtr<IStreamGetProps> getProps;
stream.QueryInterface(IID_IStreamGetProps, (void **)&getProps);
if (getProps)
if (getProps->GetProps(NULL, NULL, &ATime, NULL, NULL) == S_OK)
ATime_Defined = true;
}
*/
size_t size = kAnalysisBufSize;
result = ReadStream(stream, Buffer, &size);
stream.Release();
@@ -1586,6 +1608,11 @@ HRESULT Update(
CMyComPtr<IArchiveExtractCallbackMessage> extractCallback;
updateCallback->QueryInterface(IID_IArchiveExtractCallbackMessage, (void **)&extractCallback);
/*
CMyComPtr<IArchiveUpdateCallbackArcProp> reportArcProp;
updateCallback->QueryInterface(IID_IArchiveUpdateCallbackArcProp, (void **)&reportArcProp);
*/
// size_t totalSecureDataSize = (size_t)secureBlocks.GetTotalSizeInBytes();
/*
@@ -1756,6 +1783,7 @@ HRESULT Update(
{
CAnalysis analysis;
// analysis.Need_ATime = options.Need_ATime;
if (options.AnalysisLevel == 0)
{
analysis.ParseWav = false;
@@ -1790,7 +1818,15 @@ HRESULT Update(
CFilterMode2 fm;
if (useFilters)
{
// analysis.ATime_Defined = false;
RINOK(analysis.GetFilterGroup(i, ui, fm));
/*
if (analysis.ATime_Defined)
{
ui.ATime = FILETIME_To_UInt64(analysis.ATime);
ui.ATime_WasReadByAnalysis = true;
}
*/
}
fm.Encrypted = method.PasswordIsDefined;
@@ -2374,13 +2410,33 @@ HRESULT Update(
RINOK(lps->SetCur());
/*
const unsigned folderIndex = newDatabase.NumUnpackStreamsVector.Size();
if (opCallback)
{
RINOK(opCallback->ReportOperation(
NEventIndexType::kBlockIndex, (UInt32)folderIndex,
NUpdateNotifyOp::kAdd));
}
*/
CFolderInStream *inStreamSpec = new CFolderInStream;
CMyComPtr<ISequentialInStream> solidInStream(inStreamSpec);
// inStreamSpec->_reportArcProp = reportArcProp;
inStreamSpec->Need_CTime = options.Need_CTime;
inStreamSpec->Need_ATime = options.Need_ATime;
inStreamSpec->Need_MTime = options.Need_MTime;
inStreamSpec->Need_Attrib = options.Need_Attrib;
inStreamSpec->Init(updateCallback, &indices[i], numSubFiles);
unsigned startPackIndex = newDatabase.PackSizes.Size();
UInt64 curFolderUnpackSize = totalSize;
// curFolderUnpackSize = (UInt64)(Int64)-1;
// curFolderUnpackSize = (UInt64)(Int64)-1; // for debug
RINOK(encoder.Encode(
EXTERNAL_CODECS_LOC_VARS
@@ -2393,8 +2449,11 @@ HRESULT Update(
if (!inStreamSpec->WasFinished())
return E_FAIL;
UInt64 packSize = 0;
// const UInt32 numStreams = newDatabase.PackSizes.Size() - startPackIndex;
for (; startPackIndex < newDatabase.PackSizes.Size(); startPackIndex++)
lps->OutSize += newDatabase.PackSizes[startPackIndex];
packSize += newDatabase.PackSizes[startPackIndex];
lps->OutSize += packSize;
lps->InSize += curFolderUnpackSize;
// for ()
@@ -2403,7 +2462,9 @@ HRESULT Update(
CNum numUnpackStreams = 0;
UInt64 skippedSize = 0;
UInt64 procSize = 0;
// unsigned numProcessedFiles = 0;
for (unsigned subIndex = 0; subIndex < numSubFiles; subIndex++)
{
const CUpdateItem &ui = updateItems[indices[i + subIndex]];
@@ -2429,14 +2490,16 @@ HRESULT Update(
*/
if (!inStreamSpec->Processed[subIndex])
{
// we don't add file here
skippedSize += ui.Size;
continue;
// file.Name += ".locked";
continue; // comment it for debug
// name += ".locked"; // for debug
}
file.Crc = inStreamSpec->CRCs[subIndex];
file.Size = inStreamSpec->Sizes[subIndex];
procSize += file.Size;
// if (file.Size >= 0) // test purposes
if (file.Size != 0)
{
@@ -2450,6 +2513,23 @@ HRESULT Update(
file.HasStream = false;
}
if (inStreamSpec->TimesDefined[subIndex])
{
if (inStreamSpec->Need_CTime)
{ file2.CTimeDefined = true; file2.CTime = inStreamSpec->CTimes[subIndex]; }
if (inStreamSpec->Need_ATime
// && !ui.ATime_WasReadByAnalysis
)
{ file2.ATimeDefined = true; file2.ATime = inStreamSpec->ATimes[subIndex]; }
if (inStreamSpec->Need_MTime)
{ file2.MTimeDefined = true; file2.MTime = inStreamSpec->MTimes[subIndex]; }
if (inStreamSpec->Need_Attrib)
{
file2.AttribDefined = true;
file2.Attrib = inStreamSpec->Attribs[subIndex];
}
}
/*
file.Parent = ui.ParentFolderIndex;
if (ui.TreeFolderIndex >= 0)
@@ -2457,9 +2537,22 @@ HRESULT Update(
if (totalSecureDataSize != 0)
newDatabase.SecureIDs.Add(ui.SecureIndex);
*/
/*
if (reportArcProp)
{
RINOK(ReportItemProps(reportArcProp, ui.IndexInClient, file.Size,
file.CrcDefined ? &file.Crc : NULL))
}
*/
// numProcessedFiles++;
newDatabase.AddFile(file, file2, name);
}
// it's optional check to ensure that sizes are correct
if (procSize != curFolderUnpackSize)
return E_FAIL;
// numUnpackStreams = 0 is very bad case for locked files
// v3.13 doesn't understand it.
newDatabase.NumUnpackStreamsVector.Add(numUnpackStreams);
@@ -2470,6 +2563,44 @@ HRESULT Update(
complexity -= skippedSize;
RINOK(updateCallback->SetTotal(complexity));
}
/*
if (reportArcProp)
{
PROPVARIANT prop;
prop.vt = VT_EMPTY;
prop.wReserved1 = 0;
{
NWindows::NCOM::PropVarEm_Set_UInt32(&prop, numProcessedFiles);
RINOK(reportArcProp->ReportProp(
NEventIndexType::kBlockIndex, (UInt32)folderIndex, kpidNumSubFiles, &prop));
}
{
NWindows::NCOM::PropVarEm_Set_UInt64(&prop, curFolderUnpackSize);
RINOK(reportArcProp->ReportProp(
NEventIndexType::kBlockIndex, (UInt32)folderIndex, kpidSize, &prop));
}
{
NWindows::NCOM::PropVarEm_Set_UInt64(&prop, packSize);
RINOK(reportArcProp->ReportProp(
NEventIndexType::kBlockIndex, (UInt32)folderIndex, kpidPackSize, &prop));
}
{
NWindows::NCOM::PropVarEm_Set_UInt32(&prop, numStreams);
RINOK(reportArcProp->ReportProp(
NEventIndexType::kBlockIndex, (UInt32)folderIndex, kpidNumStreams, &prop));
}
RINOK(reportArcProp->ReportFinished(NEventIndexType::kBlockIndex, (UInt32)folderIndex, NUpdate::NOperationResult::kOK));
}
*/
/*
if (opCallback)
{
RINOK(opCallback->ReportOperation(
NEventIndexType::kBlockIndex, (UInt32)folderIndex,
NUpdateNotifyOp::kOpFinished));
}
*/
}
}

14
CPP/7zip/Archive/7z/7zUpdate.h Normal file → Executable file
View File

@@ -62,6 +62,8 @@ struct CUpdateItem
bool ATimeDefined;
bool MTimeDefined;
// bool ATime_WasReadByAnalysis;
// int SecureIndex; // 0 means (no_security)
bool HasStream() const { return !IsDir && !IsAnti && Size != 0; }
@@ -76,6 +78,7 @@ struct CUpdateItem
CTimeDefined(false),
ATimeDefined(false),
MTimeDefined(false)
// , ATime_WasReadByAnalysis(false)
// SecureIndex(0)
{}
void SetDirStatusFromAttrib() { IsDir = ((Attrib & FILE_ATTRIBUTE_DIRECTORY) != 0); }
@@ -103,6 +106,11 @@ struct CUpdateOptions
bool RemoveSfxBlock;
bool MultiThreadMixer;
bool Need_CTime;
bool Need_ATime;
bool Need_MTime;
bool Need_Attrib;
CUpdateOptions():
Method(NULL),
HeaderMethod(NULL),
@@ -114,7 +122,11 @@ struct CUpdateOptions
SolidExtension(false),
UseTypeSorting(true),
RemoveSfxBlock(false),
MultiThreadMixer(true)
MultiThreadMixer(true),
Need_CTime(false),
Need_ATime(false),
Need_MTime(false),
Need_Attrib(false)
{}
};

0
CPP/7zip/Archive/7z/StdAfx.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/7z/StdAfx.h Normal file → Executable file
View File

0
CPP/7zip/Archive/7z/makefile Normal file → Executable file
View File

0
CPP/7zip/Archive/7z/resource.rc Normal file → Executable file
View File

3546
CPP/7zip/Archive/ApfsHandler.cpp Executable file
View File

File diff suppressed because it is too large Load Diff

0
CPP/7zip/Archive/ApmHandler.cpp Normal file → Executable file
View File

14
CPP/7zip/Archive/ArHandler.cpp Normal file → Executable file
View File

@@ -322,8 +322,8 @@ static const Byte kProps[] =
kpidSize,
kpidMTime,
kpidPosixAttrib,
kpidUser,
kpidGroup
kpidUserId,
kpidGroupId
};
IMP_IInArchive_Props
@@ -734,15 +734,11 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
case kpidMTime:
{
if (item.MTime != 0)
{
FILETIME fileTime;
NTime::UnixTimeToFileTime(item.MTime, fileTime);
prop = fileTime;
}
PropVariant_SetFrom_UnixTime(prop, item.MTime);
break;
}
case kpidUser: if (item.User != 0) prop = item.User; break;
case kpidGroup: if (item.Group != 0) prop = item.Group; break;
case kpidUserId: if (item.User != 0) prop = item.User; break;
case kpidGroupId: if (item.Group != 0) prop = item.Group; break;
case kpidPosixAttrib:
if (item.TextFileIndex < 0)
prop = item.Mode;

0
CPP/7zip/Archive/Archive.def Normal file → Executable file
View File

0
CPP/7zip/Archive/Archive2.def Normal file → Executable file
View File

1
CPP/7zip/Archive/ArchiveExports.cpp Normal file → Executable file
View File

@@ -115,6 +115,7 @@ STDAPI GetHandlerProperty2(UInt32 formatIndex, PROPID propID, PROPVARIANT *value
case NArchive::NHandlerPropID::kAltStreams: prop = ((arc.Flags & NArcInfoFlags::kAltStreams) != 0); break;
case NArchive::NHandlerPropID::kNtSecure: prop = ((arc.Flags & NArcInfoFlags::kNtSecure) != 0); break;
case NArchive::NHandlerPropID::kFlags: prop = (UInt32)arc.Flags; break;
case NArchive::NHandlerPropID::kTimeFlags: prop = (UInt32)arc.TimeFlags; break;
case NArchive::NHandlerPropID::kSignatureOffset: prop = (UInt32)arc.SignatureOffset; break;
// case NArchive::NHandlerPropID::kVersion: prop = (UInt32)MY_VER_MIX; break;

10
CPP/7zip/Archive/ArjHandler.cpp Normal file → Executable file
View File

@@ -682,15 +682,7 @@ static void SetTime(UInt32 dosTime, NCOM::CPropVariant &prop)
{
if (dosTime == 0)
return;
FILETIME localFileTime, utc;
if (NTime::DosTimeToFileTime(dosTime, localFileTime))
{
if (!LocalFileTimeToFileTime(&localFileTime, &utc))
utc.dwHighDateTime = utc.dwLowDateTime = 0;
}
else
utc.dwHighDateTime = utc.dwLowDateTime = 0;
prop = utc;
PropVariant_SetFrom_DosTime(prop, dosTime);
}
static void SetHostOS(Byte hostOS, NCOM::CPropVariant &prop)

0
CPP/7zip/Archive/Base64Handler.cpp Normal file → Executable file
View File

100
CPP/7zip/Archive/Bz2Handler.cpp Normal file → Executable file
View File

@@ -305,29 +305,91 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
}
/*
static HRESULT ReportItemProp(IArchiveUpdateCallbackArcProp *reportArcProp, PROPID propID, const PROPVARIANT *value)
{
return reportArcProp->ReportProp(NEventIndexType::kOutArcIndex, 0, propID, value);
}
static HRESULT ReportArcProp(IArchiveUpdateCallbackArcProp *reportArcProp, PROPID propID, const PROPVARIANT *value)
{
return reportArcProp->ReportProp(NEventIndexType::kArcProp, 0, propID, value);
}
static HRESULT ReportArcProps(IArchiveUpdateCallbackArcProp *reportArcProp,
const UInt64 *unpackSize,
const UInt64 *numBlocks)
{
NCOM::CPropVariant sizeProp;
if (unpackSize)
{
sizeProp = *unpackSize;
RINOK(ReportItemProp(reportArcProp, kpidSize, &sizeProp));
RINOK(reportArcProp->ReportFinished(NEventIndexType::kOutArcIndex, 0, NArchive::NUpdate::NOperationResult::kOK));
}
if (unpackSize)
{
RINOK(ReportArcProp(reportArcProp, kpidSize, &sizeProp));
}
if (numBlocks)
{
NCOM::CPropVariant prop;
prop = *numBlocks;
RINOK(ReportArcProp(reportArcProp, kpidNumBlocks, &prop));
}
return S_OK;
}
*/
static HRESULT UpdateArchive(
UInt64 unpackSize,
ISequentialOutStream *outStream,
const CProps &props,
IArchiveUpdateCallback *updateCallback)
IArchiveUpdateCallback *updateCallback
// , ArchiveUpdateCallbackArcProp *reportArcProp
)
{
RINOK(updateCallback->SetTotal(unpackSize));
CMyComPtr<ISequentialInStream> fileInStream;
RINOK(updateCallback->GetStream(0, &fileInStream));
CLocalProgress *localProgressSpec = new CLocalProgress;
CMyComPtr<ICompressProgressInfo> localProgress = localProgressSpec;
localProgressSpec->Init(updateCallback, true);
NCompress::NBZip2::CEncoder *encoderSpec = new NCompress::NBZip2::CEncoder;
CMyComPtr<ICompressCoder> encoder = encoderSpec;
RINOK(props.SetCoderProps(encoderSpec, NULL));
RINOK(encoder->Code(fileInStream, outStream, NULL, NULL, localProgress));
{
CMyComPtr<ISequentialInStream> fileInStream;
RINOK(updateCallback->GetStream(0, &fileInStream));
if (!fileInStream)
return S_FALSE;
{
CMyComPtr<IStreamGetSize> streamGetSize;
fileInStream.QueryInterface(IID_IStreamGetSize, &streamGetSize);
if (streamGetSize)
{
UInt64 size;
if (streamGetSize->GetSize(&size) == S_OK)
unpackSize = size;
}
}
RINOK(updateCallback->SetTotal(unpackSize));
CLocalProgress *localProgressSpec = new CLocalProgress;
CMyComPtr<ICompressProgressInfo> localProgress = localProgressSpec;
localProgressSpec->Init(updateCallback, true);
{
NCompress::NBZip2::CEncoder *encoderSpec = new NCompress::NBZip2::CEncoder;
CMyComPtr<ICompressCoder> encoder = encoderSpec;
RINOK(props.SetCoderProps(encoderSpec, NULL));
RINOK(encoder->Code(fileInStream, outStream, NULL, NULL, localProgress));
/*
if (reportArcProp)
{
unpackSize = encoderSpec->GetInProcessedSize();
RINOK(ReportArcProps(reportArcProp, &unpackSize, &encoderSpec->NumBlocks));
}
*/
}
}
return updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK);
}
STDMETHODIMP CHandler::GetFileTimeType(UInt32 *type)
STDMETHODIMP CHandler::GetFileTimeType(UInt32 *timeType)
{
*type = NFileTimeType::kUnix;
*timeType = GET_FileTimeType_NotDefined_for_GetFileTimeType;
// *timeType = NFileTimeType::kUnix;
return S_OK;
}
@@ -345,6 +407,11 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
return E_FAIL;
RINOK(updateCallback->GetUpdateItemInfo(0, &newData, &newProps, &indexInArchive));
/*
CMyComPtr<IArchiveUpdateCallbackArcProp> reportArcProp;
updateCallback->QueryInterface(IID_IArchiveUpdateCallbackArcProp, (void **)&reportArcProp);
*/
if (IntToBool(newProps))
{
{
@@ -396,6 +463,8 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
return NCompress::CopyStream(_stream, outStream, progress);
// return ReportArcProps(reportArcProp, NULL, NULL);
COM_TRY_END
}
@@ -410,7 +479,8 @@ REGISTER_ARC_IO(
"bzip2", "bz2 bzip2 tbz2 tbz", "* * .tar .tar", 2,
k_Signature,
0,
NArcInfoFlags::kKeepName,
IsArc_BZip2)
NArcInfoFlags::kKeepName
, 0
, IsArc_BZip2)
}}

0
CPP/7zip/Archive/Cab/CabBlockInStream.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/Cab/CabBlockInStream.h Normal file → Executable file
View File

10
CPP/7zip/Archive/Cab/CabHandler.cpp Normal file → Executable file
View File

@@ -295,15 +295,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
case kpidMTime:
{
FILETIME localFileTime, utcFileTime;
if (NTime::DosTimeToFileTime(item.Time, localFileTime))
{
if (!LocalFileTimeToFileTime(&localFileTime, &utcFileTime))
utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0;
}
else
utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0;
prop = utcFileTime;
PropVariant_SetFrom_DosTime(prop, item.Time);
break;
}

0
CPP/7zip/Archive/Cab/CabHandler.h Normal file → Executable file
View File

0
CPP/7zip/Archive/Cab/CabHeader.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/Cab/CabHeader.h Normal file → Executable file
View File

0
CPP/7zip/Archive/Cab/CabIn.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/Cab/CabIn.h Normal file → Executable file
View File

0
CPP/7zip/Archive/Cab/CabItem.h Normal file → Executable file
View File

0
CPP/7zip/Archive/Cab/CabRegister.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/Cab/StdAfx.h Normal file → Executable file
View File

0
CPP/7zip/Archive/Chm/ChmHandler.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/Chm/ChmHandler.h Normal file → Executable file
View File

0
CPP/7zip/Archive/Chm/ChmIn.cpp Normal file → Executable file
View File

11
CPP/7zip/Archive/Chm/ChmIn.h Normal file → Executable file
View File

@@ -84,6 +84,11 @@ struct CResetTable
// unsigned BlockSizeBits;
CRecordVector<UInt64> ResetOffsets;
CResetTable():
UncompressedSize(0),
CompressedSize(0)
{}
bool GetCompressedSizeOfBlocks(UInt64 blockIndex, UInt32 numBlocks, UInt64 &size) const
{
if (blockIndex >= ResetOffsets.Size())
@@ -118,6 +123,12 @@ struct CLzxInfo
CResetTable ResetTable;
CLzxInfo():
Version(0),
ResetIntervalBits(0),
CacheSize(0)
{}
unsigned GetNumDictBits() const
{
if (Version == 2 || Version == 3)

0
CPP/7zip/Archive/Chm/StdAfx.h Normal file → Executable file
View File

0
CPP/7zip/Archive/ComHandler.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/Common/CoderMixer2.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/Common/CoderMixer2.h Normal file → Executable file
View File

0
CPP/7zip/Archive/Common/DummyOutStream.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/Common/DummyOutStream.h Normal file → Executable file
View File

0
CPP/7zip/Archive/Common/FindSignature.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/Common/FindSignature.h Normal file → Executable file
View File

77
CPP/7zip/Archive/Common/HandlerOut.cpp Normal file → Executable file
View File

@@ -240,34 +240,42 @@ void CSingleMethodProps::Init()
}
HRESULT CSingleMethodProps::SetProperty(const wchar_t *name2, const PROPVARIANT &value)
{
// processed = false;
UString name = name2;
name.MakeLower_Ascii();
if (name.IsEmpty())
return E_INVALIDARG;
if (name.IsPrefixedBy_Ascii_NoCase("x"))
{
UInt32 a = 9;
RINOK(ParsePropToUInt32(name.Ptr(1), value, a));
_level = a;
AddProp_Level(a);
// processed = true;
return S_OK;
}
{
HRESULT hres;
if (SetCommonProperty(name, value, hres))
{
// processed = true;
return S_OK;
}
}
RINOK(ParseMethodFromPROPVARIANT(name, value));
return S_OK;
}
HRESULT CSingleMethodProps::SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps)
{
Init();
for (UInt32 i = 0; i < numProps; i++)
{
UString name = names[i];
name.MakeLower_Ascii();
if (name.IsEmpty())
return E_INVALIDARG;
const PROPVARIANT &value = values[i];
if (name[0] == L'x')
{
UInt32 a = 9;
RINOK(ParsePropToUInt32(name.Ptr(1), value, a));
_level = a;
AddProp_Level(a);
continue;
}
{
HRESULT hres;
if (SetCommonProperty(name, value, hres))
{
RINOK(hres)
continue;
}
}
RINOK(ParseMethodFromPROPVARIANT(names[i], value));
RINOK(SetProperty(names[i], values[i]));
}
return S_OK;
@@ -275,4 +283,29 @@ HRESULT CSingleMethodProps::SetProperties(const wchar_t * const *names, const PR
#endif
static HRESULT PROPVARIANT_to_BoolPair(const PROPVARIANT &prop, CBoolPair &dest)
{
RINOK(PROPVARIANT_to_bool(prop, dest.Val));
dest.Def = true;
return S_OK;
}
HRESULT CHandlerTimeOptions::Parse(const UString &name, const PROPVARIANT &prop, bool &processed)
{
processed = true;
if (name.IsEqualTo_Ascii_NoCase("tm")) { return PROPVARIANT_to_BoolPair(prop, Write_MTime); }
if (name.IsEqualTo_Ascii_NoCase("ta")) { return PROPVARIANT_to_BoolPair(prop, Write_ATime); }
if (name.IsEqualTo_Ascii_NoCase("tc")) { return PROPVARIANT_to_BoolPair(prop, Write_CTime); }
if (name.IsPrefixedBy_Ascii_NoCase("tp"))
{
UInt32 v = 0;
RINOK(ParsePropToUInt32(name.Ptr(2), prop, v));
Prec = v;
return S_OK;
}
processed = false;
return S_OK;
}
}

26
CPP/7zip/Archive/Common/HandlerOut.h Normal file → Executable file
View File

@@ -16,6 +16,7 @@ class CCommonMethodProps
protected:
void InitCommon()
{
// _Write_MTime = true;
#ifndef _7ZIP_ST
_numProcessors = _numThreads = NWindows::NSystem::GetNumberOfProcessors();
_numThreads_WasForced = false;
@@ -118,11 +119,36 @@ public:
CSingleMethodProps() { InitSingle(); }
int GetLevel() const { return _level == (UInt32)(Int32)-1 ? 5 : (int)_level; }
HRESULT SetProperty(const wchar_t *name, const PROPVARIANT &values);
HRESULT SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps);
};
#endif
struct CHandlerTimeOptions
{
CBoolPair Write_MTime;
CBoolPair Write_ATime;
CBoolPair Write_CTime;
UInt32 Prec;
void Init()
{
Write_MTime.Init();
Write_MTime.Val = true;
Write_ATime.Init();
Write_CTime.Init();
Prec = (UInt32)(Int32)-1;
}
CHandlerTimeOptions()
{
Init();
}
HRESULT Parse(const UString &name, const PROPVARIANT &prop, bool &processed);
};
}
#endif

0
CPP/7zip/Archive/Common/InStreamWithCRC.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/Common/InStreamWithCRC.h Normal file → Executable file
View File

23
CPP/7zip/Archive/Common/ItemNameUtils.cpp Normal file → Executable file
View File

@@ -79,6 +79,29 @@ void ReplaceToOsSlashes_Remove_TailSlash(UString &name, bool
}
void NormalizeSlashes_in_FileName_for_OsPath(wchar_t *name, unsigned len)
{
for (unsigned i = 0; i < len; i++)
{
wchar_t c = name[i];
if (c == L'/')
c = L'_';
#if WCHAR_PATH_SEPARATOR != L'/'
else if (c == L'\\')
c = WCHAR_IN_FILE_NAME_BACKSLASH_REPLACEMENT; // WSL scheme
#endif
else
continue;
name[i] = c;
}
}
void NormalizeSlashes_in_FileName_for_OsPath(UString &name)
{
NormalizeSlashes_in_FileName_for_OsPath(name.GetBuf(), name.Len());
}
bool HasTailSlash(const AString &name, UINT
#if defined(_WIN32) && !defined(UNDER_CE)
codePage

2
CPP/7zip/Archive/Common/ItemNameUtils.h Normal file → Executable file
View File

@@ -14,6 +14,8 @@ UString GetOsPath(const UString &name);
UString GetOsPath_Remove_TailSlash(const UString &name);
void ReplaceToOsSlashes_Remove_TailSlash(UString &name, bool useBackslashReplacement = false);
void NormalizeSlashes_in_FileName_for_OsPath(wchar_t *s, unsigned len);
void NormalizeSlashes_in_FileName_for_OsPath(UString &name);
bool HasTailSlash(const AString &name, UINT codePage);

0
CPP/7zip/Archive/Common/MultiStream.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/Common/MultiStream.h Normal file → Executable file
View File

0
CPP/7zip/Archive/Common/OutStreamWithCRC.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/Common/OutStreamWithCRC.h Normal file → Executable file
View File

0
CPP/7zip/Archive/Common/OutStreamWithSha1.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/Common/OutStreamWithSha1.h Normal file → Executable file
View File

0
CPP/7zip/Archive/Common/ParseProperties.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/Common/ParseProperties.h Normal file → Executable file
View File

0
CPP/7zip/Archive/Common/StdAfx.h Normal file → Executable file
View File

6
CPP/7zip/Archive/CpioHandler.cpp Normal file → Executable file
View File

@@ -652,11 +652,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
case kpidMTime:
{
if (item.MTime != 0)
{
FILETIME utc;
NTime::UnixTimeToFileTime(item.MTime, utc);
prop = utc;
}
PropVariant_SetFrom_UnixTime(prop, item.MTime);
break;
}
case kpidPosixAttrib: prop = item.Mode; break;

0
CPP/7zip/Archive/CramfsHandler.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/DeflateProps.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/DeflateProps.h Normal file → Executable file
View File

0
CPP/7zip/Archive/DllExports.cpp Normal file → Executable file
View File

18
CPP/7zip/Archive/DllExports2.cpp Normal file → Executable file
View File

@@ -125,6 +125,24 @@ STDAPI SetCaseSensitive(Int32 caseSensitive)
return S_OK;
}
/*
UInt32 g_ClientVersion;
STDAPI SetClientVersion(UInt32 version);
STDAPI SetClientVersion(UInt32 version)
{
g_ClientVersion = version;
return S_OK;
}
*/
/*
STDAPI SetProperty(Int32 id, const PROPVARIANT *value);
STDAPI SetProperty(Int32 id, const PROPVARIANT *value)
{
return S_OK;
}
*/
#ifdef EXTERNAL_CODECS
CExternalCodecs g_ExternalCodecs;

0
CPP/7zip/Archive/DmgHandler.cpp Normal file → Executable file
View File

0
CPP/7zip/Archive/ElfHandler.cpp Normal file → Executable file
View File

51
CPP/7zip/Archive/ExtHandler.cpp Normal file → Executable file
View File

@@ -343,6 +343,8 @@ struct CHeader
bool UseGdtChecksum() const { return (FeatureRoCompat & RO_COMPAT_GDT_CSUM) != 0; }
bool UseMetadataChecksum() const { return (FeatureRoCompat & RO_COMPAT_METADATA_CSUM) != 0; }
UInt64 GetPhySize() const { return NumBlocks << BlockBits; }
bool Parse(const Byte *p);
};
@@ -638,7 +640,7 @@ struct CNode
CExtTime MTime;
CExtTime ATime;
CExtTime CTime;
// CExtTime InodeChangeTime;
CExtTime ChangeTime;
// CExtTime DTime;
UInt64 NumBlocks;
@@ -674,14 +676,14 @@ bool CNode::Parse(const Byte *p, const CHeader &_h)
ATime.Extra = 0;
CTime.Extra = 0;
CTime.Val = 0;
// InodeChangeTime.Extra = 0;
ChangeTime.Extra = 0;
// DTime.Extra = 0;
LE_16 (0x00, Mode);
LE_16 (0x02, Uid);
LE_32 (0x04, FileSize);
LE_32 (0x08, ATime.Val);
// LE_32 (0x0C, InodeChangeTime.Val);
LE_32 (0x0C, ChangeTime.Val);
LE_32 (0x10, MTime.Val);
// LE_32 (0x14, DTime.Val);
LE_16 (0x18, Gid);
@@ -742,7 +744,7 @@ bool CNode::Parse(const Byte *p, const CHeader &_h)
{
// UInt16 checksumUpper;
// LE_16 (0x82, checksumUpper);
// LE_32 (0x84, InodeChangeTime.Extra);
LE_32 (0x84, ChangeTime.Extra);
LE_32 (0x88, MTime.Extra);
LE_32 (0x8C, ATime.Extra);
LE_32 (0x90, CTime.Val);
@@ -1148,7 +1150,7 @@ HRESULT CHandler::Open2(IInStream *inStream)
}
_isArc = true;
_phySize = _h.NumBlocks << _h.BlockBits;
_phySize = _h.GetPhySize();
if (_openCallback)
{
@@ -1744,8 +1746,8 @@ static const UInt32 kProps[] =
kpidLinks,
kpidSymLink,
kpidCharacts,
kpidUser,
kpidGroup
kpidUserId,
kpidGroupId
};
@@ -1792,11 +1794,7 @@ static void StringToProp(bool isUTF, const char *s, unsigned size, NCOM::CPropVa
static void UnixTimeToProp(UInt32 val, NCOM::CPropVariant &prop)
{
if (val != 0)
{
FILETIME ft;
NTime::UnixTimeToFileTime(val, ft);
prop = ft;
}
PropVariant_SetFrom_UnixTime(prop, val);
}
STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
@@ -1988,15 +1986,19 @@ static void ExtTimeToProp(const CExtTime &t, NCOM::CPropVariant &prop)
return;
FILETIME ft;
unsigned low100ns = 0;
// if (t.Extra != 0)
{
// 1901-2446 :
Int64 v = (Int64)(Int32)t.Val;
v += (UInt64)(t.Extra & 3) << 32; // 2 low bits are offset for main timestamp
UInt64 ft64 = NTime::UnixTime64ToFileTime64(v);
UInt64 ft64 = NTime::UnixTime64_To_FileTime64(v);
const UInt32 ns = (t.Extra >> 2);
if (ns < 1000000000)
{
ft64 += ns / 100;
low100ns = (unsigned)(ns % 100);
}
ft.dwLowDateTime = (DWORD)ft64;
ft.dwHighDateTime = (DWORD)(ft64 >> 32);
}
@@ -2011,7 +2013,7 @@ static void ExtTimeToProp(const CExtTime &t, NCOM::CPropVariant &prop)
// NTime::UnixTimeToFileTime(t.Val, ft); // for
}
*/
prop = ft;
prop.SetAsTimeFrom_FT_Prec_Ns100(ft, k_PropVar_TimePrec_1ns, low100ns);
}
@@ -2103,10 +2105,9 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
case kpidCTime: ExtTimeToProp(node.CTime, prop); break;
case kpidATime: ExtTimeToProp(node.ATime, prop); break;
// case kpidDTime: ExtTimeToProp(node.DTime, prop); break;
// case kpidChangeTime: ExtTimeToProp(node.InodeChangeTime, prop); break;
case kpidUser: prop = (UInt32)node.Uid; break;
case kpidGroup: prop = (UInt32)node.Gid; break;
case kpidChangeTime: ExtTimeToProp(node.ChangeTime, prop); break;
case kpidUserId: prop = (UInt32)node.Uid; break;
case kpidGroupId: prop = (UInt32)node.Gid; break;
case kpidLinks: prop = node.NumLinks; break;
case kpidINode: prop = (UInt32)item.Node; break;
case kpidStreamId: if (!isDir) prop = (UInt32)item.Node; break;
@@ -2827,17 +2828,29 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
}
API_FUNC_static_IsArc IsArc_Ext(const Byte *p, size_t size)
API_FUNC_IsArc IsArc_Ext_PhySize(const Byte *p, size_t size, UInt64 *phySize);
API_FUNC_IsArc IsArc_Ext_PhySize(const Byte *p, size_t size, UInt64 *phySize)
{
if (phySize)
*phySize = 0;
if (size < kHeaderSize)
return k_IsArc_Res_NEED_MORE;
CHeader h;
if (!h.Parse(p + kHeaderDataOffset))
return k_IsArc_Res_NO;
if (phySize)
*phySize = h.GetPhySize();
return k_IsArc_Res_YES;
}
API_FUNC_IsArc IsArc_Ext(const Byte *p, size_t size);
API_FUNC_IsArc IsArc_Ext(const Byte *p, size_t size)
{
return IsArc_Ext_PhySize(p, size, NULL);
}
static const Byte k_Signature[] = { 0x53, 0xEF };
REGISTER_ARC_I(

15
CPP/7zip/Archive/FatHandler.cpp Normal file → Executable file
View File

@@ -111,14 +111,14 @@ static int GetLog(UInt32 num)
static const UInt32 kHeaderSize = 512;
API_FUNC_static_IsArc IsArc_Fat(const Byte *p, size_t size)
API_FUNC_IsArc IsArc_Fat(const Byte *p, size_t size);
API_FUNC_IsArc IsArc_Fat(const Byte *p, size_t size)
{
if (size < kHeaderSize)
return k_IsArc_Res_NEED_MORE;
CHeader h;
return h.Parse(p) ? k_IsArc_Res_YES : k_IsArc_Res_NO;
}
}
bool CHeader::Parse(const Byte *p)
{
@@ -846,17 +846,18 @@ static const CStatProp kArcProps[] =
IMP_IInArchive_Props
IMP_IInArchive_ArcProps_WITH_NAME
static void FatTimeToProp(UInt32 dosTime, UInt32 ms10, NWindows::NCOM::CPropVariant &prop)
{
FILETIME localFileTime, utc;
if (NWindows::NTime::DosTimeToFileTime(dosTime, localFileTime))
if (NWindows::NTime::DosTime_To_FileTime(dosTime, localFileTime))
if (LocalFileTimeToFileTime(&localFileTime, &utc))
{
UInt64 t64 = (((UInt64)utc.dwHighDateTime) << 32) + utc.dwLowDateTime;
t64 += ms10 * 100000;
utc.dwLowDateTime = (DWORD)t64;
utc.dwHighDateTime = (DWORD)(t64 >> 32);
prop = utc;
prop.SetAsTimeFrom_FT_Prec(utc, k_PropVar_TimePrec_Base + 2);
}
}
@@ -892,7 +893,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
case kpidPhySize: prop = PhySize; break;
case kpidFreeSpace: prop = (UInt64)NumFreeClusters << Header.ClusterSizeLog; break;
case kpidHeadersSize: prop = GetHeadersSize(); break;
case kpidMTime: if (VolItemDefined) FatTimeToProp(VolItem.MTime, 0, prop); break;
case kpidMTime: if (VolItemDefined) PropVariant_SetFrom_DosTime(prop, VolItem.MTime); break;
case kpidShortComment:
case kpidVolumeName: if (VolItemDefined) prop = VolItem.GetVolName(); break;
case kpidNumFats: if (Header.NumFats != 2) prop = Header.NumFats; break;
@@ -920,9 +921,9 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
case kpidPath: prop = GetItemPath(index); break;
case kpidShortName: prop = item.GetShortName(); break;
case kpidIsDir: prop = item.IsDir(); break;
case kpidMTime: FatTimeToProp(item.MTime, 0, prop); break;
case kpidMTime: PropVariant_SetFrom_DosTime(prop, item.MTime); break;
case kpidCTime: FatTimeToProp(item.CTime, item.CTime2, prop); break;
case kpidATime: FatTimeToProp(((UInt32)item.ADate << 16), 0, prop); break;
case kpidATime: PropVariant_SetFrom_DosTime(prop, ((UInt32)item.ADate << 16)); break;
case kpidAttrib: prop = (UInt32)item.Attrib; break;
case kpidSize: if (!item.IsDir()) prop = item.Size; break;
case kpidPackSize: if (!item.IsDir()) prop = Header.GetFilePackSize(item.Size); break;

0
CPP/7zip/Archive/FlvHandler.cpp Normal file → Executable file
View File

75
CPP/7zip/Archive/GptHandler.cpp Normal file → Executable file
View File

@@ -23,6 +23,11 @@
using namespace NWindows;
namespace NArchive {
namespace NFat {
API_FUNC_IsArc IsArc_Fat(const Byte *p, size_t size);
}
namespace NGpt {
#define SIGNATURE { 'E', 'F', 'I', ' ', 'P', 'A', 'R', 'T', 0, 0, 1, 0 }
@@ -51,6 +56,7 @@ struct CPartition
UInt64 FirstLba;
UInt64 LastLba;
UInt64 Flags;
const char *Ext; // detected later
Byte Name[kNameLen * 2];
bool IsUnused() const
@@ -73,6 +79,7 @@ struct CPartition
LastLba = Get64(p + 40);
Flags = Get64(p + 48);
memcpy(Name, p + 56, kNameLen * 2);
Ext = NULL;
}
};
@@ -252,6 +259,28 @@ HRESULT CHandler::Open2(IInStream *stream)
return S_OK;
}
static const unsigned k_Ntfs_Fat_HeaderSize = 512;
static const Byte k_NtfsSignature[] = { 'N', 'T', 'F', 'S', ' ', ' ', ' ', ' ', 0 };
static bool IsNtfs(const Byte *p)
{
if (p[0x1FE] != 0x55 || p[0x1FF] != 0xAA)
return false;
if (memcmp(p + 3, k_NtfsSignature, ARRAY_SIZE(k_NtfsSignature)) != 0)
return false;
switch (p[0])
{
case 0xE9: /* codeOffset = 3 + (Int16)Get16(p + 1); */ break;
case 0xEB: if (p[2] != 0x90) return false; /* codeOffset = 2 + (int)(signed char)p[1]; */ break;
default: return false;
}
return true;
}
STDMETHODIMP CHandler::Open(IInStream *stream,
const UInt64 * /* maxCheckStartPosition */,
IArchiveOpenCallback * /* openArchiveCallback */)
@@ -260,6 +289,42 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
Close();
RINOK(Open2(stream));
_stream = stream;
FOR_VECTOR (fileIndex, _items)
{
CPartition &item = _items[fileIndex];
const int typeIndex = FindPartType(item.Type);
if (typeIndex < 0)
continue;
const CPartType &t = kPartTypes[(unsigned)typeIndex];
if (t.Ext)
{
item.Ext = t.Ext;
continue;
}
if (t.Type && IsString1PrefixedByString2_NoCase_Ascii(t.Type, "Windows"))
{
CMyComPtr<ISequentialInStream> inStream;
if (GetStream(fileIndex, &inStream) == S_OK && inStream)
{
Byte temp[k_Ntfs_Fat_HeaderSize];
if (ReadStream_FAIL(inStream, temp, k_Ntfs_Fat_HeaderSize) == S_OK)
{
if (IsNtfs(temp))
{
item.Ext = "ntfs";
continue;
}
if (NFat::IsArc_Fat(temp, k_Ntfs_Fat_HeaderSize) == k_IsArc_Res_YES)
{
item.Ext = "fat";
continue;
}
}
}
}
}
return S_OK;
COM_TRY_END
}
@@ -355,13 +420,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
}
{
s += '.';
const char *ext = NULL;
int typeIndex = FindPartType(item.Type);
if (typeIndex >= 0)
ext = kPartTypes[(unsigned)typeIndex].Ext;
if (!ext)
ext = "img";
s += ext;
s += (item.Ext ? item.Ext : "img");
}
prop = s;
break;
@@ -375,7 +434,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
{
char s[48];
const char *res;
int typeIndex = FindPartType(item.Type);
const int typeIndex = FindPartType(item.Type);
if (typeIndex >= 0 && kPartTypes[(unsigned)typeIndex].Type)
res = kPartTypes[(unsigned)typeIndex].Type;
else

217
CPP/7zip/Archive/GzHandler.cpp Normal file → Executable file
View File

@@ -475,6 +475,7 @@ class CHandler:
NDecoder::CCOMCoder *_decoderSpec;
CSingleMethodProps _props;
CHandlerTimeOptions _timeOptions;
public:
MY_UNKNOWN_IMP4(
@@ -487,8 +488,15 @@ public:
STDMETHOD(OpenSeq)(ISequentialInStream *stream);
STDMETHOD(SetProperties)(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps);
CHandler()
CHandler():
_isArc(false),
_decoderSpec(NULL)
{}
void CreateDecoder()
{
if (_decoder)
return;
_decoderSpec = new NDecoder::CCOMCoder;
_decoder = _decoderSpec;
}
@@ -528,7 +536,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
case kpidErrorFlags:
{
UInt32 v = 0;
if (!_isArc) v |= kpv_ErrorFlags_IsNotArc;;
if (!_isArc) v |= kpv_ErrorFlags_IsNotArc;
if (_needMoreInput) v |= kpv_ErrorFlags_UnexpectedEnd;
if (_dataAfterEnd) v |= kpv_ErrorFlags_DataAfterEnd;
prop = v;
@@ -567,12 +575,13 @@ STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIAN
break;
// case kpidComment: if (_item.CommentIsPresent()) prop = MultiByteToUnicodeString(_item.Comment, CP_ACP); break;
case kpidMTime:
// gzip specification: MTIME = 0 means no time stamp is available.
if (_item.Time != 0)
{
FILETIME utc;
NTime::UnixTimeToFileTime(_item.Time, utc);
prop = utc;
}
PropVariant_SetFrom_UnixTime(prop, _item.Time);
break;
case kpidTimeType:
if (_item.Time != 0)
prop = (UInt32)NFileTimeType::kUnix;
break;
case kpidSize:
{
@@ -644,6 +653,7 @@ STDMETHODIMP CHandler::OpenSeq(ISequentialInStream *stream)
try
{
Close();
CreateDecoder();
_decoderSpec->SetInStream(stream);
_decoderSpec->InitInStream(true);
RINOK(_item.ReadHeader(_decoderSpec));
@@ -672,7 +682,8 @@ STDMETHODIMP CHandler::Close()
_headerSize = 0;
_stream.Release();
_decoderSpec->ReleaseInStream();
if (_decoder)
_decoderSpec->ReleaseInStream();
return S_OK;
}
@@ -699,6 +710,8 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
extractCallback->PrepareOperation(askMode);
CreateDecoder();
COutStreamWithCRC *outStreamSpec = new COutStreamWithCRC;
CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
outStreamSpec->SetStream(realOutStream);
@@ -873,21 +886,99 @@ static const Byte kHostOS =
NHostOS::kUnix;
#endif
/*
static HRESULT ReportItemProp(IArchiveUpdateCallbackArcProp *reportArcProp, PROPID propID, const PROPVARIANT *value)
{
return reportArcProp->ReportProp(NEventIndexType::kOutArcIndex, 0, propID, value);
}
static HRESULT ReportArcProp(IArchiveUpdateCallbackArcProp *reportArcProp, PROPID propID, const PROPVARIANT *value)
{
return reportArcProp->ReportProp(NEventIndexType::kArcProp, 0, propID, value);
}
static HRESULT ReportArcProps(IArchiveUpdateCallbackArcProp *reportArcProp,
const CItem &item,
bool needTime,
bool needCrc,
const UInt64 *unpackSize)
{
NCOM::CPropVariant timeProp;
NCOM::CPropVariant sizeProp;
if (needTime)
{
FILETIME ft;
NTime::UnixTimeToFileTime(item.Time, ft);
timeProp.SetAsTimeFrom_FT_Prec(ft, k_PropVar_TimePrec_Unix);
}
if (unpackSize)
{
sizeProp = *unpackSize;
RINOK(ReportItemProp(reportArcProp, kpidSize, &sizeProp));
}
if (needCrc)
{
NCOM::CPropVariant prop;
prop = item.Crc;
RINOK(ReportItemProp(reportArcProp, kpidCRC, &prop));
}
{
RINOK(ReportItemProp(reportArcProp, kpidMTime, &timeProp));
}
RINOK(reportArcProp->ReportFinished(NEventIndexType::kOutArcIndex, 0, NArchive::NUpdate::NOperationResult::kOK));
if (unpackSize)
{
RINOK(ReportArcProp(reportArcProp, kpidSize, &sizeProp));
}
{
RINOK(ReportArcProp(reportArcProp, kpidComboMTime, &timeProp));
}
return S_OK;
}
*/
static HRESULT UpdateArchive(
ISequentialOutStream *outStream,
UInt64 unpackSize,
CItem &item,
const CSingleMethodProps &props,
IArchiveUpdateCallback *updateCallback)
const CHandlerTimeOptions &timeOptions,
IArchiveUpdateCallback *updateCallback
// , IArchiveUpdateCallbackArcProp *reportArcProp
)
{
UInt64 complexity = 0;
RINOK(updateCallback->SetTotal(unpackSize));
RINOK(updateCallback->SetCompleted(&complexity));
UInt64 unpackSizeReal;
{
CMyComPtr<ISequentialInStream> fileInStream;
RINOK(updateCallback->GetStream(0, &fileInStream));
if (!fileInStream)
return S_FALSE;
{
CMyComPtr<IStreamGetProps> getProps;
fileInStream->QueryInterface(IID_IStreamGetProps, (void **)&getProps);
if (getProps)
{
FILETIME mTime;
UInt64 size;
if (getProps->GetProps(&size, NULL, NULL, &mTime, NULL) == S_OK)
{
unpackSize = size;
if (timeOptions.Write_MTime.Val)
NTime::FileTime_To_UnixTime(mTime, item.Time);
}
}
}
UInt64 complexity = 0;
RINOK(updateCallback->SetTotal(unpackSize));
RINOK(updateCallback->SetCompleted(&complexity));
CSequentialInStreamWithCRC *inStreamSpec = new CSequentialInStreamWithCRC;
CMyComPtr<ISequentialInStream> crcStream(inStreamSpec);
inStreamSpec->SetStream(fileInStream);
@@ -911,14 +1002,50 @@ static HRESULT UpdateArchive(
RINOK(deflateEncoder->Code(crcStream, outStream, NULL, NULL, progress));
item.Crc = inStreamSpec->GetCRC();
item.Size32 = (UInt32)inStreamSpec->GetSize();
unpackSizeReal = inStreamSpec->GetSize();
item.Size32 = (UInt32)unpackSizeReal;
RINOK(item.WriteFooter(outStream));
}
/*
if (reportArcProp)
{
RINOK(ReportArcProps(reportArcProp,
item,
props._Write_MTime, // item.Time != 0,
true, // writeCrc
&unpackSizeReal));
}
*/
return updateCallback->SetOperationResult(NUpdate::NOperationResult::kOK);
}
STDMETHODIMP CHandler::GetFileTimeType(UInt32 *timeType)
{
*timeType = NFileTimeType::kUnix;
/*
if (_item.Time != 0)
{
we set NFileTimeType::kUnix in precision,
and we return NFileTimeType::kUnix in kpidTimeType
so GetFileTimeType() value is not used in any version of 7-zip.
}
else // (_item.Time == 0)
{
kpidMTime and kpidTimeType are not defined
before 22.00 : GetFileTimeType() value is used in GetUpdatePairInfoList();
22.00 : GetFileTimeType() value is not used
}
*/
UInt32 t;
t = NFileTimeType::kUnix;
if (_isArc ? (_item.Time == 0) : !_timeOptions.Write_MTime.Val)
{
t = GET_FileTimeType_NotDefined_for_GetFileTimeType;
// t = k_PropVar_TimePrec_1ns; // failed in 7-Zip 21
// t = (UInt32)(Int32)NFileTimeType::kNotDefined; // failed in 7-Zip 21
}
*timeType = t;
return S_OK;
}
@@ -936,6 +1063,11 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
return E_FAIL;
RINOK(updateCallback->GetUpdateItemInfo(0, &newData, &newProps, &indexInArchive));
/*
CMyComPtr<IArchiveUpdateCallbackArcProp> reportArcProp;
updateCallback->QueryInterface(IID_IArchiveUpdateCallbackArcProp, (void **)&reportArcProp);
*/
CItem newItem;
if (!IntToBool(newProps))
@@ -945,11 +1077,12 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
else
{
newItem.HostOS = kHostOS;
if (_timeOptions.Write_MTime.Val)
{
NCOM::CPropVariant prop;
RINOK(updateCallback->GetProperty(0, kpidMTime, &prop));
if (prop.vt == VT_FILETIME)
NTime::FileTimeToUnixTime(prop.filetime, newItem.Time);
NTime::FileTime_To_UnixTime(prop.filetime, newItem.Time);
else if (prop.vt == VT_EMPTY)
newItem.Time = 0;
else
@@ -990,7 +1123,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
return E_INVALIDARG;
size = prop.uhVal.QuadPart;
}
return UpdateArchive(outStream, size, newItem, _props, updateCallback);
return UpdateArchive(outStream, size, newItem, _props, _timeOptions, updateCallback);
}
if (indexInArchive != 0)
@@ -1022,6 +1155,14 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
}
RINOK(_stream->Seek((Int64)offset, STREAM_SEEK_SET, NULL));
/*
if (reportArcProp)
ReportArcProps(reportArcProp, newItem,
_props._Write_MTime,
false, // writeCrc
NULL); // unpacksize
*/
return NCompress::CopyStream(_stream, outStream, progress);
COM_TRY_END
@@ -1029,16 +1170,48 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps)
{
return _props.SetProperties(names, values, numProps);
_timeOptions.Init();
_props.Init();
for (UInt32 i = 0; i < numProps; i++)
{
UString name = names[i];
name.MakeLower_Ascii();
if (name.IsEmpty())
return E_INVALIDARG;
const PROPVARIANT &value = values[i];
{
bool processed = false;
RINOK(_timeOptions.Parse(name, value, processed));
if (processed)
{
if (_timeOptions.Write_CTime.Val ||
_timeOptions.Write_ATime.Val)
return E_INVALIDARG;
if ( _timeOptions.Prec != (UInt32)(Int32)-1
&& _timeOptions.Prec != k_PropVar_TimePrec_0
&& _timeOptions.Prec != k_PropVar_TimePrec_Unix
&& _timeOptions.Prec != k_PropVar_TimePrec_HighPrec
&& _timeOptions.Prec != k_PropVar_TimePrec_Base)
return E_INVALIDARG;
continue;
}
}
RINOK(_props.SetProperty(name, value));
}
return S_OK;
}
static const Byte k_Signature[] = { kSignature_0, kSignature_1, kSignature_2 };
REGISTER_ARC_IO(
"gzip", "gz gzip tgz tpz apk", "* * .tar .tar .tar", 0xEF,
k_Signature,
0,
NArcInfoFlags::kKeepName,
IsArc_Gz)
k_Signature, 0,
NArcInfoFlags::kKeepName
| NArcInfoFlags::kMTime
| NArcInfoFlags::kMTime_Default
, TIME_PREC_TO_ARC_FLAGS_MASK (NFileTimeType::kUnix)
| TIME_PREC_TO_ARC_FLAGS_TIME_DEFAULT (NFileTimeType::kUnix)
, IsArc_Gz)
}}

55
CPP/7zip/Archive/HandlerCont.cpp Normal file → Executable file
View File

@@ -14,6 +14,10 @@
namespace NArchive {
namespace NExt {
API_FUNC_IsArc IsArc_Ext(const Byte *p, size_t size);
}
STDMETHODIMP CHandlerCont::Extract(const UInt32 *indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *extractCallback)
{
@@ -132,11 +136,12 @@ STDMETHODIMP CHandlerImg::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosit
}
static const Byte k_GDP_Signature[] = { 'E', 'F', 'I', ' ', 'P', 'A', 'R', 'T' };
// static const Byte k_Ext_Signature[] = { 0x53, 0xEF };
// static const unsigned k_Ext_Signature_offset = 0x438;
static const char *GetImgExt(ISequentialInStream *stream)
{
const size_t kHeaderSize = 1 << 10;
const size_t kHeaderSize = 1 << 11;
Byte buf[kHeaderSize];
if (ReadStream_FAIL(stream, buf, kHeaderSize) == S_OK)
{
@@ -146,6 +151,8 @@ static const char *GetImgExt(ISequentialInStream *stream)
return "gpt";
return "mbr";
}
if (NExt::IsArc_Ext(buf, kHeaderSize) == k_IsArc_Res_YES)
return "ext";
}
return NULL;
}
@@ -208,6 +215,33 @@ STDMETHODIMP CHandlerImg::GetNumberOfItems(UInt32 *numItems)
return S_OK;
}
class CHandlerImgProgress:
public ICompressProgressInfo,
public CMyUnknownImp
{
public:
CHandlerImg &Handler;
CMyComPtr<ICompressProgressInfo> _ratioProgress;
CHandlerImgProgress(CHandlerImg &handler) : Handler(handler) {}
// MY_UNKNOWN_IMP1(ICompressProgressInfo)
MY_UNKNOWN_IMP
STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
};
STDMETHODIMP CHandlerImgProgress::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
{
UInt64 inSize2;
if (Handler.Get_PackSizeProcessed(inSize2))
inSize = &inSize2;
return _ratioProgress->SetRatioInfo(inSize, outSize);
}
STDMETHODIMP CHandlerImg::Extract(const UInt32 *indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *extractCallback)
{
@@ -227,10 +261,6 @@ STDMETHODIMP CHandlerImg::Extract(const UInt32 *indices, UInt32 numItems,
return S_OK;
RINOK(extractCallback->PrepareOperation(askMode));
CLocalProgress *lps = new CLocalProgress;
CMyComPtr<ICompressProgressInfo> progress = lps;
lps->Init(extractCallback, false);
int opRes = NExtract::NOperationResult::kDataError;
ClearStreamVars();
@@ -242,6 +272,19 @@ STDMETHODIMP CHandlerImg::Extract(const UInt32 *indices, UInt32 numItems,
if (hres == S_OK && inStream)
{
CLocalProgress *lps = new CLocalProgress;
CMyComPtr<ICompressProgressInfo> progress = lps;
lps->Init(extractCallback, false);
if (Init_PackSizeProcessed())
{
CHandlerImgProgress *imgProgressSpec = new CHandlerImgProgress(*this);
CMyComPtr<ICompressProgressInfo> imgProgress = imgProgressSpec;
imgProgressSpec->_ratioProgress = progress;
progress.Release();
progress = imgProgress;
}
NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;

12
CPP/7zip/Archive/HandlerCont.h Normal file → Executable file
View File

@@ -94,7 +94,19 @@ protected:
virtual HRESULT Open2(IInStream *stream, IArchiveOpenCallback *openCallback) = 0;
virtual void CloseAtError();
// returns (true), if Get_PackSizeProcessed() is required in Extract()
virtual bool Init_PackSizeProcessed()
{
return false;
}
public:
virtual bool Get_PackSizeProcessed(UInt64 &size)
{
size = 0;
return false;
}
MY_UNKNOWN_IMP3(IInArchive, IInArchiveGetStream, IInStream)
INTERFACE_IInArchive_Img(PURE)

21
CPP/7zip/Archive/HfsHandler.cpp Normal file → Executable file
View File

@@ -240,7 +240,7 @@ struct CItem
UInt32 ID;
UInt32 CTime;
UInt32 MTime;
// UInt32 AttrMTime;
UInt32 AttrMTime;
UInt32 ATime;
// UInt32 BackupDate;
@@ -1000,7 +1000,7 @@ HRESULT CDatabase::LoadCatalog(const CFork &fork, const CObjectVector<CIdExtents
item.CTime = Get32(r + 0xC);
item.MTime = Get32(r + 0x10);
// item.AttrMTime = Get32(r + 0x14);
item.AttrMTime = Get32(r + 0x14);
item.ATime = Get32(r + 0x18);
// item.BackupDate = Get32(r + 0x1C);
@@ -1404,6 +1404,7 @@ static const Byte kProps[] =
kpidCTime,
kpidMTime,
kpidATime,
kpidChangeTime,
kpidPosixAttrib
};
@@ -1421,9 +1422,11 @@ IMP_IInArchive_ArcProps
static void HfsTimeToProp(UInt32 hfsTime, NWindows::NCOM::CPropVariant &prop)
{
if (hfsTime == 0)
return;
FILETIME ft;
HfsTimeToFileTime(hfsTime, ft);
prop = ft;
prop.SetAsTimeFrom_FT_Prec(ft, k_PropVar_TimePrec_Base);
}
STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
@@ -1447,10 +1450,13 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
case kpidMTime: HfsTimeToProp(Header.MTime, prop); break;
case kpidCTime:
{
FILETIME localFt, ft;
HfsTimeToFileTime(Header.CTime, localFt);
if (LocalFileTimeToFileTime(&localFt, &ft))
prop = ft;
if (Header.CTime != 0)
{
FILETIME localFt, ft;
HfsTimeToFileTime(Header.CTime, localFt);
if (LocalFileTimeToFileTime(&localFt, &ft))
prop.SetAsTimeFrom_FT_Prec(ft, k_PropVar_TimePrec_Base);
}
break;
}
case kpidIsTree: prop = true; break;
@@ -1578,6 +1584,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
case kpidCTime: HfsTimeToProp(item.CTime, prop); break;
case kpidMTime: HfsTimeToProp(item.MTime, prop); break;
case kpidATime: HfsTimeToProp(item.ATime, prop); break;
case kpidChangeTime: HfsTimeToProp(item.AttrMTime, prop); break;
case kpidPosixAttrib: if (ref.AttrIndex < 0) prop = (UInt32)item.FileMode; break;
}

89
CPP/7zip/Archive/IArchive.h Normal file → Executable file
View File

@@ -38,9 +38,11 @@ namespace NFileTimeType
{
enum EEnum
{
kWindows,
kNotDefined = -1,
kWindows = 0,
kUnix,
kDOS
kDOS,
k1ns
};
}
@@ -60,8 +62,31 @@ namespace NArcInfoFlags
const UInt32 kHardLinks = 1 << 11; // the handler supports hard links
const UInt32 kByExtOnlyOpen = 1 << 12; // call handler only if file extension matches
const UInt32 kHashHandler = 1 << 13; // the handler contains the hashes (checksums)
const UInt32 kCTime = 1 << 14;
const UInt32 kCTime_Default = 1 << 15;
const UInt32 kATime = 1 << 16;
const UInt32 kATime_Default = 1 << 17;
const UInt32 kMTime = 1 << 18;
const UInt32 kMTime_Default = 1 << 19;
// const UInt32 kTTime_Reserved = 1 << 20;
// const UInt32 kTTime_Reserved_Default = 1 << 21;
}
namespace NArcInfoTimeFlags
{
const unsigned kTime_Prec_Mask_bit_index = 0;
const unsigned kTime_Prec_Mask_num_bits = 26;
const unsigned kTime_Prec_Default_bit_index = 27;
const unsigned kTime_Prec_Default_num_bits = 5;
}
#define TIME_PREC_TO_ARC_FLAGS_MASK(x) \
((UInt32)1 << (NArcInfoTimeFlags::kTime_Prec_Mask_bit_index + (x)))
#define TIME_PREC_TO_ARC_FLAGS_TIME_DEFAULT(x) \
((UInt32)(x) << NArcInfoTimeFlags::kTime_Prec_Default_bit_index)
namespace NArchive
{
namespace NHandlerPropID
@@ -79,8 +104,8 @@ namespace NArchive
kSignatureOffset, // VT_UI4
kAltStreams, // VT_BOOL
kNtSecure, // VT_BOOL
kFlags // VT_UI4
// kVersion // VT_UI4 ((VER_MAJOR << 8) | VER_MINOR)
kFlags, // VT_UI4
kTimeFlags // VT_UI4
};
}
@@ -123,6 +148,7 @@ namespace NArchive
kInArcIndex,
kBlockIndex,
kOutArcIndex
// kArcProp
};
}
@@ -133,7 +159,8 @@ namespace NArchive
enum
{
kOK = 0
// , kError
// kError = 1,
// kError_FileChanged
};
}
}
@@ -461,9 +488,10 @@ namespace NUpdateNotifyOp
kSkip,
kDelete,
kHeader,
kHashRead
// kNumDefined
kHashRead,
kInFileChanged
// , kOpFinished
// , kNumDefined
};
};
@@ -492,6 +520,20 @@ ARCHIVE_INTERFACE(IArchiveGetDiskProperty, 0x84)
INTERFACE_IArchiveGetDiskProperty(PURE);
};
/*
#define INTERFACE_IArchiveUpdateCallbackArcProp(x) \
STDMETHOD(ReportProp)(UInt32 indexType, UInt32 index, PROPID propID, const PROPVARIANT *value) x; \
STDMETHOD(ReportRawProp)(UInt32 indexType, UInt32 index, PROPID propID, const void *data, UInt32 dataSize, UInt32 propType) x; \
STDMETHOD(ReportFinished)(UInt32 indexType, UInt32 index, Int32 opRes) x; \
STDMETHOD(DoNeedArcProp)(PROPID propID, Int32 *answer) x; \
ARCHIVE_INTERFACE(IArchiveUpdateCallbackArcProp, 0x85)
{
INTERFACE_IArchiveUpdateCallbackArcProp(PURE);
};
*/
/*
UpdateItems()
-------------
@@ -636,9 +678,40 @@ extern "C"
typedef HRESULT (WINAPI *Func_SetCaseSensitive)(Int32 caseSensitive);
typedef HRESULT (WINAPI *Func_SetLargePageMode)();
// typedef HRESULT (WINAPI *Func_SetClientVersion)(UInt32 version);
typedef IOutArchive * (*Func_CreateOutArchive)();
typedef IInArchive * (*Func_CreateInArchive)();
}
/*
if there is no time in archive, external MTime of archive
will be used instead of _item.Time from archive.
For 7-zip before 22.00 we need to return some supported value.
But (kpidTimeType > kDOS) is not allowed in 7-Zip before 22.00.
So we return highest precision value supported by old 7-Zip.
new 7-Zip 22.00 doesn't use that value in usual cases.
*/
#define DECLARE_AND_SET_CLIENT_VERSION_VAR
#define GET_FileTimeType_NotDefined_for_GetFileTimeType \
NFileTimeType::kWindows
/*
extern UInt32 g_ClientVersion;
#define GET_CLIENT_VERSION(major, minor) \
((UInt32)(((UInt32)(major) << 16) | (UInt32)(minor)))
#define DECLARE_AND_SET_CLIENT_VERSION_VAR \
UInt32 g_ClientVersion = GET_CLIENT_VERSION(MY_VER_MAJOR, MY_VER_MINOR);
#define GET_FileTimeType_NotDefined_for_GetFileTimeType \
((UInt32)(g_ClientVersion >= GET_CLIENT_VERSION(22, 0) ? \
(UInt32)(Int32)NFileTimeType::kNotDefined : \
NFileTimeType::kWindows))
*/
#endif

0
CPP/7zip/Archive/Icons/7z.ico Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Some files were not shown because too many files have changed in this diff Show More