summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/lzma/CPP/7zip/UI/Client7z/Client7z.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2023-12-06 07:58:49 +1100
committer Vas Crabb <vas@vastheman.com>2023-12-06 07:58:49 +1100
commit79bef1e23049fdac25f1fefd132e0b6c7d2cc3a1 (patch)
tree643e9313fe86f583c4022c338677cbc12b761df7 /3rdparty/lzma/CPP/7zip/UI/Client7z/Client7z.cpp
parent512ccf0c7c9b4f08e41038b2ed2de220e140385b (diff)
3rdparty/lzma: Updated to version 23.01.
Diffstat (limited to '3rdparty/lzma/CPP/7zip/UI/Client7z/Client7z.cpp')
-rw-r--r--3rdparty/lzma/CPP/7zip/UI/Client7z/Client7z.cpp144
1 files changed, 57 insertions, 87 deletions
diff --git a/3rdparty/lzma/CPP/7zip/UI/Client7z/Client7z.cpp b/3rdparty/lzma/CPP/7zip/UI/Client7z/Client7z.cpp
index a55fa22d699..121a2f1051f 100644
--- a/3rdparty/lzma/CPP/7zip/UI/Client7z/Client7z.cpp
+++ b/3rdparty/lzma/CPP/7zip/UI/Client7z/Client7z.cpp
@@ -5,10 +5,9 @@
#include <stdio.h>
#include "../../../Common/MyWindows.h"
-
-#include "../../../Common/Defs.h"
#include "../../../Common/MyInitGuid.h"
+#include "../../../Common/Defs.h"
#include "../../../Common/IntToString.h"
#include "../../../Common/StringConvert.h"
@@ -30,13 +29,13 @@
#ifdef _WIN32
extern
HINSTANCE g_hInstance;
-HINSTANCE g_hInstance = 0;
+HINSTANCE g_hInstance = NULL;
#endif
// You can find full list of all GUIDs supported by 7-Zip in Guid.txt file.
// 7z format GUID: {23170F69-40C1-278A-1000-000110070000}
-#define DEFINE_GUID_ARC(name, id) DEFINE_GUID(name, \
+#define DEFINE_GUID_ARC(name, id) Z7_DEFINE_GUID(name, \
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, id, 0x00, 0x00);
enum
@@ -154,7 +153,7 @@ static void PrintError(const char *message, const FString &name)
static HRESULT IsArchiveItemProp(IInArchive *archive, UInt32 index, PROPID propID, bool &result)
{
NCOM::CPropVariant prop;
- RINOK(archive->GetProperty(index, propID, &prop));
+ RINOK(archive->GetProperty(index, propID, &prop))
if (prop.vt == VT_BOOL)
result = VARIANT_BOOLToBool(prop.boolVal);
else if (prop.vt == VT_EMPTY)
@@ -177,18 +176,13 @@ static const wchar_t * const kEmptyFileAlias = L"[Content]";
// Archive Open callback class
-class CArchiveOpenCallback:
+class CArchiveOpenCallback Z7_final:
public IArchiveOpenCallback,
public ICryptoGetTextPassword,
public CMyUnknownImp
{
+ Z7_IFACES_IMP_UNK_2(IArchiveOpenCallback, ICryptoGetTextPassword)
public:
- MY_UNKNOWN_IMP1(ICryptoGetTextPassword)
-
- STDMETHOD(SetTotal)(const UInt64 *files, const UInt64 *bytes);
- STDMETHOD(SetCompleted)(const UInt64 *files, const UInt64 *bytes);
-
- STDMETHOD(CryptoGetTextPassword)(BSTR *password);
bool PasswordIsDefined;
UString Password;
@@ -196,17 +190,17 @@ public:
CArchiveOpenCallback() : PasswordIsDefined(false) {}
};
-STDMETHODIMP CArchiveOpenCallback::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */)
+Z7_COM7F_IMF(CArchiveOpenCallback::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */))
{
return S_OK;
}
-STDMETHODIMP CArchiveOpenCallback::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */)
+Z7_COM7F_IMF(CArchiveOpenCallback::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */))
{
return S_OK;
}
-STDMETHODIMP CArchiveOpenCallback::CryptoGetTextPassword(BSTR *password)
+Z7_COM7F_IMF(CArchiveOpenCallback::CryptoGetTextPassword(BSTR *password))
{
if (!PasswordIsDefined)
{
@@ -321,27 +315,14 @@ struct CArcTime
-class CArchiveExtractCallback:
+class CArchiveExtractCallback Z7_final:
public IArchiveExtractCallback,
public ICryptoGetTextPassword,
public CMyUnknownImp
{
-public:
- MY_UNKNOWN_IMP1(ICryptoGetTextPassword)
-
- // IProgress
- STDMETHOD(SetTotal)(UInt64 size);
- STDMETHOD(SetCompleted)(const UInt64 *completeValue);
-
- // IArchiveExtractCallback
- STDMETHOD(GetStream)(UInt32 index, ISequentialOutStream **outStream, Int32 askExtractMode);
- STDMETHOD(PrepareOperation)(Int32 askExtractMode);
- STDMETHOD(SetOperationResult)(Int32 resultEOperationResult);
+ Z7_IFACES_IMP_UNK_2(IArchiveExtractCallback, ICryptoGetTextPassword)
+ Z7_IFACE_COM7_IMP(IProgress)
- // ICryptoGetTextPassword
- STDMETHOD(CryptoGetTextPassword)(BSTR *aPassword);
-
-private:
CMyComPtr<IInArchive> _archiveHandler;
FString _directoryPath; // Output directory
UString _filePath; // name inside arcvhive
@@ -376,26 +357,26 @@ void CArchiveExtractCallback::Init(IInArchive *archiveHandler, const FString &di
NName::NormalizeDirPathPrefix(_directoryPath);
}
-STDMETHODIMP CArchiveExtractCallback::SetTotal(UInt64 /* size */)
+Z7_COM7F_IMF(CArchiveExtractCallback::SetTotal(UInt64 /* size */))
{
return S_OK;
}
-STDMETHODIMP CArchiveExtractCallback::SetCompleted(const UInt64 * /* completeValue */)
+Z7_COM7F_IMF(CArchiveExtractCallback::SetCompleted(const UInt64 * /* completeValue */))
{
return S_OK;
}
-STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index,
- ISequentialOutStream **outStream, Int32 askExtractMode)
+Z7_COM7F_IMF(CArchiveExtractCallback::GetStream(UInt32 index,
+ ISequentialOutStream **outStream, Int32 askExtractMode))
{
- *outStream = 0;
+ *outStream = NULL;
_outFileStream.Release();
{
// Get Name
NCOM::CPropVariant prop;
- RINOK(_archiveHandler->GetProperty(index, kpidPath, &prop));
+ RINOK(_archiveHandler->GetProperty(index, kpidPath, &prop))
UString fullPath;
if (prop.vt == VT_EMPTY)
@@ -415,7 +396,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index,
{
// Get Attrib
NCOM::CPropVariant prop;
- RINOK(_archiveHandler->GetProperty(index, kpidAttrib, &prop));
+ RINOK(_archiveHandler->GetProperty(index, kpidAttrib, &prop))
if (prop.vt == VT_EMPTY)
{
_processedFileInfo.Attrib = 0;
@@ -430,13 +411,13 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index,
}
}
- RINOK(IsArchiveItemFolder(_archiveHandler, index, _processedFileInfo.isDir));
+ RINOK(IsArchiveItemFolder(_archiveHandler, index, _processedFileInfo.isDir))
{
_processedFileInfo.MTime.Clear();
// Get Modified Time
NCOM::CPropVariant prop;
- RINOK(_archiveHandler->GetProperty(index, kpidMTime, &prop));
+ RINOK(_archiveHandler->GetProperty(index, kpidMTime, &prop))
switch (prop.vt)
{
case VT_EMPTY:
@@ -453,7 +434,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index,
{
// Get Size
NCOM::CPropVariant prop;
- RINOK(_archiveHandler->GetProperty(index, kpidSize, &prop));
+ RINOK(_archiveHandler->GetProperty(index, kpidSize, &prop))
UInt64 newFileSize;
/* bool newFileSizeDefined = */ ConvertPropVariantToUInt64(prop, newFileSize);
}
@@ -498,13 +479,13 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index,
return S_OK;
}
-STDMETHODIMP CArchiveExtractCallback::PrepareOperation(Int32 askExtractMode)
+Z7_COM7F_IMF(CArchiveExtractCallback::PrepareOperation(Int32 askExtractMode))
{
_extractMode = false;
switch (askExtractMode)
{
case NArchive::NExtract::NAskMode::kExtract: _extractMode = true; break;
- };
+ }
switch (askExtractMode)
{
case NArchive::NExtract::NAskMode::kExtract: Print(kExtractingString); break;
@@ -513,12 +494,12 @@ STDMETHODIMP CArchiveExtractCallback::PrepareOperation(Int32 askExtractMode)
case NArchive::NExtract::NAskMode::kReadExternal: Print(kReadingString); break;
default:
Print("??? "); break;
- };
+ }
Print(_filePath);
return S_OK;
}
-STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
+Z7_COM7F_IMF(CArchiveExtractCallback::SetOperationResult(Int32 operationResult))
{
switch (operationResult)
{
@@ -564,7 +545,7 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
else
{
char temp[16];
- ConvertUInt32ToString(operationResult, temp);
+ ConvertUInt32ToString((UInt32)operationResult, temp);
Print("Error #");
Print(temp);
}
@@ -579,7 +560,7 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
_processedFileInfo.MTime.Write_To_FiTime(ft);
_outFileStreamSpec->SetMTime(&ft);
}
- RINOK(_outFileStreamSpec->Close());
+ RINOK(_outFileStreamSpec->Close())
}
_outFileStream.Release();
if (_extractMode && _processedFileInfo.Attrib_Defined)
@@ -589,7 +570,7 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
}
-STDMETHODIMP CArchiveExtractCallback::CryptoGetTextPassword(BSTR *password)
+Z7_COM7F_IMF(CArchiveExtractCallback::CryptoGetTextPassword(BSTR *password))
{
if (!PasswordIsDefined)
{
@@ -617,28 +598,14 @@ struct CDirItem: public NWindows::NFile::NFind::CFileInfoBase
{}
};
-class CArchiveUpdateCallback:
+class CArchiveUpdateCallback Z7_final:
public IArchiveUpdateCallback2,
public ICryptoGetTextPassword2,
public CMyUnknownImp
{
-public:
- MY_UNKNOWN_IMP2(IArchiveUpdateCallback2, ICryptoGetTextPassword2)
-
- // IProgress
- STDMETHOD(SetTotal)(UInt64 size);
- STDMETHOD(SetCompleted)(const UInt64 *completeValue);
-
- // IUpdateCallback2
- STDMETHOD(GetUpdateItemInfo)(UInt32 index,
- Int32 *newData, Int32 *newProperties, UInt32 *indexInArchive);
- STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
- STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **inStream);
- STDMETHOD(SetOperationResult)(Int32 operationResult);
- STDMETHOD(GetVolumeSize)(UInt32 index, UInt64 *size);
- STDMETHOD(GetVolumeStream)(UInt32 index, ISequentialOutStream **volumeStream);
-
- STDMETHOD(CryptoGetTextPassword2)(Int32 *passwordIsDefined, BSTR *password);
+ Z7_IFACES_IMP_UNK_2(IArchiveUpdateCallback2, ICryptoGetTextPassword2)
+ Z7_IFACE_COM7_IMP(IProgress)
+ Z7_IFACE_COM7_IMP(IArchiveUpdateCallback)
public:
CRecordVector<UInt64> VolumesSizes;
@@ -675,18 +642,18 @@ public:
}
};
-STDMETHODIMP CArchiveUpdateCallback::SetTotal(UInt64 /* size */)
+Z7_COM7F_IMF(CArchiveUpdateCallback::SetTotal(UInt64 /* size */))
{
return S_OK;
}
-STDMETHODIMP CArchiveUpdateCallback::SetCompleted(const UInt64 * /* completeValue */)
+Z7_COM7F_IMF(CArchiveUpdateCallback::SetCompleted(const UInt64 * /* completeValue */))
{
return S_OK;
}
-STDMETHODIMP CArchiveUpdateCallback::GetUpdateItemInfo(UInt32 /* index */,
- Int32 *newData, Int32 *newProperties, UInt32 *indexInArchive)
+Z7_COM7F_IMF(CArchiveUpdateCallback::GetUpdateItemInfo(UInt32 /* index */,
+ Int32 *newData, Int32 *newProperties, UInt32 *indexInArchive))
{
if (newData)
*newData = BoolToInt(true);
@@ -697,7 +664,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetUpdateItemInfo(UInt32 /* index */,
return S_OK;
}
-STDMETHODIMP CArchiveUpdateCallback::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+Z7_COM7F_IMF(CArchiveUpdateCallback::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value))
{
NCOM::CPropVariant prop;
@@ -744,9 +711,9 @@ static void GetStream2(const wchar_t *name)
Print(name);
}
-STDMETHODIMP CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream **inStream)
+Z7_COM7F_IMF(CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream **inStream))
{
- RINOK(Finilize());
+ RINOK(Finilize())
const CDirItem &dirItem = (*DirItems)[index];
GetStream2(dirItem.Path_For_Handler);
@@ -760,8 +727,8 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream
FString path = DirPrefix + dirItem.FullPath;
if (!inStreamSpec->Open(path))
{
- DWORD sysError = ::GetLastError();
- FailedCodes.Add(sysError);
+ const DWORD sysError = ::GetLastError();
+ FailedCodes.Add(HRESULT_FROM_WIN32(sysError));
FailedFiles.Add(path);
// if (systemError == ERROR_SHARING_VIOLATION)
{
@@ -777,13 +744,13 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream
return S_OK;
}
-STDMETHODIMP CArchiveUpdateCallback::SetOperationResult(Int32 /* operationResult */)
+Z7_COM7F_IMF(CArchiveUpdateCallback::SetOperationResult(Int32 /* operationResult */))
{
m_NeedBeClosed = true;
return S_OK;
}
-STDMETHODIMP CArchiveUpdateCallback::GetVolumeSize(UInt32 index, UInt64 *size)
+Z7_COM7F_IMF(CArchiveUpdateCallback::GetVolumeSize(UInt32 index, UInt64 *size))
{
if (VolumesSizes.Size() == 0)
return S_FALSE;
@@ -793,7 +760,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetVolumeSize(UInt32 index, UInt64 *size)
return S_OK;
}
-STDMETHODIMP CArchiveUpdateCallback::GetVolumeStream(UInt32 index, ISequentialOutStream **volumeStream)
+Z7_COM7F_IMF(CArchiveUpdateCallback::GetVolumeStream(UInt32 index, ISequentialOutStream **volumeStream))
{
wchar_t temp[16];
ConvertUInt32ToString(index + 1, temp);
@@ -801,18 +768,18 @@ STDMETHODIMP CArchiveUpdateCallback::GetVolumeStream(UInt32 index, ISequentialOu
while (res.Len() < 2)
res.InsertAtFront(L'0');
UString fileName = VolName;
- fileName += '.';
+ fileName.Add_Dot();
fileName += res;
fileName += VolExt;
COutFileStream *streamSpec = new COutFileStream;
CMyComPtr<ISequentialOutStream> streamLoc(streamSpec);
if (!streamSpec->Create(us2fs(fileName), false))
- return ::GetLastError();
+ return GetLastError_noZero_HRESULT();
*volumeStream = streamLoc.Detach();
return S_OK;
}
-STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)
+Z7_COM7F_IMF(CArchiveUpdateCallback::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password))
{
if (!PasswordIsDefined)
{
@@ -836,7 +803,7 @@ STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword2(Int32 *passwordIsDef
#define NT_CHECK_FAIL_ACTION PrintError("Unsupported Windows version"); return 1;
#endif
-int MY_CDECL main(int numArgs, const char *args[])
+int Z7_CDECL main(int numArgs, const char *args[])
{
NT_CHECK
@@ -872,8 +839,11 @@ int MY_CDECL main(int numArgs, const char *args[])
return 1;
}
- Func_CreateObject createObjectFunc = (Func_CreateObject)lib.GetProc("CreateObject");
- if (!createObjectFunc)
+ Func_CreateObject
+ f_CreateObject = Z7_GET_PROC_ADDRESS(
+ Func_CreateObject, lib.Get_HMODULE(),
+ "CreateObject");
+ if (!f_CreateObject)
{
PrintError("Cannot get CreateObject");
return 1;
@@ -966,7 +936,7 @@ int MY_CDECL main(int numArgs, const char *args[])
}
CMyComPtr<IOutArchive> outArchive;
- if (createObjectFunc(&CLSID_Format, &IID_IOutArchive, (void **)&outArchive) != S_OK)
+ if (f_CreateObject(&CLSID_Format, &IID_IOutArchive, (void **)&outArchive) != S_OK)
{
PrintError("Cannot get class object");
return 1;
@@ -986,7 +956,7 @@ int MY_CDECL main(int numArgs, const char *args[])
L"s",
L"x"
};
- const unsigned kNumProps = ARRAY_SIZE(names);
+ const unsigned kNumProps = Z7_ARRAY_SIZE(names);
NCOM::CPropVariant values[kNumProps] =
{
L"lzma",
@@ -1048,7 +1018,7 @@ int MY_CDECL main(int numArgs, const char *args[])
}
CMyComPtr<IInArchive> archive;
- if (createObjectFunc(&CLSID_Format, &IID_IInArchive, (void **)&archive) != S_OK)
+ if (f_CreateObject(&CLSID_Format, &IID_IInArchive, (void **)&archive) != S_OK)
{
PrintError("Cannot get class object");
return 1;