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/Common/CWrappers.cpp Normal file → Executable file
View File

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

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

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

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

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

292
CPP/7zip/Common/FileStreams.cpp Normal file → Executable file
View File

@@ -2,18 +2,30 @@
#include "StdAfx.h"
// #include <stdio.h>
#ifndef _WIN32
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include "../../Windows/FileFind.h"
#include <grp.h>
#include <pwd.h>
// for major minor
// BSD: <sys/types.h>
#include <sys/sysmacros.h>
#endif
#include "../../Windows/FileFind.h"
#ifdef SUPPORT_DEVICE_FILE
#include "../../../C/Alloc.h"
#include "../../Common/Defs.h"
#endif
#include "../PropID.h"
#include "FileStreams.h"
static inline HRESULT GetLastError_HRESULT()
@@ -37,12 +49,19 @@ static const UInt32 kClusterSize = 1 << 18;
#endif
CInFileStream::CInFileStream():
#ifdef SUPPORT_DEVICE_FILE
#ifdef SUPPORT_DEVICE_FILE
VirtPos(0),
PhyPos(0),
Buf(0),
BufSize(0),
#endif
#endif
#ifndef _WIN32
_uid(0),
_gid(0),
StoreOwnerId(false),
StoreOwnerName(false),
#endif
_info_WasLoaded(false),
SupportHardLinks(false),
Callback(NULL),
CallbackRef(0)
@@ -56,7 +75,7 @@ CInFileStream::~CInFileStream()
#endif
if (Callback)
Callback->InFileStream_On_Destroy(CallbackRef);
Callback->InFileStream_On_Destroy(this, CallbackRef);
}
STDMETHODIMP CInFileStream::Read(void *data, UInt32 size, UInt32 *processedSize)
@@ -306,8 +325,14 @@ STDMETHODIMP CInFileStream::GetSize(UInt64 *size)
STDMETHODIMP CInFileStream::GetProps(UInt64 *size, FILETIME *cTime, FILETIME *aTime, FILETIME *mTime, UInt32 *attrib)
{
if (!_info_WasLoaded)
RINOK(ReloadProps());
const BY_HANDLE_FILE_INFORMATION &info = _info;
/*
BY_HANDLE_FILE_INFORMATION info;
if (File.GetFileInformation(&info))
if (!File.GetFileInformation(&info))
return GetLastError_HRESULT();
*/
{
if (size) *size = (((UInt64)info.nFileSizeHigh) << 32) + info.nFileSizeLow;
if (cTime) *cTime = info.ftCreationTime;
@@ -316,13 +341,18 @@ STDMETHODIMP CInFileStream::GetProps(UInt64 *size, FILETIME *cTime, FILETIME *aT
if (attrib) *attrib = info.dwFileAttributes;
return S_OK;
}
return GetLastError_HRESULT();
}
STDMETHODIMP CInFileStream::GetProps2(CStreamFileProps *props)
{
if (!_info_WasLoaded)
RINOK(ReloadProps());
const BY_HANDLE_FILE_INFORMATION &info = _info;
/*
BY_HANDLE_FILE_INFORMATION info;
if (File.GetFileInformation(&info))
if (!File.GetFileInformation(&info))
return GetLastError_HRESULT();
*/
{
props->Size = (((UInt64)info.nFileSizeHigh) << 32) + info.nFileSizeLow;
props->VolID = info.dwVolumeSerialNumber;
@@ -335,27 +365,114 @@ STDMETHODIMP CInFileStream::GetProps2(CStreamFileProps *props)
props->MTime = info.ftLastWriteTime;
return S_OK;
}
return GetLastError_HRESULT();
}
STDMETHODIMP CInFileStream::GetProperty(PROPID propID, PROPVARIANT *value)
{
if (!_info_WasLoaded)
RINOK(ReloadProps());
if (!_info_WasLoaded)
return S_OK;
NWindows::NCOM::CPropVariant prop;
#ifdef SUPPORT_DEVICE_FILE
if (File.IsDeviceFile)
{
switch (propID)
{
case kpidSize:
if (File.SizeDefined)
prop = File.Size;
break;
// case kpidAttrib: prop = (UInt32)0; break;
case kpidPosixAttrib:
{
prop = (UInt32)NWindows::NFile::NFind::NAttributes::
Get_PosixMode_From_WinAttrib(0);
/* GNU TAR by default can't extract file with MY_LIN_S_IFBLK attribute
so we don't use MY_LIN_S_IFBLK here */
// prop = (UInt32)(MY_LIN_S_IFBLK | 0600); // for debug
break;
}
/*
case kpidDeviceMajor:
prop = (UInt32)8; // id for SCSI type device (sda)
break;
case kpidDeviceMinor:
prop = (UInt32)0;
break;
*/
}
}
else
#endif
{
switch (propID)
{
case kpidSize:
{
const UInt64 size = (((UInt64)_info.nFileSizeHigh) << 32) + _info.nFileSizeLow;
prop = size;
break;
}
case kpidAttrib: prop = (UInt32)_info.dwFileAttributes; break;
case kpidCTime: PropVariant_SetFrom_FiTime(prop, _info.ftCreationTime); break;
case kpidATime: PropVariant_SetFrom_FiTime(prop, _info.ftLastAccessTime); break;
case kpidMTime: PropVariant_SetFrom_FiTime(prop, _info.ftLastWriteTime); break;
case kpidPosixAttrib:
prop = (UInt32)NWindows::NFile::NFind::NAttributes::
Get_PosixMode_From_WinAttrib(_info.dwFileAttributes);
// | (UInt32)(1 << 21); // for debug
break;
}
}
prop.Detach(value);
return S_OK;
}
STDMETHODIMP CInFileStream::ReloadProps()
{
#ifdef SUPPORT_DEVICE_FILE
if (File.IsDeviceFile)
{
memset(&_info, 0, sizeof(_info));
if (File.SizeDefined)
{
_info.nFileSizeHigh = (DWORD)(File.Size >> 32);
_info.nFileSizeLow = (DWORD)(File.Size);
}
_info.nNumberOfLinks = 1;
_info_WasLoaded = true;
return S_OK;
}
#endif
_info_WasLoaded = File.GetFileInformation(&_info);
if (!_info_WasLoaded)
return GetLastError_HRESULT();
return S_OK;
}
#elif !defined(_WIN32)
STDMETHODIMP CInFileStream::GetProps(UInt64 *size, FILETIME *cTime, FILETIME *aTime, FILETIME *mTime, UInt32 *attrib)
{
if (!_info_WasLoaded)
RINOK(ReloadProps());
const struct stat &st = _info;
/*
struct stat st;
if (File.my_fstat(&st) != 0)
return GetLastError_HRESULT();
*/
if (size) *size = (UInt64)st.st_size;
#ifdef __APPLE__
if (cTime) NWindows::NFile::NFind::timespec_To_FILETIME(st.st_ctimespec, *cTime);
if (aTime) NWindows::NFile::NFind::timespec_To_FILETIME(st.st_atimespec, *aTime);
if (mTime) NWindows::NFile::NFind::timespec_To_FILETIME(st.st_mtimespec, *mTime);
#else
if (cTime) NWindows::NFile::NFind::timespec_To_FILETIME(st.st_ctim, *cTime);
if (aTime) NWindows::NFile::NFind::timespec_To_FILETIME(st.st_atim, *aTime);
if (mTime) NWindows::NFile::NFind::timespec_To_FILETIME(st.st_mtim, *mTime);
#endif
if (cTime) FiTime_To_FILETIME (ST_CTIME(st), *cTime);
if (aTime) FiTime_To_FILETIME (ST_ATIME(st), *aTime);
if (mTime) FiTime_To_FILETIME (ST_MTIME(st), *mTime);
if (attrib) *attrib = NWindows::NFile::NFind::Get_WinAttribPosix_From_PosixMode(st.st_mode);
return S_OK;
@@ -365,9 +482,14 @@ STDMETHODIMP CInFileStream::GetProps(UInt64 *size, FILETIME *cTime, FILETIME *aT
STDMETHODIMP CInFileStream::GetProps2(CStreamFileProps *props)
{
if (!_info_WasLoaded)
RINOK(ReloadProps());
const struct stat &st = _info;
/*
struct stat st;
if (File.my_fstat(&st) != 0)
return GetLastError_HRESULT();
*/
props->Size = (UInt64)st.st_size;
/*
@@ -381,15 +503,9 @@ STDMETHODIMP CInFileStream::GetProps2(CStreamFileProps *props)
props->NumLinks = (UInt32)st.st_nlink; // we reduce to UInt32 from (nlink_t) that is (unsigned long)
props->Attrib = NWindows::NFile::NFind::Get_WinAttribPosix_From_PosixMode(st.st_mode);
#ifdef __APPLE__
NWindows::NFile::NFind::timespec_To_FILETIME(st.st_ctimespec, props->CTime);
NWindows::NFile::NFind::timespec_To_FILETIME(st.st_atimespec, props->ATime);
NWindows::NFile::NFind::timespec_To_FILETIME(st.st_mtimespec, props->MTime);
#else
NWindows::NFile::NFind::timespec_To_FILETIME(st.st_ctim, props->CTime);
NWindows::NFile::NFind::timespec_To_FILETIME(st.st_atim, props->ATime);
NWindows::NFile::NFind::timespec_To_FILETIME(st.st_mtim, props->MTime);
#endif
FiTime_To_FILETIME (ST_CTIME(st), props->CTime);
FiTime_To_FILETIME (ST_ATIME(st), props->ATime);
FiTime_To_FILETIME (ST_MTIME(st), props->MTime);
/*
printf("\nGetProps2() NumLinks=%d = st_dev=%d st_ino = %d\n"
@@ -402,8 +518,130 @@ STDMETHODIMP CInFileStream::GetProps2(CStreamFileProps *props)
return S_OK;
}
STDMETHODIMP CInFileStream::GetProperty(PROPID propID, PROPVARIANT *value)
{
if (!_info_WasLoaded)
RINOK(ReloadProps());
if (!_info_WasLoaded)
return S_OK;
const struct stat &st = _info;
NWindows::NCOM::CPropVariant prop;
{
switch (propID)
{
case kpidSize: prop = (UInt64)st.st_size; break;
case kpidAttrib:
prop = (UInt32)NWindows::NFile::NFind::Get_WinAttribPosix_From_PosixMode(st.st_mode);
break;
case kpidCTime: PropVariant_SetFrom_FiTime(prop, ST_CTIME(st)); break;
case kpidATime: PropVariant_SetFrom_FiTime(prop, ST_ATIME(st)); break;
case kpidMTime: PropVariant_SetFrom_FiTime(prop, ST_MTIME(st)); break;
case kpidPosixAttrib: prop = (UInt32)st.st_mode; break;
case kpidDeviceMajor:
{
// printf("\nst.st_rdev = %d\n", st.st_rdev);
if (S_ISCHR(st.st_mode) ||
S_ISBLK(st.st_mode))
prop = (UInt32)(major(st.st_rdev)); // + 1000);
// prop = (UInt32)12345678; // for debug
break;
}
case kpidDeviceMinor:
if (S_ISCHR(st.st_mode) ||
S_ISBLK(st.st_mode))
prop = (UInt32)(minor(st.st_rdev)); // + 100);
// prop = (UInt32)(st.st_rdev); // for debug
// printf("\nst.st_rdev = %d\n", st.st_rdev);
// prop = (UInt32)123456789; // for debug
break;
/*
case kpidDevice:
if (S_ISCHR(st.st_mode) ||
S_ISBLK(st.st_mode))
prop = (UInt64)(st.st_rdev);
break;
*/
case kpidUserId:
{
if (StoreOwnerId)
prop = (UInt32)st.st_uid;
break;
}
case kpidGroupId:
{
if (StoreOwnerId)
prop = (UInt32)st.st_gid;
break;
}
case kpidUser:
{
if (StoreOwnerName)
{
const uid_t uid = st.st_uid;
{
if (!OwnerName.IsEmpty() && _uid == uid)
prop = OwnerName;
else
{
const passwd *pw = getpwuid(uid);
if (pw)
{
// we can use utf-8 here.
// prop = pw->pw_name;
}
}
}
}
break;
}
case kpidGroup:
{
if (StoreOwnerName)
{
const uid_t gid = st.st_gid;
{
if (!OwnerGroup.IsEmpty() && _gid == gid)
prop = OwnerGroup;
else
{
const group *gr = getgrgid(gid);
if (gr)
{
// we can use utf-8 here.
// prop = gr->gr_name;
}
}
}
}
break;
}
}
}
prop.Detach(value);
return S_OK;
}
STDMETHODIMP CInFileStream::ReloadProps()
{
_info_WasLoaded = (File.my_fstat(&_info) == 0);
if (!_info_WasLoaded)
return GetLastError_HRESULT();
return S_OK;
}
#endif
//////////////////////////
// COutFileStream

42
CPP/7zip/Common/FileStreams.h Normal file → Executable file
View File

@@ -14,10 +14,14 @@
#include "../IStream.h"
#include "UniqBlocks.h"
class CInFileStream;
struct IInFileStream_Callback
{
virtual HRESULT InFileStream_On_Error(UINT_PTR val, DWORD error) = 0;
virtual void InFileStream_On_Destroy(UINT_PTR val) = 0;
virtual void InFileStream_On_Destroy(CInFileStream *stream, UINT_PTR val) = 0;
};
class CInFileStream:
@@ -25,10 +29,11 @@ class CInFileStream:
public IStreamGetSize,
public IStreamGetProps,
public IStreamGetProps2,
public IStreamGetProp,
public CMyUnknownImp
{
public:
NWindows::NFile::NIO::CInFile File;
public:
#ifdef USE_WIN_FILE
@@ -42,22 +47,46 @@ public:
#endif
bool SupportHardLinks;
#ifdef _WIN32
BY_HANDLE_FILE_INFORMATION _info;
#else
struct stat _info;
UInt32 _uid;
UInt32 _gid;
UString OwnerName;
UString OwnerGroup;
bool StoreOwnerId;
bool StoreOwnerName;
#endif
bool _info_WasLoaded;
bool SupportHardLinks;
IInFileStream_Callback *Callback;
UINT_PTR CallbackRef;
virtual ~CInFileStream();
CInFileStream();
void Set_PreserveATime(bool v)
{
File.PreserveATime = v;
}
bool GetLength(UInt64 &length) const throw()
{
return File.GetLength(length);
}
bool Open(CFSTR fileName)
{
_info_WasLoaded = false;
return File.Open(fileName);
}
bool OpenShared(CFSTR fileName, bool shareForWrite)
{
_info_WasLoaded = false;
return File.OpenShared(fileName, shareForWrite);
}
@@ -65,6 +94,7 @@ public:
MY_QUERYINTERFACE_ENTRY(IStreamGetSize)
MY_QUERYINTERFACE_ENTRY(IStreamGetProps)
MY_QUERYINTERFACE_ENTRY(IStreamGetProps2)
MY_QUERYINTERFACE_ENTRY(IStreamGetProp)
MY_QUERYINTERFACE_END
MY_ADDREF_RELEASE
@@ -74,6 +104,8 @@ public:
STDMETHOD(GetSize)(UInt64 *size);
STDMETHOD(GetProps)(UInt64 *size, FILETIME *cTime, FILETIME *aTime, FILETIME *mTime, UInt32 *attrib);
STDMETHOD(GetProps2)(CStreamFileProps *props);
STDMETHOD(GetProperty)(PROPID propID, PROPVARIANT *value);
STDMETHOD(ReloadProps)();
};
class CStdInFileStream:
@@ -110,11 +142,11 @@ public:
UInt64 ProcessedSize;
bool SetTime(const FILETIME *cTime, const FILETIME *aTime, const FILETIME *mTime)
bool SetTime(const CFiTime *cTime, const CFiTime *aTime, const CFiTime *mTime)
{
return File.SetTime(cTime, aTime, mTime);
}
bool SetMTime(const FILETIME *mTime) { return File.SetMTime(mTime); }
bool SetMTime(const CFiTime *mTime) { return File.SetMTime(mTime); }
MY_UNKNOWN_IMP1(IOutStream)

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

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

3
CPP/7zip/Common/InBuffer.cpp Normal file → Executable file
View File

@@ -77,7 +77,8 @@ bool CInBufferBase::ReadByte_FromNewBlock(Byte &b)
{
if (!ReadBlock())
{
NumExtraBytes++;
// 22.00: we don't increment (NumExtraBytes) here
// NumExtraBytes++;
b = 0xFF;
return false;
}

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

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

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

68
CPP/7zip/Common/LimitedStreams.cpp Normal file → Executable file
View File

@@ -154,44 +154,70 @@ STDMETHODIMP CExtentsStream::Read(void *data, UInt32 size, UInt32 *processedSize
{
if (processedSize)
*processedSize = 0;
if (_virtPos >= Extents.Back().Virt)
const UInt64 virt = _virtPos;
if (virt >= Extents.Back().Virt)
return S_OK;
if (size == 0)
return S_OK;
unsigned left = 0, right = Extents.Size() - 1;
for (;;)
unsigned left = _prevExtentIndex;
if (virt < Extents[left].Virt ||
virt >= Extents[left + 1].Virt)
{
unsigned mid = (left + right) / 2;
if (mid == left)
break;
if (_virtPos < Extents[mid].Virt)
right = mid;
else
left = mid;
left = 0;
unsigned right = Extents.Size() - 1;
for (;;)
{
const unsigned mid = (unsigned)(((size_t)left + (size_t)right) / 2);
if (mid == left)
break;
if (virt < Extents[mid].Virt)
right = mid;
else
left = mid;
}
_prevExtentIndex = left;
}
{
const UInt64 rem = Extents[left + 1].Virt - virt;
if (size > rem)
size = (UInt32)rem;
}
const CSeekExtent &extent = Extents[left];
UInt64 phyPos = extent.Phy + (_virtPos - extent.Virt);
if (_needStartSeek || _phyPos != phyPos)
if (extent.Is_ZeroFill())
{
_needStartSeek = false;
_phyPos = phyPos;
RINOK(SeekToPhys());
memset(data, 0, size);
_virtPos += size;
if (processedSize)
*processedSize = size;
return S_OK;
}
{
const UInt64 phy = extent.Phy + (virt - extent.Virt);
if (_phyPos != phy)
{
_phyPos = (UInt64)0 - 1; // we don't trust seek_pos in case of error
RINOK(Stream->Seek((Int64)phy, STREAM_SEEK_SET, NULL));
_phyPos = phy;
}
}
UInt64 rem = Extents[left + 1].Virt - _virtPos;
if (size > rem)
size = (UInt32)rem;
HRESULT res = Stream->Read(data, size, &size);
_phyPos += size;
const HRESULT res = Stream->Read(data, size, &size);
_virtPos += size;
if (res == S_OK)
_phyPos += size;
else
_phyPos = (UInt64)0 - 1; // we don't trust seek_pos in case of error
if (processedSize)
*processedSize = size;
return res;
}
STDMETHODIMP CExtentsStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
{
switch (seekOrigin)

21
CPP/7zip/Common/LimitedStreams.h Normal file → Executable file
View File

@@ -101,21 +101,26 @@ public:
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
};
const UInt64 k_SeekExtent_Phy_Type_ZeroFill = (UInt64)(Int64)-1;
struct CSeekExtent
{
UInt64 Phy;
UInt64 Virt;
UInt64 Phy;
void SetAs_ZeroFill() { Phy = k_SeekExtent_Phy_Type_ZeroFill; }
bool Is_ZeroFill() const { return Phy == k_SeekExtent_Phy_Type_ZeroFill; }
};
class CExtentsStream:
public IInStream,
public CMyUnknownImp
{
UInt64 _phyPos;
UInt64 _virtPos;
bool _needStartSeek;
HRESULT SeekToPhys() { return Stream->Seek((Int64)_phyPos, STREAM_SEEK_SET, NULL); }
UInt64 _phyPos;
unsigned _prevExtentIndex;
public:
CMyComPtr<IInStream> Stream;
@@ -129,11 +134,13 @@ public:
void Init()
{
_virtPos = 0;
_phyPos = 0;
_needStartSeek = true;
_phyPos = (UInt64)0 - 1; // we need Seek() for Stream
_prevExtentIndex = 0;
}
};
class CLimitedSequentialOutStream:
public ISequentialOutStream,
public CMyUnknownImp

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

9
CPP/7zip/Common/PropId.cpp Normal file → Executable file
View File

@@ -104,5 +104,12 @@ const Byte k7z_PROPID_To_VARTYPE[kpid_NUM_DEFINED] =
VT_UI8,
VT_BOOL,
VT_BSTR,
VT_BSTR
VT_BSTR,
VT_BSTR,
VT_BOOL,
VT_FILETIME, // kpidChangeTime
VT_UI4,
VT_UI4,
VT_UI4,
VT_UI4 // kpidDeviceMinor
};

24
CPP/7zip/Common/RegisterArc.h Normal file → Executable file
View File

@@ -7,7 +7,7 @@
struct CArcInfo
{
UInt16 Flags;
UInt32 Flags;
Byte Id;
Byte SignatureSize;
UInt16 SignatureOffset;
@@ -17,6 +17,8 @@ struct CArcInfo
const char *Ext;
const char *AddExt;
UInt32 TimeFlags;
Func_CreateInArchive CreateInArchive;
Func_CreateOutArchive CreateOutArchive;
Func_IsArc IsArc;
@@ -39,22 +41,22 @@ void RegisterArc(const CArcInfo *arcInfo) throw();
#define IMP_CreateArcOut static IOutArchive *CreateArcOut() { return new CHandler(); }
#endif
#define REGISTER_ARC_V(n, e, ae, id, sigSize, sig, offs, flags, crIn, crOut, isArc) \
static const CArcInfo g_ArcInfo = { flags, id, sigSize, offs, sig, n, e, ae, crIn, crOut, isArc } ; \
#define REGISTER_ARC_V(n, e, ae, id, sigSize, sig, offs, flags, tf, crIn, crOut, isArc) \
static const CArcInfo g_ArcInfo = { flags, id, sigSize, offs, sig, n, e, ae, tf, crIn, crOut, isArc } ; \
#define REGISTER_ARC_R(n, e, ae, id, sigSize, sig, offs, flags, crIn, crOut, isArc) \
REGISTER_ARC_V(n, e, ae, id, sigSize, sig, offs, flags, crIn, crOut, isArc) \
#define REGISTER_ARC_R(n, e, ae, id, sigSize, sig, offs, flags, tf, crIn, crOut, isArc) \
REGISTER_ARC_V (n, e, ae, id, sigSize, sig, offs, flags, tf, crIn, crOut, isArc) \
struct CRegisterArc { CRegisterArc() { RegisterArc(&g_ArcInfo); }}; \
static CRegisterArc g_RegisterArc;
#define REGISTER_ARC_I_CLS(cls, n, e, ae, id, sig, offs, flags, isArc) \
IMP_CreateArcIn_2(cls) \
REGISTER_ARC_R(n, e, ae, id, ARRAY_SIZE(sig), sig, offs, flags, CreateArc, NULL, isArc)
REGISTER_ARC_R(n, e, ae, id, ARRAY_SIZE(sig), sig, offs, flags, 0, CreateArc, NULL, isArc)
#define REGISTER_ARC_I_CLS_NO_SIG(cls, n, e, ae, id, offs, flags, isArc) \
IMP_CreateArcIn_2(cls) \
REGISTER_ARC_R(n, e, ae, id, 0, NULL, offs, flags, CreateArc, NULL, isArc)
REGISTER_ARC_R(n, e, ae, id, 0, NULL, offs, flags, 0, CreateArc, NULL, isArc)
#define REGISTER_ARC_I(n, e, ae, id, sig, offs, flags, isArc) \
REGISTER_ARC_I_CLS(CHandler(), n, e, ae, id, sig, offs, flags, isArc)
@@ -63,15 +65,15 @@ void RegisterArc(const CArcInfo *arcInfo) throw();
REGISTER_ARC_I_CLS_NO_SIG(CHandler(), n, e, ae, id, offs, flags, isArc)
#define REGISTER_ARC_IO(n, e, ae, id, sig, offs, flags, isArc) \
#define REGISTER_ARC_IO(n, e, ae, id, sig, offs, flags, tf, isArc) \
IMP_CreateArcIn \
IMP_CreateArcOut \
REGISTER_ARC_R(n, e, ae, id, ARRAY_SIZE(sig), sig, offs, flags, CreateArc, CreateArcOut, isArc)
REGISTER_ARC_R(n, e, ae, id, ARRAY_SIZE(sig), sig, offs, flags, tf, CreateArc, CreateArcOut, isArc)
#define REGISTER_ARC_IO_DECREMENT_SIG(n, e, ae, id, sig, offs, flags, isArc) \
#define REGISTER_ARC_IO_DECREMENT_SIG(n, e, ae, id, sig, offs, flags, tf, isArc) \
IMP_CreateArcIn \
IMP_CreateArcOut \
REGISTER_ARC_V(n, e, ae, id, ARRAY_SIZE(sig), sig, offs, flags, CreateArc, CreateArcOut, isArc) \
REGISTER_ARC_V(n, e, ae, id, ARRAY_SIZE(sig), sig, offs, flags, tf, CreateArc, CreateArcOut, isArc) \
struct CRegisterArcDecSig { CRegisterArcDecSig() { sig[0]--; RegisterArc(&g_ArcInfo); }}; \
static CRegisterArcDecSig g_RegisterArc;

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

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

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

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

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

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

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

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

8
CPP/7zip/Common/UniqBlocks.cpp Normal file → Executable file
View File

@@ -11,10 +11,10 @@ unsigned CUniqBlocks::AddUniq(const Byte *data, size_t size)
unsigned left = 0, right = Sorted.Size();
while (left != right)
{
unsigned mid = (left + right) / 2;
unsigned index = Sorted[mid];
const unsigned mid = (unsigned)(((size_t)left + (size_t)right) / 2);
const unsigned index = Sorted[mid];
const CByteBuffer &buf = Bufs[index];
size_t sizeMid = buf.Size();
const size_t sizeMid = buf.Size();
if (size < sizeMid)
right = mid;
else if (size > sizeMid)
@@ -23,7 +23,7 @@ unsigned CUniqBlocks::AddUniq(const Byte *data, size_t size)
{
if (size == 0)
return index;
int cmp = memcmp(data, buf, size);
const int cmp = memcmp(data, buf, size);
if (cmp == 0)
return index;
if (cmp < 0)

19
CPP/7zip/Common/UniqBlocks.h Normal file → Executable file
View File

@@ -3,9 +3,24 @@
#ifndef __UNIQ_BLOCKS_H
#define __UNIQ_BLOCKS_H
#include "../../Common/MyTypes.h"
#include "../../Common/MyBuffer.h"
#include "../../Common/MyVector.h"
#include "../../Common/MyString.h"
struct C_UInt32_UString_Map
{
CRecordVector<UInt32> Numbers;
UStringVector Strings;
void Add_UInt32(const UInt32 n)
{
Numbers.AddToUniqueSorted(n);
}
int Find(const UInt32 n)
{
return Numbers.FindInSorted(n);
}
};
struct CUniqBlocks
{

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

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