Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2022-06-23 13:43:16 +0300
committerKornel <kornel@geekhood.net>2022-06-23 13:43:16 +0300
commitec44a8a0700a8b2444b07f576be332f756754323 (patch)
tree0b19ee3b63dd53aacca6990451022aee54d0aa69 /CPP/7zip/Common
parentc3529a41f527101f05e9e834a19205ee33a3b097 (diff)
Diffstat (limited to 'CPP/7zip/Common')
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/CWrappers.cpp0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/CWrappers.h0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/CreateCoder.cpp0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/CreateCoder.h0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/FilePathAutoRename.cpp0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/FilePathAutoRename.h0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/FileStreams.cpp292
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/FileStreams.h42
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/FilterCoder.cpp0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/FilterCoder.h0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/InBuffer.cpp3
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/InBuffer.h0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/InOutTempBuffer.cpp0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/InOutTempBuffer.h0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/LimitedStreams.cpp68
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/LimitedStreams.h21
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/LockedStream.cpp0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/LockedStream.h0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/MemBlocks.cpp0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/MemBlocks.h0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/MethodId.cpp0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/MethodId.h0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/MethodProps.cpp0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/MethodProps.h0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/OffsetStream.cpp0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/OffsetStream.h0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/OutBuffer.cpp0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/OutBuffer.h0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/OutMemStream.cpp0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/OutMemStream.h0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/ProgressMt.cpp0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/ProgressMt.h0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/ProgressUtils.cpp0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/ProgressUtils.h0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/PropId.cpp9
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/RegisterArc.h24
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/RegisterCodec.h0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/StdAfx.h0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/StreamBinder.cpp0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/StreamBinder.h0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/StreamObjects.cpp0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/StreamObjects.h0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/StreamUtils.cpp0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/StreamUtils.h0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/UniqBlocks.cpp8
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/UniqBlocks.h19
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/VirtThread.cpp0
-rwxr-xr-x[-rw-r--r--]CPP/7zip/Common/VirtThread.h0
48 files changed, 407 insertions, 79 deletions
diff --git a/CPP/7zip/Common/CWrappers.cpp b/CPP/7zip/Common/CWrappers.cpp
index ee4c36a2..ee4c36a2 100644..100755
--- a/CPP/7zip/Common/CWrappers.cpp
+++ b/CPP/7zip/Common/CWrappers.cpp
diff --git a/CPP/7zip/Common/CWrappers.h b/CPP/7zip/Common/CWrappers.h
index e7196a5c..e7196a5c 100644..100755
--- a/CPP/7zip/Common/CWrappers.h
+++ b/CPP/7zip/Common/CWrappers.h
diff --git a/CPP/7zip/Common/CreateCoder.cpp b/CPP/7zip/Common/CreateCoder.cpp
index 872f17fc..872f17fc 100644..100755
--- a/CPP/7zip/Common/CreateCoder.cpp
+++ b/CPP/7zip/Common/CreateCoder.cpp
diff --git a/CPP/7zip/Common/CreateCoder.h b/CPP/7zip/Common/CreateCoder.h
index 24e6b663..24e6b663 100644..100755
--- a/CPP/7zip/Common/CreateCoder.h
+++ b/CPP/7zip/Common/CreateCoder.h
diff --git a/CPP/7zip/Common/FilePathAutoRename.cpp b/CPP/7zip/Common/FilePathAutoRename.cpp
index 1ebfd72b..1ebfd72b 100644..100755
--- a/CPP/7zip/Common/FilePathAutoRename.cpp
+++ b/CPP/7zip/Common/FilePathAutoRename.cpp
diff --git a/CPP/7zip/Common/FilePathAutoRename.h b/CPP/7zip/Common/FilePathAutoRename.h
index 7b576591..7b576591 100644..100755
--- a/CPP/7zip/Common/FilePathAutoRename.h
+++ b/CPP/7zip/Common/FilePathAutoRename.h
diff --git a/CPP/7zip/Common/FileStreams.cpp b/CPP/7zip/Common/FileStreams.cpp
index 9e0e79ca..6862a9b6 100644..100755
--- a/CPP/7zip/Common/FileStreams.cpp
+++ b/CPP/7zip/Common/FileStreams.cpp
@@ -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
diff --git a/CPP/7zip/Common/FileStreams.h b/CPP/7zip/Common/FileStreams.h
index fe9f4c19..f2c19eea 100644..100755
--- a/CPP/7zip/Common/FileStreams.h
+++ b/CPP/7zip/Common/FileStreams.h
@@ -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
+ #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)
diff --git a/CPP/7zip/Common/FilterCoder.cpp b/CPP/7zip/Common/FilterCoder.cpp
index fb99f610..fb99f610 100644..100755
--- a/CPP/7zip/Common/FilterCoder.cpp
+++ b/CPP/7zip/Common/FilterCoder.cpp
diff --git a/CPP/7zip/Common/FilterCoder.h b/CPP/7zip/Common/FilterCoder.h
index 6668fdb3..6668fdb3 100644..100755
--- a/CPP/7zip/Common/FilterCoder.h
+++ b/CPP/7zip/Common/FilterCoder.h
diff --git a/CPP/7zip/Common/InBuffer.cpp b/CPP/7zip/Common/InBuffer.cpp
index 6f6eecad..fe6d1490 100644..100755
--- a/CPP/7zip/Common/InBuffer.cpp
+++ b/CPP/7zip/Common/InBuffer.cpp
@@ -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;
}
diff --git a/CPP/7zip/Common/InBuffer.h b/CPP/7zip/Common/InBuffer.h
index fa063949..fa063949 100644..100755
--- a/CPP/7zip/Common/InBuffer.h
+++ b/CPP/7zip/Common/InBuffer.h
diff --git a/CPP/7zip/Common/InOutTempBuffer.cpp b/CPP/7zip/Common/InOutTempBuffer.cpp
index cae6b803..cae6b803 100644..100755
--- a/CPP/7zip/Common/InOutTempBuffer.cpp
+++ b/CPP/7zip/Common/InOutTempBuffer.cpp
diff --git a/CPP/7zip/Common/InOutTempBuffer.h b/CPP/7zip/Common/InOutTempBuffer.h
index 755935ea..755935ea 100644..100755
--- a/CPP/7zip/Common/InOutTempBuffer.h
+++ b/CPP/7zip/Common/InOutTempBuffer.h
diff --git a/CPP/7zip/Common/LimitedStreams.cpp b/CPP/7zip/Common/LimitedStreams.cpp
index add6636b..980c795d 100644..100755
--- a/CPP/7zip/Common/LimitedStreams.cpp
+++ b/CPP/7zip/Common/LimitedStreams.cpp
@@ -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 CSeekExtent &extent = Extents[left];
- UInt64 phyPos = extent.Phy + (_virtPos - extent.Virt);
- if (_needStartSeek || _phyPos != phyPos)
{
- _needStartSeek = false;
- _phyPos = phyPos;
- RINOK(SeekToPhys());
+ const UInt64 rem = Extents[left + 1].Virt - virt;
+ if (size > rem)
+ size = (UInt32)rem;
}
- UInt64 rem = Extents[left + 1].Virt - _virtPos;
- if (size > rem)
- size = (UInt32)rem;
+ const CSeekExtent &extent = Extents[left];
- HRESULT res = Stream->Read(data, size, &size);
- _phyPos += size;
+ if (extent.Is_ZeroFill())
+ {
+ 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;
+ }
+ }
+
+ 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)
diff --git a/CPP/7zip/Common/LimitedStreams.h b/CPP/7zip/Common/LimitedStreams.h
index ade29937..50c7cd85 100644..100755
--- a/CPP/7zip/Common/LimitedStreams.h
+++ b/CPP/7zip/Common/LimitedStreams.h
@@ -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
diff --git a/CPP/7zip/Common/LockedStream.cpp b/CPP/7zip/Common/LockedStream.cpp
index ca39fb45..ca39fb45 100644..100755
--- a/CPP/7zip/Common/LockedStream.cpp
+++ b/CPP/7zip/Common/LockedStream.cpp
diff --git a/CPP/7zip/Common/LockedStream.h b/CPP/7zip/Common/LockedStream.h
index efebf197..efebf197 100644..100755
--- a/CPP/7zip/Common/LockedStream.h
+++ b/CPP/7zip/Common/LockedStream.h
diff --git a/CPP/7zip/Common/MemBlocks.cpp b/CPP/7zip/Common/MemBlocks.cpp
index 9b0652c6..9b0652c6 100644..100755
--- a/CPP/7zip/Common/MemBlocks.cpp
+++ b/CPP/7zip/Common/MemBlocks.cpp
diff --git a/CPP/7zip/Common/MemBlocks.h b/CPP/7zip/Common/MemBlocks.h
index 3c9cefdb..3c9cefdb 100644..100755
--- a/CPP/7zip/Common/MemBlocks.h
+++ b/CPP/7zip/Common/MemBlocks.h
diff --git a/CPP/7zip/Common/MethodId.cpp b/CPP/7zip/Common/MethodId.cpp
index 1566c97c..1566c97c 100644..100755
--- a/CPP/7zip/Common/MethodId.cpp
+++ b/CPP/7zip/Common/MethodId.cpp
diff --git a/CPP/7zip/Common/MethodId.h b/CPP/7zip/Common/MethodId.h
index 28b615fc..28b615fc 100644..100755
--- a/CPP/7zip/Common/MethodId.h
+++ b/CPP/7zip/Common/MethodId.h
diff --git a/CPP/7zip/Common/MethodProps.cpp b/CPP/7zip/Common/MethodProps.cpp
index 0e8ff1c6..0e8ff1c6 100644..100755
--- a/CPP/7zip/Common/MethodProps.cpp
+++ b/CPP/7zip/Common/MethodProps.cpp
diff --git a/CPP/7zip/Common/MethodProps.h b/CPP/7zip/Common/MethodProps.h
index 5b5c96a4..5b5c96a4 100644..100755
--- a/CPP/7zip/Common/MethodProps.h
+++ b/CPP/7zip/Common/MethodProps.h
diff --git a/CPP/7zip/Common/OffsetStream.cpp b/CPP/7zip/Common/OffsetStream.cpp
index b16124c2..b16124c2 100644..100755
--- a/CPP/7zip/Common/OffsetStream.cpp
+++ b/CPP/7zip/Common/OffsetStream.cpp
diff --git a/CPP/7zip/Common/OffsetStream.h b/CPP/7zip/Common/OffsetStream.h
index 9074a24e..9074a24e 100644..100755
--- a/CPP/7zip/Common/OffsetStream.h
+++ b/CPP/7zip/Common/OffsetStream.h
diff --git a/CPP/7zip/Common/OutBuffer.cpp b/CPP/7zip/Common/OutBuffer.cpp
index 4ba34a05..4ba34a05 100644..100755
--- a/CPP/7zip/Common/OutBuffer.cpp
+++ b/CPP/7zip/Common/OutBuffer.cpp
diff --git a/CPP/7zip/Common/OutBuffer.h b/CPP/7zip/Common/OutBuffer.h
index d7ca9f6a..d7ca9f6a 100644..100755
--- a/CPP/7zip/Common/OutBuffer.h
+++ b/CPP/7zip/Common/OutBuffer.h
diff --git a/CPP/7zip/Common/OutMemStream.cpp b/CPP/7zip/Common/OutMemStream.cpp
index 241589d2..241589d2 100644..100755
--- a/CPP/7zip/Common/OutMemStream.cpp
+++ b/CPP/7zip/Common/OutMemStream.cpp
diff --git a/CPP/7zip/Common/OutMemStream.h b/CPP/7zip/Common/OutMemStream.h
index 873742ed..873742ed 100644..100755
--- a/CPP/7zip/Common/OutMemStream.h
+++ b/CPP/7zip/Common/OutMemStream.h
diff --git a/CPP/7zip/Common/ProgressMt.cpp b/CPP/7zip/Common/ProgressMt.cpp
index c2714a27..c2714a27 100644..100755
--- a/CPP/7zip/Common/ProgressMt.cpp
+++ b/CPP/7zip/Common/ProgressMt.cpp
diff --git a/CPP/7zip/Common/ProgressMt.h b/CPP/7zip/Common/ProgressMt.h
index 32da976b..32da976b 100644..100755
--- a/CPP/7zip/Common/ProgressMt.h
+++ b/CPP/7zip/Common/ProgressMt.h
diff --git a/CPP/7zip/Common/ProgressUtils.cpp b/CPP/7zip/Common/ProgressUtils.cpp
index 41385ccb..41385ccb 100644..100755
--- a/CPP/7zip/Common/ProgressUtils.cpp
+++ b/CPP/7zip/Common/ProgressUtils.cpp
diff --git a/CPP/7zip/Common/ProgressUtils.h b/CPP/7zip/Common/ProgressUtils.h
index e94265ba..e94265ba 100644..100755
--- a/CPP/7zip/Common/ProgressUtils.h
+++ b/CPP/7zip/Common/ProgressUtils.h
diff --git a/CPP/7zip/Common/PropId.cpp b/CPP/7zip/Common/PropId.cpp
index 11d20d55..0e643e85 100644..100755
--- a/CPP/7zip/Common/PropId.cpp
+++ b/CPP/7zip/Common/PropId.cpp
@@ -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
};
diff --git a/CPP/7zip/Common/RegisterArc.h b/CPP/7zip/Common/RegisterArc.h
index 3421ba1b..a0384fad 100644..100755
--- a/CPP/7zip/Common/RegisterArc.h
+++ b/CPP/7zip/Common/RegisterArc.h
@@ -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;
diff --git a/CPP/7zip/Common/RegisterCodec.h b/CPP/7zip/Common/RegisterCodec.h
index a942da7a..a942da7a 100644..100755
--- a/CPP/7zip/Common/RegisterCodec.h
+++ b/CPP/7zip/Common/RegisterCodec.h
diff --git a/CPP/7zip/Common/StdAfx.h b/CPP/7zip/Common/StdAfx.h
index 1cbd7fea..1cbd7fea 100644..100755
--- a/CPP/7zip/Common/StdAfx.h
+++ b/CPP/7zip/Common/StdAfx.h
diff --git a/CPP/7zip/Common/StreamBinder.cpp b/CPP/7zip/Common/StreamBinder.cpp
index 6b6e0e58..6b6e0e58 100644..100755
--- a/CPP/7zip/Common/StreamBinder.cpp
+++ b/CPP/7zip/Common/StreamBinder.cpp
diff --git a/CPP/7zip/Common/StreamBinder.h b/CPP/7zip/Common/StreamBinder.h
index 16c872fb..16c872fb 100644..100755
--- a/CPP/7zip/Common/StreamBinder.h
+++ b/CPP/7zip/Common/StreamBinder.h
diff --git a/CPP/7zip/Common/StreamObjects.cpp b/CPP/7zip/Common/StreamObjects.cpp
index 2d941df6..2d941df6 100644..100755
--- a/CPP/7zip/Common/StreamObjects.cpp
+++ b/CPP/7zip/Common/StreamObjects.cpp
diff --git a/CPP/7zip/Common/StreamObjects.h b/CPP/7zip/Common/StreamObjects.h
index a8fb229c..a8fb229c 100644..100755
--- a/CPP/7zip/Common/StreamObjects.h
+++ b/CPP/7zip/Common/StreamObjects.h
diff --git a/CPP/7zip/Common/StreamUtils.cpp b/CPP/7zip/Common/StreamUtils.cpp
index 1402f420..1402f420 100644..100755
--- a/CPP/7zip/Common/StreamUtils.cpp
+++ b/CPP/7zip/Common/StreamUtils.cpp
diff --git a/CPP/7zip/Common/StreamUtils.h b/CPP/7zip/Common/StreamUtils.h
index ae914c00..ae914c00 100644..100755
--- a/CPP/7zip/Common/StreamUtils.h
+++ b/CPP/7zip/Common/StreamUtils.h
diff --git a/CPP/7zip/Common/UniqBlocks.cpp b/CPP/7zip/Common/UniqBlocks.cpp
index 8f754e17..32dc2762 100644..100755
--- a/CPP/7zip/Common/UniqBlocks.cpp
+++ b/CPP/7zip/Common/UniqBlocks.cpp
@@ -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)
diff --git a/CPP/7zip/Common/UniqBlocks.h b/CPP/7zip/Common/UniqBlocks.h
index d6cd3728..8479d68c 100644..100755
--- a/CPP/7zip/Common/UniqBlocks.h
+++ b/CPP/7zip/Common/UniqBlocks.h
@@ -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
{
diff --git a/CPP/7zip/Common/VirtThread.cpp b/CPP/7zip/Common/VirtThread.cpp
index bf24bb1c..bf24bb1c 100644..100755
--- a/CPP/7zip/Common/VirtThread.cpp
+++ b/CPP/7zip/Common/VirtThread.cpp
diff --git a/CPP/7zip/Common/VirtThread.h b/CPP/7zip/Common/VirtThread.h
index b4d8a5a9..b4d8a5a9 100644..100755
--- a/CPP/7zip/Common/VirtThread.h
+++ b/CPP/7zip/Common/VirtThread.h