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
path: root/CPP/7zip/UI
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2007-04-17 04:00:00 +0400
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:15:50 +0300
commita145bfc7cf17f7bbcfae8f0064333c8ea75b455c (patch)
tree4ea458c9f35956fe080562989a702ea8c9af4b90 /CPP/7zip/UI
parentd9666cf046a8453b33b3e2fbf4d82295a9f87df3 (diff)
4.45 beta
Diffstat (limited to 'CPP/7zip/UI')
-rwxr-xr-xCPP/7zip/UI/Agent/Agent.cpp25
-rwxr-xr-xCPP/7zip/UI/Agent/Agent.h50
-rwxr-xr-xCPP/7zip/UI/Agent/AgentOut.cpp32
-rwxr-xr-xCPP/7zip/UI/Agent/ArchiveFolderOpen.cpp100
-rwxr-xr-xCPP/7zip/UI/Agent/ArchiveFolderOut.cpp3
-rwxr-xr-xCPP/7zip/UI/Agent/IFolderArchive.h18
-rwxr-xr-xCPP/7zip/UI/Client7z/Client7z.cpp4
-rwxr-xr-xCPP/7zip/UI/Client7z/makefile2
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveCommandLine.cpp159
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveCommandLine.h13
-rwxr-xr-xCPP/7zip/UI/Common/ArchiverInfo.cpp372
-rwxr-xr-xCPP/7zip/UI/Common/ArchiverInfo.h66
-rwxr-xr-xCPP/7zip/UI/Common/CompressCall.cpp8
-rwxr-xr-xCPP/7zip/UI/Common/CompressCall.h2
-rwxr-xr-xCPP/7zip/UI/Common/Extract.cpp7
-rwxr-xr-xCPP/7zip/UI/Common/Extract.h7
-rwxr-xr-xCPP/7zip/UI/Common/LoadCodecs.cpp621
-rwxr-xr-xCPP/7zip/UI/Common/LoadCodecs.h215
-rwxr-xr-xCPP/7zip/UI/Common/OpenArchive.cpp292
-rwxr-xr-xCPP/7zip/UI/Common/OpenArchive.h73
-rwxr-xr-xCPP/7zip/UI/Common/Update.cpp125
-rwxr-xr-xCPP/7zip/UI/Common/Update.h16
-rwxr-xr-xCPP/7zip/UI/Common/ZipRegistry.cpp29
-rwxr-xr-xCPP/7zip/UI/Common/ZipRegistry.h7
-rwxr-xr-xCPP/7zip/UI/Console/Console.dsp82
-rwxr-xr-xCPP/7zip/UI/Console/ExtractCallbackConsole.cpp6
-rwxr-xr-xCPP/7zip/UI/Console/List.cpp6
-rwxr-xr-xCPP/7zip/UI/Console/List.h5
-rwxr-xr-xCPP/7zip/UI/Console/Main.cpp210
-rwxr-xr-xCPP/7zip/UI/Console/MainAr.cpp17
-rwxr-xr-xCPP/7zip/UI/Console/PercentPrinter.cpp2
-rwxr-xr-xCPP/7zip/UI/Console/makefile29
-rwxr-xr-xCPP/7zip/UI/Explorer/ContextMenu.cpp61
-rwxr-xr-xCPP/7zip/UI/Explorer/Explorer.dsp137
-rwxr-xr-xCPP/7zip/UI/Explorer/SystemPage/SystemPage.h4
-rwxr-xr-xCPP/7zip/UI/Explorer/makefile7
-rwxr-xr-xCPP/7zip/UI/Far/ExtractEngine.cpp8
-rwxr-xr-xCPP/7zip/UI/Far/Far.dsp50
-rwxr-xr-xCPP/7zip/UI/Far/FarUtils.cpp2
-rwxr-xr-xCPP/7zip/UI/Far/Main.cpp9
-rwxr-xr-xCPP/7zip/UI/Far/Messages.h2
-rwxr-xr-xCPP/7zip/UI/Far/Plugin.cpp42
-rwxr-xr-xCPP/7zip/UI/Far/Plugin.h1
-rwxr-xr-xCPP/7zip/UI/Far/PluginDelete.cpp3
-rwxr-xr-xCPP/7zip/UI/Far/PluginWrite.cpp79
-rwxr-xr-xCPP/7zip/UI/Far/ProgressBox.cpp7
-rwxr-xr-xCPP/7zip/UI/Far/StdAfx.h1
-rwxr-xr-xCPP/7zip/UI/Far/UpdateCallback100.cpp6
-rwxr-xr-xCPP/7zip/UI/Far/makefile8
-rwxr-xr-xCPP/7zip/UI/GUI/CompressDialog.cpp335
-rwxr-xr-xCPP/7zip/UI/GUI/CompressDialog.h39
-rwxr-xr-xCPP/7zip/UI/GUI/ExtractGUI.cpp8
-rwxr-xr-xCPP/7zip/UI/GUI/ExtractGUI.h1
-rwxr-xr-xCPP/7zip/UI/GUI/GUI.cpp30
-rwxr-xr-xCPP/7zip/UI/GUI/GUI.dsp505
-rwxr-xr-xCPP/7zip/UI/GUI/Resource/BenchmarkDialog/BenchmarkDialog.cpp584
-rwxr-xr-xCPP/7zip/UI/GUI/Resource/BenchmarkDialog/BenchmarkDialog.h126
-rwxr-xr-xCPP/7zip/UI/GUI/Resource/BenchmarkDialog/StdAfx.h16
-rwxr-xr-xCPP/7zip/UI/GUI/Resource/BenchmarkDialog/resource.h54
-rwxr-xr-xCPP/7zip/UI/GUI/Resource/BenchmarkDialog/resource.rc116
-rwxr-xr-xCPP/7zip/UI/GUI/UpdateGUI.cpp71
-rwxr-xr-xCPP/7zip/UI/GUI/UpdateGUI.h1
-rwxr-xr-xCPP/7zip/UI/GUI/makefile34
-rwxr-xr-xCPP/7zip/UI/GUI/resource.h3
-rwxr-xr-xCPP/7zip/UI/GUI/resource.rc4
-rwxr-xr-xCPP/7zip/UI/Resource/CompressDialog/resource.h14
-rwxr-xr-xCPP/7zip/UI/Resource/CompressDialog/resource.rc36
67 files changed, 3356 insertions, 1651 deletions
diff --git a/CPP/7zip/UI/Agent/Agent.cpp b/CPP/7zip/UI/Agent/Agent.cpp
index f983e2f9..25cc42e4 100755
--- a/CPP/7zip/UI/Agent/Agent.cpp
+++ b/CPP/7zip/UI/Agent/Agent.cpp
@@ -13,10 +13,6 @@
#include "Agent.h"
-#ifdef FORMAT_7Z
-#include "../../Archive/7z/7zHandler.h"
-#endif
-
extern "C"
{
#include "../../../../C/Sort.h"
@@ -407,7 +403,8 @@ STDMETHODIMP CAgentFolder::Extract(const UINT32 *indices,
// CAgent
CAgent::CAgent():
- _proxyArchive(NULL)
+ _proxyArchive(NULL),
+ _codecs(0)
{
}
@@ -430,11 +427,17 @@ STDMETHODIMP CAgent::Open(
return ::GetLastError();
if (fileInfo.IsDirectory())
return E_FAIL;
- CArchiverInfo archiverInfo0, archiverInfo1;
- HRESULT res = OpenArchive(_archiveFilePath, _archiveLink, openArchiveCallback);
+ CArcInfoEx archiverInfo0, archiverInfo1;
+
+ _compressCodecsInfo.Release();
+ _codecs = new CCodecs;
+ _compressCodecsInfo = _codecs;
+ RINOK(_codecs->Load());
+
+ HRESULT res = OpenArchive(_codecs, _archiveFilePath, _archiveLink, openArchiveCallback);
// _archive = _archiveLink.GetArchive();
DefaultName = _archiveLink.GetDefaultItemName();
- const CArchiverInfo &ai = _archiveLink.GetArchiverInfo();
+ const CArcInfoEx &ai = _codecs->Formats[_archiveLink.GetArchiverIndex()];
RINOK(res);
DefaultTime = fileInfo.LastWriteTime;
@@ -449,9 +452,7 @@ STDMETHODIMP CAgent::Open(
COM_TRY_END
}
-STDMETHODIMP CAgent::ReOpen(
- // const wchar_t *filePath,
- IArchiveOpenCallback * /* openArchiveCallback */)
+STDMETHODIMP CAgent::ReOpen(IArchiveOpenCallback * /* openArchiveCallback */)
{
COM_TRY_BEGIN
if (_proxyArchive != NULL)
@@ -459,7 +460,7 @@ STDMETHODIMP CAgent::ReOpen(
delete _proxyArchive;
_proxyArchive = NULL;
}
- RINOK(ReOpenArchive(_archiveLink, _archiveFilePath));
+ RINOK(ReOpenArchive(_codecs, _archiveLink, _archiveFilePath));
return ReadItems();
COM_TRY_END
}
diff --git a/CPP/7zip/UI/Agent/Agent.h b/CPP/7zip/UI/Agent/Agent.h
index 41f80266..1be181a6 100755
--- a/CPP/7zip/UI/Agent/Agent.h
+++ b/CPP/7zip/UI/Agent/Agent.h
@@ -7,17 +7,14 @@
#include "Windows/PropVariant.h"
#include "../Common/UpdateAction.h"
-#include "../Common/ArchiverInfo.h"
#include "../Common/OpenArchive.h"
#include "IFolderArchive.h"
#include "AgentProxy.h"
-#ifndef EXCLUDE_COM
-#include "Windows/DLL.h"
-#endif
#ifdef NEW_FOLDER_INTERFACE
#include "../../FileManager/IFolder.h"
+#include "../Common/LoadCodecs.h"
#endif
class CAgentFolder;
@@ -184,21 +181,10 @@ public:
STDMETHOD(Open)(
const wchar_t *filePath,
- // CLSID *clsIDResult,
BSTR *archiveType,
IArchiveOpenCallback *openArchiveCallback);
- STDMETHOD(ReOpen)(
- // const wchar_t *filePath,
- IArchiveOpenCallback *openArchiveCallback);
- /*
- STDMETHOD(ReOpen)(IInStream *stream,
- const wchar_t *defaultName,
- const FILETIME *defaultTime,
- UINT32 defaultAttributes,
- const UINT64 *maxCheckStartPosition,
- IArchiveOpenCallback *openArchiveCallback);
- */
+ STDMETHOD(ReOpen)(IArchiveOpenCallback *openArchiveCallback);
STDMETHOD(Close)();
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
STDMETHOD(GetNumberOfProperties)(UINT32 *numProperties);
@@ -221,8 +207,13 @@ public:
STDMETHOD(DeleteItems)(const wchar_t *newArchiveName, const UINT32 *indices,
UINT32 numItems, IFolderArchiveUpdateCallback *updateCallback);
STDMETHOD(DoOperation)(
- const wchar_t *filePath,
- const CLSID *clsID,
+ CCodecs *codecs,
+ int formatIndex,
+ const wchar_t *newArchiveName,
+ const Byte *stateActions,
+ const wchar_t *sfxModule,
+ IFolderArchiveUpdateCallback *updateCallback);
+ STDMETHOD(DoOperation2)(
const wchar_t *newArchiveName,
const Byte *stateActions,
const wchar_t *sfxModule,
@@ -248,6 +239,9 @@ public:
STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, INT32 numProperties);
#endif
+ CCodecs *_codecs;
+ CMyComPtr<ICompressCodecsInfo> _compressCodecsInfo;
+
CAgent();
~CAgent();
private:
@@ -288,26 +282,22 @@ public:
#ifdef NEW_FOLDER_INTERFACE
class CArchiveFolderManager:
public IFolderManager,
- public IFolderManagerGetIconPath,
public CMyUnknownImp
{
public:
- MY_UNKNOWN_IMP2(
- IFolderManager,
- IFolderManagerGetIconPath
- )
+ MY_UNKNOWN_IMP1(IFolderManager)
// IFolderManager
STDMETHOD(OpenFolderFile)(const wchar_t *filePath, IFolderFolder **resultFolder, IProgress *progress);
- STDMETHOD(GetTypes)(BSTR *types);
- STDMETHOD(GetExtension)(const wchar_t *type, BSTR *extension);
- STDMETHOD(CreateFolderFile)(const wchar_t *type, const wchar_t *filePath, IProgress *progress);
- STDMETHOD(GetIconPath)(const wchar_t *type, BSTR *iconPath);
- CArchiveFolderManager(): _formatsLoaded(false) {}
+ STDMETHOD(GetExtensions)(BSTR *extensions);
+ STDMETHOD(GetIconPath)(const wchar_t *ext, BSTR *iconPath, Int32 *iconIndex);
+ // STDMETHOD(GetTypes)(BSTR *types);
+ // STDMETHOD(CreateFolderFile)(const wchar_t *type, const wchar_t *filePath, IProgress *progress);
+ CArchiveFolderManager(): _codecs(0) {}
private:
void LoadFormats();
int FindFormat(const UString &type);
- bool _formatsLoaded;
- CObjectVector<CArchiverInfo> _formats;
+ CCodecs *_codecs;
+ CMyComPtr<ICompressCodecsInfo> _compressCodecsInfo;
};
#endif
diff --git a/CPP/7zip/UI/Agent/AgentOut.cpp b/CPP/7zip/UI/Agent/AgentOut.cpp
index 25d65bb2..a9e4ee8f 100755
--- a/CPP/7zip/UI/Agent/AgentOut.cpp
+++ b/CPP/7zip/UI/Agent/AgentOut.cpp
@@ -141,8 +141,8 @@ static HRESULT EnumerateArchiveItems(CAgent *agent,
}
STDMETHODIMP CAgent::DoOperation(
- const wchar_t *filePath,
- const CLSID *clsID,
+ CCodecs *codecs,
+ int formatIndex,
const wchar_t *newArchiveName,
const Byte *stateActions,
const wchar_t *sfxModule,
@@ -167,8 +167,6 @@ STDMETHODIMP CAgent::DoOperation(
return errorCodes.Front();
}
- NWindows::NDLL::CLibrary library;
-
CMyComPtr<IOutArchive> outArchive;
if (GetArchive())
{
@@ -176,9 +174,20 @@ STDMETHODIMP CAgent::DoOperation(
}
else
{
- CHandlerLoader loader;
- RINOK(loader.CreateHandler(filePath, *clsID, (void **)&outArchive, true));
- library.Attach(loader.Detach());
+ if (formatIndex < 0)
+ return E_FAIL;
+ RINOK(codecs->CreateOutArchive(formatIndex, outArchive));
+ #ifdef EXTERNAL_CODECS
+ {
+ CMyComPtr<ISetCompressCodecsInfo> setCompressCodecsInfo;
+ outArchive.QueryInterface(IID_ISetCompressCodecsInfo, (void **)&setCompressCodecsInfo);
+ if (setCompressCodecsInfo)
+ {
+ RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(codecs));
+ }
+ }
+ #endif
+
}
NFileTimeType::EEnum fileTimeType;
@@ -281,6 +290,15 @@ STDMETHODIMP CAgent::DoOperation(
return outArchive->UpdateItems(outStream, updatePairs2.Size(),updateCallback);
}
+STDMETHODIMP CAgent::DoOperation2(
+ const wchar_t *newArchiveName,
+ const Byte *stateActions,
+ const wchar_t *sfxModule,
+ IFolderArchiveUpdateCallback *updateCallback100)
+{
+ return DoOperation(_codecs, -1, newArchiveName,
+ stateActions, sfxModule, updateCallback100);
+}
HRESULT CAgent::CommonUpdate(
const wchar_t *newArchiveName,
diff --git a/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp b/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp
index ce423941..01eb4fed 100755
--- a/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp
+++ b/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp
@@ -15,15 +15,17 @@ static inline UINT GetCurrentFileCodePage()
void CArchiveFolderManager::LoadFormats()
{
- if (!_formatsLoaded)
- ReadArchiverInfoList(_formats);
+ if (!_codecs)
+ {
+ _compressCodecsInfo = _codecs = new CCodecs;
+ _codecs->Load();
+ }
}
int CArchiveFolderManager::FindFormat(const UString &type)
{
- // LoadFormats();
- for (int i = 0; i < _formats.Size(); i++)
- if (type.CompareNoCase(_formats[i].Name) == 0)
+ for (int i = 0; i < _codecs->Formats.Size(); i++)
+ if (type.CompareNoCase(_codecs->Formats[i].Name) == 0)
return i;
return -1;
}
@@ -51,48 +53,80 @@ HRESULT CAgent::FolderReOpen(
}
*/
-STDMETHODIMP CArchiveFolderManager::GetTypes(BSTR *types)
+
+/*
+STDMETHODIMP CArchiveFolderManager::GetExtensions(const wchar_t *type, BSTR *extensions)
+{
+ *extensions = 0;
+ int formatIndex = FindFormat(type);
+ if (formatIndex < 0)
+ return E_INVALIDARG;
+ CMyComBSTR valueTemp = _codecs.Formats[formatIndex].GetAllExtensions(); // Exts[0].Ext;
+ *extensions = valueTemp.Detach();
+ return S_OK;
+}
+*/
+STDMETHODIMP CArchiveFolderManager::GetExtensions(BSTR *extensions)
{
LoadFormats();
- UString typesStrings;
- for(int i = 0; i < _formats.Size(); i++)
+ *extensions = 0;
+ UString res;
+ for (int i = 0; i < _codecs->Libs.Size(); i++)
{
- const CArchiverInfo &ai = _formats[i];
- if (!ai.Associate)
- continue;
- if (i != 0)
- typesStrings += L' ';
- typesStrings += ai.Name;
+ const CCodecLib &lib = _codecs->Libs[i];
+ for (int j = 0; j < lib.IconPairs.Size(); j++)
+ {
+ if (!res.IsEmpty())
+ res += L' ';
+ res += lib.IconPairs[j].Ext;
+ }
}
- CMyComBSTR valueTemp = typesStrings;
- *types = valueTemp.Detach();
+ CMyComBSTR valueTemp = res;
+ *extensions = valueTemp.Detach();
return S_OK;
}
-STDMETHODIMP CArchiveFolderManager::GetExtension(const wchar_t *type, BSTR *extension)
+STDMETHODIMP CArchiveFolderManager::GetIconPath(const wchar_t *ext, BSTR *iconPath, Int32 *iconIndex)
{
- *extension = 0;
- int formatIndex = FindFormat(type);
- if (formatIndex < 0)
- return E_INVALIDARG;
- CMyComBSTR valueTemp = _formats[formatIndex].Extensions[0].Ext;
- *extension = valueTemp.Detach();
+ LoadFormats();
+ *iconPath = 0;
+ *iconIndex = 0;
+ for (int i = 0; i < _codecs->Libs.Size(); i++)
+ {
+ const CCodecLib &lib = _codecs->Libs[i];
+ int ii = lib.FindIconIndex(ext);
+ if (ii >= 0)
+ {
+ CMyComBSTR iconPathTemp = GetUnicodeString(lib.Path, GetCurrentFileCodePage());
+ *iconIndex = ii;
+ *iconPath = iconPathTemp.Detach();
+ return S_OK;
+ }
+ }
return S_OK;
}
-STDMETHODIMP CArchiveFolderManager::GetIconPath(const wchar_t *type, BSTR *iconPath)
+/*
+STDMETHODIMP CArchiveFolderManager::GetTypes(BSTR *types)
{
- *iconPath = 0;
- int formatIndex = FindFormat(type);
- if (formatIndex < 0)
- return E_INVALIDARG;
- CMyComBSTR iconPathTemp = _formats[formatIndex].FilePath;
- *iconPath = iconPathTemp.Detach();
+ LoadFormats();
+ UString typesStrings;
+ for(int i = 0; i < _codecs.Formats.Size(); i++)
+ {
+ const CArcInfoEx &ai = _codecs.Formats[i];
+ if (ai.AssociateExts.Size() == 0)
+ continue;
+ if (i != 0)
+ typesStrings += L' ';
+ typesStrings += ai.Name;
+ }
+ CMyComBSTR valueTemp = typesStrings;
+ *types = valueTemp.Detach();
return S_OK;
}
-
-STDMETHODIMP CArchiveFolderManager::CreateFolderFile(const wchar_t * /* type */,
- const wchar_t * /* filePath */, IProgress * /* progress */)
+STDMETHODIMP CArchiveFolderManager::CreateFolderFile(const wchar_t * type,
+ const wchar_t * filePath, IProgress progress)
{
return E_NOTIMPL;
}
+*/
diff --git a/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp b/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp
index 4d66d86d..336f5fda 100755
--- a/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp
+++ b/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp
@@ -88,8 +88,7 @@ HRESULT CAgentFolder::CommonUpdateOperation(
Byte actionSetByte[NUpdateArchive::NPairState::kNumValues];
for (int i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
actionSetByte[i] = (Byte)actionSet->StateActions[i];
- result = _agentSpec->DoOperation(NULL, NULL,
- tempFileName, actionSetByte, NULL, updateCallback100);
+ result = _agentSpec->DoOperation2(tempFileName, actionSetByte, NULL, updateCallback100);
}
if (result != S_OK)
diff --git a/CPP/7zip/UI/Agent/IFolderArchive.h b/CPP/7zip/UI/Agent/IFolderArchive.h
index 41d9eb22..ece56112 100755
--- a/CPP/7zip/UI/Agent/IFolderArchive.h
+++ b/CPP/7zip/UI/Agent/IFolderArchive.h
@@ -8,6 +8,7 @@
#include "../../FileManager/IFolder.h"
#include "../Common/IFileExtractCallback.h"
#include "../Common/ExtractMode.h"
+#include "../../UI/Common/LoadCodecs.h"
// {23170F69-40C1-278A-0000-000100050000}
DEFINE_GUID(IID_IArchiveFolder,
@@ -31,7 +32,8 @@ MIDL_INTERFACE("23170F69-40C1-278A-0000-000100060000")
IInFolderArchive: public IUnknown
{
public:
- STDMETHOD(Open)(const wchar_t *filePath,
+ STDMETHOD(Open)(
+ const wchar_t *filePath,
// CLSID *clsIDResult,
BSTR *archiveType,
IArchiveOpenCallback *openArchiveCallback) PURE;
@@ -68,10 +70,9 @@ public:
STDMETHOD(UpdateErrorMessage)(const wchar_t *message) PURE;
};
-// {23170F69-40C1-278A-0000-0001000A0000}
DEFINE_GUID(IID_IOutFolderArchive,
-0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x00, 0x00);
-MIDL_INTERFACE("23170F69-40C1-278A-0000-0001000A0000")
+0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x00, 0x02);
+MIDL_INTERFACE("23170F69-40C1-278A-0000-0001000A0002")
IOutFolderArchive: public IUnknown
{
STDMETHOD(SetFolder)(IFolderFolder *folder) PURE;
@@ -79,8 +80,13 @@ IOutFolderArchive: public IUnknown
STDMETHOD(DeleteItems)(const wchar_t *newArchiveName,
const UINT32 *indices, UINT32 numItems, IFolderArchiveUpdateCallback *updateCallback) PURE;
STDMETHOD(DoOperation)(
- const wchar_t *filePath,
- const CLSID *clsID,
+ CCodecs *codecs,
+ int index,
+ const wchar_t *newArchiveName,
+ const Byte *stateActions,
+ const wchar_t *sfxModule,
+ IFolderArchiveUpdateCallback *updateCallback) PURE;
+ STDMETHOD(DoOperation2)(
const wchar_t *newArchiveName,
const Byte *stateActions,
const wchar_t *sfxModule,
diff --git a/CPP/7zip/UI/Client7z/Client7z.cpp b/CPP/7zip/UI/Client7z/Client7z.cpp
index 46bdb727..43aec4f8 100755
--- a/CPP/7zip/UI/Client7z/Client7z.cpp
+++ b/CPP/7zip/UI/Client7z/Client7z.cpp
@@ -23,7 +23,7 @@ DEFINE_GUID(CLSID_CFormat7z,
using namespace NWindows;
-static const char *kCopyrightString = "7-Zip 4.43 (7za.DLL client example) (c) 1999-2006 Igor Pavlov 2006-08-10\n";
+static const char *kCopyrightString = "7-Zip (7za.DLL client example) (c) 1999-2007 Igor Pavlov 2007-03-30\n";
static const char *kHelpString =
"Usage: Client7z.exe [a | l | x ] archive.7z [fileName ...]\n"
"Examples:\n"
@@ -56,7 +56,7 @@ void PrintString(const UString &s)
void PrintString(const AString &s)
{
- printf("%s", s);
+ printf("%s", (LPCSTR)s);
}
void PrintNewLine()
diff --git a/CPP/7zip/UI/Client7z/makefile b/CPP/7zip/UI/Client7z/makefile
index c4ae0aaf..4650c293 100755
--- a/CPP/7zip/UI/Client7z/makefile
+++ b/CPP/7zip/UI/Client7z/makefile
@@ -1,6 +1,6 @@
PROG = 7z.exe
LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib
-CFLAGS = $(CFLAGS) -I ../../../ -DCOMPRESS_MT
+CFLAGS = $(CFLAGS) -I ../../../
CONSOLE_OBJS = \
$O\Client7z.obj \
diff --git a/CPP/7zip/UI/Common/ArchiveCommandLine.cpp b/CPP/7zip/UI/Common/ArchiveCommandLine.cpp
index 6f951a27..f9548024 100755
--- a/CPP/7zip/UI/Common/ArchiveCommandLine.cpp
+++ b/CPP/7zip/UI/Common/ArchiveCommandLine.cpp
@@ -19,7 +19,6 @@
#include "ArchiveCommandLine.h"
#include "UpdateAction.h"
#include "Update.h"
-#include "ArchiverInfo.h"
#include "SortUtils.h"
#include "EnumDirItems.h"
@@ -68,14 +67,6 @@ enum Enum
static const wchar_t kRecursedIDChar = 'R';
static const wchar_t *kRecursedPostCharSet = L"0-";
-static const wchar_t *kDefaultArchiveType = L"7z";
-static const wchar_t *kSFXExtension =
- #ifdef _WIN32
- L"exe";
- #else
- L"";
- #endif
-
namespace NRecursedPostCharIndex {
enum EEnum
{
@@ -111,21 +102,21 @@ static const CSwitchForm kSwitchForms[kNumSwitches] =
{ L"T", NSwitchType::kUnLimitedPostString, false, 1 },
{ L"Y", NSwitchType::kSimple, false },
{ L"P", NSwitchType::kUnLimitedPostString, false, 0 },
- { L"M", NSwitchType::kUnLimitedPostString, true, 1 },
+ { L"M", NSwitchType::kUnLimitedPostString, true, 1 },
{ L"O", NSwitchType::kUnLimitedPostString, false, 1 },
{ L"W", NSwitchType::kUnLimitedPostString, false, 0 },
{ L"I", NSwitchType::kUnLimitedPostString, true, kSomeCludePostStringMinSize},
{ L"X", NSwitchType::kUnLimitedPostString, true, kSomeCludePostStringMinSize},
- { L"AI", NSwitchType::kUnLimitedPostString, true, kSomeCludePostStringMinSize},
- { L"AX", NSwitchType::kUnLimitedPostString, true, kSomeCludePostStringMinSize},
+ { L"AI", NSwitchType::kUnLimitedPostString, true, kSomeCludePostStringMinSize},
+ { L"AX", NSwitchType::kUnLimitedPostString, true, kSomeCludePostStringMinSize},
{ L"AN", NSwitchType::kSimple, false },
{ L"U", NSwitchType::kUnLimitedPostString, true, 1},
{ L"V", NSwitchType::kUnLimitedPostString, true, 1},
{ L"R", NSwitchType::kPostChar, false, 0, 0, kRecursedPostCharSet },
{ L"SFX", NSwitchType::kUnLimitedPostString, false, 0 },
- { L"SI", NSwitchType::kUnLimitedPostString, false, 0 },
- { L"SO", NSwitchType::kSimple, false, 0 },
- { L"AO", NSwitchType::kPostChar, false, 1, 1, kOverwritePostCharSet},
+ { L"SI", NSwitchType::kUnLimitedPostString, false, 0 },
+ { L"SO", NSwitchType::kSimple, false, 0 },
+ { L"AO", NSwitchType::kPostChar, false, 1, 1, kOverwritePostCharSet},
{ L"SEML", NSwitchType::kUnLimitedPostString, false, 0},
{ L"AD", NSwitchType::kSimple, false },
{ L"SLP", NSwitchType::kUnLimitedPostString, false, 0},
@@ -133,9 +124,8 @@ static const CSwitchForm kSwitchForms[kNumSwitches] =
{ L"SLT", NSwitchType::kSimple, false }
};
-static const int kNumCommandForms = 7;
-static const CCommandForm g_CommandForms[kNumCommandForms] =
+static const CCommandForm g_CommandForms[] =
{
{ L"A", false },
{ L"U", false },
@@ -143,9 +133,13 @@ static const CCommandForm g_CommandForms[kNumCommandForms] =
{ L"T", false },
{ L"E", false },
{ L"X", false },
- { L"L", false }
+ { L"L", false },
+ { L"B", false },
+ { L"I", false }
};
+static const int kNumCommandForms = sizeof(g_CommandForms) / sizeof(g_CommandForms[0]);
+
static const int kMaxCmdLineSize = 1000;
static const wchar_t *kUniversalWildcard = L"*";
static const int kMinNonSwitchWords = 1;
@@ -155,7 +149,7 @@ static const int kCommandIndex = 0;
// exception messages
static const char *kUserErrorMessage = "Incorrect command line";
-static const char *kIncorrectListFile = "Incorrect wildcard in listfile";
+static const char *kIncorrectListFile = "Incorrect item in listfile.\nCheck charset encoding and -scs switch.";
static const char *kIncorrectWildCardInListFile = "Incorrect wildcard in listfile";
static const char *kIncorrectWildCardInCommandLine = "Incorrect wildcard in command line";
static const char *kTerminalOutError = "I won't write compressed data to a terminal";
@@ -545,9 +539,7 @@ static void ParseUpdateCommandString(CUpdateOptions &options,
UString archivePath = postString.Mid(1);
if (archivePath.IsEmpty())
ThrowUserErrorException();
- uc.ArchivePath.BaseExtension = options.ArchivePath.BaseExtension;
- uc.ArchivePath.VolExtension = options.ArchivePath.VolExtension;
- uc.ArchivePath.ParseFromPath(archivePath);
+ uc.UserArchivePath = archivePath;
uc.ActionSet = actionSet;
options.Commands.Add(uc);
}
@@ -674,42 +666,6 @@ static void SetMethodOptions(const CParser &parser, CObjectVector<CProperty> &pr
}
}
-
-static void SetArchiveType(const UString &archiveType,
-#ifndef EXCLUDE_COM
- UString &filePath, CLSID &classID,
-#else
- UString &formatName,
-#endif
- UString &archiveExtension)
-{
- CObjectVector<CArchiverInfo> archiverInfoVector;
- ReadArchiverInfoList(archiverInfoVector);
- if (archiverInfoVector.Size() == 0)
- ThrowException("There are no installed archive handlers");
- if (archiveType.IsEmpty())
- ThrowException("Incorrect archive type was assigned");
- for (int i = 0; i < archiverInfoVector.Size(); i++)
- {
- const CArchiverInfo &archiverInfo = archiverInfoVector[i];
- if (archiverInfo.Name.CompareNoCase(archiveType) == 0)
- {
- #ifndef EXCLUDE_COM
- classID = archiverInfo.ClassID;
- filePath = archiverInfo.FilePath;
- #else
- formatName = archiverInfo.Name;
-
- #endif
-
- archiveExtension = archiverInfo.GetMainExtension();
- return;
- }
- }
- ThrowException("Incorrect archive type was assigned");
-}
-
-
CArchiveCommandLineParser::CArchiveCommandLineParser(): parser(kNumSwitches) {}
void CArchiveCommandLineParser::Parse1(const UStringVector &commandStrings,
@@ -757,6 +713,18 @@ static CCodePagePair g_CodePagePairs[] =
static const int kNumCodePages = sizeof(g_CodePagePairs) / sizeof(g_CodePagePairs[0]);
+static bool ConvertStringToUInt32(const wchar_t *s, UInt32 &v)
+{
+ const wchar_t *end;
+ UInt64 number = ConvertStringToUInt64(s, &end);
+ if (*end != 0)
+ return false;
+ if (number > (UInt32)0xFFFFFFFF)
+ return false;
+ v = (UInt32)number;
+ return true;
+}
+
void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
{
const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
@@ -806,7 +774,9 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
parser[NKey::kExclude].PostStrings, false, recursedType, codePage);
int curCommandIndex = kCommandIndex + 1;
- bool thereIsArchiveName = !parser[NKey::kNoArName].ThereIs;
+ bool thereIsArchiveName = !parser[NKey::kNoArName].ThereIs &&
+ options.Command.CommandType != NCommandType::kBenchmark &&
+ options.Command.CommandType != NCommandType::kInfo;
if (thereIsArchiveName)
{
if(curCommandIndex >= numNonSwitchStrings)
@@ -918,28 +888,9 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
{
CUpdateOptions &updateOptions = options.UpdateOptions;
- UString archiveType;
if(parser[NKey::kArchiveType].ThereIs)
- archiveType = parser[NKey::kArchiveType].PostStrings[0];
- else
- archiveType = kDefaultArchiveType;
+ options.ArcType = parser[NKey::kArchiveType].PostStrings[0];
- UString typeExtension;
- if (!archiveType.IsEmpty())
- {
- #ifndef EXCLUDE_COM
- SetArchiveType(archiveType, updateOptions.MethodMode.FilePath,
- updateOptions.MethodMode.ClassID, typeExtension);
- #else
- SetArchiveType(archiveType, updateOptions.MethodMode.Name, typeExtension);
- #endif
- }
- UString extension = typeExtension;
- if(parser[NKey::kSfx].ThereIs)
- extension = kSFXExtension;
- updateOptions.ArchivePath.BaseExtension = extension;
- updateOptions.ArchivePath.VolExtension = typeExtension;
- updateOptions.ArchivePath.ParseFromPath(options.ArchiveName);
SetAddCommandOptions(options.Command.CommandType, parser, updateOptions);
SetMethodOptions(parser, updateOptions.MethodMode.Properties);
@@ -979,6 +930,56 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
ConvertToLongNames(options.WildcardCensor);
#endif
}
+ else if(options.Command.CommandType == NCommandType::kBenchmark)
+ {
+ options.NumThreads = (UInt32)-1;
+ options.DictionarySize = (UInt32)-1;
+ options.NumIterations = 1;
+ if (curCommandIndex < numNonSwitchStrings)
+ {
+ if (!ConvertStringToUInt32(nonSwitchStrings[curCommandIndex++], options.NumIterations))
+ ThrowUserErrorException();
+ }
+ for (int i = 0; i < parser[NKey::kProperty].PostStrings.Size(); i++)
+ {
+ UString postString = parser[NKey::kProperty].PostStrings[i];
+ postString.MakeUpper();
+ if (postString.Length() < 2)
+ ThrowUserErrorException();
+ if (postString[0] == 'D')
+ {
+ int pos = 1;
+ if (postString[pos] == '=')
+ pos++;
+ UInt32 logSize;
+ if (!ConvertStringToUInt32((const wchar_t *)postString + pos, logSize))
+ ThrowUserErrorException();
+ if (logSize > 31)
+ ThrowUserErrorException();
+ options.DictionarySize = 1 << logSize;
+ }
+ else if (postString[0] == 'M' && postString[1] == 'T' )
+ {
+ int pos = 2;
+ if (postString[pos] == '=')
+ pos++;
+ if (postString[pos] != 0)
+ if (!ConvertStringToUInt32((const wchar_t *)postString + pos, options.NumThreads))
+ ThrowUserErrorException();
+ }
+ else if (postString[0] == 'M' && postString[1] == '=' )
+ {
+ int pos = 2;
+ if (postString[pos] != 0)
+ options.Method = postString.Mid(2);
+ }
+ else
+ ThrowUserErrorException();
+ }
+ }
+ else if(options.Command.CommandType == NCommandType::kInfo)
+ {
+ }
else
ThrowUserErrorException();
options.WildcardCensor.ExtendExclude();
diff --git a/CPP/7zip/UI/Common/ArchiveCommandLine.h b/CPP/7zip/UI/Common/ArchiveCommandLine.h
index daa66fb6..7183de9b 100755
--- a/CPP/7zip/UI/Common/ArchiveCommandLine.h
+++ b/CPP/7zip/UI/Common/ArchiveCommandLine.h
@@ -22,7 +22,9 @@ namespace NCommandType { enum EEnum
kTest,
kExtract,
kFullExtract,
- kList
+ kList,
+ kBenchmark,
+ kInfo
};}
namespace NRecursedType { enum EEnum
@@ -77,10 +79,17 @@ struct CArchiveCommandLineOptions
CObjectVector<CProperty> ExtractProperties;
CUpdateOptions UpdateOptions;
+ UString ArcType;
bool EnablePercents;
- CArchiveCommandLineOptions(): StdInMode(false), StdOutMode(false) {};
+ // Benchmark
+ UInt32 NumIterations;
+ UInt32 NumThreads;
+ UInt32 DictionarySize;
+ UString Method;
+
+ CArchiveCommandLineOptions(): StdInMode(false), StdOutMode(false) {};
};
class CArchiveCommandLineParser
diff --git a/CPP/7zip/UI/Common/ArchiverInfo.cpp b/CPP/7zip/UI/Common/ArchiverInfo.cpp
deleted file mode 100755
index 7833ed3c..00000000
--- a/CPP/7zip/UI/Common/ArchiverInfo.cpp
+++ /dev/null
@@ -1,372 +0,0 @@
-// ArchiverInfo.cpp
-
-#include "StdAfx.h"
-
-#include "ArchiverInfo.h"
-
-#ifndef EXCLUDE_COM
-
-#include "Common/StringConvert.h"
-#include "Windows/FileFind.h"
-#include "Windows/FileName.h"
-#include "Windows/DLL.h"
-#ifdef _WIN32
-#include "Windows/Registry.h"
-#endif
-#include "Windows/PropVariant.h"
-#include "../../Archive/IArchive.h"
-
-using namespace NWindows;
-using namespace NFile;
-
-#endif
-
-extern HINSTANCE g_hInstance;
-
-#ifndef EXCLUDE_COM
-
-static void SplitString(const UString &srcString, UStringVector &destStrings)
-{
- destStrings.Clear();
- UString string;
- int len = srcString.Length();
- if (len == 0)
- return;
- for (int i = 0; i < len; i++)
- {
- wchar_t c = srcString[i];
- if (c == L' ')
- {
- if (!string.IsEmpty())
- {
- destStrings.Add(string);
- string.Empty();
- }
- }
- else
- string += c;
- }
- if (!string.IsEmpty())
- destStrings.Add(string);
-}
-
-typedef UInt32 (WINAPI * GetHandlerPropertyFunc)(
- PROPID propID, PROPVARIANT *value);
-
-static UString GetModuleFolderPrefix()
-{
- UString path;
- NDLL::MyGetModuleFileName(g_hInstance, path);
- int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR);
- return path.Left(pos + 1);
-}
-
-static wchar_t *kFormatFolderName = L"Formats";
-
-#ifdef _WIN32
-static LPCTSTR kRegistryPath = TEXT("Software\\7-zip");
-static LPCWSTR kProgramPathValue = L"Path";
-static bool ReadPathFromRegistry(HKEY baseKey, UString &path)
-{
- NRegistry::CKey key;
- if(key.Open(baseKey, kRegistryPath, KEY_READ) == ERROR_SUCCESS)
- if (key.QueryValue(kProgramPathValue, path) == ERROR_SUCCESS)
- {
- NName::NormalizeDirPathPrefix(path);
- return true;
- }
- return false;
-}
-#endif
-
-static UString GetBaseFolderPrefixFromRegistry()
-{
- UString moduleFolderPrefix = GetModuleFolderPrefix();
- NFind::CFileInfoW fileInfo;
- if (NFind::FindFile(moduleFolderPrefix + kFormatFolderName, fileInfo))
- if (fileInfo.IsDirectory())
- return moduleFolderPrefix;
- UString path;
- #ifdef _WIN32
- if(ReadPathFromRegistry(HKEY_CURRENT_USER, path))
- return path;
- if(ReadPathFromRegistry(HKEY_LOCAL_MACHINE, path))
- return path;
- #endif
- return moduleFolderPrefix;
-}
-
-typedef UInt32 (WINAPI *CreateObjectPointer)(
- const GUID *clsID,
- const GUID *interfaceID,
- void **outObject);
-
-#endif
-
-#ifndef _SFX
-static inline void SetBuffer(CByteBuffer &bb, const Byte *data, int size)
-{
- bb.SetCapacity(size);
- memmove((Byte *)bb, data, size);
-}
-#endif
-
-void ReadArchiverInfoList(CObjectVector<CArchiverInfo> &archivers)
-{
- archivers.Clear();
-
- #ifdef EXCLUDE_COM
-
- #ifdef FORMAT_7Z
- {
- CArchiverInfo item;
- item.UpdateEnabled = true;
- item.Name = L"7z";
- item.Extensions.Add(CArchiverExtInfo(L"7z"));
- #ifndef _SFX
- const unsigned char kSig[] = {'7' , 'z', 0xBC, 0xAF, 0x27, 0x1C};
- SetBuffer(item.StartSignature, kSig, 6);
- #endif
- archivers.Add(item);
- }
- #endif
-
- #ifdef FORMAT_BZIP2
- {
- CArchiverInfo item;
- item.UpdateEnabled = true;
- item.KeepName = true;
- item.Name = L"BZip2";
- item.Extensions.Add(CArchiverExtInfo(L"bz2"));
- item.Extensions.Add(CArchiverExtInfo(L"tbz2", L".tar"));
- #ifndef _SFX
- const unsigned char sig[] = {'B' , 'Z', 'h' };
- SetBuffer(item.StartSignature, sig, 3);
- #endif
- archivers.Add(item);
- }
- #endif
-
- #ifdef FORMAT_CAB
- {
- CArchiverInfo item;
- item.Name = L"Cab";
- item.Extensions.Add(CArchiverExtInfo(L"cab"));
- #ifndef _SFX
- const unsigned char sig[] = { 0x4D, 0x53, 0x43, 0x46 };
- SetBuffer(item.StartSignature, sig, 4);
- #endif
- archivers.Add(item);
- }
- #endif
-
- #ifdef FORMAT_GZIP
- {
- CArchiverInfo item;
- item.UpdateEnabled = true;
- item.Name = L"GZip";
- item.Extensions.Add(CArchiverExtInfo(L"gz"));
- item.Extensions.Add(CArchiverExtInfo(L"tgz", L".tar"));
- #ifndef _SFX
- const unsigned char sig[] = { 0x1F, 0x8B };
- SetBuffer(item.StartSignature, sig, 2);
- #endif
- archivers.Add(item);
- }
- #endif
-
- #ifdef FORMAT_SPLIT
- {
- CArchiverInfo item;
- item.UpdateEnabled = false;
- item.KeepName = true;
- item.Name = L"Split";
- item.Extensions.Add(CArchiverExtInfo(L"001"));
- archivers.Add(item);
- }
- #endif
-
- #ifdef FORMAT_TAR
- {
- CArchiverInfo item;
- item.UpdateEnabled = true;
- item.Name = L"Tar";
- item.Extensions.Add(CArchiverExtInfo(L"tar"));
- archivers.Add(item);
- }
- #endif
-
- #ifdef FORMAT_ZIP
- {
- CArchiverInfo item;
- item.UpdateEnabled = true;
- item.Name = L"Zip";
- item.Extensions.Add(CArchiverExtInfo(L"zip"));
- #ifndef _SFX
- const unsigned char sig[] = { 0x50, 0x4B, 0x03, 0x04 };
- SetBuffer(item.StartSignature, sig, 4);
- #endif
- archivers.Add(item);
- }
- #endif
-
- #ifdef FORMAT_CPIO
- {
- CArchiverInfo item;
- item.Name = L"Cpio";
- item.Extensions.Add(CArchiverExtInfo(L"cpio"));
- archivers.Add(item);
- }
- #endif
-
- #ifdef FORMAT_RPM
- {
- CArchiverInfo item;
- item.Name = L"Rpm";
- item.Extensions.Add(CArchiverExtInfo(L"rpm", L".cpio.gz"));
- archivers.Add(item);
- }
- #endif
-
- #ifdef FORMAT_ARJ
- {
- CArchiverInfo item;
- item.Name = L"Arj";
- item.Extensions.Add(CArchiverExtInfo(L"arj"));
- #ifndef _SFX
- const unsigned char sig[] = { 0x60, 0xEA };
- SetBuffer(item.StartSignature, sig, 2);
- #endif
- archivers.Add(item);
- }
- #endif
-
- #ifdef FORMAT_Z
- {
- CArchiverInfo item;
- item.Name = L"Z";
- item.Extensions.Add(CArchiverExtInfo(L"Z"));
- #ifndef _SFX
- const unsigned char sig[] = { 0x1F, 0x9D };
- SetBuffer(item.StartSignature, sig, 2);
- #endif
- archivers.Add(item);
- }
- #endif
-
- #else
-
- UString folderPath = GetBaseFolderPrefixFromRegistry() +
- (UString)kFormatFolderName + (UString)WSTRING_PATH_SEPARATOR;
- NFind::CEnumeratorW enumerator(folderPath + L"*");
- NFind::CFileInfoW fileInfo;
- while (enumerator.Next(fileInfo))
- {
- if (fileInfo.IsDirectory())
- continue;
- UString filePath = folderPath + fileInfo.Name;
- {
- NDLL::CLibrary library;
- if (!library.LoadEx(filePath, LOAD_LIBRARY_AS_DATAFILE))
- continue;
- }
-
- NDLL::CLibrary library;
- if (!library.Load(filePath))
- continue;
- GetHandlerPropertyFunc getHandlerProperty = (GetHandlerPropertyFunc)
- library.GetProcAddress("GetHandlerProperty");
- if (getHandlerProperty == NULL)
- continue;
-
- CArchiverInfo item;
- item.FilePath = filePath;
-
- NWindows::NCOM::CPropVariant prop;
- if (getHandlerProperty(NArchive::kName, &prop) != S_OK)
- continue;
- if (prop.vt != VT_BSTR)
- continue;
- item.Name = prop.bstrVal;
- prop.Clear();
-
- if (getHandlerProperty(NArchive::kClassID, &prop) != S_OK)
- continue;
- if (prop.vt != VT_BSTR)
- continue;
- item.ClassID = *(const GUID *)prop.bstrVal;
- prop.Clear();
-
- if (getHandlerProperty(NArchive::kExtension, &prop) != S_OK)
- continue;
- if (prop.vt != VT_BSTR)
- continue;
-
- UString ext = prop.bstrVal;
- UString addExt;
-
- prop.Clear();
-
- if (getHandlerProperty(NArchive::kAddExtension, &prop) != S_OK)
- continue;
- if (prop.vt == VT_BSTR)
- {
- addExt = prop.bstrVal;
- }
- else if (prop.vt != VT_EMPTY)
- continue;
- prop.Clear();
-
- UStringVector exts, addExts;
- SplitString(ext, exts);
- SplitString(addExt, addExts);
-
- prop.Clear();
- for (int i = 0; i < exts.Size(); i++)
- {
- CArchiverExtInfo extInfo;
- extInfo.Ext = exts[i];
- if (addExts.Size() > 0)
- extInfo.AddExt = addExts[i];
- if (extInfo.AddExt == L"*")
- extInfo.AddExt.Empty();
- item.Extensions.Add(extInfo);
- }
-
- if (getHandlerProperty(NArchive::kUpdate, &prop) == S_OK)
- if (prop.vt == VT_BOOL)
- item.UpdateEnabled = VARIANT_BOOLToBool(prop.boolVal);
- prop.Clear();
-
- if (item.UpdateEnabled)
- {
- if (getHandlerProperty(NArchive::kKeepName, &prop) == S_OK)
- if (prop.vt == VT_BOOL)
- item.KeepName = VARIANT_BOOLToBool(prop.boolVal);
- prop.Clear();
- }
-
- if (getHandlerProperty(NArchive::kStartSignature, &prop) == S_OK)
- {
- if (prop.vt == VT_BSTR)
- {
- UINT len = ::SysStringByteLen(prop.bstrVal);
- item.StartSignature.SetCapacity(len);
- memmove(item.StartSignature, prop.bstrVal, len);
- }
- }
- prop.Clear();
-
- if (getHandlerProperty(NArchive::kAssociate, &prop) == S_OK)
- if (prop.vt == VT_BOOL)
- item.Associate = VARIANT_BOOLToBool(prop.boolVal);
- prop.Clear();
-
-
- archivers.Add(item);
- }
-
- #endif
-}
-
-
diff --git a/CPP/7zip/UI/Common/ArchiverInfo.h b/CPP/7zip/UI/Common/ArchiverInfo.h
deleted file mode 100755
index 3b829518..00000000
--- a/CPP/7zip/UI/Common/ArchiverInfo.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// ArchiverInfo.h
-
-#ifndef __ARCHIVERINFO_H
-#define __ARCHIVERINFO_H
-
-#include "Common/String.h"
-#include "Common/Types.h"
-#include "Common/Buffer.h"
-
-struct CArchiverExtInfo
-{
- UString Ext;
- UString AddExt;
- CArchiverExtInfo() {}
- CArchiverExtInfo(const UString &ext): Ext(ext) {}
- CArchiverExtInfo(const UString &ext, const UString &addExt): Ext(ext), AddExt(addExt) {}
-};
-
-struct CArchiverInfo
-{
- #ifndef EXCLUDE_COM
- UString FilePath;
- CLSID ClassID;
- #endif
- UString Name;
- CObjectVector<CArchiverExtInfo> Extensions;
- #ifndef _SFX
- CByteBuffer StartSignature;
- CByteBuffer FinishSignature;
- bool Associate;
- #endif
- int FindExtension(const UString &ext) const
- {
- for (int i = 0; i < Extensions.Size(); i++)
- if (ext.CompareNoCase(Extensions[i].Ext) == 0)
- return i;
- return -1;
- }
- UString GetAllExtensions() const
- {
- UString s;
- for (int i = 0; i < Extensions.Size(); i++)
- {
- if (i > 0)
- s += ' ';
- s += Extensions[i].Ext;
- }
- return s;
- }
- const UString &GetMainExtension() const
- {
- return Extensions[0].Ext;
- }
- bool UpdateEnabled;
- bool KeepName;
-
- CArchiverInfo(): UpdateEnabled(false), KeepName(false)
- #ifndef _SFX
- ,Associate(true)
- #endif
- {}
-};
-
-void ReadArchiverInfoList(CObjectVector<CArchiverInfo> &archivers);
-
-#endif
diff --git a/CPP/7zip/UI/Common/CompressCall.cpp b/CPP/7zip/UI/Common/CompressCall.cpp
index 86bdd297..8b858bd3 100755
--- a/CPP/7zip/UI/Common/CompressCall.cpp
+++ b/CPP/7zip/UI/Common/CompressCall.cpp
@@ -365,3 +365,11 @@ HRESULT TestArchives(const UStringVector &archivePaths)
params += L" t";
return ExtractGroupCommand(archivePaths, params);
}
+
+HRESULT Benchmark()
+{
+ UString params;
+ params = Get7zGuiPath();
+ params += L" b";
+ return MyCreateProcess(params, 0, false, NULL);
+}
diff --git a/CPP/7zip/UI/Common/CompressCall.h b/CPP/7zip/UI/Common/CompressCall.h
index 95be95c3..23e68838 100755
--- a/CPP/7zip/UI/Common/CompressCall.h
+++ b/CPP/7zip/UI/Common/CompressCall.h
@@ -24,5 +24,7 @@ HRESULT ExtractArchives(
HRESULT TestArchives(const UStringVector &archivePaths);
+HRESULT Benchmark();
+
#endif
diff --git a/CPP/7zip/UI/Common/Extract.cpp b/CPP/7zip/UI/Common/Extract.cpp
index 34fb383b..8d3df8e1 100755
--- a/CPP/7zip/UI/Common/Extract.cpp
+++ b/CPP/7zip/UI/Common/Extract.cpp
@@ -10,10 +10,6 @@
#include "OpenArchive.h"
#include "SetProperties.h"
-#ifndef EXCLUDE_COM
-#include "Windows/DLL.h"
-#endif
-
using namespace NWindows;
HRESULT DecompressArchive(
@@ -85,6 +81,7 @@ HRESULT DecompressArchive(
}
HRESULT DecompressArchives(
+ CCodecs *codecs,
UStringVector &archivePaths, UStringVector &archivePathsFull,
const NWildcard::CCensorNode &wildcardCensor,
const CExtractOptions &optionsSpec,
@@ -111,7 +108,7 @@ HRESULT DecompressArchives(
RINOK(extractCallback->BeforeOpen(archivePath));
CArchiveLink archiveLink;
- HRESULT result = MyOpenArchive(archivePath, archiveLink, openCallback);
+ HRESULT result = MyOpenArchive(codecs, archivePath, archiveLink, openCallback);
bool crypted = false;
#ifndef _NO_CRYPTO
diff --git a/CPP/7zip/UI/Common/Extract.h b/CPP/7zip/UI/Common/Extract.h
index c7b47c84..232f988f 100755
--- a/CPP/7zip/UI/Common/Extract.h
+++ b/CPP/7zip/UI/Common/Extract.h
@@ -13,6 +13,8 @@
#include "ExtractMode.h"
#include "Property.h"
+#include "../Common/LoadCodecs.h"
+
class CExtractOptions
{
public:
@@ -34,6 +36,10 @@ public:
NExtract::NOverwriteMode::EEnum OverwriteMode;
+ #ifdef EXTERNAL_CODECS
+ CCodecs *Codecs;
+ #endif
+
CExtractOptions():
StdOutMode(false),
YesToAll(false),
@@ -49,6 +55,7 @@ public:
};
HRESULT DecompressArchives(
+ CCodecs *codecs,
UStringVector &archivePaths, UStringVector &archivePathsFull,
const NWildcard::CCensorNode &wildcardCensor,
const CExtractOptions &options,
diff --git a/CPP/7zip/UI/Common/LoadCodecs.cpp b/CPP/7zip/UI/Common/LoadCodecs.cpp
new file mode 100755
index 00000000..bb6b9696
--- /dev/null
+++ b/CPP/7zip/UI/Common/LoadCodecs.cpp
@@ -0,0 +1,621 @@
+// LoadCodecs.cpp
+
+#include "StdAfx.h"
+
+#include "LoadCodecs.h"
+
+#include "../../../Common/MyCom.h"
+#ifdef NEW_FOLDER_INTERFACE
+#include "../../../Common/StringToInt.h"
+#endif
+#include "../../../Windows/PropVariant.h"
+
+#include "../../ICoder.h"
+#include "../../Common/RegisterArc.h"
+
+#ifdef EXTERNAL_CODECS
+#include "../../../Windows/FileFind.h"
+#include "../../../Windows/DLL.h"
+#ifdef NEW_FOLDER_INTERFACE
+#include "../../../Windows/ResourceString.h"
+static const UINT kIconTypesResId = 100;
+#endif
+
+#ifdef _WIN32
+#include "Windows/Registry.h"
+#endif
+
+using namespace NWindows;
+using namespace NFile;
+
+extern HINSTANCE g_hInstance;
+
+static CSysString GetLibraryFolderPrefix()
+{
+ TCHAR fullPath[MAX_PATH + 1];
+ ::GetModuleFileName(g_hInstance, fullPath, MAX_PATH);
+ CSysString path = fullPath;
+ int pos = path.ReverseFind(TEXT(CHAR_PATH_SEPARATOR));
+ return path.Left(pos + 1);
+}
+
+#define kCodecsFolderName TEXT("Codecs")
+#define kFormatsFolderName TEXT("Formats")
+static TCHAR *kMainDll = TEXT("7z.dll");
+
+#ifdef _WIN32
+static LPCTSTR kRegistryPath = TEXT("Software\\7-zip");
+static LPCTSTR kProgramPathValue = TEXT("Path");
+static bool ReadPathFromRegistry(HKEY baseKey, CSysString &path)
+{
+ NRegistry::CKey key;
+ if(key.Open(baseKey, kRegistryPath, KEY_READ) == ERROR_SUCCESS)
+ if (key.QueryValue(kProgramPathValue, path) == ERROR_SUCCESS)
+ {
+ NName::NormalizeDirPathPrefix(path);
+ return true;
+ }
+ return false;
+}
+
+CSysString GetBaseFolderPrefixFromRegistry()
+{
+ CSysString moduleFolderPrefix = GetLibraryFolderPrefix();
+ NFind::CFileInfo fileInfo;
+ if (NFind::FindFile(moduleFolderPrefix + kMainDll, fileInfo))
+ if (!fileInfo.IsDirectory())
+ return moduleFolderPrefix;
+ if (NFind::FindFile(moduleFolderPrefix + kCodecsFolderName, fileInfo))
+ if (fileInfo.IsDirectory())
+ return moduleFolderPrefix;
+ if (NFind::FindFile(moduleFolderPrefix + kFormatsFolderName, fileInfo))
+ if (fileInfo.IsDirectory())
+ return moduleFolderPrefix;
+ CSysString path;
+ #ifdef _WIN32
+ if (ReadPathFromRegistry(HKEY_CURRENT_USER, path))
+ return path;
+ if (ReadPathFromRegistry(HKEY_LOCAL_MACHINE, path))
+ return path;
+ #endif
+ return moduleFolderPrefix;
+}
+
+#endif
+
+
+typedef UInt32 (WINAPI *GetNumberOfMethodsFunc)(UInt32 *numMethods);
+typedef UInt32 (WINAPI *GetNumberOfFormatsFunc)(UInt32 *numFormats);
+typedef UInt32 (WINAPI *GetHandlerPropertyFunc)(PROPID propID, PROPVARIANT *value);
+typedef UInt32 (WINAPI *GetHandlerPropertyFunc2)(UInt32 index, PROPID propID, PROPVARIANT *value);
+typedef UINT32 (WINAPI *CreateObjectFunc)(const GUID *clsID, const GUID *iid, void **outObject);
+
+
+static HRESULT GetCoderClass(GetMethodPropertyFunc getMethodProperty, UInt32 index,
+ PROPID propId, CLSID &clsId, bool &isAssigned)
+{
+ NWindows::NCOM::CPropVariant prop;
+ isAssigned = false;
+ RINOK(getMethodProperty(index, propId, &prop));
+ if (prop.vt == VT_BSTR)
+ {
+ isAssigned = true;
+ clsId = *(const GUID *)prop.bstrVal;
+ }
+ else if (prop.vt != VT_EMPTY)
+ return E_FAIL;
+ return S_OK;
+}
+
+HRESULT CCodecs::LoadCodecs()
+{
+ CCodecLib &lib = Libs.Back();
+ lib.GetMethodProperty = (GetMethodPropertyFunc)lib.Lib.GetProcAddress("GetMethodProperty");
+ if (lib.GetMethodProperty == NULL)
+ return S_OK;
+
+ UInt32 numMethods = 1;
+ GetNumberOfMethodsFunc getNumberOfMethodsFunc = (GetNumberOfMethodsFunc)lib.Lib.GetProcAddress("GetNumberOfMethods");
+ if (getNumberOfMethodsFunc != NULL)
+ {
+ RINOK(getNumberOfMethodsFunc(&numMethods));
+ }
+
+ for(UInt32 i = 0; i < numMethods; i++)
+ {
+ CDllCodecInfo info;
+ info.LibIndex = Libs.Size() - 1;
+ info.CodecIndex = i;
+
+ RINOK(GetCoderClass(lib.GetMethodProperty, i, NMethodPropID::kEncoder, info.Encoder, info.EncoderIsAssigned));
+ RINOK(GetCoderClass(lib.GetMethodProperty, i, NMethodPropID::kDecoder, info.Decoder, info.DecoderIsAssigned));
+
+ Codecs.Add(info);
+ }
+ return S_OK;
+}
+
+static HRESULT ReadProp(
+ GetHandlerPropertyFunc getProp,
+ GetHandlerPropertyFunc2 getProp2,
+ UInt32 index, PROPID propID, NCOM::CPropVariant &prop)
+{
+ if (getProp2)
+ return getProp2(index, propID, &prop);;
+ return getProp(propID, &prop);
+}
+
+static HRESULT ReadBoolProp(
+ GetHandlerPropertyFunc getProp,
+ GetHandlerPropertyFunc2 getProp2,
+ UInt32 index, PROPID propID, bool &res)
+{
+ NCOM::CPropVariant prop;
+ RINOK(ReadProp(getProp, getProp2, index, propID, prop));
+ if (prop.vt == VT_BOOL)
+ res = VARIANT_BOOLToBool(prop.boolVal);
+ else if (prop.vt != VT_EMPTY)
+ return E_FAIL;
+ return S_OK;
+}
+
+static HRESULT ReadStringProp(
+ GetHandlerPropertyFunc getProp,
+ GetHandlerPropertyFunc2 getProp2,
+ UInt32 index, PROPID propID, UString &res)
+{
+ NCOM::CPropVariant prop;
+ RINOK(ReadProp(getProp, getProp2, index, propID, prop));
+ if (prop.vt == VT_BSTR)
+ res = prop.bstrVal;
+ else if (prop.vt != VT_EMPTY)
+ return E_FAIL;
+ return S_OK;
+}
+
+#endif
+
+static const unsigned int kNumArcsMax = 32;
+static unsigned int g_NumArcs = 0;
+static const CArcInfo *g_Arcs[kNumArcsMax];
+void RegisterArc(const CArcInfo *arcInfo)
+{
+ if (g_NumArcs < kNumArcsMax)
+ g_Arcs[g_NumArcs++] = arcInfo;
+}
+
+static void SplitString(const UString &srcString, UStringVector &destStrings)
+{
+ destStrings.Clear();
+ UString s;
+ int len = srcString.Length();
+ if (len == 0)
+ return;
+ for (int i = 0; i < len; i++)
+ {
+ wchar_t c = srcString[i];
+ if (c == L' ')
+ {
+ if (!s.IsEmpty())
+ {
+ destStrings.Add(s);
+ s.Empty();
+ }
+ }
+ else
+ s += c;
+ }
+ if (!s.IsEmpty())
+ destStrings.Add(s);
+}
+
+void CArcInfoEx::AddExts(const wchar_t* ext, const wchar_t* addExt)
+{
+ UStringVector exts, addExts;
+ SplitString(ext, exts);
+ if (addExt != 0)
+ SplitString(addExt, addExts);
+ for (int i = 0; i < exts.Size(); i++)
+ {
+ CArcExtInfo extInfo;
+ extInfo.Ext = exts[i];
+ if (i < addExts.Size())
+ {
+ extInfo.AddExt = addExts[i];
+ if (extInfo.AddExt == L"*")
+ extInfo.AddExt.Empty();
+ }
+ Exts.Add(extInfo);
+ }
+}
+
+#ifdef EXTERNAL_CODECS
+
+HRESULT CCodecs::LoadFormats()
+{
+ const NDLL::CLibrary &lib = Libs.Back().Lib;
+ GetHandlerPropertyFunc getProp = 0;
+ GetHandlerPropertyFunc2 getProp2 = (GetHandlerPropertyFunc2)
+ lib.GetProcAddress("GetHandlerProperty2");
+ if (getProp2 == NULL)
+ {
+ getProp = (GetHandlerPropertyFunc)
+ lib.GetProcAddress("GetHandlerProperty");
+ if (getProp == NULL)
+ return S_OK;
+ }
+
+ UInt32 numFormats = 1;
+ GetNumberOfFormatsFunc getNumberOfFormats = (GetNumberOfFormatsFunc)
+ lib.GetProcAddress("GetNumberOfFormats");
+ if (getNumberOfFormats != NULL)
+ {
+ RINOK(getNumberOfFormats(&numFormats));
+ }
+ if (getProp2 == NULL)
+ numFormats = 1;
+
+ for(UInt32 i = 0; i < numFormats; i++)
+ {
+ CArcInfoEx item;
+ item.LibIndex = Libs.Size() - 1;
+ item.FormatIndex = i;
+
+ RINOK(ReadStringProp(getProp, getProp2, i, NArchive::kName, item.Name));
+
+ NCOM::CPropVariant prop;
+ if (ReadProp(getProp, getProp2, i, NArchive::kClassID, prop) != S_OK)
+ continue;
+ if (prop.vt != VT_BSTR)
+ continue;
+ item.ClassID = *(const GUID *)prop.bstrVal;
+ prop.Clear();
+
+ UString ext, addExt;
+ RINOK(ReadStringProp(getProp, getProp2, i, NArchive::kExtension, ext));
+ RINOK(ReadStringProp(getProp, getProp2, i, NArchive::kAddExtension, addExt));
+ item.AddExts(ext, addExt);
+
+ ReadBoolProp(getProp, getProp2, i, NArchive::kUpdate, item.UpdateEnabled);
+ if (item.UpdateEnabled)
+ ReadBoolProp(getProp, getProp2, i, NArchive::kKeepName, item.KeepName);
+
+ if (ReadProp(getProp, getProp2, i, NArchive::kStartSignature, prop) == S_OK)
+ if (prop.vt == VT_BSTR)
+ {
+ UINT len = ::SysStringByteLen(prop.bstrVal);
+ item.StartSignature.SetCapacity(len);
+ memmove(item.StartSignature, prop.bstrVal, len);
+ }
+ Formats.Add(item);
+ }
+ return S_OK;
+}
+
+#ifdef NEW_FOLDER_INTERFACE
+void CCodecLib::LoadIcons()
+{
+ UString iconTypes = MyLoadStringW((HMODULE)Lib, kIconTypesResId);
+ UStringVector pairs;
+ SplitString(iconTypes, pairs);
+ for (int i = 0; i < pairs.Size(); i++)
+ {
+ const UString &s = pairs[i];
+ int pos = s.Find(L':');
+ if (pos < 0)
+ continue;
+ CIconPair iconPair;
+ const wchar_t *end;
+ UString num = s.Mid(pos + 1);
+ iconPair.IconIndex = (UInt32)ConvertStringToUInt64(num, &end);
+ if (*end != L'\0')
+ continue;
+ iconPair.Ext = s.Left(pos);
+ IconPairs.Add(iconPair);
+ }
+}
+
+int CCodecLib::FindIconIndex(const UString &ext) const
+{
+ for (int i = 0; i < IconPairs.Size(); i++)
+ {
+ const CIconPair &pair = IconPairs[i];
+ if (ext.CompareNoCase(pair.Ext) == 0)
+ return pair.IconIndex;
+ }
+ return -1;
+}
+#endif
+
+HRESULT CCodecs::LoadDll(const CSysString &dllPath)
+{
+ {
+ NDLL::CLibrary library;
+ if (!library.LoadEx(dllPath, LOAD_LIBRARY_AS_DATAFILE))
+ return S_OK;
+ }
+ Libs.Add(CCodecLib());
+ CCodecLib &lib = Libs.Back();
+ #ifdef NEW_FOLDER_INTERFACE
+ lib.Path = dllPath;
+ #endif
+ bool used = false;
+ HRESULT res = S_OK;
+ if (lib.Lib.Load(dllPath))
+ {
+ #ifdef NEW_FOLDER_INTERFACE
+ lib.LoadIcons();
+ #endif
+ lib.CreateObject = (CreateObjectFunc)lib.Lib.GetProcAddress("CreateObject");
+ if (lib.CreateObject != 0)
+ {
+ int startSize = Codecs.Size();
+ res = LoadCodecs();
+ used = (Codecs.Size() != startSize);
+ if (res == S_OK)
+ {
+ startSize = Formats.Size();
+ res = LoadFormats();
+ used = used || (Formats.Size() != startSize);
+ }
+ }
+ }
+ if (!used)
+ Libs.DeleteBack();
+ return res;
+}
+
+HRESULT CCodecs::LoadDllsFromFolder(const CSysString &folderPrefix)
+{
+ NFile::NFind::CEnumerator enumerator(folderPrefix + CSysString(TEXT("*")));
+ NFile::NFind::CFileInfo fileInfo;
+ while (enumerator.Next(fileInfo))
+ {
+ if (fileInfo.IsDirectory())
+ continue;
+ RINOK(LoadDll(folderPrefix + fileInfo.Name));
+ }
+ return S_OK;
+}
+
+#endif
+
+#ifndef _SFX
+static inline void SetBuffer(CByteBuffer &bb, const Byte *data, int size)
+{
+ bb.SetCapacity(size);
+ memmove((Byte *)bb, data, size);
+}
+#endif
+
+HRESULT CCodecs::Load()
+{
+ Formats.Clear();
+ #ifdef EXTERNAL_CODECS
+ Codecs.Clear();
+ #endif
+ for (UInt32 i = 0; i < g_NumArcs; i++)
+ {
+ const CArcInfo &arc = *g_Arcs[i];
+ CArcInfoEx item;
+ item.Name = arc.Name;
+ item.CreateInArchive = arc.CreateInArchive;
+ item.CreateOutArchive = arc.CreateOutArchive;
+ item.AddExts(arc.Ext, arc.AddExt);
+ item.UpdateEnabled = (arc.CreateOutArchive != 0);
+ item.KeepName = arc.KeepName;
+
+ #ifndef _SFX
+ SetBuffer(item.StartSignature, arc.Signature, arc.SignatureSize);
+ #endif
+ Formats.Add(item);
+ }
+ #ifdef EXTERNAL_CODECS
+ const CSysString baseFolder = GetBaseFolderPrefixFromRegistry();
+ RINOK(LoadDll(baseFolder + kMainDll));
+ RINOK(LoadDllsFromFolder(baseFolder + kCodecsFolderName TEXT(STRING_PATH_SEPARATOR)));
+ RINOK(LoadDllsFromFolder(baseFolder + kFormatsFolderName TEXT(STRING_PATH_SEPARATOR)));
+ #endif
+ return S_OK;
+}
+
+int CCodecs::FindFormatForArchiveName(const UString &archivePath) const
+{
+ int slashPos1 = archivePath.ReverseFind(L'\\');
+ int slashPos2 = archivePath.ReverseFind(L'.');
+ int dotPos = archivePath.ReverseFind(L'.');
+ if (dotPos < 0 || dotPos < slashPos1 || dotPos < slashPos2)
+ return -1;
+ UString ext = archivePath.Mid(dotPos + 1);
+ for (int i = 0; i < Formats.Size(); i++)
+ {
+ const CArcInfoEx &arc = Formats[i];
+ if (!arc.UpdateEnabled)
+ continue;
+ // if (arc.FindExtension(ext) >= 0)
+ UString mainExt = arc.GetMainExt();
+ if (!mainExt.IsEmpty() && ext.CompareNoCase(mainExt) == 0)
+ return i;
+ }
+ return -1;
+}
+
+int CCodecs::FindFormatForArchiveType(const UString &arcType) const
+{
+ for (int i = 0; i < Formats.Size(); i++)
+ {
+ const CArcInfoEx &arc = Formats[i];
+ if (!arc.UpdateEnabled)
+ continue;
+ if (arc.Name.CompareNoCase(arcType) == 0)
+ return i;
+ }
+ return -1;
+}
+
+#ifdef EXTERNAL_CODECS
+
+#ifdef EXPORT_CODECS
+extern unsigned int g_NumCodecs;
+STDAPI CreateCoder2(bool encode, UInt32 index, const GUID *iid, void **outObject);
+STDAPI GetMethodProperty(UInt32 codecIndex, PROPID propID, PROPVARIANT *value);
+// STDAPI GetNumberOfMethods(UINT32 *numCodecs);
+#endif
+
+STDMETHODIMP CCodecs::GetNumberOfMethods(UINT32 *numMethods)
+{
+ *numMethods =
+ #ifdef EXPORT_CODECS
+ g_NumCodecs +
+ #endif
+ Codecs.Size();
+ return S_OK;
+}
+
+STDMETHODIMP CCodecs::GetProperty(UINT32 index, PROPID propID, PROPVARIANT *value)
+{
+ #ifdef EXPORT_CODECS
+ if (index < g_NumCodecs)
+ return GetMethodProperty(index, propID, value);
+ #endif
+
+ const CDllCodecInfo &ci = Codecs[index
+ #ifdef EXPORT_CODECS
+ - g_NumCodecs
+ #endif
+ ];
+
+ if (propID == NMethodPropID::kDecoderIsAssigned)
+ {
+ NWindows::NCOM::CPropVariant propVariant;
+ propVariant = ci.DecoderIsAssigned;
+ propVariant.Detach(value);
+ return S_OK;
+ }
+ if (propID == NMethodPropID::kEncoderIsAssigned)
+ {
+ NWindows::NCOM::CPropVariant propVariant;
+ propVariant = ci.EncoderIsAssigned;
+ propVariant.Detach(value);
+ return S_OK;
+ }
+ return Libs[ci.LibIndex].GetMethodProperty(ci.CodecIndex, propID, value);
+}
+
+STDMETHODIMP CCodecs::CreateDecoder(UINT32 index, const GUID *iid, void **coder)
+{
+ #ifdef EXPORT_CODECS
+ if (index < g_NumCodecs)
+ return CreateCoder2(false, index, iid, coder);
+ #endif
+ const CDllCodecInfo &ci = Codecs[index
+ #ifdef EXPORT_CODECS
+ - g_NumCodecs
+ #endif
+ ];
+ if (ci.DecoderIsAssigned)
+ return Libs[ci.LibIndex].CreateObject(&ci.Decoder, iid, (void **)coder);
+ return S_OK;
+}
+
+STDMETHODIMP CCodecs::CreateEncoder(UINT32 index, const GUID *iid, void **coder)
+{
+ #ifdef EXPORT_CODECS
+ if (index < g_NumCodecs)
+ return CreateCoder2(true, index, iid, coder);
+ #endif
+ const CDllCodecInfo &ci = Codecs[index
+ #ifdef EXPORT_CODECS
+ - g_NumCodecs
+ #endif
+ ];
+ if (ci.EncoderIsAssigned)
+ return Libs[ci.LibIndex].CreateObject(&ci.Encoder, iid, (void **)coder);
+ return S_OK;
+}
+
+HRESULT CCodecs::CreateCoder(const UString &name, bool encode, CMyComPtr<ICompressCoder> &coder) const
+{
+ for (int i = 0; i < Codecs.Size(); i++)
+ {
+ const CDllCodecInfo &codec = Codecs[i];
+ if (encode && !codec.EncoderIsAssigned || !encode && !codec.DecoderIsAssigned)
+ continue;
+ const CCodecLib &lib = Libs[codec.LibIndex];
+ UString res;
+ NWindows::NCOM::CPropVariant prop;
+ RINOK(lib.GetMethodProperty(codec.CodecIndex, NMethodPropID::kName, &prop));
+ if (prop.vt == VT_BSTR)
+ res = prop.bstrVal;
+ else if (prop.vt != VT_EMPTY)
+ continue;
+ if (name.CompareNoCase(res) == 0)
+ return lib.CreateObject(encode ? &codec.Encoder : &codec.Decoder, &IID_ICompressCoder, (void **)&coder);
+ }
+ return CLASS_E_CLASSNOTAVAILABLE;
+}
+
+int CCodecs::GetCodecLibIndex(UInt32 index)
+{
+ #ifdef EXPORT_CODECS
+ if (index < g_NumCodecs)
+ return -1;
+ #endif
+ #ifdef EXTERNAL_CODECS
+ const CDllCodecInfo &ci = Codecs[index
+ #ifdef EXPORT_CODECS
+ - g_NumCodecs
+ #endif
+ ];
+ return ci.LibIndex;
+ #else
+ return -1;
+ #endif
+}
+
+bool CCodecs::GetCodecEncoderIsAssigned(UInt32 index)
+{
+ #ifdef EXPORT_CODECS
+ if (index < g_NumCodecs)
+ {
+ NWindows::NCOM::CPropVariant prop;
+ if (GetProperty(index, NMethodPropID::kEncoder, &prop) == S_OK)
+ if (prop.vt != VT_EMPTY)
+ return true;
+ return false;
+ }
+ #endif
+ #ifdef EXTERNAL_CODECS
+ const CDllCodecInfo &ci = Codecs[index
+ #ifdef EXPORT_CODECS
+ - g_NumCodecs
+ #endif
+ ];
+ return ci.EncoderIsAssigned;
+ #else
+ return false;
+ #endif
+}
+
+HRESULT CCodecs::GetCodecId(UInt32 index, UInt64 &id)
+{
+ UString s;
+ NWindows::NCOM::CPropVariant prop;
+ RINOK(GetProperty(index, NMethodPropID::kID, &prop));
+ if (prop.vt != VT_UI8)
+ return E_INVALIDARG;
+ id = prop.uhVal.QuadPart;
+ return S_OK;
+}
+
+UString CCodecs::GetCodecName(UInt32 index)
+{
+ UString s;
+ NWindows::NCOM::CPropVariant prop;
+ if (GetProperty(index, NMethodPropID::kName, &prop) == S_OK)
+ if (prop.vt == VT_BSTR)
+ s = prop.bstrVal;
+ return s;
+}
+
+#endif
diff --git a/CPP/7zip/UI/Common/LoadCodecs.h b/CPP/7zip/UI/Common/LoadCodecs.h
new file mode 100755
index 00000000..28cc7dad
--- /dev/null
+++ b/CPP/7zip/UI/Common/LoadCodecs.h
@@ -0,0 +1,215 @@
+// LoadCodecs.h
+
+#ifndef __LOADCODECS_H
+#define __LOADCODECS_H
+
+#include "../../../Common/Types.h"
+#include "../../../Common/MyCom.h"
+#include "../../../Common/String.h"
+#include "../../../Common/Buffer.h"
+#include "../../ICoder.h"
+
+#ifdef EXTERNAL_CODECS
+#include "../../../Windows/DLL.h"
+#endif
+
+struct CDllCodecInfo
+{
+ CLSID Encoder;
+ CLSID Decoder;
+ bool EncoderIsAssigned;
+ bool DecoderIsAssigned;
+ int LibIndex;
+ UInt32 CodecIndex;
+};
+
+#include "../../Archive/IArchive.h"
+
+typedef IInArchive * (*CreateInArchiveP)();
+typedef IOutArchive * (*CreateOutArchiveP)();
+
+struct CArcExtInfo
+{
+ UString Ext;
+ UString AddExt;
+ CArcExtInfo() {}
+ CArcExtInfo(const UString &ext): Ext(ext) {}
+ CArcExtInfo(const UString &ext, const UString &addExt): Ext(ext), AddExt(addExt) {}
+};
+
+
+struct CArcInfoEx
+{
+ #ifdef EXTERNAL_CODECS
+ int LibIndex;
+ UInt32 FormatIndex;
+ CLSID ClassID;
+ #endif
+ bool UpdateEnabled;
+ CreateInArchiveP CreateInArchive;
+ CreateOutArchiveP CreateOutArchive;
+ UString Name;
+ CObjectVector<CArcExtInfo> Exts;
+ #ifndef _SFX
+ CByteBuffer StartSignature;
+ // CByteBuffer FinishSignature;
+ #ifdef NEW_FOLDER_INTERFACE
+ UStringVector AssociateExts;
+ #endif
+ #endif
+ bool KeepName;
+ UString GetMainExt() const
+ {
+ if (Exts.IsEmpty())
+ return UString();
+ return Exts[0].Ext;
+ }
+ int FindExtension(const UString &ext) const
+ {
+ for (int i = 0; i < Exts.Size(); i++)
+ if (ext.CompareNoCase(Exts[i].Ext) == 0)
+ return i;
+ return -1;
+ }
+ UString GetAllExtensions() const
+ {
+ UString s;
+ for (int i = 0; i < Exts.Size(); i++)
+ {
+ if (i > 0)
+ s += ' ';
+ s += Exts[i].Ext;
+ }
+ return s;
+ }
+
+ void AddExts(const wchar_t* ext, const wchar_t* addExt);
+
+ CArcInfoEx():
+ #ifdef EXTERNAL_CODECS
+ LibIndex(-1),
+ #endif
+ UpdateEnabled(false),
+ CreateInArchive(0), CreateOutArchive(0),
+ KeepName(false)
+ #ifndef _SFX
+ #endif
+ {}
+};
+
+#ifdef EXTERNAL_CODECS
+typedef UInt32 (WINAPI *GetMethodPropertyFunc)(UInt32 index, PROPID propID, PROPVARIANT *value);
+typedef UInt32 (WINAPI *CreateObjectFunc)(const GUID *clsID, const GUID *interfaceID, void **outObject);
+
+
+struct CCodecLib
+{
+ NWindows::NDLL::CLibrary Lib;
+ GetMethodPropertyFunc GetMethodProperty;
+ CreateObjectFunc CreateObject;
+ #ifdef NEW_FOLDER_INTERFACE
+ struct CIconPair
+ {
+ UString Ext;
+ UInt32 IconIndex;
+ };
+ CSysString Path;
+ CObjectVector<CIconPair> IconPairs;
+ void LoadIcons();
+ int FindIconIndex(const UString &ext) const;
+ #endif
+ CCodecLib(): GetMethodProperty(0) {}
+};
+#endif
+
+class CCodecs:
+ #ifdef EXTERNAL_CODECS
+ public ICompressCodecsInfo,
+ #else
+ public IUnknown,
+ #endif
+ public CMyUnknownImp
+{
+public:
+ #ifdef EXTERNAL_CODECS
+ CObjectVector<CCodecLib> Libs;
+ CObjectVector<CDllCodecInfo> Codecs;
+ HRESULT LoadCodecs();
+ HRESULT LoadFormats();
+ HRESULT LoadDll(const CSysString &path);
+ HRESULT LoadDllsFromFolder(const CSysString &folderPrefix);
+
+ HRESULT CreateArchiveHandler(const CArcInfoEx &ai, void **archive, bool outHandler) const
+ {
+ return Libs[ai.LibIndex].CreateObject(&ai.ClassID, outHandler ? &IID_IOutArchive : &IID_IInArchive, (void **)archive);
+ }
+ #endif
+
+public:
+ CObjectVector<CArcInfoEx> Formats;
+ HRESULT Load();
+ int FindFormatForArchiveName(const UString &archivePath) const;
+ int FindFormatForArchiveType(const UString &arcType) const;
+
+ MY_UNKNOWN_IMP
+
+ #ifdef EXTERNAL_CODECS
+ STDMETHOD(GetNumberOfMethods)(UINT32 *numMethods);
+ STDMETHOD(GetProperty)(UINT32 index, PROPID propID, PROPVARIANT *value);
+ STDMETHOD(CreateDecoder)(UINT32 index, const GUID *interfaceID, void **coder);
+ STDMETHOD(CreateEncoder)(UINT32 index, const GUID *interfaceID, void **coder);
+ #endif
+
+ int GetCodecLibIndex(UInt32 index);
+ bool GetCodecEncoderIsAssigned(UInt32 index);
+ HRESULT GetCodecId(UInt32 index, UInt64 &id);
+ UString GetCodecName(UInt32 index);
+
+ HRESULT CreateInArchive(int formatIndex, CMyComPtr<IInArchive> &archive) const
+ {
+ const CArcInfoEx &ai = Formats[formatIndex];
+ #ifdef EXTERNAL_CODECS
+ if (ai.LibIndex < 0)
+ #endif
+ {
+ archive = ai.CreateInArchive();
+ return S_OK;
+ }
+ #ifdef EXTERNAL_CODECS
+ return CreateArchiveHandler(ai, (void **)&archive, false);
+ #endif
+ }
+ HRESULT CreateOutArchive(int formatIndex, CMyComPtr<IOutArchive> &archive) const
+ {
+ const CArcInfoEx &ai = Formats[formatIndex];
+ #ifdef EXTERNAL_CODECS
+ if (ai.LibIndex < 0)
+ #endif
+ {
+ archive = ai.CreateOutArchive();
+ return S_OK;
+ }
+ #ifdef EXTERNAL_CODECS
+ return CreateArchiveHandler(ai, (void **)&archive, true);
+ #endif
+ }
+ int FindOutFormatFromName(const UString &name) const
+ {
+ for (int i = 0; i < Formats.Size(); i++)
+ {
+ const CArcInfoEx &arc = Formats[i];
+ if (!arc.UpdateEnabled)
+ continue;
+ if (arc.Name.CompareNoCase(name) == 0)
+ return i;
+ }
+ return -1;
+ }
+
+ #ifdef EXTERNAL_CODECS
+ HRESULT CreateCoder(const UString &name, bool encode, CMyComPtr<ICompressCoder> &coder) const;
+ #endif
+
+};
+
+#endif
diff --git a/CPP/7zip/UI/Common/OpenArchive.cpp b/CPP/7zip/UI/Common/OpenArchive.cpp
index ce1a6de3..0f73890f 100755
--- a/CPP/7zip/UI/Common/OpenArchive.cpp
+++ b/CPP/7zip/UI/Common/OpenArchive.cpp
@@ -16,42 +16,6 @@
#include "Common/StringConvert.h"
-#ifdef FORMAT_7Z
-#include "../../Archive/7z/7zHandler.h"
-#endif
-
-#ifdef FORMAT_BZIP2
-#include "../../Archive/BZip2/BZip2Handler.h"
-#endif
-
-#ifdef FORMAT_CAB
-#include "../../Archive/Cab/CabHandler.h"
-#endif
-
-#ifdef FORMAT_GZIP
-#include "../../Archive/GZip/GZipHandler.h"
-#endif
-
-#ifdef FORMAT_SPLIT
-#include "../../Archive/Split/SplitHandler.h"
-#endif
-
-#ifdef FORMAT_TAR
-#include "../../Archive/Tar/TarHandler.h"
-#endif
-
-#ifdef FORMAT_ZIP
-#include "../../Archive/Zip/ZipHandler.h"
-#endif
-
-#ifdef FORMAT_Z
-#include "../../Archive/Z/ZHandler.h"
-#endif
-
-#ifndef EXCLUDE_COM
-#include "HandlerLoader.h"
-#endif
-
#include "DefaultName.h"
using namespace NWindows;
@@ -136,19 +100,15 @@ static inline bool TestSignature(const Byte *p1, const Byte *p2, size_t size)
#endif
HRESULT OpenArchive(
+ CCodecs *codecs,
IInStream *inStream,
const UString &fileName,
- #ifndef EXCLUDE_COM
- HMODULE *module,
- #endif
IInArchive **archiveResult,
- CArchiverInfo &archiverInfoResult,
+ int &formatIndex,
UString &defaultItemName,
IArchiveOpenCallback *openArchiveCallback)
{
*archiveResult = NULL;
- CObjectVector<CArchiverInfo> archiverInfoList;
- ReadArchiverInfoList(archiverInfoList);
UString extension;
{
int dotPos = fileName.ReverseFind(L'.');
@@ -157,21 +117,17 @@ HRESULT OpenArchive(
}
CIntVector orderIndices;
int i;
- bool finded = false;
- for(i = 0; i < archiverInfoList.Size(); i++)
- {
- if (archiverInfoList[i].FindExtension(extension) >= 0)
- {
- orderIndices.Insert(0, i);
- finded = true;
- }
+ int numFinded = 0;
+ for (i = 0; i < codecs->Formats.Size(); i++)
+ if (codecs->Formats[i].FindExtension(extension) >= 0)
+ orderIndices.Insert(numFinded++, i);
else
orderIndices.Add(i);
- }
#ifndef _SFX
- if (!finded)
+ if (numFinded != 1)
{
+ CIntVector orderIndices2;
CByteBuffer byteBuffer;
const UInt32 kBufferSize = (200 << 10);
byteBuffer.SetCapacity(kBufferSize);
@@ -179,13 +135,12 @@ HRESULT OpenArchive(
RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
UInt32 processedSize;
RINOK(ReadStream(inStream, buffer, kBufferSize, &processedSize));
- int numFinded = 0;
- for (int pos = (int)processedSize; pos >= 0 ; pos--)
+ for (UInt32 pos = 0; pos < processedSize; pos++)
{
- for(int i = numFinded; i < orderIndices.Size(); i++)
+ for (int i = 0; i < orderIndices.Size(); i++)
{
int index = orderIndices[i];
- const CArchiverInfo &ai = archiverInfoList[index];
+ const CArcInfoEx &ai = codecs->Formats[index];
const CByteBuffer &sig = ai.StartSignature;
if (sig.GetCapacity() == 0)
continue;
@@ -193,12 +148,13 @@ HRESULT OpenArchive(
continue;
if (TestSignature(buffer + pos, sig, sig.GetCapacity()))
{
- orderIndices.Delete(i);
- orderIndices.Insert(0, index);
- numFinded++;
+ orderIndices2.Add(index);
+ orderIndices.Delete(i--);
}
}
}
+ orderIndices2 += orderIndices;
+ orderIndices = orderIndices2;
}
#endif
@@ -206,68 +162,27 @@ HRESULT OpenArchive(
for(i = 0; i < orderIndices.Size(); i++)
{
inStream->Seek(0, STREAM_SEEK_SET, NULL);
- const CArchiverInfo &archiverInfo = archiverInfoList[orderIndices[i]];
- #ifndef EXCLUDE_COM
- CHandlerLoader loader;
- #endif
- CMyComPtr<IInArchive> archive;
-
- #ifdef FORMAT_7Z
- if (archiverInfo.Name.CompareNoCase(L"7z") == 0)
- archive = new NArchive::N7z::CHandler;
- #endif
-
- #ifdef FORMAT_BZIP2
- if (archiverInfo.Name.CompareNoCase(L"BZip2") == 0)
- archive = new NArchive::NBZip2::CHandler;
- #endif
-
- #ifdef FORMAT_CAB
- if (archiverInfo.Name.CompareNoCase(L"Cab") == 0)
- archive = new NArchive::NCab::CHandler;
- #endif
-
- #ifdef FORMAT_GZIP
- if (archiverInfo.Name.CompareNoCase(L"GZip") == 0)
- archive = new NArchive::NGZip::CHandler;
- #endif
-
- #ifdef FORMAT_SPLIT
- if (archiverInfo.Name.CompareNoCase(L"Split") == 0)
- archive = new NArchive::NSplit::CHandler;
- #endif
-
- #ifdef FORMAT_TAR
- if (archiverInfo.Name.CompareNoCase(L"Tar") == 0)
- archive = new NArchive::NTar::CHandler;
- #endif
-
- #ifdef FORMAT_ZIP
- if (archiverInfo.Name.CompareNoCase(L"Zip") == 0)
- archive = new NArchive::NZip::CHandler;
- #endif
-
- #ifdef FORMAT_Z
- if (archiverInfo.Name.CompareNoCase(L"Z") == 0)
- archive = new NArchive::NZ::CHandler;
- #endif
+ CMyComPtr<IInArchive> archive;
- #ifndef EXCLUDE_COM
+ formatIndex = orderIndices[i];
+ RINOK(codecs->CreateInArchive(formatIndex, archive));
if (!archive)
+ continue;
+
+ #ifdef EXTERNAL_CODECS
{
- HRESULT result = loader.CreateHandler(archiverInfo.FilePath,
- archiverInfo.ClassID, (void **)&archive, false);
- if (result != S_OK)
- continue;
+ CMyComPtr<ISetCompressCodecsInfo> setCompressCodecsInfo;
+ archive.QueryInterface(IID_ISetCompressCodecsInfo, (void **)&setCompressCodecsInfo);
+ if (setCompressCodecsInfo)
+ {
+ RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(codecs));
+ }
}
#endif
-
- if (!archive)
- return E_FAIL;
-
+
HRESULT result = archive->Open(inStream, &kMaxCheckStartPosition, openArchiveCallback);
- if(result == S_FALSE)
+ if (result == S_FALSE)
continue;
if(result != S_OK)
{
@@ -277,17 +192,20 @@ HRESULT OpenArchive(
continue;
}
*archiveResult = archive.Detach();
- #ifndef EXCLUDE_COM
- *module = loader.Detach();
- #endif
- archiverInfoResult = archiverInfo;
- int subExtIndex = archiverInfo.FindExtension(extension);
- if (subExtIndex < 0)
- subExtIndex = 0;
- defaultItemName = GetDefaultName2(fileName,
- archiverInfo.Extensions[subExtIndex].Ext,
- archiverInfo.Extensions[subExtIndex].AddExt);
-
+ const CArcInfoEx &format = codecs->Formats[formatIndex];
+ if (format.Exts.Size() == 0)
+ {
+ defaultItemName = GetDefaultName2(fileName, L"", L"");
+ }
+ else
+ {
+ int subExtIndex = format.FindExtension(extension);
+ if (subExtIndex < 0)
+ subExtIndex = 0;
+ defaultItemName = GetDefaultName2(fileName,
+ format.Exts[subExtIndex].Ext,
+ format.Exts[subExtIndex].AddExt);
+ }
return S_OK;
}
if (badResult != S_OK)
@@ -295,12 +213,11 @@ HRESULT OpenArchive(
return S_FALSE;
}
-HRESULT OpenArchive(const UString &filePath,
- #ifndef EXCLUDE_COM
- HMODULE *module,
- #endif
+HRESULT OpenArchive(
+ CCodecs *codecs,
+ const UString &filePath,
IInArchive **archiveResult,
- CArchiverInfo &archiverInfo,
+ int &formatIndex,
UString &defaultItemName,
IArchiveOpenCallback *openArchiveCallback)
{
@@ -308,11 +225,8 @@ HRESULT OpenArchive(const UString &filePath,
CMyComPtr<IInStream> inStream(inStreamSpec);
if (!inStreamSpec->Open(filePath))
return GetLastError();
- return OpenArchive(inStream, ExtractFileNameFromPath(filePath),
- #ifndef EXCLUDE_COM
- module,
- #endif
- archiveResult, archiverInfo,
+ return OpenArchive(codecs, inStream, ExtractFileNameFromPath(filePath),
+ archiveResult, formatIndex,
defaultItemName, openArchiveCallback);
}
@@ -330,24 +244,19 @@ static void MakeDefaultName(UString &name)
name = name.Left(dotPos);
}
-HRESULT OpenArchive(const UString &fileName,
- #ifndef EXCLUDE_COM
- HMODULE *module0,
- HMODULE *module1,
- #endif
+HRESULT OpenArchive(
+ CCodecs *codecs,
+ const UString &fileName,
IInArchive **archive0,
IInArchive **archive1,
- CArchiverInfo &archiverInfo0,
- CArchiverInfo &archiverInfo1,
+ int &formatIndex0,
+ int &formatIndex1,
UString &defaultItemName0,
UString &defaultItemName1,
IArchiveOpenCallback *openArchiveCallback)
{
- HRESULT result = OpenArchive(fileName,
- #ifndef EXCLUDE_COM
- module0,
- #endif
- archive0, archiverInfo0, defaultItemName0, openArchiveCallback);
+ HRESULT result = OpenArchive(codecs, fileName,
+ archive0, formatIndex0, defaultItemName0, openArchiveCallback);
RINOK(result);
CMyComPtr<IInArchiveGetStream> getStream;
result = (*archive0)->QueryInterface(IID_IInArchiveGetStream, (void **)&getStream);
@@ -376,7 +285,8 @@ HRESULT OpenArchive(const UString &fileName,
{
MakeDefaultName(defaultItemName0);
subPath = defaultItemName0;
- if (archiverInfo0.Name.CompareNoCase(L"7z") == 0)
+ const CArcInfoEx &format = codecs->Formats[formatIndex0];
+ if (format.Name.CompareNoCase(L"7z") == 0)
{
if (subPath.Right(3).CompareNoCase(L".7z") != 0)
subPath += L".7z";
@@ -390,21 +300,15 @@ HRESULT OpenArchive(const UString &fileName,
if (setSubArchiveName)
setSubArchiveName->SetSubArchiveName(subPath);
- result = OpenArchive(subStream, subPath,
- #ifndef EXCLUDE_COM
- module1,
- #endif
- archive1, archiverInfo1, defaultItemName1, openArchiveCallback);
+ result = OpenArchive(codecs, subStream, subPath,
+ archive1, formatIndex1, defaultItemName1, openArchiveCallback);
return S_OK;
}
-HRESULT MyOpenArchive(const UString &archiveName,
- #ifndef EXCLUDE_COM
- HMODULE *module,
- #endif
- IInArchive **archive,
- UString &defaultItemName,
- IOpenCallbackUI *openCallbackUI)
+HRESULT MyOpenArchive(
+ CCodecs *codecs,
+ const UString &archiveName,
+ IInArchive **archive, UString &defaultItemName, IOpenCallbackUI *openCallbackUI)
{
COpenCallbackImp *openCallbackSpec = new COpenCallbackImp;
CMyComPtr<IArchiveOpenCallback> openCallback = openCallbackSpec;
@@ -417,22 +321,13 @@ HRESULT MyOpenArchive(const UString &archiveName,
fullName.Left(fileNamePartStartIndex),
fullName.Mid(fileNamePartStartIndex));
- CArchiverInfo archiverInfo;
- return OpenArchive(archiveName,
- #ifndef EXCLUDE_COM
- module,
- #endif
- archive,
- archiverInfo,
- defaultItemName,
- openCallback);
+ int formatInfo;
+ return OpenArchive(codecs, archiveName, archive, formatInfo, defaultItemName, openCallback);
}
-HRESULT MyOpenArchive(const UString &archiveName,
- #ifndef EXCLUDE_COM
- HMODULE *module0,
- HMODULE *module1,
- #endif
+HRESULT MyOpenArchive(
+ CCodecs *codecs,
+ const UString &archiveName,
IInArchive **archive0,
IInArchive **archive1,
UString &defaultItemName0,
@@ -451,20 +346,15 @@ HRESULT MyOpenArchive(const UString &archiveName,
UString name = fullName.Mid(fileNamePartStartIndex);
openCallbackSpec->Init(prefix, name);
- CArchiverInfo archiverInfo0, archiverInfo1;
- HRESULT result = OpenArchive(archiveName,
- #ifndef EXCLUDE_COM
- module0,
- module1,
- #endif
+ int formatIndex0, formatIndex1;
+ RINOK(OpenArchive(codecs, archiveName,
archive0,
archive1,
- archiverInfo0,
- archiverInfo1,
+ formatIndex0,
+ formatIndex1,
defaultItemName0,
defaultItemName1,
- openCallback);
- RINOK(result);
+ openCallback));
volumePaths.Add(prefix + name);
for (int i = 0; i < openCallbackSpec->FileNames.Size(); i++)
volumePaths.Add(prefix + openCallbackSpec->FileNames[i]);
@@ -482,50 +372,40 @@ HRESULT CArchiveLink::Close()
void CArchiveLink::Release()
{
- if (Archive1 != 0)
- Archive1.Release();
- if (Archive0 != 0)
- Archive0.Release();
- #ifndef EXCLUDE_COM
- Library1.Free();
- Library0.Free();
- #endif
+ Archive1.Release();
+ Archive0.Release();
}
-HRESULT OpenArchive(const UString &archiveName,
+HRESULT OpenArchive(
+ CCodecs *codecs,
+ const UString &archiveName,
CArchiveLink &archiveLink,
IArchiveOpenCallback *openCallback)
{
- return OpenArchive(archiveName,
- #ifndef EXCLUDE_COM
- &archiveLink.Library0, &archiveLink.Library1,
- #endif
+ return OpenArchive(codecs, archiveName,
&archiveLink.Archive0, &archiveLink.Archive1,
- archiveLink.ArchiverInfo0, archiveLink.ArchiverInfo1,
+ archiveLink.FormatIndex0, archiveLink.FormatIndex1,
archiveLink.DefaultItemName0, archiveLink.DefaultItemName1,
openCallback);
}
-HRESULT MyOpenArchive(const UString &archiveName,
+HRESULT MyOpenArchive(CCodecs *codecs,
+ const UString &archiveName,
CArchiveLink &archiveLink,
IOpenCallbackUI *openCallbackUI)
{
- return MyOpenArchive(archiveName,
- #ifndef EXCLUDE_COM
- &archiveLink.Library0, &archiveLink.Library1,
- #endif
+ return MyOpenArchive(codecs, archiveName,
&archiveLink.Archive0, &archiveLink.Archive1,
archiveLink.DefaultItemName0, archiveLink.DefaultItemName1,
archiveLink.VolumePaths,
openCallbackUI);
}
-HRESULT ReOpenArchive(CArchiveLink &archiveLink,
- const UString &fileName)
+HRESULT ReOpenArchive(CCodecs *codecs, CArchiveLink &archiveLink, const UString &fileName)
{
if (archiveLink.GetNumLevels() > 1)
return E_NOTIMPL;
if (archiveLink.GetNumLevels() == 0)
- return MyOpenArchive(fileName, archiveLink, 0);
+ return MyOpenArchive(codecs, fileName, archiveLink, 0);
return ReOpenArchive(archiveLink.GetArchive(), fileName);
}
diff --git a/CPP/7zip/UI/Common/OpenArchive.h b/CPP/7zip/UI/Common/OpenArchive.h
index f96b1ebf..d43c22b3 100755
--- a/CPP/7zip/UI/Common/OpenArchive.h
+++ b/CPP/7zip/UI/Common/OpenArchive.h
@@ -7,13 +7,9 @@
#include "Windows/FileFind.h"
#include "../../Archive/IArchive.h"
-#include "ArchiverInfo.h"
+#include "LoadCodecs.h"
#include "ArchiveOpenCallback.h"
-#ifndef EXCLUDE_COM
-#include "Windows/DLL.h"
-#endif
-
HRESULT GetArchiveItemPath(IInArchive *archive, UInt32 index, UString &result);
HRESULT GetArchiveItemPath(IInArchive *archive, UInt32 index, const UString &defaultName, UString &result);
HRESULT GetArchiveItemFileTime(IInArchive *archive, UInt32 index,
@@ -27,55 +23,46 @@ struct ISetSubArchiveName
};
HRESULT OpenArchive(
+ CCodecs *codecs,
IInStream *inStream,
const UString &fileName,
- #ifndef EXCLUDE_COM
- HMODULE *module,
- #endif
IInArchive **archiveResult,
- CArchiverInfo &archiverInfoResult,
+ int &formatIndex,
UString &defaultItemName,
IArchiveOpenCallback *openArchiveCallback);
-HRESULT OpenArchive(const UString &filePath,
- #ifndef EXCLUDE_COM
- HMODULE *module,
- #endif
+HRESULT OpenArchive(
+ CCodecs *codecs,
+ const UString &filePath,
IInArchive **archive,
- CArchiverInfo &archiverInfo,
+ int &formatIndex,
UString &defaultItemName,
IArchiveOpenCallback *openArchiveCallback);
-HRESULT OpenArchive(const UString &filePath,
- #ifndef EXCLUDE_COM
- HMODULE *module0,
- HMODULE *module1,
- #endif
+HRESULT OpenArchive(
+ CCodecs *codecs,
+ const UString &filePath,
IInArchive **archive0,
IInArchive **archive1,
- CArchiverInfo &archiverInfo0,
- CArchiverInfo &archiverInfo1,
+ int &formatIndex0,
+ int &formatIndex1,
UString &defaultItemName0,
UString &defaultItemName1,
IArchiveOpenCallback *openArchiveCallback);
-HRESULT ReOpenArchive(IInArchive *archive,
- const UString &fileName);
+HRESULT ReOpenArchive(IInArchive *archive, const UString &fileName);
-HRESULT MyOpenArchive(const UString &archiveName,
- #ifndef EXCLUDE_COM
- HMODULE *module,
- #endif
+HRESULT MyOpenArchive(
+ CCodecs *codecs,
+ const UString &archiveName,
IInArchive **archive,
UString &defaultItemName,
IOpenCallbackUI *openCallbackUI);
-HRESULT MyOpenArchive(const UString &archiveName,
- #ifndef EXCLUDE_COM
- HMODULE *module0,
- HMODULE *module1,
- #endif
+HRESULT MyOpenArchive(
+ CCodecs *codecs,
+ const UString &archiveName,
IInArchive **archive0,
IInArchive **archive1,
UString &defaultItemName0,
@@ -85,17 +72,13 @@ HRESULT MyOpenArchive(const UString &archiveName,
struct CArchiveLink
{
- #ifndef EXCLUDE_COM
- NWindows::NDLL::CLibrary Library0;
- NWindows::NDLL::CLibrary Library1;
- #endif
CMyComPtr<IInArchive> Archive0;
CMyComPtr<IInArchive> Archive1;
UString DefaultItemName0;
UString DefaultItemName1;
- CArchiverInfo ArchiverInfo0;
- CArchiverInfo ArchiverInfo1;
+ int FormatIndex0;
+ int FormatIndex1;
UStringVector VolumePaths;
@@ -114,20 +97,26 @@ struct CArchiveLink
IInArchive *GetArchive() { return Archive1 != 0 ? Archive1: Archive0; }
UString GetDefaultItemName() { return Archive1 != 0 ? DefaultItemName1: DefaultItemName0; }
- const CArchiverInfo &GetArchiverInfo() { return Archive1 != 0 ? ArchiverInfo1: ArchiverInfo0; }
+ const int GetArchiverIndex() const { return Archive1 != 0 ? FormatIndex1: FormatIndex0; }
HRESULT Close();
void Release();
};
-HRESULT OpenArchive(const UString &archiveName,
+HRESULT OpenArchive(
+ CCodecs *codecs,
+ const UString &archiveName,
CArchiveLink &archiveLink,
IArchiveOpenCallback *openCallback);
-HRESULT MyOpenArchive(const UString &archiveName,
+HRESULT MyOpenArchive(
+ CCodecs *codecs,
+ const UString &archiveName,
CArchiveLink &archiveLink,
IOpenCallbackUI *openCallbackUI);
-HRESULT ReOpenArchive(CArchiveLink &archiveLink,
+HRESULT ReOpenArchive(
+ CCodecs *codecs,
+ CArchiveLink &archiveLink,
const UString &fileName);
#endif
diff --git a/CPP/7zip/UI/Common/Update.cpp b/CPP/7zip/UI/Common/Update.cpp
index cd7975d0..3772b676 100755
--- a/CPP/7zip/UI/Common/Update.cpp
+++ b/CPP/7zip/UI/Common/Update.cpp
@@ -37,30 +37,6 @@
#include "EnumDirItems.h"
#include "SetProperties.h"
-#ifdef FORMAT_7Z
-#include "../../Archive/7z/7zHandler.h"
-#endif
-
-#ifdef FORMAT_BZIP2
-#include "../../Archive/BZip2/BZip2Handler.h"
-#endif
-
-#ifdef FORMAT_GZIP
-#include "../../Archive/GZip/GZipHandler.h"
-#endif
-
-#ifdef FORMAT_TAR
-#include "../../Archive/Tar/TarHandler.h"
-#endif
-
-#ifdef FORMAT_ZIP
-#include "../../Archive/Zip/ZipHandler.h"
-#endif
-
-#ifndef EXCLUDE_COM
-#include "../Common/HandlerLoader.h"
-#endif
-
static const char *kUpdateIsNotSupoorted =
"update operations are not supported for this archive";
@@ -255,8 +231,47 @@ STDMETHODIMP COutMultiVolStream::SetSize(Int64 newSize)
return S_OK;
}
+static const wchar_t *kDefaultArchiveType = L"7z";
+static const wchar_t *kSFXExtension =
+ #ifdef _WIN32
+ L"exe";
+ #else
+ L"";
+ #endif
+
+bool CUpdateOptions::Init(const CCodecs *codecs, const UString &arcPath, const UString &arcType)
+{
+ if (!arcType.IsEmpty())
+ MethodMode.FormatIndex = codecs->FindFormatForArchiveType(arcType);
+ else
+ {
+ MethodMode.FormatIndex = codecs->FindFormatForArchiveName(arcPath);
+ if (MethodMode.FormatIndex < 0)
+ MethodMode.FormatIndex = codecs->FindFormatForArchiveType(kDefaultArchiveType);
+ }
+ if (MethodMode.FormatIndex < 0)
+ return false;
+ const CArcInfoEx &arcInfo = codecs->Formats[MethodMode.FormatIndex];
+ UString typeExt = arcInfo.GetMainExt();
+ UString ext = typeExt;
+ if (SfxMode)
+ ext = kSFXExtension;
+ ArchivePath.BaseExtension = ext;
+ ArchivePath.VolExtension = typeExt;
+ ArchivePath.ParseFromPath(arcPath);
+ for (int i = 0; i < Commands.Size(); i++)
+ {
+ CUpdateArchiveCommand &uc = Commands[i];
+ uc.ArchivePath.BaseExtension = ext;
+ uc.ArchivePath.VolExtension = typeExt;
+ uc.ArchivePath.ParseFromPath(uc.UserArchivePath);
+ }
+ return true;
+}
+
static HRESULT Compress(
+ CCodecs *codecs,
const CActionSet &actionSet,
IInArchive *archive,
const CCompressionMethodMode &compressionMethod,
@@ -273,10 +288,6 @@ static HRESULT Compress(
CUpdateErrorInfo &errorInfo,
IUpdateCallbackUI *callback)
{
- #ifndef EXCLUDE_COM
- CHandlerLoader loader;
- #endif
-
CMyComPtr<IOutArchive> outArchive;
if(archive != NULL)
{
@@ -287,38 +298,18 @@ static HRESULT Compress(
}
else
{
- #ifndef EXCLUDE_COM
-
- if (loader.CreateHandler(compressionMethod.FilePath,
- compressionMethod.ClassID, (void **)&outArchive, true) != S_OK)
- throw kUpdateIsNotSupoorted;
- #endif
-
- #ifdef FORMAT_7Z
- if (compressionMethod.Name.CompareNoCase(L"7z") == 0)
- outArchive = new NArchive::N7z::CHandler;
- #endif
-
- #ifdef FORMAT_BZIP2
- if (compressionMethod.Name.CompareNoCase(L"BZip2") == 0)
- outArchive = new NArchive::NBZip2::CHandler;
- #endif
+ RINOK(codecs->CreateOutArchive(compressionMethod.FormatIndex, outArchive));
- #ifdef FORMAT_GZIP
- if (compressionMethod.Name.CompareNoCase(L"GZip") == 0)
- outArchive = new NArchive::NGZip::CHandler;
- #endif
-
- #ifdef FORMAT_TAR
- if (compressionMethod.Name.CompareNoCase(L"Tar") == 0)
- outArchive = new NArchive::NTar::CHandler;
- #endif
-
- #ifdef FORMAT_ZIP
- if (compressionMethod.Name.CompareNoCase(L"Zip") == 0)
- outArchive = new NArchive::NZip::CHandler;
+ #ifdef EXTERNAL_CODECS
+ {
+ CMyComPtr<ISetCompressCodecsInfo> setCompressCodecsInfo;
+ outArchive.QueryInterface(IID_ISetCompressCodecsInfo, (void **)&setCompressCodecsInfo);
+ if (setCompressCodecsInfo)
+ {
+ RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(codecs));
+ }
+ }
#endif
-
}
if (outArchive == 0)
throw kUpdateIsNotSupoorted;
@@ -460,14 +451,11 @@ static HRESULT Compress(
RINOK(CopyBlock(sfxStream, sfxOutStream));
}
- HRESULT result = outArchive->UpdateItems(outStream, updatePairs2.Size(),
- updateCallback);
+ HRESULT result = outArchive->UpdateItems(outStream, updatePairs2.Size(), updateCallback);
callback->Finilize();
return result;
}
-
-
HRESULT EnumerateInArchiveItems(const NWildcard::CCensor &censor,
IInArchive *archive,
const UString &defaultItemName,
@@ -502,6 +490,7 @@ HRESULT EnumerateInArchiveItems(const NWildcard::CCensor &censor,
static HRESULT UpdateWithItemLists(
+ CCodecs *codecs,
CUpdateOptions &options,
IInArchive *archive,
const CObjectVector<CArchiveItem> &archiveItems,
@@ -523,7 +512,9 @@ static HRESULT UpdateWithItemLists(
i == 0 && options.UpdateArchiveItself && archive != 0));
}
- RINOK(Compress(command.ActionSet, archive,
+ RINOK(Compress(
+ codecs,
+ command.ActionSet, archive,
options.MethodMode,
command.ArchivePath,
archiveItems,
@@ -561,7 +552,9 @@ struct CEnumDirItemUpdateCallback: public IEnumDirItemCallback
HRESULT CheckBreak() { return Callback->CheckBreak(); }
};
-HRESULT UpdateArchive(const NWildcard::CCensor &censor,
+HRESULT UpdateArchive(
+ CCodecs *codecs,
+ const NWildcard::CCensor &censor,
CUpdateOptions &options,
CUpdateErrorInfo &errorInfo,
IOpenCallbackUI *openCallback,
@@ -605,7 +598,7 @@ HRESULT UpdateArchive(const NWildcard::CCensor &censor,
throw "there is no such archive";
if (options.VolumesSizes.Size() > 0)
return E_NOTIMPL;
- HRESULT result = MyOpenArchive(archiveName, archiveLink, openCallback);
+ HRESULT result = MyOpenArchive(codecs, archiveName, archiveLink, openCallback);
RINOK(callback->OpenResult(archiveName, result));
RINOK(result);
if (archiveLink.VolumePaths.Size() > 1)
@@ -731,7 +724,7 @@ HRESULT UpdateArchive(const NWildcard::CCensor &censor,
archive, defaultItemName, archiveFileInfo, archiveItems));
}
- RINOK(UpdateWithItemLists(options, archive, archiveItems, dirItems,
+ RINOK(UpdateWithItemLists(codecs, options, archive, archiveItems, dirItems,
tempFiles, errorInfo, callback));
if (archive != NULL)
diff --git a/CPP/7zip/UI/Common/Update.h b/CPP/7zip/UI/Common/Update.h
index 465acc24..284f8657 100755
--- a/CPP/7zip/UI/Common/Update.h
+++ b/CPP/7zip/UI/Common/Update.h
@@ -11,6 +11,7 @@
#include "ArchiveOpenCallback.h"
#include "UpdateCallback.h"
#include "Property.h"
+#include "LoadCodecs.h"
struct CArchivePath
{
@@ -75,19 +76,16 @@ struct CArchivePath
struct CUpdateArchiveCommand
{
+ UString UserArchivePath;
CArchivePath ArchivePath;
NUpdateArchive::CActionSet ActionSet;
};
struct CCompressionMethodMode
{
- #ifndef EXCLUDE_COM
- UString FilePath;
- CLSID ClassID;
- #else
- UString Name;
- #endif
+ int FormatIndex;
CObjectVector<CProperty> Properties;
+ CCompressionMethodMode(): FormatIndex(-1) {}
};
struct CUpdateOptions
@@ -111,6 +109,8 @@ struct CUpdateOptions
UString WorkingDir;
+ bool Init(const CCodecs *codecs, const UString &arcPath, const UString &arcType);
+
CUpdateOptions():
UpdateArchiveItself(true),
SfxMode(false),
@@ -149,7 +149,9 @@ struct IUpdateCallbackUI2: public IUpdateCallbackUI
virtual HRESULT FinishArchive() = 0;
};
-HRESULT UpdateArchive(const NWildcard::CCensor &censor,
+HRESULT UpdateArchive(
+ CCodecs *codecs,
+ const NWildcard::CCensor &censor,
CUpdateOptions &options,
CUpdateErrorInfo &errorInfo,
IOpenCallbackUI *openCallback,
diff --git a/CPP/7zip/UI/Common/ZipRegistry.cpp b/CPP/7zip/UI/Common/ZipRegistry.cpp
index e449d6b4..8969a4ab 100755
--- a/CPP/7zip/UI/Common/ZipRegistry.cpp
+++ b/CPP/7zip/UI/Common/ZipRegistry.cpp
@@ -17,8 +17,6 @@ using namespace NRegistry;
static const TCHAR *kCUBasePath = TEXT("Software\\7-ZIP");
-// static const TCHAR *kArchiversKeyName = TEXT("Archivers");
-
static NSynchronization::CCriticalSection g_RegistryOperationsCriticalSection;
//////////////////////
@@ -126,7 +124,6 @@ static const TCHAR *kCompressionLevelValueName = TEXT("Level");
static const TCHAR *kCompressionLastFormatValueName = TEXT("Archiver");
static const TCHAR *kCompressionShowPasswordValueName = TEXT("ShowPassword");
static const TCHAR *kCompressionEncryptHeadersValueName = TEXT("EncryptHeaders");
-// static const TCHAR *kCompressionMaximizeValueName = TEXT("Maximize");
static const TCHAR *kCompressionOptionsKeyName = TEXT("Options");
static const TCHAR *kSolid = TEXT("Solid");
@@ -138,6 +135,8 @@ static const WCHAR *kCompressionMethod = L"Method";
static const WCHAR *kEncryptionMethod = L"EncryptionMethod";
static const TCHAR *kCompressionDictionary = TEXT("Dictionary");
static const TCHAR *kCompressionOrder = TEXT("Order");
+static const TCHAR *kCompressionNumThreads = TEXT("NumThreads");
+static const TCHAR *kCompressionBlockSize = TEXT("BlockSize");
static void SetRegString(CKey &key, const WCHAR *name, const UString &value)
@@ -186,8 +185,8 @@ void SaveCompressionInfo(const NCompression::CInfo &info)
}
}
- compressionKey.SetValue(kSolid, info.Solid);
- compressionKey.SetValue(kMultiThread, info.MultiThread);
+ // compressionKey.SetValue(kSolid, info.Solid);
+ // compressionKey.SetValue(kMultiThread, info.MultiThread);
compressionKey.RecurseDeleteKey(kCompressionOptionsKeyName);
{
CKey optionsKey;
@@ -205,31 +204,25 @@ void SaveCompressionInfo(const NCompression::CInfo &info)
SetRegUInt32(formatKey, kCompressionLevel, fo.Level);
SetRegUInt32(formatKey, kCompressionDictionary, fo.Dictionary);
SetRegUInt32(formatKey, kCompressionOrder, fo.Order);
+ SetRegUInt32(formatKey, kCompressionBlockSize, fo.BlockLogSize);
+ SetRegUInt32(formatKey, kCompressionNumThreads, fo.NumThreads);
}
}
compressionKey.SetValue(kCompressionLevelValueName, UInt32(info.Level));
- compressionKey.SetValue(kCompressionLastFormatValueName,
- GetSystemString(info.ArchiveType));
+ compressionKey.SetValue(kCompressionLastFormatValueName, GetSystemString(info.ArchiveType));
compressionKey.SetValue(kCompressionShowPasswordValueName, info.ShowPassword);
compressionKey.SetValue(kCompressionEncryptHeadersValueName, info.EncryptHeaders);
// compressionKey.SetValue(kCompressionMaximizeValueName, info.Maximize);
}
-static bool IsMultiProcessor()
-{
- SYSTEM_INFO systemInfo;
- GetSystemInfo(&systemInfo);
- return systemInfo.dwNumberOfProcessors > 1;
-}
-
void ReadCompressionInfo(NCompression::CInfo &info)
{
info.HistoryArchives.Clear();
- info.Solid = true;
- info.MultiThread = IsMultiProcessor();
+ // info.Solid = true;
+ // info.MultiThread = IsMultiProcessor();
info.FormatOptionsVector.Clear();
info.Level = 5;
@@ -263,12 +256,14 @@ void ReadCompressionInfo(NCompression::CInfo &info)
}
+ /*
bool solid = false;
if (compressionKey.QueryValue(kSolid, solid) == ERROR_SUCCESS)
info.Solid = solid;
bool multiThread = false;
if (compressionKey.QueryValue(kMultiThread, multiThread) == ERROR_SUCCESS)
info.MultiThread = multiThread;
+ */
{
CKey optionsKey;
@@ -291,6 +286,8 @@ void ReadCompressionInfo(NCompression::CInfo &info)
GetRegUInt32(formatKey, kCompressionLevel, fo.Level);
GetRegUInt32(formatKey, kCompressionDictionary, fo.Dictionary);
GetRegUInt32(formatKey, kCompressionOrder, fo.Order);
+ GetRegUInt32(formatKey, kCompressionBlockSize, fo.BlockLogSize);
+ GetRegUInt32(formatKey, kCompressionNumThreads, fo.NumThreads);
info.FormatOptionsVector.Add(fo);
}
diff --git a/CPP/7zip/UI/Common/ZipRegistry.h b/CPP/7zip/UI/Common/ZipRegistry.h
index 30e7ee44..fcb0cce4 100755
--- a/CPP/7zip/UI/Common/ZipRegistry.h
+++ b/CPP/7zip/UI/Common/ZipRegistry.h
@@ -29,9 +29,11 @@ namespace NCompression {
UInt32 Level;
UInt32 Dictionary;
UInt32 Order;
+ UInt32 BlockLogSize;
+ UInt32 NumThreads;
void ResetForLevelChange()
{
- Level = Dictionary = Order = UInt32(-1);
+ BlockLogSize = NumThreads = Level = Dictionary = Order = UInt32(-1);
Method.Empty();
// EncryptionMethod.Empty();
// Options.Empty();
@@ -42,12 +44,9 @@ namespace NCompression {
struct CInfo
{
UStringVector HistoryArchives;
- // bool LevelIsDefined;
UInt32 Level;
UString ArchiveType;
- bool Solid;
- bool MultiThread;
CObjectVector<CFormatOptions> FormatOptionsVector;
bool ShowPassword;
diff --git a/CPP/7zip/UI/Console/Console.dsp b/CPP/7zip/UI/Console/Console.dsp
index e457008c..75c71330 100755
--- a/CPP/7zip/UI/Console/Console.dsp
+++ b/CPP/7zip/UI/Console/Console.dsp
@@ -44,7 +44,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MT" /Yu"StdAfx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /D "EXTERNAL_LZMA" /D "EXTERNAL_CODECS" /D "BREAK_HANDLER" /D "BENCH_MT" /D "_7ZIP_LARGE_PAGES" /Yu"StdAfx.h" /FD /c
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
@@ -69,7 +69,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "../../../" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MT" /Yu"StdAfx.h" /FD /GZ /c
+# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "../../../" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /D "EXTERNAL_LZMA" /D "EXTERNAL_CODECS" /D "BREAK_HANDLER" /D "BENCH_MT" /D "_7ZIP_LARGE_PAGES" /Yu"StdAfx.h" /FD /GZ /c
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
@@ -94,7 +94,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"StdAfx.h" /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MT" /Yu"StdAfx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /D "EXTERNAL_LZMA" /D "EXTERNAL_CODECS" /D "BREAK_HANDLER" /D "BENCH_MT" /D "_7ZIP_LARGE_PAGES" /Yu"StdAfx.h" /FD /c
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
@@ -120,7 +120,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "../../../" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
-# ADD CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "../../../" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MT" /Yu"StdAfx.h" /FD /GZ /c
+# ADD CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "../../../" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /D "EXTERNAL_LZMA" /D "EXTERNAL_CODECS" /D "BREAK_HANDLER" /D "BENCH_MT" /D "_7ZIP_LARGE_PAGES" /Yu"StdAfx.h" /FD /GZ /c
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
@@ -316,14 +316,6 @@ SOURCE=..\..\..\Windows\Time.h
# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\..\..\Common\Alloc.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Alloc.h
-# End Source File
-# Begin Source File
-
SOURCE=..\..\..\Common\Buffer.h
# End Source File
# Begin Source File
@@ -340,6 +332,10 @@ SOURCE=..\..\..\Common\ComTry.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\Common\CRC.cpp
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\Common\Defs.h
# End Source File
# Begin Source File
@@ -468,14 +464,6 @@ SOURCE=..\Common\ArchiveOpenCallback.h
# End Source File
# Begin Source File
-SOURCE=..\Common\ArchiverInfo.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ArchiverInfo.h
-# End Source File
-# Begin Source File
-
SOURCE=..\Common\CompressionMode.h
# End Source File
# Begin Source File
@@ -528,6 +516,14 @@ SOURCE=..\Common\IFileExtractCallback.h
# End Source File
# Begin Source File
+SOURCE=..\Common\LoadCodecs.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\LoadCodecs.h
+# End Source File
+# Begin Source File
+
SOURCE=..\Common\OpenArchive.cpp
# End Source File
# Begin Source File
@@ -644,6 +640,10 @@ SOURCE=..\..\Common\FileStreams.h
# End Source File
# Begin Source File
+SOURCE=..\..\Common\RegisterArc.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\Common\StreamUtils.cpp
# End Source File
# Begin Source File
@@ -654,6 +654,26 @@ SOURCE=..\..\Common\StreamUtils.h
# Begin Group "Compress"
# PROP Default_Filter ""
+# Begin Group "LzmaBench"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\LZMA_Alone\LzmaBench.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZMA_Alone\LzmaBench.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZMA_Alone\LzmaBenchCon.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\LZMA_Alone\LzmaBenchCon.h
+# End Source File
+# End Group
# Begin Source File
SOURCE=..\..\Compress\Copy\CopyCoder.cpp
@@ -663,5 +683,27 @@ SOURCE=..\..\Compress\Copy\CopyCoder.cpp
SOURCE=..\..\Compress\Copy\CopyCoder.h
# End Source File
# End Group
+# Begin Group "C"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\..\C\7zCrc.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\7zCrc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Alloc.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Alloc.h
+# End Source File
+# End Group
# End Target
# End Project
diff --git a/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp b/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp
index 9bd605ec..f4badb78 100755
--- a/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp
+++ b/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp
@@ -28,9 +28,9 @@ static const char *kTestingString = "Testing ";
static const char *kExtractingString = "Extracting ";
static const char *kSkippingString = "Skipping ";
-static const char *kCantAutoRename = "can not create file with auto name\n";
-static const char *kCantRenameFile = "can not rename existing file\n";
-static const char *kCantDeleteOutputFile = "can not delete output file ";
+// static const char *kCantAutoRename = "can not create file with auto name\n";
+// static const char *kCantRenameFile = "can not rename existing file\n";
+// static const char *kCantDeleteOutputFile = "can not delete output file ";
static const char *kError = "ERROR: ";
static const char *kMemoryExceptionMessage = "Can't allocate required memory!";
diff --git a/CPP/7zip/UI/Console/List.cpp b/CPP/7zip/UI/Console/List.cpp
index 6001e114..3d7001d2 100755
--- a/CPP/7zip/UI/Console/List.cpp
+++ b/CPP/7zip/UI/Console/List.cpp
@@ -392,7 +392,9 @@ bool GetUInt64Value(IInArchive *archive, UInt32 index, PROPID propID, UInt64 &va
return true;
}
-HRESULT ListArchives(UStringVector &archivePaths, UStringVector &archivePathsFull,
+HRESULT ListArchives(
+ CCodecs *codecs,
+ UStringVector &archivePaths, UStringVector &archivePathsFull,
const NWildcard::CCensorNode &wildcardCensor,
bool enableHeaders, bool techMode, bool &passwordEnabled, UString &password)
{
@@ -427,7 +429,7 @@ HRESULT ListArchives(UStringVector &archivePaths, UStringVector &archivePathsFul
openCallback.PasswordIsDefined = passwordEnabled;
openCallback.Password = password;
- HRESULT result = MyOpenArchive(archiveName, archiveLink, &openCallback);
+ HRESULT result = MyOpenArchive(codecs, archiveName, archiveLink, &openCallback);
if (result != S_OK)
{
g_StdOut << endl << "Error: " << archiveName << " is not supported archive" << endl;
diff --git a/CPP/7zip/UI/Console/List.h b/CPP/7zip/UI/Console/List.h
index 201a4128..2827bceb 100755
--- a/CPP/7zip/UI/Console/List.h
+++ b/CPP/7zip/UI/Console/List.h
@@ -4,8 +4,11 @@
#define __LIST_H
#include "Common/Wildcard.h"
+#include "../Common/LoadCodecs.h"
-HRESULT ListArchives(UStringVector &archivePaths, UStringVector &archivePathsFull,
+HRESULT ListArchives(
+ CCodecs *codecs,
+ UStringVector &archivePaths, UStringVector &archivePathsFull,
const NWildcard::CCensorNode &wildcardCensor,
bool enableHeaders, bool techMode, bool &passwordEnabled, UString &password);
diff --git a/CPP/7zip/UI/Console/Main.cpp b/CPP/7zip/UI/Console/Main.cpp
index 387b8c2a..392bef03 100755
--- a/CPP/7zip/UI/Console/Main.cpp
+++ b/CPP/7zip/UI/Console/Main.cpp
@@ -5,32 +5,37 @@
#include <io.h>
#include "Common/MyInitGuid.h"
+
#include "Common/CommandLineParser.h"
-#include "Common/StdOutStream.h"
-#include "Common/Wildcard.h"
+#include "Common/Exception.h"
+#include "Common/IntToString.h"
#include "Common/ListFileUtils.h"
-#include "Common/StringConvert.h"
#include "Common/StdInStream.h"
+#include "Common/StdOutStream.h"
+#include "Common/StringConvert.h"
#include "Common/StringToInt.h"
-#include "Common/Exception.h"
+#include "Common/Wildcard.h"
#include "Windows/FileDir.h"
#include "Windows/FileName.h"
#include "Windows/Defs.h"
#include "Windows/Error.h"
-// #include "Windows/System.h"
#ifdef _WIN32
#include "Windows/MemoryLock.h"
#endif
#include "../../IPassword.h"
#include "../../ICoder.h"
-#include "../Common/ArchiverInfo.h"
#include "../Common/UpdateAction.h"
#include "../Common/Update.h"
#include "../Common/Extract.h"
#include "../Common/ArchiveCommandLine.h"
#include "../Common/ExitCode.h"
+#ifdef EXTERNAL_CODECS
+#include "../Common/LoadCodecs.h"
+#endif
+
+#include "../../Compress/LZMA_Alone/LzmaBenchCon.h"
#include "List.h"
#include "OpenCallbackConsole.h"
@@ -39,8 +44,11 @@
#include "../../MyVersion.h"
-#ifndef EXCLUDE_COM
-#include "Windows/DLL.h"
+#if defined( _WIN32) && defined( _7ZIP_LARGE_PAGES)
+extern "C"
+{
+#include "../../../../C/Alloc.h"
+}
#endif
using namespace NWindows;
@@ -51,12 +59,12 @@ HINSTANCE g_hInstance = 0;
extern CStdOutStream *g_StdStream;
static const char *kCopyrightString = "\n7-Zip"
-#ifdef EXCLUDE_COM
+#ifndef EXTERNAL_CODECS
" (A)"
#endif
-#ifdef UNICODE
-" [NT]"
+#ifdef _WIN64
+" [64]"
#endif
" " MY_VERSION_COPYRIGHT_DATE "\n";
@@ -65,14 +73,17 @@ static const char *kHelpString =
"\nUsage: 7z"
#ifdef _NO_CRYPTO
"r"
-#elif EXCLUDE_COM
+#else
+#ifndef EXTERNAL_CODECS
"a"
#endif
+#endif
" <command> [<switches>...] <archive_name> [<file_names>...]\n"
" [<@listfiles...>]\n"
"\n"
"<Commands>\n"
" a: Add files to archive\n"
+ " b: Benchmark\n"
" d: Delete files from archive\n"
" e: Extract files from archive (without using directory names)\n"
" l: List contents of archive\n"
@@ -151,6 +162,29 @@ static void ShowCopyrightAndHelp(CStdOutStream &s, bool needHelp)
s << kHelpString;
}
+#ifdef EXTERNAL_CODECS
+static void PrintString(CStdOutStream &stdStream, const AString &s, int size)
+{
+ int len = s.Length();
+ stdStream << s;
+ for (int i = len; i < size; i++)
+ stdStream << ' ';
+}
+#endif
+
+static void PrintString(CStdOutStream &stdStream, const UString &s, int size)
+{
+ int len = s.Length();
+ stdStream << s;
+ for (int i = len; i < size; i++)
+ stdStream << ' ';
+}
+
+static inline char GetHex(Byte value)
+{
+ return (char)((value < 10) ? ('0' + value) : ('A' + (value - 10)));
+}
+
int Main2(
#ifndef _WIN32
int numArguments, const char *arguments[]
@@ -187,9 +221,12 @@ int Main2(
return 0;
}
- #ifdef _WIN32
+ #if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES)
if (options.LargePages)
+ {
+ SetLargePageSize();
NSecurity::EnableLockMemoryPrivilege();
+ }
#endif
CStdOutStream &stdStream = options.StdOutMode ? g_StdErr : g_StdOut;
@@ -200,9 +237,145 @@ int Main2(
parser.Parse2(options);
+ CCodecs *codecs = new CCodecs;
+ CMyComPtr<
+ #ifdef EXTERNAL_CODECS
+ ICompressCodecsInfo
+ #else
+ IUnknown
+ #endif
+ > compressCodecsInfo = codecs;
+ HRESULT result = codecs->Load();
+ if (result != S_OK)
+ throw CSystemException(result);
+
bool isExtractGroupCommand = options.Command.IsFromExtractGroup();
- if(isExtractGroupCommand ||
- options.Command.CommandType == NCommandType::kList)
+ if (options.Command.CommandType == NCommandType::kInfo)
+ {
+ stdStream << endl << "Formats:" << endl;
+ int i;
+ for (i = 0; i < codecs->Formats.Size(); i++)
+ {
+ const CArcInfoEx &arc = codecs->Formats[i];
+ #ifdef EXTERNAL_CODECS
+ if (arc.LibIndex >= 0)
+ {
+ char s[32];
+ ConvertUInt64ToString(arc.LibIndex, s);
+ PrintString(stdStream, s, 2);
+ }
+ else
+ #endif
+ stdStream << " ";
+ stdStream << ' ';
+ stdStream << (char)(arc.UpdateEnabled ? 'C' : ' ');
+ stdStream << (char)(arc.KeepName ? 'K' : ' ');
+ stdStream << " ";
+ PrintString(stdStream, arc.Name, 6);
+ stdStream << " ";
+ UString s;
+ for (int t = 0; t < arc.Exts.Size(); t++)
+ {
+ const CArcExtInfo &ext = arc.Exts[t];
+ s += ext.Ext;
+ if (!ext.AddExt.IsEmpty())
+ {
+ s += L" (";
+ s += ext.AddExt;
+ s += L')';
+ }
+ s += L' ';
+ }
+ PrintString(stdStream, s, 14);
+ stdStream << " ";
+ const CByteBuffer &sig = arc.StartSignature;
+ for (size_t j = 0; j < sig.GetCapacity(); j++)
+ {
+ Byte b = sig[j];
+ if (b > 0x20 && b < 0x80)
+ {
+ stdStream << (char)b;
+ }
+ else
+ {
+ stdStream << GetHex((Byte)((b >> 4) & 0xF));
+ stdStream << GetHex((Byte)(b & 0xF));
+ }
+ stdStream << ' ';
+ }
+ stdStream << endl;
+ }
+ stdStream << endl << "Codecs:" << endl;
+
+ #ifdef EXTERNAL_CODECS
+ UINT32 numMethods;
+ if (codecs->GetNumberOfMethods(&numMethods) == S_OK)
+ for (UInt32 j = 0; j < numMethods; j++)
+ {
+ int libIndex = codecs->GetCodecLibIndex(j);
+ if (libIndex >= 0)
+ {
+ char s[32];
+ ConvertUInt64ToString(libIndex, s);
+ PrintString(stdStream, s, 2);
+ }
+ else
+ stdStream << " ";
+ stdStream << ' ';
+ stdStream << (char)(codecs->GetCodecEncoderIsAssigned(j) ? 'C' : ' ');
+ UInt64 id;
+ stdStream << " ";
+ HRESULT res = codecs->GetCodecId(j, id);
+ if (res != S_OK)
+ id = (UInt64)(Int64)-1;
+ char s[32];
+ ConvertUInt64ToString(id, s, 16);
+ PrintString(stdStream, s, 8);
+ stdStream << " ";
+ PrintString(stdStream, codecs->GetCodecName(j), 11);
+ stdStream << endl;
+ /*
+ if (res != S_OK)
+ throw "incorrect Codec ID";
+ */
+ }
+ #endif
+ return S_OK;
+ }
+ else if (options.Command.CommandType == NCommandType::kBenchmark)
+ {
+ if (options.Method.CompareNoCase(L"CRC") == 0)
+ {
+ HRESULT res = CrcBenchCon((FILE *)stdStream, options.NumIterations, options.NumThreads, options.DictionarySize);
+ if (res != S_OK)
+ {
+ if (res == S_FALSE)
+ {
+ stdStream << "\nCRC Error\n";
+ return NExitCode::kFatalError;
+ }
+ throw CSystemException(res);
+ }
+ }
+ else
+ {
+ HRESULT res = LzmaBenchCon(
+ #ifdef EXTERNAL_LZMA
+ codecs,
+ #endif
+ (FILE *)stdStream, options.NumIterations, options.NumThreads, options.DictionarySize);
+ if (res != S_OK)
+ {
+ if (res == S_FALSE)
+ {
+ stdStream << "\nDecoding Error\n";
+ return NExitCode::kFatalError;
+ }
+ throw CSystemException(res);
+ }
+ }
+ }
+ else if (isExtractGroupCommand || options.Command.CommandType == NCommandType::kList)
{
if(isExtractGroupCommand)
{
@@ -231,6 +404,7 @@ int Main2(
#endif
UString errorMessage;
HRESULT result = DecompressArchives(
+ codecs,
options.ArchivePathsSorted,
options.ArchivePathsFullSorted,
options.WildcardCensor.Pairs.Front().Head,
@@ -266,6 +440,7 @@ int Main2(
else
{
HRESULT result = ListArchives(
+ codecs,
options.ArchivePathsSorted,
options.ArchivePathsFullSorted,
options.WildcardCensor.Pairs.Front().Head,
@@ -303,7 +478,10 @@ int Main2(
CUpdateErrorInfo errorInfo;
- HRESULT result = UpdateArchive(options.WildcardCensor, uo,
+ if (!uo.Init(codecs, options.ArchiveName, options.ArcType))
+ throw "Unsupported archive type";
+ HRESULT result = UpdateArchive(codecs,
+ options.WildcardCensor, uo,
errorInfo, &openCallback, &callback);
int exitCode = NExitCode::kSuccess;
diff --git a/CPP/7zip/UI/Console/MainAr.cpp b/CPP/7zip/UI/Console/MainAr.cpp
index 4bdf813a..06f602ce 100755
--- a/CPP/7zip/UI/Console/MainAr.cpp
+++ b/CPP/7zip/UI/Console/MainAr.cpp
@@ -10,21 +10,11 @@
#include "Common/NewHandler.h"
#include "Common/Exception.h"
#include "Common/StringConvert.h"
-#ifdef _WIN32
-#include "Common/Alloc.h"
-#endif
#include "../Common/ExitCode.h"
#include "../Common/ArchiveCommandLine.h"
#include "ConsoleClose.h"
-#ifdef CRC_GENERATE_TABLE
-extern "C"
-{
- #include "../../../../C/7zCrc.h"
-}
-#endif
-
using namespace NWindows;
CStdOutStream *g_StdStream = 0;
@@ -66,9 +56,6 @@ int numArguments, const char *arguments[]
#endif
)
{
- #ifdef CRC_GENERATE_TABLE
- CrcGenerateTable();
- #endif
g_StdStream = &g_StdOut;
#ifdef _UNICODE
if (!IsItWindowsNT())
@@ -80,10 +67,6 @@ int numArguments, const char *arguments[]
g_IsNT = IsItWindowsNT();
#endif
- #ifdef _WIN32
- SetLargePageSize();
- #endif
-
// setlocale(LC_COLLATE, ".OCP");
NConsoleClose::CCtrlHandlerSetter ctrlHandlerSetter;
int res = 0;
diff --git a/CPP/7zip/UI/Console/PercentPrinter.cpp b/CPP/7zip/UI/Console/PercentPrinter.cpp
index ec87b5d4..d6324303 100755
--- a/CPP/7zip/UI/Console/PercentPrinter.cpp
+++ b/CPP/7zip/UI/Console/PercentPrinter.cpp
@@ -75,7 +75,7 @@ void CPercentPrinter::RePrintRatio()
m_NumExtraChars = extraSize;
for (; size < m_NumExtraChars; size++)
*p++ = ' ';
- strcpy(p, s);
+ MyStringCopy(p, s);
(*OutStream) << fullString;
OutStream->Flush();
m_PrevValue = m_CurValue;
diff --git a/CPP/7zip/UI/Console/makefile b/CPP/7zip/UI/Console/makefile
index 54e83ea1..466e5c56 100755
--- a/CPP/7zip/UI/Console/makefile
+++ b/CPP/7zip/UI/Console/makefile
@@ -1,6 +1,13 @@
PROG = 7z.exe
LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib
-CFLAGS = $(CFLAGS) -I ../../../ -DCOMPRESS_MT -DWIN_LONG_PATH
+CFLAGS = $(CFLAGS) -I ../../../ \
+ -DCOMPRESS_MT \
+ -DWIN_LONG_PATH \
+ -DEXTERNAL_LZMA \
+ -DEXTERNAL_CODECS \
+ -DBREAK_HANDLER \
+ -DBENCH_MT \
+ -D_7ZIP_LARGE_PAGES \
CONSOLE_OBJS = \
$O\ConsoleClose.obj \
@@ -14,8 +21,8 @@ CONSOLE_OBJS = \
$O\UserInputUtils.obj \
COMMON_OBJS = \
- $O\Alloc.obj \
$O\CommandLineParser.obj \
+ $O\CRC.obj \
$O\IntToString.obj \
$O\ListFileUtils.obj \
$O\NewHandler.obj \
@@ -49,11 +56,11 @@ UI_COMMON_OBJS = \
$O\ArchiveCommandLine.obj \
$O\ArchiveExtractCallback.obj \
$O\ArchiveOpenCallback.obj \
- $O\ArchiverInfo.obj \
$O\DefaultName.obj \
$O\EnumDirItems.obj \
$O\Extract.obj \
$O\ExtractingFilePath.obj \
+ $O\LoadCodecs.obj \
$O\OpenArchive.obj \
$O\PropIDUtils.obj \
$O\SetProperties.obj \
@@ -66,6 +73,14 @@ UI_COMMON_OBJS = \
$O\UpdateProduce.obj \
$O\WorkDir.obj \
+LZMA_BENCH_OBJS = \
+ $O\LzmaBench.obj \
+ $O\LzmaBenchCon.obj \
+
+C_OBJS = \
+ $O\Alloc.obj \
+
+!include "../../Crc2.mak"
OBJS = \
$O\StdAfx.obj \
@@ -75,6 +90,9 @@ OBJS = \
$(7ZIP_COMMON_OBJS) \
$(UI_COMMON_OBJS) \
$O\CopyCoder.obj \
+ $(LZMA_BENCH_OBJS) \
+ $(C_OBJS) \
+ $(CRC_OBJS) \
$O\resource.res
!include "../../../Build.mak"
@@ -91,3 +109,8 @@ $(UI_COMMON_OBJS): ../Common/$(*B).cpp
$(COMPL)
$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
$(COMPL)
+$(LZMA_BENCH_OBJS): ../../Compress/LZMA_Alone/$(*B).cpp
+ $(COMPL)
+$(C_OBJS): ../../../../C/$(*B).c
+ $(COMPL_O2)
+!include "../../Crc.mak"
diff --git a/CPP/7zip/UI/Explorer/ContextMenu.cpp b/CPP/7zip/UI/Explorer/ContextMenu.cpp
index fd40add5..01305fba 100755
--- a/CPP/7zip/UI/Explorer/ContextMenu.cpp
+++ b/CPP/7zip/UI/Explorer/ContextMenu.cpp
@@ -260,13 +260,45 @@ static bool MyInsertMenu(CMenu &menu, int pos, UINT id, const UString &s)
return menu.InsertItem(pos, true, menuItem);
}
+static const wchar_t *kArcExts[] =
+{
+ L"7z",
+ L"bz2",
+ L"gz",
+ L"rar",
+ L"zip"
+};
+
+static bool IsItArcExt(const UString &ext2)
+{
+ UString ext = ext2;
+ ext.MakeLower();
+ for (int i = 0; i < sizeof(kArcExts) / sizeof(kArcExts[0]); i++)
+ if (ext.Compare(kArcExts[i]) == 0)
+ return true;
+ return false;
+}
+
static UString GetSubFolderNameForExtract(const UString &archiveName)
{
int dotPos = archiveName.ReverseFind(L'.');
if (dotPos < 0)
return archiveName + UString(L"~");
+ const UString ext = archiveName.Mid(dotPos + 1);
UString res = archiveName.Left(dotPos);
res.TrimRight();
+ dotPos = res.ReverseFind(L'.');
+ if (dotPos > 0)
+ {
+ const UString ext2 = res.Mid(dotPos + 1);
+ if (ext.CompareNoCase(L"rar") == 0 &&
+ (ext2.CompareNoCase(L"part001") == 0 ||
+ ext2.CompareNoCase(L"part01") == 0 ||
+ ext2.CompareNoCase(L"part1") == 0) ||
+ IsItArcExt(ext2) && ext.CompareNoCase(L"001") == 0)
+ res = res.Left(dotPos);
+ res.TrimRight();
+ }
return res;
}
@@ -279,6 +311,25 @@ static UString GetReducedString(const UString &s)
return s.Left(kFirstPartSize) + UString(L" ... ") + s.Right(kMaxSize - kFirstPartSize);
}
+static const wchar_t *kExtractExludeExtensions[] =
+{
+ L"txt", L"htm", L"html", L"xml", L"doc", L"xls",
+ L"bmp", L"gif", L"jpeg", L"jpg"
+};
+
+static bool DoNeedExtract(const UString &name)
+{
+ int extPos = name.ReverseFind('.');
+ if (extPos < 0)
+ return true;
+ UString ext = name.Mid(extPos + 1);
+ ext.MakeLower();
+ for (int i = 0; i < sizeof(kExtractExludeExtensions) / sizeof(kExtractExludeExtensions[0]); i++)
+ if (ext.Compare(kExtractExludeExtensions[i]) == 0)
+ return false;
+ return true;
+}
+
STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
UINT commandIDFirst, UINT commandIDLast, UINT flags)
{
@@ -332,7 +383,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
NFile::NFind::CFileInfoW fileInfo;
if (!NFile::NFind::FindFile(fileName, fileInfo))
return E_FAIL;
- if (!fileInfo.IsDirectory())
+ if (!fileInfo.IsDirectory() && DoNeedExtract(fileInfo.Name))
{
// Open
if ((contextMenuFlags & NContextMenuFlags::kOpen) != 0)
@@ -347,17 +398,17 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
if(_fileNames.Size() > 0 && currentCommandID + 10 <= commandIDLast)
{
- bool thereAreFolders = false;
+ bool needExtract = false;
for(int i = 0; i < _fileNames.Size(); i++)
{
NFile::NFind::CFileInfoW fileInfo;
if (!NFile::NFind::FindFile(_fileNames[i], fileInfo))
return E_FAIL;
- if (fileInfo.IsDirectory())
- thereAreFolders = true;
+ if (!fileInfo.IsDirectory() && DoNeedExtract(fileInfo.Name))
+ needExtract = true;
}
const UString &fileName = _fileNames.Front();
- if (!thereAreFolders)
+ if (needExtract)
{
UString folderPrefix;
NFile::NDirectory::GetOnlyDirPrefix(fileName, folderPrefix);
diff --git a/CPP/7zip/UI/Explorer/Explorer.dsp b/CPP/7zip/UI/Explorer/Explorer.dsp
index c395c6d2..724ed0d9 100755
--- a/CPP/7zip/UI/Explorer/Explorer.dsp
+++ b/CPP/7zip/UI/Explorer/Explorer.dsp
@@ -45,7 +45,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "NEW_FOLDER_INTERFACE" /Yu"StdAfx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
@@ -72,7 +72,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "NEW_FOLDER_INTERFACE" /Yu"StdAfx.h" /FD /GZ /c
+# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"
@@ -99,7 +99,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "_MBCS" /Yu"StdAfx.h" /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "NEW_FOLDER_INTERFACE" /Yu"StdAfx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
@@ -128,7 +128,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
-# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "NEW_FOLDER_INTERFACE" /Yu"StdAfx.h" /FD /GZ /c
+# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "EXPLORER_EXPORTS" /D "LANG" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"
@@ -206,14 +206,6 @@ SOURCE=..\Common\ArchiveOpenCallback.h
# End Source File
# Begin Source File
-SOURCE=..\Common\ArchiverInfo.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ArchiverInfo.h
-# End Source File
-# Begin Source File
-
SOURCE=..\Common\CompressCall.cpp
# End Source File
# Begin Source File
@@ -250,6 +242,14 @@ SOURCE=..\Common\HandlerLoader.h
# End Source File
# Begin Source File
+SOURCE=..\Common\LoadCodecs.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\LoadCodecs.h
+# End Source File
+# Begin Source File
+
SOURCE=..\Common\OpenArchive.cpp
# End Source File
# Begin Source File
@@ -473,20 +473,71 @@ SOURCE=..\..\FileManager\RegistryUtils.cpp
SOURCE=..\..\FileManager\RegistryUtils.h
# End Source File
# End Group
-# Begin Group "SDK"
+# Begin Group "7-zip common"
# PROP Default_Filter ""
-# Begin Group "Common"
+# Begin Source File
+
+SOURCE=..\..\Common\FilePathAutoRename.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\FilePathAutoRename.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\FileStreams.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\FileStreams.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\StreamUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\StreamUtils.h
+# End Source File
+# End Group
+# Begin Group "Compress"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\Copy\CopyCoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Copy\CopyCoder.h
+# End Source File
+# End Group
+# Begin Group "C"
# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\..\..\Common\Alloc.cpp
+SOURCE=..\..\..\..\C\Alloc.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Alloc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Sort.c
+# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\Alloc.h
+SOURCE=..\..\..\..\C\Sort.h
# End Source File
+# End Group
+# Begin Group "Common"
+
+# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\Common\IntToString.cpp
@@ -736,60 +787,6 @@ SOURCE=..\..\..\Windows\Window.cpp
SOURCE=..\..\..\Windows\Window.h
# End Source File
# End Group
-# End Group
-# Begin Group "7-zip common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Common\FilePathAutoRename.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\FilePathAutoRename.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\FileStreams.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\FileStreams.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\StreamUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Common\StreamUtils.h
-# End Source File
-# End Group
-# Begin Group "Compress"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Compress\Copy\CopyCoder.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Compress\Copy\CopyCoder.h
-# End Source File
-# End Group
-# Begin Group "C"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\..\..\C\Sort.c
-# SUBTRACT CPP /YX /Yc /Yu
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\..\C\Sort.h
-# End Source File
-# End Group
# Begin Source File
SOURCE=".\7-zip.dll.manifest"
diff --git a/CPP/7zip/UI/Explorer/SystemPage/SystemPage.h b/CPP/7zip/UI/Explorer/SystemPage/SystemPage.h
index a7de7c79..75130189 100755
--- a/CPP/7zip/UI/Explorer/SystemPage/SystemPage.h
+++ b/CPP/7zip/UI/Explorer/SystemPage/SystemPage.h
@@ -6,12 +6,12 @@
#include "Windows/Control/PropertyPage.h"
#include "Windows/Control/ListView.h"
-#include "../../Common/ArchiverInfo.h"
+#include "../../Common/LoadCodecs.h"
class CSystemPage: public NWindows::NControl::CPropertyPage
{
bool _initMode;
- CObjectVector<CArchiverInfo> m_Archivers;
+ CObjectVector<CArcInfoEx> m_Archivers;
NWindows::NControl::CListView m_ListView;
public:
virtual bool OnInit();
diff --git a/CPP/7zip/UI/Explorer/makefile b/CPP/7zip/UI/Explorer/makefile
index 0fcc57e4..21ace854 100755
--- a/CPP/7zip/UI/Explorer/makefile
+++ b/CPP/7zip/UI/Explorer/makefile
@@ -4,7 +4,8 @@ LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib htmlhelp.lib shell32.lib com
CFLAGS = $(CFLAGS) -I ../../../ \
-DLANG \
-DNEW_FOLDER_INTERFACE \
- -DWIN_LONG_PATH
+ -DWIN_LONG_PATH \
+ -DEXTERNAL_CODECS \
EXPLORER_OBJS = \
$O\DllExports.obj \
@@ -14,7 +15,6 @@ EXPLORER_OBJS = \
$O\RegistryContextMenu.obj \
COMMON_OBJS = \
- $O\Alloc.obj \
$O\IntToString.obj \
$O\Lang.obj \
$O\ListFileUtils.obj \
@@ -58,11 +58,11 @@ UI_COMMON_OBJS = \
$O\ArchiveExtractCallback.obj \
$O\ArchiveName.obj \
$O\ArchiveOpenCallback.obj \
- $O\ArchiverInfo.obj \
$O\CompressCall.obj \
$O\DefaultName.obj \
$O\EnumDirItems.obj \
$O\ExtractingFilePath.obj \
+ $O\LoadCodecs.obj \
$O\OpenArchive.obj \
$O\PropIDUtils.obj \
$O\SortUtils.obj \
@@ -91,6 +91,7 @@ FM_COMMON_OBJS = \
$O\RegistryUtils.obj \
C_OBJS = \
+ $O\Alloc.obj \
$O\Sort.obj \
OBJS = \
diff --git a/CPP/7zip/UI/Far/ExtractEngine.cpp b/CPP/7zip/UI/Far/ExtractEngine.cpp
index e85df5e1..15548949 100755
--- a/CPP/7zip/UI/Far/ExtractEngine.cpp
+++ b/CPP/7zip/UI/Far/ExtractEngine.cpp
@@ -134,10 +134,14 @@ STDMETHODIMP CExtractCallBackImp::SetOperationResult(INT32 operationResult, bool
idMessage = NMessageID::kExtractUnsupportedMethod;
break;
case NArchive::NExtract::NOperationResult::kCRCError:
- idMessage = NMessageID::kExtractCRCFailed;
+ idMessage = encrypted ?
+ NMessageID::kExtractCRCFailedEncrypted :
+ NMessageID::kExtractCRCFailed;
break;
case NArchive::NExtract::NOperationResult::kDataError:
- idMessage = NMessageID::kExtractDataError;
+ idMessage = encrypted ?
+ NMessageID::kExtractDataErrorEncrypted :
+ NMessageID::kExtractDataError;
break;
default:
return E_FAIL;
diff --git a/CPP/7zip/UI/Far/Far.dsp b/CPP/7zip/UI/Far/Far.dsp
index 47c44c69..fa540ed2 100755
--- a/CPP/7zip/UI/Far/Far.dsp
+++ b/CPP/7zip/UI/Far/Far.dsp
@@ -43,7 +43,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FAR_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FAR_EXPORTS" /Yu"StdAfx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FAR_EXPORTS" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
@@ -70,7 +70,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FAR_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FAR_EXPORTS" /Yu"StdAfx.h" /FD /GZ /c
+# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FAR_EXPORTS" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"
@@ -118,14 +118,6 @@ SOURCE=.\StdAfx.h
# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\..\..\Common\Alloc.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\..\Common\Alloc.h
-# End Source File
-# Begin Source File
-
SOURCE=..\..\..\Common\IntToString.cpp
# End Source File
# Begin Source File
@@ -366,14 +358,6 @@ SOURCE=..\Common\ArchiveOpenCallback.h
# End Source File
# Begin Source File
-SOURCE=..\Common\ArchiverInfo.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\ArchiverInfo.h
-# End Source File
-# Begin Source File
-
SOURCE=..\Common\DefaultName.cpp
# End Source File
# Begin Source File
@@ -410,6 +394,14 @@ SOURCE=..\Common\HandlerLoader.h
# End Source File
# Begin Source File
+SOURCE=..\Common\LoadCodecs.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\LoadCodecs.h
+# End Source File
+# Begin Source File
+
SOURCE=..\Common\OpenArchive.cpp
# End Source File
# Begin Source File
@@ -557,5 +549,27 @@ SOURCE=..\..\Common\StreamUtils.cpp
SOURCE=..\..\Common\StreamUtils.h
# End Source File
# End Group
+# Begin Group "C"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Alloc.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Alloc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Sort.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Sort.h
+# End Source File
+# End Group
# End Target
# End Project
diff --git a/CPP/7zip/UI/Far/FarUtils.cpp b/CPP/7zip/UI/Far/FarUtils.cpp
index abbb6817..c4a30524 100755
--- a/CPP/7zip/UI/Far/FarUtils.cpp
+++ b/CPP/7zip/UI/Far/FarUtils.cpp
@@ -353,7 +353,7 @@ void CScreenRestorer::Restore()
static AString DWORDToString(DWORD number)
{
char buffer[32];
- ultoa(number, buffer, 10);
+ _ultoa(number, buffer, 10);
return buffer;
}
diff --git a/CPP/7zip/UI/Far/Main.cpp b/CPP/7zip/UI/Far/Main.cpp
index a7994b6d..70d9117c 100755
--- a/CPP/7zip/UI/Far/Main.cpp
+++ b/CPP/7zip/UI/Far/Main.cpp
@@ -355,9 +355,6 @@ HRESULT OpenArchive(const CSysString &fileName,
IArchiveOpenCallback *openArchiveCallback)
{
HRESULT OpenArchive(const CSysString &fileName,
- #ifndef EXCLUDE_COM
- HMODULE *module,
- #endif
IInArchive **archive,
CArchiverInfo &archiverInfoResult,
IArchiveOpenCallback *openArchiveCallback);
@@ -451,7 +448,7 @@ HANDLE WINAPI OpenPlugin(int openFrom, int item)
MY_TRY_BEGIN;
if(openFrom == OPEN_COMMANDLINE)
{
- CSysString fileName = (const char *)item;
+ CSysString fileName = (const char *)(UINT_PTR)item;
if(fileName.IsEmpty())
return INVALID_HANDLE_VALUE;
if (fileName.Length() >= 2 &&
@@ -478,7 +475,7 @@ HANDLE WINAPI OpenPlugin(int openFrom, int item)
throw 142134;
if (CompressFiles(pluginPanelItem) == S_OK)
{
- int t = g_StartupInfo.ControlClearPanelSelection();
+ /* int t = */ g_StartupInfo.ControlClearPanelSelection();
g_StartupInfo.ControlRequestActivePanel(FCTL_UPDATEPANEL, NULL);
g_StartupInfo.ControlRequestActivePanel(FCTL_REDRAWPANEL, NULL);
g_StartupInfo.ControlRequestActivePanel(FCTL_UPDATEANOTHERPANEL, NULL);
@@ -554,7 +551,7 @@ void WINAPI GetPluginInfo(struct PluginInfo *info)
MY_TRY_END1("GetPluginInfo");
}
-int WINAPI Configure(int itemNumber)
+int WINAPI Configure(int /* itemNumber */)
{
MY_TRY_BEGIN;
diff --git a/CPP/7zip/UI/Far/Messages.h b/CPP/7zip/UI/Far/Messages.h
index 8b6e2a49..7a36ab30 100755
--- a/CPP/7zip/UI/Far/Messages.h
+++ b/CPP/7zip/UI/Far/Messages.h
@@ -79,6 +79,8 @@ enum EEnum
kExtractUnsupportedMethod,
kExtractCRCFailed,
kExtractDataError,
+ kExtractCRCFailedEncrypted,
+ kExtractDataErrorEncrypted,
kOverwriteTitle,
kOverwriteMessage1,
diff --git a/CPP/7zip/UI/Far/Plugin.cpp b/CPP/7zip/UI/Far/Plugin.cpp
index 0d4b150e..fde53756 100755
--- a/CPP/7zip/UI/Far/Plugin.cpp
+++ b/CPP/7zip/UI/Far/Plugin.cpp
@@ -79,7 +79,7 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UINT32 itemIndex)
throw 272340;
CSysString oemString = UnicodeStringToMultiByte(propVariant.bstrVal, CP_OEMCP);
- strcpy(panelItem.FindData.cFileName, oemString);
+ MyStringCopy(panelItem.FindData.cFileName, (const char *)oemString);
panelItem.FindData.cAlternateFileName[0] = 0;
if (_folder->GetProperty(itemIndex, kpidAttributes, &propVariant) != S_OK)
@@ -204,7 +204,7 @@ void CPlugin::EnterToDirectory(const UString &aDirName)
_folder = newFolder;
}
-int CPlugin::SetDirectory(const char *aszDir, int opMode)
+int CPlugin::SetDirectory(const char *aszDir, int /* opMode */)
{
UString path = MultiByteToUnicodeString(aszDir, CP_OEMCP);
if (path == L"\\")
@@ -361,12 +361,14 @@ static int FindPropertyInfo(PROPID propID)
*/
// char *g_Titles[] = { "a", "f", "v" };
-static void SmartAddToString(AString &aDestString, const char *aSrcString)
+/*
+static void SmartAddToString(AString &destString, const char *srcString)
{
- if (!aDestString.IsEmpty())
- aDestString += ',';
- aDestString += aSrcString;
+ if (!destString.IsEmpty())
+ destString += ',';
+ destString += srcString;
}
+*/
/*
void CPlugin::AddColumn(PROPID propID)
@@ -401,10 +403,10 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
UINT codePage = ::AreFileApisANSI() ? CP_ACP : CP_OEMCP;
- strcpy(m_FileNameBuffer, UnicodeStringToMultiByte(m_FileName, codePage));
+ MyStringCopy(m_FileNameBuffer, (const char *)UnicodeStringToMultiByte(m_FileName, codePage));
info->HostFile = m_FileNameBuffer; // test it it is not static
- strcpy(m_CurrentDirBuffer, UnicodeStringToMultiByte(m_CurrentDir, CP_OEMCP));
+ MyStringCopy(m_CurrentDirBuffer, (const char *)UnicodeStringToMultiByte(m_CurrentDir, CP_OEMCP));
info->CurDir = m_CurrentDirBuffer;
info->Format = kPluginFormatName;
@@ -429,15 +431,15 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
m_PannelTitle += m_CurrentDir;
}
- strcpy(m_PannelTitleBuffer, UnicodeStringToMultiByte(m_PannelTitle, CP_OEMCP));
+ MyStringCopy(m_PannelTitleBuffer, (const char *)UnicodeStringToMultiByte(m_PannelTitle, CP_OEMCP));
info->PanelTitle = m_PannelTitleBuffer;
memset(m_InfoLines,0,sizeof(m_InfoLines));
- strcpy(m_InfoLines[0].Text,"");
+ MyStringCopy(m_InfoLines[0].Text,"");
m_InfoLines[0].Separator = TRUE;
- strcpy(m_InfoLines[1].Text, g_StartupInfo.GetMsgString(NMessageID::kArchiveType));
- strcpy(m_InfoLines[1].Data, UnicodeStringToMultiByte(_archiveTypeName, CP_OEMCP));
+ MyStringCopy(m_InfoLines[1].Text, g_StartupInfo.GetMsgString(NMessageID::kArchiveType));
+ MyStringCopy(m_InfoLines[1].Data, (const char *)UnicodeStringToMultiByte(_archiveTypeName, CP_OEMCP));
int numItems = 2;
UINT32 numProps;
@@ -456,19 +458,19 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
if (index < 0)
{
if (name != 0)
- strcpy(item.Text, UnicodeStringToMultiByte(
+ MyStringCopy(item.Text, (const char *)UnicodeStringToMultiByte(
(const wchar_t *)name, CP_OEMCP));
else
- strcpy(item.Text, "");
+ MyStringCopy(item.Text, "");
}
else
- strcpy(item.Text, g_StartupInfo.GetMsgString(kPROPIDToName[index].PluginID));
+ MyStringCopy(item.Text, g_StartupInfo.GetMsgString(kPROPIDToName[index].PluginID));
NCOM::CPropVariant propVariant;
if (m_ArchiveHandler->GetArchiveProperty(propID, &propVariant) != S_OK)
continue;
CSysString s = ConvertPropertyToString2(propVariant, propID);
- strcpy(item.Data, s);
+ MyStringCopy(item.Data, (const char *)s);
numItems++;
}
}
@@ -577,8 +579,6 @@ HRESULT CPlugin::ShowAttributesWindow()
}
*/
- const int kPathIndex = 2;
- const int kOkButtonIndex = 4;
int size = 2;
CRecordVector<CInitDialogItem> initDialogItems;
@@ -637,7 +637,7 @@ HRESULT CPlugin::ShowAttributesWindow()
for (i = 0; i < numLines; i++)
{
FarDialogItem &dialogItem = dialogItems[1 + i * 2];
- int len = strlen(dialogItem.Data);
+ int len = (int)strlen(dialogItem.Data);
if (len > maxLen)
maxLen = len;
}
@@ -646,7 +646,7 @@ HRESULT CPlugin::ShowAttributesWindow()
for (i = 0; i < numLines; i++)
{
FarDialogItem &dialogItem = dialogItems[1 + i * 2 + 1];
- int len = strlen(dialogItem.Data);
+ int len = (int)strlen(dialogItem.Data);
if (len > maxLen2)
maxLen2 = len;
dialogItem.X1 = maxLen + kSpace;
@@ -657,7 +657,7 @@ HRESULT CPlugin::ShowAttributesWindow()
aFirstDialogItem.Y2 = size - 2;
aFirstDialogItem.X2 = xSize - 4;
- int askCode = g_StartupInfo.ShowDialog(xSize, size, NULL, &dialogItems.Front(), numDialogItems);
+ /* int askCode = */ g_StartupInfo.ShowDialog(xSize, size, NULL, &dialogItems.Front(), numDialogItems);
return S_OK;
}
diff --git a/CPP/7zip/UI/Far/Plugin.h b/CPP/7zip/UI/Far/Plugin.h
index 0b617cfb..736fc7d0 100755
--- a/CPP/7zip/UI/Far/Plugin.h
+++ b/CPP/7zip/UI/Far/Plugin.h
@@ -9,7 +9,6 @@
#include "Windows/FileFind.h"
#include "Windows/PropVariant.h"
-#include "../Common/ArchiverInfo.h"
#include "../Agent/IFolderArchive.h"
#include "FarUtils.h"
diff --git a/CPP/7zip/UI/Far/PluginDelete.cpp b/CPP/7zip/UI/Far/PluginDelete.cpp
index 6a969c15..95e43a36 100755
--- a/CPP/7zip/UI/Far/PluginDelete.cpp
+++ b/CPP/7zip/UI/Far/PluginDelete.cpp
@@ -89,7 +89,8 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems,
CRecordVector<UINT32> indices;
indices.Reserve(numItems);
- for(int i = 0; i < numItems; i++)
+ int i;
+ for(i = 0; i < numItems; i++)
indices.Add(panelItems[i].UserData);
////////////////////////////
diff --git a/CPP/7zip/UI/Far/PluginWrite.cpp b/CPP/7zip/UI/Far/PluginWrite.cpp
index d6730985..a159a476 100755
--- a/CPP/7zip/UI/Far/PluginWrite.cpp
+++ b/CPP/7zip/UI/Far/PluginWrite.cpp
@@ -80,7 +80,8 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
ReadCompressionInfo(compressionInfo);
int methodIndex = 0;
- for (int i = sizeof(g_MethodMap) / sizeof(g_MethodMap[0]) - 1; i >= 0; i--)
+ int i;
+ for (i = sizeof(g_MethodMap) / sizeof(g_MethodMap[0]) - 1; i >= 0; i--)
if (compressionInfo.Level >= g_MethodMap[i])
{
methodIndex = i;
@@ -226,7 +227,7 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
&fileNamePointers.Front(), fileNamePointers.Size());
BYTE actionSetByte[NUpdateArchive::NPairState::kNumValues];
for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
- actionSetByte[i] = actionSet->StateActions[i];
+ actionSetByte[i] = (BYTE)actionSet->StateActions[i];
CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp;
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
@@ -236,8 +237,7 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
if (SetOutProperties(outArchive, compressionInfo.Level) != S_OK)
return NFileOperationReturnCode::kError;
- result = outArchive->DoOperation(NULL, NULL,
- tempFileName, actionSetByte, NULL, updateCallback);
+ result = outArchive->DoOperation2(tempFileName, actionSetByte, NULL, updateCallback);
updateCallback.Release();
outArchive.Release();
@@ -332,7 +332,8 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
return E_FAIL;
UStringVector fileNames;
- for(int i = 0; i < pluginPanelItems.Size(); i++)
+ int i;
+ for(i = 0; i < pluginPanelItems.Size(); i++)
{
const PluginPanelItem &panelItem = pluginPanelItems[i];
CSysString fullName;
@@ -353,23 +354,23 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
int archiverIndex = 0;
- CObjectVector<CArchiverInfo> archiverInfoList;
+ CCodecs *codecs = new CCodecs;
+ CMyComPtr<ICompressCodecsInfo> compressCodecsInfo = codecs;
+ if (codecs->Load() != S_OK)
+ throw "Can't load 7-Zip codecs";
{
- CObjectVector<CArchiverInfo> fullArchiverInfoList;
- ReadArchiverInfoList(fullArchiverInfoList);
- for (int i = 0; i < fullArchiverInfoList.Size(); i++)
+ for (int i = 0; i < codecs->Formats.Size(); i++)
{
- const CArchiverInfo &archiverInfo = fullArchiverInfoList[i];
- if (archiverInfo.UpdateEnabled)
+ const CArcInfoEx &arcInfo = codecs->Formats[i];
+ if (arcInfo.UpdateEnabled)
{
- if (archiverInfo.Name.CompareNoCase(compressionInfo.ArchiveType) == 0)
- archiverIndex = archiverInfoList.Size();
- archiverInfoList.Add(archiverInfo);
+ if (archiverIndex == -1)
+ archiverIndex = i;
+ if (arcInfo.Name.CompareNoCase(compressionInfo.ArchiveType) == 0)
+ archiverIndex = i;
}
}
}
- if (archiverInfoList.IsEmpty())
- throw "There is no update achivers";
UString resultPath;
@@ -392,10 +393,10 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
UString archiveNameSrc = resultPath;
UString archiveName = archiveNameSrc;
- const CArchiverInfo &archiverInfo = archiverInfoList[archiverIndex];
+ const CArcInfoEx &arcInfo = codecs->Formats[archiverIndex];
int prevFormat = archiverIndex;
- if (!archiverInfo.KeepName)
+ if (!arcInfo.KeepName)
{
int dotPos = archiveName.ReverseFind('.');
int slashPos = MyMax(archiveName.ReverseFind('\\'), archiveName.ReverseFind('/'));
@@ -403,7 +404,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
archiveName = archiveName.Left(dotPos);
}
archiveName += L'.';
- archiveName += archiverInfo.GetMainExtension();
+ archiveName += arcInfo.GetMainExt();
const CActionSet *actionSet = &kAddActionSet;
@@ -417,14 +418,15 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
const int kMethodRadioIndex = kArchiveNameIndex + 2;
const int kModeRadioIndex = kMethodRadioIndex + 7;
- const CArchiverInfo &archiverInfo = archiverInfoList[archiverIndex];
+ const CArcInfoEx &arcInfo = codecs->Formats[archiverIndex];
char updateAddToArchiveString[512];
sprintf(updateAddToArchiveString,
- g_StartupInfo.GetMsgString(NMessageID::kUpdateAddToArchive), GetSystemString(archiverInfo.Name), CP_OEMCP);
+ g_StartupInfo.GetMsgString(NMessageID::kUpdateAddToArchive), GetSystemString(arcInfo.Name), CP_OEMCP);
int methodIndex = 0;
- for (int i = sizeof(g_MethodMap) / sizeof(g_MethodMap[0]) - 1; i >= 0; i--)
+ int i;
+ for (i = sizeof(g_MethodMap) / sizeof(g_MethodMap[0]) - 1; i >= 0; i--)
if (compressionInfo.Level >= g_MethodMap[i])
{
methodIndex = i;
@@ -507,20 +509,27 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
if (askCode == kSelectarchiverButtonIndex)
{
+ CIntVector indices;
CSysStringVector archiverNames;
- for(int i = 0; i < archiverInfoList.Size(); i++)
- archiverNames.Add(GetSystemString(archiverInfoList[i].Name,
- CP_OEMCP));
+ for(int i = 0; i < codecs->Formats.Size(); i++)
+ {
+ const CArcInfoEx &arc = codecs->Formats[i];
+ if (arc.UpdateEnabled)
+ {
+ indices.Add(i);
+ archiverNames.Add(GetSystemString(arc.Name, CP_OEMCP));
+ }
+ }
int index = g_StartupInfo.Menu(FMENU_AUTOHIGHLIGHT,
g_StartupInfo.GetMsgString(NMessageID::kUpdateSelectArchiverMenuTitle),
NULL, archiverNames, archiverIndex);
if(index >= 0)
{
- const CArchiverInfo &prevArchiverInfo = archiverInfoList[prevFormat];
+ const CArcInfoEx &prevArchiverInfo = codecs->Formats[prevFormat];
if (prevArchiverInfo.KeepName)
{
- const UString &prevExtension = prevArchiverInfo.GetMainExtension();
+ const UString &prevExtension = prevArchiverInfo.GetMainExt();
const int prevExtensionLen = prevExtension.Length();
if (archiveName.Right(prevExtensionLen).CompareNoCase(prevExtension) == 0)
{
@@ -535,12 +544,11 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
}
}
- archiverIndex = index;
- const CArchiverInfo &archiverInfo =
- archiverInfoList[archiverIndex];
+ archiverIndex = indices[index];
+ const CArcInfoEx &arcInfo = codecs->Formats[archiverIndex];
prevFormat = archiverIndex;
- if (archiverInfo.KeepName)
+ if (arcInfo.KeepName)
archiveName = archiveNameSrc;
else
{
@@ -550,7 +558,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
archiveName = archiveName.Left(dotPos);
}
archiveName += L'.';
- archiveName += archiverInfo.GetMainExtension();
+ archiveName += arcInfo.GetMainExt();
}
continue;
}
@@ -561,7 +569,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
break;
}
- const CArchiverInfo &archiverInfoFinal = archiverInfoList[archiverIndex];
+ const CArcInfoEx &archiverInfoFinal = codecs->Formats[archiverIndex];
compressionInfo.ArchiveType = archiverInfoFinal.Name;
SaveCompressionInfo(compressionInfo);
@@ -651,7 +659,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
&fileNamePointers.Front(), fileNamePointers.Size());
BYTE actionSetByte[NUpdateArchive::NPairState::kNumValues];
for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
- actionSetByte[i] = actionSet->StateActions[i];
+ actionSetByte[i] = (BYTE)actionSet->StateActions[i];
CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp;
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
@@ -662,8 +670,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
RINOK(SetOutProperties(outArchive, compressionInfo.Level));
HRESULT result = outArchive->DoOperation(
- GetUnicodeString(archiverInfoFinal.FilePath, CP_OEMCP),
- &archiverInfoFinal.ClassID,
+ codecs, archiverIndex,
tempFileName, actionSetByte,
NULL, updateCallback);
updateCallback.Release();
diff --git a/CPP/7zip/UI/Far/ProgressBox.cpp b/CPP/7zip/UI/Far/ProgressBox.cpp
index 64e0e09d..d708331a 100755
--- a/CPP/7zip/UI/Far/ProgressBox.cpp
+++ b/CPP/7zip/UI/Far/ProgressBox.cpp
@@ -12,7 +12,8 @@ using namespace NFar;
static void CopySpaces(char *destString, int numSpaces)
{
- for(int i = 0; i < numSpaces; i++)
+ int i;
+ for(i = 0; i < numSpaces; i++)
destString[i] = ' ';
destString[i] = '\0';
}
@@ -47,11 +48,11 @@ void CMessageBox::ShowProcessMessages(const char *messages[])
for (int i = 0; i < m_NumStrings; i++)
{
char *formattedMessage = formattedMessages[i];
- int len = strlen(messages[i]);
+ int len = (int)strlen(messages[i]);
int size = MyMax(m_Width, len);
int startPos = (size - len) / 2;
CopySpaces(formattedMessage, startPos);
- strcpy(formattedMessage + startPos, messages[i]);
+ MyStringCopy(formattedMessage + startPos, messages[i]);
CopySpaces(formattedMessage + startPos + len, size - startPos - len);
msgItems[kNumStaticStrings + i] = formattedMessage;
}
diff --git a/CPP/7zip/UI/Far/StdAfx.h b/CPP/7zip/UI/Far/StdAfx.h
index 0a7c347b..ae0e328a 100755
--- a/CPP/7zip/UI/Far/StdAfx.h
+++ b/CPP/7zip/UI/Far/StdAfx.h
@@ -3,6 +3,7 @@
#ifndef __STDAFX_H
#define __STDAFX_H
+#define _CRT_SECURE_NO_DEPRECATE
#include <windows.h>
#include <stdio.h>
diff --git a/CPP/7zip/UI/Far/UpdateCallback100.cpp b/CPP/7zip/UI/Far/UpdateCallback100.cpp
index f1a2946e..96699174 100755
--- a/CPP/7zip/UI/Far/UpdateCallback100.cpp
+++ b/CPP/7zip/UI/Far/UpdateCallback100.cpp
@@ -29,17 +29,17 @@ STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UINT64 *aCompleteValue)
return S_OK;
}
-STDMETHODIMP CUpdateCallback100Imp::CompressOperation(const wchar_t *aName)
+STDMETHODIMP CUpdateCallback100Imp::CompressOperation(const wchar_t* /* name */)
{
return S_OK;
}
-STDMETHODIMP CUpdateCallback100Imp::DeleteOperation(const wchar_t *aName)
+STDMETHODIMP CUpdateCallback100Imp::DeleteOperation(const wchar_t* /* name */)
{
return S_OK;
}
-STDMETHODIMP CUpdateCallback100Imp::OperationResult(INT32 aOperationResult)
+STDMETHODIMP CUpdateCallback100Imp::OperationResult(INT32 /* operationResult */)
{
return S_OK;
}
diff --git a/CPP/7zip/UI/Far/makefile b/CPP/7zip/UI/Far/makefile
index 4dbd1988..42c5a0a7 100755
--- a/CPP/7zip/UI/Far/makefile
+++ b/CPP/7zip/UI/Far/makefile
@@ -1,7 +1,9 @@
PROG = 7-ZipFar.dll
DEF_FILE = Far.def
LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib ole32.lib
-CFLAGS = $(CFLAGS) -I ../../../ -DWIN_LONG_PATH
+CFLAGS = $(CFLAGS) -I ../../../ \
+ -DWIN_LONG_PATH \
+ -DEXTERNAL_CODECS
FAR_OBJS = \
$O\CLSIDConst.obj \
@@ -18,7 +20,6 @@ FAR_OBJS = \
$O\UpdateCallback100.obj \
COMMON_OBJS = \
- $O\Alloc.obj \
$O\IntToString.obj \
$O\NewHandler.obj \
$O\String.obj \
@@ -47,10 +48,10 @@ WIN_OBJS = \
UI_COMMON_OBJS = \
$O\ArchiveExtractCallback.obj \
$O\ArchiveOpenCallback.obj \
- $O\ArchiverInfo.obj \
$O\DefaultName.obj \
$O\EnumDirItems.obj \
$O\ExtractingFilePath.obj \
+ $O\LoadCodecs.obj \
$O\OpenArchive.obj \
$O\PropIDUtils.obj \
$O\SortUtils.obj \
@@ -68,6 +69,7 @@ AGENT_OBJS = \
$O\UpdateCallbackAgent.obj \
C_OBJS = \
+ $O\Alloc.obj \
$O\Sort.obj \
OBJS = \
diff --git a/CPP/7zip/UI/GUI/CompressDialog.cpp b/CPP/7zip/UI/GUI/CompressDialog.cpp
index f49bb078..de182923 100755
--- a/CPP/7zip/UI/GUI/CompressDialog.cpp
+++ b/CPP/7zip/UI/GUI/CompressDialog.cpp
@@ -45,8 +45,8 @@ static CIDLangPair kIDLangPairs[] =
{ IDC_STATIC_COMPRESS_ORDER, 0x02000D0D },
{ IDC_STATIC_COMPRESS_MEMORY, 0x02000D0E },
{ IDC_STATIC_COMPRESS_MEMORY_DE, 0x02000D0F },
- { IDC_COMPRESS_SOLID, 0x02000D05 },
- { IDC_COMPRESS_MULTI_THREAD, 0x02000D09 },
+ { IDC_STATIC_COMPRESS_THREADS, 0x02000D12 },
+ { IDC_STATIC_COMPRESS_SOLID, 0x02000D13 },
{ IDC_STATIC_COMPRESS_VOLUME, 0x02000D40 },
{ IDC_STATIC_COMPRESS_PARAMETERS, 0x02000D06 },
@@ -221,38 +221,9 @@ static bool IsMethodSupportedBySfx(int methodID)
return false;
};
-#ifndef _WIN64
-typedef BOOL (WINAPI *GlobalMemoryStatusExP)(LPMEMORYSTATUSEX lpBuffer);
-#endif
-
-static UInt64 GetPhysicalRamSize()
-{
- MEMORYSTATUSEX stat;
- stat.dwLength = sizeof(stat);
- // return (128 << 20);
- #ifdef _WIN64
- if (!::GlobalMemoryStatusEx(&stat))
- return 0;
- return stat.ullTotalPhys;
- #else
- GlobalMemoryStatusExP globalMemoryStatusEx = (GlobalMemoryStatusExP)
- ::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")),
- "GlobalMemoryStatusEx");
- if (globalMemoryStatusEx != 0)
- if (globalMemoryStatusEx(&stat))
- return stat.ullTotalPhys;
- {
- MEMORYSTATUS stat;
- stat.dwLength = sizeof(stat);
- GlobalMemoryStatus(&stat);
- return stat.dwTotalPhys;
- }
- #endif
-}
-
static UInt64 GetMaxRamSizeForProgram()
{
- UInt64 physSize = GetPhysicalRamSize();
+ UInt64 physSize = NSystem::GetRamSize();
const UInt64 kMinSysSize = (1 << 24);
if (physSize <= kMinSysSize)
physSize = 0;
@@ -282,6 +253,8 @@ bool CCompressDialog::OnInit()
m_Method.Attach(GetItem(IDC_COMPRESS_COMBO_METHOD));
m_Dictionary.Attach(GetItem(IDC_COMPRESS_COMBO_DICTIONARY));
m_Order.Attach(GetItem(IDC_COMPRESS_COMBO_ORDER));
+ m_Solid.Attach(GetItem(IDC_COMPRESS_COMBO_SOLID));
+ m_NumThreads.Attach(GetItem(IDC_COMPRESS_COMBO_THREADS));
m_UpdateMode.Attach(GetItem(IDC_COMPRESS_COMBO_UPDATE_MODE));
m_Volume.Attach(GetItem(IDC_COMPRESS_COMBO_VOLUME));
@@ -299,7 +272,7 @@ bool CCompressDialog::OnInit()
int i;
for(i = 0; i < m_ArchiverInfoList.Size(); i++)
{
- const CArchiverInfo &ai = m_ArchiverInfoList[i];
+ const CArcInfoEx &ai = m_ArchiverInfoList[i];
m_Format.AddString(ai.Name);
if (ai.Name.CompareNoCase(m_RegistryInfo.ArchiveType) == 0)
Info.ArchiverInfoIndex = i;
@@ -320,11 +293,13 @@ bool CCompressDialog::OnInit()
m_UpdateMode.SetCurSel(0);
- Info.Solid = m_RegistryInfo.Solid;
- Info.MultiThread = m_RegistryInfo.MultiThread;
+ SetSolidBlockSize();
+ SetNumThreads();
+
+ TCHAR s[40] = { TEXT('/'), TEXT(' '), 0 };
+ ConvertUInt64ToString(NSystem::GetNumberOfProcessors(), s + 2);
+ SetItemText(IDC_COMPRESS_HARDWARE_THREADS, s);
- CheckButton(IDC_COMPRESS_SOLID, Info.Solid);
- CheckButton(IDC_COMPRESS_MULTI_THREAD, Info.MultiThread);
CheckButton(IDC_COMPRESS_SFX, Info.SFXMode);
CheckControlsEnable();
@@ -380,20 +355,10 @@ bool CCompressDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
UpdatePasswordControl();
return true;
}
- case IDC_COMPRESS_MULTI_THREAD:
- {
- SetMemoryUsage();
- return true;
- }
}
return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
}
-static bool IsMultiProcessor()
-{
- return NSystem::GetNumberOfProcessors() > 1;
-}
-
void CCompressDialog::CheckSFXControlsEnable()
{
const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
@@ -419,13 +384,13 @@ void CCompressDialog::CheckVolumeEnable()
void CCompressDialog::CheckControlsEnable()
{
const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
- Info.SolidIsAllowed = fi.Solid;
- bool multiThreadEnable = fi.MultiThread & IsMultiProcessor();
+ Info.SolidIsSpecified = fi.Solid;
+ bool multiThreadEnable = fi.MultiThread;
Info.MultiThreadIsAllowed = multiThreadEnable;
Info.EncryptHeadersIsAllowed = fi.EncryptFileNames;
- EnableItem(IDC_COMPRESS_SOLID, fi.Solid);
- EnableItem(IDC_COMPRESS_MULTI_THREAD, multiThreadEnable);
+ EnableItem(IDC_COMPRESS_COMBO_SOLID, fi.Solid);
+ EnableItem(IDC_COMPRESS_COMBO_THREADS, multiThreadEnable);
CheckSFXControlsEnable();
CheckVolumeEnable();
@@ -563,14 +528,17 @@ void CCompressDialog::OnOK()
Info.Dictionary = GetDictionarySpec();
Info.Order = GetOrderSpec();
Info.OrderMode = GetOrderMode();
+ Info.NumThreads = GetNumThreadsSpec();
+
+ UInt32 solidLogSize = GetBlockSizeSpec();
+ Info.SolidBlockSize = 0;
+ if (solidLogSize > 0)
+ Info.SolidBlockSize = (solidLogSize >= 64) ? (UInt64)(Int64)-1 : ((UInt64)1 << solidLogSize);
+
Info.Method = GetMethodSpec();
Info.EncryptionMethod = GetEncryptionMethodSpec();
-
Info.ArchiverInfoIndex = m_Format.GetCurSel();
-
Info.SFXMode = IsSFX();
- m_RegistryInfo.Solid = Info.Solid = IsButtonCheckedBool(IDC_COMPRESS_SOLID);
- m_RegistryInfo.MultiThread = Info.MultiThread = IsMultiThread();
m_RegistryInfo.EncryptHeaders = Info.EncryptHeaders = IsButtonCheckedBool(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES);
m_Params.GetText(Info.Options);
@@ -609,12 +577,7 @@ void CCompressDialog::OnOK()
if (m_RegistryInfo.HistoryArchives.Size() > kHistorySize)
m_RegistryInfo.HistoryArchives.DeleteBack();
- ////////////////////
- // Method
-
- m_RegistryInfo.Level = Info.Level;
m_RegistryInfo.ArchiveType = m_ArchiverInfoList[Info.ArchiverInfoIndex].Name;
-
m_RegistryInfo.ShowPassword = IsShowPasswordChecked();
SaveCompressionInfo(m_RegistryInfo);
@@ -642,11 +605,13 @@ bool CCompressDialog::OnCommand(int code, int itemID, LPARAM lParam)
}
case IDC_COMPRESS_COMBO_LEVEL:
{
- const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
+ const CArcInfoEx &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
int index = FindRegistryFormatAlways(ai.Name);
NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
fo.ResetForLevelChange();
SetMethod();
+ SetSolidBlockSize();
+ SetNumThreads();
CheckSFXNameChange();
return true;
}
@@ -654,12 +619,20 @@ bool CCompressDialog::OnCommand(int code, int itemID, LPARAM lParam)
{
SetDictionary();
SetOrder();
+ SetSolidBlockSize();
+ SetNumThreads();
CheckSFXNameChange();
return true;
}
case IDC_COMPRESS_COMBO_DICTIONARY:
case IDC_COMPRESS_COMBO_ORDER:
{
+ SetSolidBlockSize();
+ SetMemoryUsage();
+ return true;
+ }
+ case IDC_COMPRESS_COMBO_THREADS:
+ {
SetMemoryUsage();
return true;
}
@@ -680,10 +653,10 @@ void CCompressDialog::SetArchiveName2(bool prevWasSFX)
{
UString fileName;
m_ArchivePath.GetText(fileName);
- const CArchiverInfo &prevArchiverInfo = m_ArchiverInfoList[m_PrevFormat];
+ const CArcInfoEx &prevArchiverInfo = m_ArchiverInfoList[m_PrevFormat];
if (prevArchiverInfo.KeepName || Info.KeepName)
{
- UString prevExtension = prevArchiverInfo.GetMainExtension();
+ UString prevExtension = prevArchiverInfo.GetMainExt();
if (prevWasSFX)
prevExtension = kExeExt;
else
@@ -701,6 +674,8 @@ void CCompressDialog::OnChangeFormat()
bool isSFX = IsSFX();
SaveOptionsInMem();
SetLevel();
+ SetSolidBlockSize();
+ SetNumThreads();
SetParams();
CheckControlsEnable();
SetArchiveName2(isSFX);
@@ -715,7 +690,7 @@ void CCompressDialog::SetArchiveName(const UString &name)
{
UString fileName = name;
Info.ArchiverInfoIndex = m_Format.GetCurSel();
- const CArchiverInfo &ai = m_ArchiverInfoList[Info.ArchiverInfoIndex];
+ const CArcInfoEx &ai = m_ArchiverInfoList[Info.ArchiverInfoIndex];
m_PrevFormat = Info.ArchiverInfoIndex;
if (ai.KeepName)
{
@@ -737,7 +712,7 @@ void CCompressDialog::SetArchiveName(const UString &name)
else
{
fileName += L'.';
- fileName += ai.GetMainExtension();
+ fileName += ai.GetMainExt();
}
m_ArchivePath.SetText(fileName);
}
@@ -768,15 +743,14 @@ int CCompressDialog::FindRegistryFormatAlways(const UString &name)
int CCompressDialog::GetStaticFormatIndex()
{
int formatIndex = m_Format.GetCurSel();
- const CArchiverInfo &ai = m_ArchiverInfoList[formatIndex];
+ const CArcInfoEx &ai = m_ArchiverInfoList[formatIndex];
for (int i = 0; i < MY_SIZE_OF_ARRAY(g_Formats); i++)
if (ai.Name.CompareNoCase(g_Formats[i].Name) == 0)
return i;
return 0; // -1;
}
-void CCompressDialog::SetNearestSelectComboBox(
- NControl::CComboBox &comboBox, UInt32 value)
+void CCompressDialog::SetNearestSelectComboBox(NControl::CComboBox &comboBox, UInt32 value)
{
for (int i = comboBox.GetCount() - 1; i >= 0; i--)
if ((UInt32)comboBox.GetItemData(i) <= value)
@@ -792,7 +766,7 @@ void CCompressDialog::SetLevel()
{
m_Level.ResetContent();
const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
- const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
+ const CArcInfoEx &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
int index = FindRegistryFormat(ai.Name);
UInt32 level = kNormal;
if (index >= 0)
@@ -817,50 +791,18 @@ void CCompressDialog::SetLevel()
SetMethod();
}
-int CCompressDialog::GetLevel()
-{
- if (m_Level.GetCount() <= 0)
- return -1;
- return (int)m_Level.GetItemData(m_Level.GetCurSel());
-}
-
-int CCompressDialog::GetLevelSpec()
-{
- if (m_Level.GetCount() <= 1)
- return -1;
- return GetLevel();
-}
-
-int CCompressDialog::GetLevel2()
-{
- int level = GetLevel();
- if (level < 0)
- level = 5;
- return level;
-}
-
-bool CCompressDialog::IsMultiThread()
-{
- /*
- const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
- bool multiThreadEnable = fi.MultiThread & IsMultiProcessor();
- if (!multiThreadEnable)
- return false;
- */
- return IsButtonCheckedBool(IDC_COMPRESS_MULTI_THREAD);
-}
-
void CCompressDialog::SetMethod()
{
m_Method.ResetContent();
- if (GetLevel() <= 0)
+ UInt32 level = GetLevel();
+ if (level == 0)
{
SetDictionary();
SetOrder();
return;
}
const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
- const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
+ const CArcInfoEx &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
int index = FindRegistryFormat(ai.Name);
UString defaultMethod;
if (index >= 0)
@@ -886,14 +828,14 @@ void CCompressDialog::SetMethod()
bool CCompressDialog::IsZipFormat()
{
- const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
+ const CArcInfoEx &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
return (ai.Name.CompareNoCase(L"zip") == 0);
}
void CCompressDialog::SetEncryptionMethod()
{
_encryptionMethod.ResetContent();
- const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
+ const CArcInfoEx &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
if (ai.Name.CompareNoCase(L"7z") == 0)
{
_encryptionMethod.AddString(TEXT("AES-256"));
@@ -935,7 +877,7 @@ UString CCompressDialog::GetMethodSpec()
UString CCompressDialog::GetEncryptionMethodSpec()
{
- if (m_Method.GetCount() <= 1)
+ if (_encryptionMethod.GetCount() <= 1)
return UString();
if (_encryptionMethod.GetCurSel() <= 0)
return UString();
@@ -981,7 +923,7 @@ int CCompressDialog::AddDictionarySize(UInt32 size)
void CCompressDialog::SetDictionary()
{
m_Dictionary.ResetContent();
- const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
+ const CArcInfoEx &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
int index = FindRegistryFormat(ai.Name);
UInt32 defaultDictionary = UInt32(-1);
if (index >= 0)
@@ -991,7 +933,7 @@ void CCompressDialog::SetDictionary()
defaultDictionary = fo.Dictionary;
}
int methodID = GetMethodID();
- int level = GetLevel2();
+ UInt32 level = GetLevel2();
if (methodID < 0)
{
SetMemoryUsage();
@@ -1005,16 +947,11 @@ void CCompressDialog::SetDictionary()
static const UInt32 kMinDicSize = (1 << 16);
if (defaultDictionary == UInt32(-1))
{
- if (level >= 9)
- defaultDictionary = (1 << 26);
- else if (level >= 7)
- defaultDictionary = (1 << 24);
- else if (level >= 5)
- defaultDictionary = (1 << 22);
- else if (level >= 3)
- defaultDictionary = (1 << 20);
- else
- defaultDictionary = (kMinDicSize);
+ if (level >= 9) defaultDictionary = (1 << 26);
+ else if (level >= 7) defaultDictionary = (1 << 25);
+ else if (level >= 5) defaultDictionary = (1 << 24);
+ else if (level >= 3) defaultDictionary = (1 << 20);
+ else defaultDictionary = (kMinDicSize);
}
int i;
AddDictionarySize(kMinDicSize);
@@ -1029,13 +966,13 @@ void CCompressDialog::SetDictionary()
#ifdef _WIN64
(1 << 30)
#else
- (1 << 27)
+ (1 << 26)
#endif
)
continue;
AddDictionarySize(dictionary);
UInt64 decomprSize;
- UInt64 requiredComprSize = GetMemoryUsage(dictionary, false, decomprSize);
+ UInt64 requiredComprSize = GetMemoryUsage(dictionary, decomprSize);
if (dictionary <= defaultDictionary && requiredComprSize <= maxRamSize)
m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
}
@@ -1047,14 +984,10 @@ void CCompressDialog::SetDictionary()
{
if (defaultDictionary == UInt32(-1))
{
- if (level >= 9)
- defaultDictionary = (192 << 20);
- else if (level >= 7)
- defaultDictionary = (64 << 20);
- else if (level >= 5)
- defaultDictionary = (16 << 20);
- else
- defaultDictionary = (4 << 20);
+ if (level >= 9) defaultDictionary = (192 << 20);
+ else if (level >= 7) defaultDictionary = ( 64 << 20);
+ else if (level >= 5) defaultDictionary = ( 16 << 20);
+ else defaultDictionary = ( 4 << 20);
}
int i;
for (i = 20; i < 31; i++)
@@ -1067,7 +1000,7 @@ void CCompressDialog::SetDictionary()
continue;
AddDictionarySize(dictionary);
UInt64 decomprSize;
- UInt64 requiredComprSize = GetMemoryUsage(dictionary, false, decomprSize);
+ UInt64 requiredComprSize = GetMemoryUsage(dictionary, decomprSize);
if (dictionary <= defaultDictionary && requiredComprSize <= maxRamSize || m_Dictionary.GetCount() == 0)
m_Dictionary.SetCurSel(m_Dictionary.GetCount() - 1);
}
@@ -1108,18 +1041,19 @@ void CCompressDialog::SetDictionary()
SetMemoryUsage();
}
-UInt32 CCompressDialog::GetDictionary()
+UInt32 CCompressDialog::GetComboValue(NWindows::NControl::CComboBox &c, int defMax)
{
- if (m_Dictionary.GetCount() <= 0)
+ if (c.GetCount() <= defMax)
return (UInt32)-1;
- return (UInt32)m_Dictionary.GetItemData(m_Dictionary.GetCurSel());
+ return (UInt32)c.GetItemData(c.GetCurSel());
}
-UInt32 CCompressDialog::GetDictionarySpec()
+UInt32 CCompressDialog::GetLevel2()
{
- if (m_Dictionary.GetCount() <= 1)
- return (UInt32)-1;
- return GetDictionary();
+ UInt32 level = GetLevel();
+ if (level == (UInt32)-1)
+ level = 5;
+ return level;
}
int CCompressDialog::AddOrder(UInt32 size)
@@ -1134,7 +1068,7 @@ int CCompressDialog::AddOrder(UInt32 size)
void CCompressDialog::SetOrder()
{
m_Order.ResetContent();
- const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
+ const CArcInfoEx &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
int index = FindRegistryFormat(ai.Name);
UInt32 defaultOrder = UInt32(-1);
if (index >= 0)
@@ -1144,7 +1078,7 @@ void CCompressDialog::SetOrder()
defaultOrder = fo.Order;
}
int methodID = GetMethodID();
- int level = GetLevel2();
+ UInt32 level = GetLevel2();
if (methodID < 0)
{
SetMemoryUsage();
@@ -1236,24 +1170,107 @@ bool CCompressDialog::GetOrderMode()
return false;
}
-UInt32 CCompressDialog::GetOrder()
+static const UInt32 kNoSolidBlockSize = 0;
+static const UInt32 kSolidBlockSize = 64;
+
+void CCompressDialog::SetSolidBlockSize()
{
- if (m_Order.GetCount() <= 0)
- return (UInt32)-1;
- return (UInt32)m_Order.GetItemData(m_Order.GetCurSel());
+ m_Solid.ResetContent();
+ const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
+ if (!fi.Solid)
+ return;
+
+ UInt32 dictionary = GetDictionarySpec();
+ if (dictionary == UInt32(-1))
+ dictionary = 1;
+
+ UInt32 defaultBlockSize = (UInt32)-1;
+
+ const CArcInfoEx &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
+ int index = FindRegistryFormat(ai.Name);
+ if (index >= 0)
+ {
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ if (fo.Method.CompareNoCase(GetMethodSpec()) == 0)
+ defaultBlockSize = fo.BlockLogSize;
+ }
+
+ index = (int)m_Solid.AddString(LangString(IDS_COMPRESS_NON_SOLID, 0x02000D14));
+ m_Solid.SetItemData(index, (UInt32)kNoSolidBlockSize);
+ m_Solid.SetCurSel(0);
+ bool needSet = defaultBlockSize == (UInt32)-1;
+ for (int i = 20; i <= 36; i++)
+ {
+ if (needSet && dictionary >= (((UInt64)1 << (i - 7))) && i <= 32)
+ defaultBlockSize = i;
+ TCHAR s[40];
+ ConvertUInt64ToString(1 << (i % 10), s);
+ if (i < 30) lstrcat(s, TEXT(" M"));
+ else lstrcat(s, TEXT(" G"));
+ lstrcat(s, TEXT("B"));
+ int index = (int)m_Solid.AddString(s);
+ m_Solid.SetItemData(index, (UInt32)i);
+ }
+ index = (int)m_Solid.AddString(LangString(IDS_COMPRESS_SOLID, 0x02000D15));
+ m_Solid.SetItemData(index, kSolidBlockSize);
+ if (defaultBlockSize == (UInt32)-1)
+ defaultBlockSize = kSolidBlockSize;
+ if (defaultBlockSize != kNoSolidBlockSize)
+ SetNearestSelectComboBox(m_Solid, defaultBlockSize);
}
-UInt32 CCompressDialog::GetOrderSpec()
+void CCompressDialog::SetNumThreads()
{
- if (m_Order.GetCount() <= 1)
- return (UInt32)-1;
- return GetOrder();
+ m_NumThreads.ResetContent();
+
+ const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
+ if (!fi.MultiThread)
+ return;
+
+ UInt32 numHardwareThreads = NSystem::GetNumberOfProcessors();
+ UInt32 defaultValue = numHardwareThreads;
+
+ const CArcInfoEx &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
+ int index = FindRegistryFormat(ai.Name);
+ if (index >= 0)
+ {
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ if (fo.Method.CompareNoCase(GetMethodSpec()) == 0)
+ defaultValue = fo.NumThreads;
+ }
+
+ UInt32 numAlgoThreadsMax = 1;
+ int methodID = GetMethodID();
+ switch (methodID)
+ {
+ case kLZMA:
+ {
+ numAlgoThreadsMax = 2;
+ break;
+ }
+ case kBZip2:
+ {
+ numAlgoThreadsMax = 32;
+ break;
+ }
+ }
+ if (IsZipFormat())
+ numAlgoThreadsMax = 128;
+ for (UInt32 i = 1; i <= numHardwareThreads * 2 && i <= numAlgoThreadsMax; i++)
+ {
+ TCHAR s[40];
+ ConvertUInt64ToString(i, s);
+ int index = (int)m_NumThreads.AddString(s);
+ m_NumThreads.SetItemData(index, (UInt32)i);
+ }
+ SetNearestSelectComboBox(m_NumThreads, defaultValue);
}
-UInt64 CCompressDialog::GetMemoryUsage(UInt32 dictionary, bool isMultiThread, UInt64 &decompressMemory)
+
+UInt64 CCompressDialog::GetMemoryUsage(UInt32 dictionary, UInt64 &decompressMemory)
{
decompressMemory = UInt64(Int64(-1));
- int level = GetLevel2();
+ UInt32 level = GetLevel2();
if (level == 0)
{
decompressMemory = (1 << 20);
@@ -1264,6 +1281,12 @@ UInt64 CCompressDialog::GetMemoryUsage(UInt32 dictionary, bool isMultiThread, UI
const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
if (fi.Filter && level >= 9)
size += (12 << 20) * 2 + (5 << 20);
+ UInt32 numThreads = GetNumThreads2();
+ if (IsZipFormat())
+ {
+ if (numThreads > 1)
+ size += (UInt64)numThreads << 25;
+ }
switch (GetMethodID())
{
case kLZMA:
@@ -1283,7 +1306,7 @@ UInt64 CCompressDialog::GetMemoryUsage(UInt32 dictionary, bool isMultiThread, UI
if (level >= 5)
size += dictionary * 4;
size += (2 << 20);
- if (isMultiThread && level >= 5)
+ if (numThreads > 1 && level >= 5)
size += (2 << 20) + (4 << 20);
decompressMemory = dictionary + (2 << 20);
@@ -1310,9 +1333,7 @@ UInt64 CCompressDialog::GetMemoryUsage(UInt32 dictionary, bool isMultiThread, UI
{
decompressMemory = (7 << 20);
UInt64 memForOneThread = (10 << 20);
- if (isMultiThread)
- memForOneThread *= NSystem::GetNumberOfProcessors();
- return size + (10 << 20);
+ return size + memForOneThread * numThreads;
}
}
return UInt64(Int64(-1));
@@ -1320,7 +1341,7 @@ UInt64 CCompressDialog::GetMemoryUsage(UInt32 dictionary, bool isMultiThread, UI
UInt64 CCompressDialog::GetMemoryUsage(UInt64 &decompressMemory)
{
- return GetMemoryUsage(GetDictionary(), IsMultiThread(), decompressMemory);
+ return GetMemoryUsage(GetDictionary(), decompressMemory);
}
void CCompressDialog::PrintMemUsage(UINT res, UInt64 value)
@@ -1347,7 +1368,7 @@ void CCompressDialog::SetMemoryUsage()
void CCompressDialog::SetParams()
{
- const CArchiverInfo &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
+ const CArcInfoEx &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
m_Params.SetText(TEXT(""));
int index = FindRegistryFormat(ai.Name);
if (index >= 0)
@@ -1359,7 +1380,7 @@ void CCompressDialog::SetParams()
void CCompressDialog::SaveOptionsInMem()
{
- const CArchiverInfo &ai = m_ArchiverInfoList[Info.ArchiverInfoIndex];
+ const CArcInfoEx &ai = m_ArchiverInfoList[Info.ArchiverInfoIndex];
int index = FindRegistryFormatAlways(ai.Name);
m_Params.GetText(Info.Options);
Info.Options.Trim();
@@ -1370,4 +1391,6 @@ void CCompressDialog::SaveOptionsInMem()
fo.Order = GetOrderSpec();
fo.Method = GetMethodSpec();
fo.EncryptionMethod = GetEncryptionMethodSpec();
+ fo.NumThreads = GetNumThreadsSpec();
+ fo.BlockLogSize = GetBlockSizeSpec();
}
diff --git a/CPP/7zip/UI/GUI/CompressDialog.h b/CPP/7zip/UI/GUI/CompressDialog.h
index 87cf5d79..1ff20cd0 100755
--- a/CPP/7zip/UI/GUI/CompressDialog.h
+++ b/CPP/7zip/UI/GUI/CompressDialog.h
@@ -4,7 +4,7 @@
#define __COMPRESSDIALOG_H
#include "../Common/ZipRegistry.h"
-#include "../Common/ArchiverInfo.h"
+#include "../Common/LoadCodecs.h"
#include "../Resource/CompressDialog/resource.h"
#include "Windows/Control/Dialog.h"
@@ -26,11 +26,10 @@ namespace NCompressDialog
struct CInfo
{
NUpdateMode::EEnum UpdateMode;
- bool SolidIsAllowed;
- bool Solid;
-
+ bool SolidIsSpecified;
bool MultiThreadIsAllowed;
- bool MultiThread;
+ UInt64 SolidBlockSize;
+ UInt32 NumThreads;
CRecordVector<UInt64> VolumeSizes;
@@ -80,6 +79,8 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
NWindows::NControl::CComboBox m_Method;
NWindows::NControl::CComboBox m_Dictionary;
NWindows::NControl::CComboBox m_Order;
+ NWindows::NControl::CComboBox m_Solid;
+ NWindows::NControl::CComboBox m_NumThreads;
NWindows::NControl::CComboBox m_UpdateMode;
NWindows::NControl::CComboBox m_Volume;
NWindows::NControl::CDialogChildControl m_Params;
@@ -104,10 +105,6 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
void SetNearestSelectComboBox(NWindows::NControl::CComboBox &comboBox, UInt32 value);
void SetLevel();
- int GetLevel();
- int GetLevelSpec();
- int GetLevel2();
- bool IsMultiThread();
void SetMethod();
int GetMethodID();
@@ -122,16 +119,28 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
int AddDictionarySize(UInt32 size);
void SetDictionary();
- UInt32 GetDictionary();
- UInt32 GetDictionarySpec();
+
+ UInt32 GetComboValue(NWindows::NControl::CComboBox &c, int defMax = 0);
+
+ UInt32 GetLevel() { return GetComboValue(m_Level); }
+ UInt32 GetLevelSpec() { return GetComboValue(m_Level, 1); }
+ UInt32 GetLevel2();
+ UInt32 GetDictionary() { return GetComboValue(m_Dictionary); }
+ UInt32 GetDictionarySpec() { return GetComboValue(m_Dictionary, 1); }
+ UInt32 GetOrder() { return GetComboValue(m_Order); }
+ UInt32 GetOrderSpec() { return GetComboValue(m_Order, 1); }
+ UInt32 GetNumThreadsSpec() { return GetComboValue(m_NumThreads, 1); }
+ UInt32 GetNumThreads2() { UInt32 num = GetNumThreadsSpec(); if (num == UInt32(-1)) num = 1; return num; }
+ UInt32 GetBlockSizeSpec() { return GetComboValue(m_Solid, 1); }
int AddOrder(UInt32 size);
void SetOrder();
bool GetOrderMode();
- UInt32 GetOrder();
- UInt32 GetOrderSpec();
- UInt64 GetMemoryUsage(UInt32 dictionary, bool isMultiThread, UInt64 &decompressMemory);
+ void SetSolidBlockSize();
+ void SetNumThreads();
+
+ UInt64 GetMemoryUsage(UInt32 dictionary, UInt64 &decompressMemory);
UInt64 GetMemoryUsage(UInt64 &decompressMemory);
void PrintMemUsage(UINT res, UInt64 value);
void SetMemoryUsage();
@@ -142,7 +151,7 @@ class CCompressDialog: public NWindows::NControl::CModalDialog
bool IsShowPasswordChecked() const
{ return IsButtonChecked(IDC_COMPRESS_CHECK_SHOW_PASSWORD) == BST_CHECKED; }
public:
- CObjectVector<CArchiverInfo> m_ArchiverInfoList;
+ CObjectVector<CArcInfoEx> m_ArchiverInfoList;
NCompressDialog::CInfo Info;
UString OriginalFileName; // for bzip2, gzip2
diff --git a/CPP/7zip/UI/GUI/ExtractGUI.cpp b/CPP/7zip/UI/GUI/ExtractGUI.cpp
index 395df5a9..3edb1229 100755
--- a/CPP/7zip/UI/GUI/ExtractGUI.cpp
+++ b/CPP/7zip/UI/GUI/ExtractGUI.cpp
@@ -28,8 +28,8 @@ static const wchar_t *kIncorrectOutDir = L"Incorrect output directory path";
struct CThreadExtracting
{
+ CCodecs *codecs;
CExtractCallbackImp *ExtractCallbackSpec;
-
UStringVector *ArchivePaths;
UStringVector *ArchivePathsFull;
const NWildcard::CCensorNode *WildcardCensor;
@@ -45,7 +45,9 @@ struct CThreadExtracting
ExtractCallbackSpec->ProgressDialog.WaitCreating();
try
{
- Result = DecompressArchives(*ArchivePaths, *ArchivePathsFull,
+ Result = DecompressArchives(
+ codecs,
+ *ArchivePaths, *ArchivePathsFull,
*WildcardCensor, *Options, OpenCallback, ExtractCallback, ErrorMessage);
}
catch(const UString &s)
@@ -77,6 +79,7 @@ struct CThreadExtracting
};
HRESULT ExtractGUI(
+ CCodecs *codecs,
UStringVector &archivePaths,
UStringVector &archivePathsFull,
const NWildcard::CCensorNode &wildcardCensor,
@@ -86,6 +89,7 @@ HRESULT ExtractGUI(
CExtractCallbackImp *extractCallback)
{
CThreadExtracting extracter;
+ extracter.codecs = codecs;
if (!options.TestMode)
{
diff --git a/CPP/7zip/UI/GUI/ExtractGUI.h b/CPP/7zip/UI/GUI/ExtractGUI.h
index 5a0b157d..281fcc43 100755
--- a/CPP/7zip/UI/GUI/ExtractGUI.h
+++ b/CPP/7zip/UI/GUI/ExtractGUI.h
@@ -9,6 +9,7 @@
#include "../../FileManager/ExtractCallback.h"
HRESULT ExtractGUI(
+ CCodecs *codecs,
UStringVector &archivePaths,
UStringVector &archivePathsFull,
const NWildcard::CCensorNode &wildcardCensor,
diff --git a/CPP/7zip/UI/GUI/GUI.cpp b/CPP/7zip/UI/GUI/GUI.cpp
index fe956dbd..ad58a451 100755
--- a/CPP/7zip/UI/GUI/GUI.cpp
+++ b/CPP/7zip/UI/GUI/GUI.cpp
@@ -4,6 +4,11 @@
#include <initguid.h>
+extern "C"
+{
+ #include "../../../../C/Alloc.h"
+}
+
#include "Common/NewHandler.h"
#include "Common/StringConvert.h"
#include "Common/CommandLineParser.h"
@@ -17,7 +22,6 @@
#include "Windows/FileName.h"
#ifdef _WIN32
#include "Windows/MemoryLock.h"
-#include "Common/Alloc.h"
#endif
#include "../../IStream.h"
@@ -33,6 +37,7 @@
#include "ExtractGUI.h"
#include "UpdateGUI.h"
+#include "Resource/BenchmarkDialog/BenchmarkDialog.h"
using namespace NWindows;
@@ -83,10 +88,26 @@ int Main2()
if (options.LargePages)
NSecurity::EnableLockMemoryPrivilege();
#endif
+
+ CCodecs *codecs = new CCodecs;
+ CMyComPtr<IUnknown> compressCodecsInfo = codecs;
+ HRESULT result = codecs->Load();
+ if (result != S_OK)
+ throw CSystemException(result);
bool isExtractGroupCommand = options.Command.IsFromExtractGroup();
- if (isExtractGroupCommand)
+ if (options.Command.CommandType == NCommandType::kBenchmark)
+ {
+ HRESULT res = Benchmark(
+ #ifdef EXTERNAL_LZMA
+ codecs,
+ #endif
+ options.NumThreads, options.DictionarySize);
+ if (res != S_OK)
+ throw CSystemException(res);
+ }
+ else if (isExtractGroupCommand)
{
CExtractCallbackImp *ecs = new CExtractCallbackImp;
CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;
@@ -109,7 +130,7 @@ int Main2()
eo.Properties = options.ExtractProperties;
#endif
- HRESULT result = ExtractGUI(
+ HRESULT result = ExtractGUI(codecs,
options.ArchivePathsSorted,
options.ArchivePathsFullSorted,
options.WildcardCensor.Pairs.Front().Head,
@@ -138,7 +159,10 @@ int Main2()
CUpdateErrorInfo errorInfo;
+ if (!options.UpdateOptions.Init(codecs, options.ArchiveName, options.ArcType))
+ throw "Unsupported archive type";
HRESULT result = UpdateGUI(
+ codecs,
options.WildcardCensor, options.UpdateOptions,
options.ShowDialog,
errorInfo, &openCallback, &callback);
diff --git a/CPP/7zip/UI/GUI/GUI.dsp b/CPP/7zip/UI/GUI/GUI.dsp
index dadb9648..ccfe98ab 100755
--- a/CPP/7zip/UI/GUI/GUI.dsp
+++ b/CPP/7zip/UI/GUI/GUI.dsp
@@ -45,7 +45,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /D "EXTERNAL_LZMA" /D "EXTERNAL_CODECS" /D "BENCH_MT" /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
@@ -72,7 +72,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
-# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /D "EXTERNAL_LZMA" /D "EXTERNAL_CODECS" /D "BENCH_MT" /Yu"stdafx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"
@@ -99,7 +99,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /D "EXTERNAL_LZMA" /D "EXTERNAL_CODECS" /D "BENCH_MT" /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
@@ -127,7 +127,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
-# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "COMPRESS_MT" /D "WIN_LONG_PATH" /D "EXTERNAL_LZMA" /D "EXTERNAL_CODECS" /D "BENCH_MT" /Yu"stdafx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"
@@ -176,728 +176,789 @@ SOURCE=.\StdAfx.cpp
SOURCE=.\StdAfx.h
# End Source File
# End Group
-# Begin Group "SDK"
-
-# PROP Default_Filter ""
-# Begin Group "Common"
+# Begin Group "UI Common"
# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\..\..\Common\Alloc.cpp
+SOURCE=..\Common\ArchiveCommandLine.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\Alloc.h
+SOURCE=..\Common\ArchiveCommandLine.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\CommandLineParser.cpp
+SOURCE=..\Common\ArchiveExtractCallback.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\CommandLineParser.h
+SOURCE=..\Common\ArchiveExtractCallback.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\IntToString.cpp
+SOURCE=..\Common\ArchiveOpenCallback.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\IntToString.h
+SOURCE=..\Common\ArchiveOpenCallback.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\Lang.cpp
+SOURCE=..\Common\DefaultName.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\Lang.h
+SOURCE=..\Common\DefaultName.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\ListFileUtils.cpp
+SOURCE=..\Common\DirItem.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\ListFileUtils.h
+SOURCE=..\Common\EnumDirItems.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\NewHandler.cpp
+SOURCE=..\Common\EnumDirItems.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\NewHandler.h
+SOURCE=..\Common\ExitCode.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\StdInStream.cpp
+SOURCE=..\Common\Extract.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\StdInStream.h
+SOURCE=..\Common\Extract.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\String.cpp
+SOURCE=..\Common\ExtractingFilePath.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\String.h
+SOURCE=..\Common\ExtractingFilePath.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\StringConvert.cpp
+SOURCE=..\Common\ExtractMode.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\StringConvert.h
+SOURCE=..\Common\HandlerLoader.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\StringToInt.cpp
+SOURCE=..\Common\IFileExtractCallback.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\StringToInt.h
+SOURCE=..\Common\LoadCodecs.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\TextConfig.cpp
+SOURCE=..\Common\LoadCodecs.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\TextConfig.h
+SOURCE=..\Common\OpenArchive.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\UTFConvert.cpp
+SOURCE=..\Common\OpenArchive.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\UTFConvert.h
+SOURCE=..\Common\Property.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\Vector.cpp
+SOURCE=..\Common\PropIDUtils.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\Vector.h
+SOURCE=..\Common\PropIDUtils.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\Wildcard.cpp
+SOURCE=..\Common\SetProperties.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Common\Wildcard.h
+SOURCE=..\Common\SetProperties.h
# End Source File
-# End Group
-# Begin Group "Windows"
-
-# PROP Default_Filter ""
-# Begin Group "Control"
-
-# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\..\..\Windows\Control\ComboBox.cpp
+SOURCE=..\Common\SortUtils.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\Control\ComboBox.h
+SOURCE=..\Common\SortUtils.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\Control\Dialog.cpp
+SOURCE=..\Common\TempFiles.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\Control\Dialog.h
+SOURCE=..\Common\TempFiles.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\Control\Edit.h
+SOURCE=..\Common\Update.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\Control\ListView.cpp
+SOURCE=..\Common\Update.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\Control\ListView.h
+SOURCE=..\Common\UpdateAction.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\Control\ProgressBar.h
+SOURCE=..\Common\UpdateAction.h
# End Source File
-# End Group
# Begin Source File
-SOURCE=..\..\..\Windows\CommonDialog.cpp
+SOURCE=..\Common\UpdateCallback.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\CommonDialog.h
+SOURCE=..\Common\UpdateCallback.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\DLL.cpp
+SOURCE=..\Common\UpdatePair.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\DLL.h
+SOURCE=..\Common\UpdatePair.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\Error.cpp
+SOURCE=..\Common\UpdateProduce.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\Error.h
+SOURCE=..\Common\UpdateProduce.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\FileDir.cpp
+SOURCE=..\Common\WorkDir.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\FileDir.h
+SOURCE=..\Common\WorkDir.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\FileFind.cpp
+SOURCE=..\Common\ZipRegistry.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\FileFind.h
+SOURCE=..\Common\ZipRegistry.h
# End Source File
+# End Group
+# Begin Group "Explorer"
+
+# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\..\..\Windows\FileIO.cpp
+SOURCE=..\Explorer\MyMessages.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\FileIO.h
+SOURCE=..\Explorer\MyMessages.h
# End Source File
+# End Group
+# Begin Group "Dialogs"
+
+# PROP Default_Filter ""
+# Begin Group "Progress"
+
+# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\..\..\Windows\FileName.cpp
+SOURCE=..\..\FileManager\Resource\ProgressDialog2\ProgressDialog.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\FileName.h
+SOURCE=..\..\FileManager\Resource\ProgressDialog2\ProgressDialog.h
# End Source File
+# End Group
+# Begin Group "Messages"
+
+# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\..\..\Windows\MemoryLock.cpp
+SOURCE=..\..\FileManager\Resource\MessagesDialog\MessagesDialog.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\MemoryLock.h
+SOURCE=..\..\FileManager\Resource\MessagesDialog\MessagesDialog.h
# End Source File
+# End Group
+# Begin Group "Overwtite"
+
+# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\..\..\Windows\PropVariant.cpp
+SOURCE=..\..\FileManager\Resource\OverwriteDialog\OverwriteDialog.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\PropVariant.h
+SOURCE=..\..\FileManager\Resource\OverwriteDialog\OverwriteDialog.h
# End Source File
+# End Group
+# Begin Group "Password"
+
+# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\..\..\Windows\PropVariantConversions.cpp
+SOURCE=..\..\FileManager\Resource\PasswordDialog\PasswordDialog.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\PropVariantConversions.h
+SOURCE=..\..\FileManager\Resource\PasswordDialog\PasswordDialog.h
# End Source File
+# End Group
+# Begin Group "Compress Dialog"
+
+# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\..\..\Windows\Registry.cpp
+SOURCE=.\CompressDialog.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\Registry.h
+SOURCE=.\CompressDialog.h
# End Source File
+# End Group
+# Begin Group "Extract Dialog"
+
+# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\..\..\Windows\ResourceString.cpp
+SOURCE=.\ExtractDialog.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\ResourceString.h
+SOURCE=.\ExtractDialog.h
# End Source File
+# End Group
+# Begin Group "Benchmark Dialog"
+
+# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\..\..\Windows\Shell.cpp
+SOURCE=.\Resource\BenchmarkDialog\BenchmarkDialog.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\Shell.h
+SOURCE=.\Resource\BenchmarkDialog\BenchmarkDialog.h
# End Source File
+# End Group
+# End Group
+# Begin Group "FM Common"
+
+# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\..\..\Windows\Synchronization.cpp
+SOURCE=..\..\FileManager\ExtractCallback.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\Synchronization.h
+SOURCE=..\..\FileManager\ExtractCallback.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\Window.cpp
+SOURCE=..\..\FileManager\FolderInterface.h
# End Source File
# Begin Source File
-SOURCE=..\..\..\Windows\Window.h
+SOURCE=..\..\FileManager\FormatUtils.cpp
# End Source File
-# End Group
-# End Group
-# Begin Group "UI Common"
-
-# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\Common\ArchiveCommandLine.cpp
+SOURCE=..\..\FileManager\FormatUtils.h
# End Source File
# Begin Source File
-SOURCE=..\Common\ArchiveCommandLine.h
+SOURCE=..\..\FileManager\HelpUtils.cpp
# End Source File
# Begin Source File
-SOURCE=..\Common\ArchiveExtractCallback.cpp
+SOURCE=..\..\FileManager\HelpUtils.h
# End Source File
# Begin Source File
-SOURCE=..\Common\ArchiveExtractCallback.h
+SOURCE=..\..\FileManager\LangUtils.cpp
# End Source File
# Begin Source File
-SOURCE=..\Common\ArchiveOpenCallback.cpp
+SOURCE=..\..\FileManager\LangUtils.h
# End Source File
# Begin Source File
-SOURCE=..\Common\ArchiveOpenCallback.h
+SOURCE=..\..\FileManager\OpenCallback.cpp
# End Source File
# Begin Source File
-SOURCE=..\Common\ArchiverInfo.cpp
+SOURCE=..\..\FileManager\OpenCallback.h
# End Source File
# Begin Source File
-SOURCE=..\Common\ArchiverInfo.h
+SOURCE=..\..\FileManager\ProgramLocation.cpp
# End Source File
# Begin Source File
-SOURCE=..\Common\DefaultName.cpp
+SOURCE=..\..\FileManager\ProgramLocation.h
# End Source File
# Begin Source File
-SOURCE=..\Common\DefaultName.h
+SOURCE=..\..\FileManager\RegistryUtils.cpp
# End Source File
# Begin Source File
-SOURCE=..\Common\DirItem.h
+SOURCE=..\..\FileManager\RegistryUtils.h
# End Source File
# Begin Source File
-SOURCE=..\Common\EnumDirItems.cpp
+SOURCE=..\..\FileManager\SplitUtils.cpp
# End Source File
# Begin Source File
-SOURCE=..\Common\EnumDirItems.h
+SOURCE=..\..\FileManager\SplitUtils.h
# End Source File
# Begin Source File
-SOURCE=..\Common\ExitCode.h
+SOURCE=..\..\FileManager\StringUtils.cpp
# End Source File
# Begin Source File
-SOURCE=..\Common\Extract.cpp
+SOURCE=..\..\FileManager\StringUtils.h
# End Source File
# Begin Source File
-SOURCE=..\Common\Extract.h
+SOURCE=..\..\FileManager\UpdateCallback100.cpp
# End Source File
# Begin Source File
-SOURCE=..\Common\ExtractingFilePath.cpp
+SOURCE=..\..\FileManager\UpdateCallback100.h
# End Source File
+# End Group
+# Begin Group "Engine"
+
+# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\Common\ExtractingFilePath.h
+SOURCE=.\ExtractGUI.cpp
# End Source File
# Begin Source File
-SOURCE=..\Common\ExtractMode.h
+SOURCE=.\ExtractGUI.h
# End Source File
# Begin Source File
-SOURCE=..\Common\HandlerLoader.h
+SOURCE=.\GUI.cpp
# End Source File
# Begin Source File
-SOURCE=..\Common\IFileExtractCallback.h
+SOURCE=.\OpenCallbackGUI.cpp
# End Source File
# Begin Source File
-SOURCE=..\Common\OpenArchive.cpp
+SOURCE=.\OpenCallbackGUI.h
# End Source File
# Begin Source File
-SOURCE=..\Common\OpenArchive.h
+SOURCE=.\UpdateCallbackGUI.cpp
# End Source File
# Begin Source File
-SOURCE=..\Common\Property.h
+SOURCE=.\UpdateCallbackGUI.h
# End Source File
# Begin Source File
-SOURCE=..\Common\PropIDUtils.cpp
+SOURCE=.\UpdateGUI.cpp
# End Source File
# Begin Source File
-SOURCE=..\Common\PropIDUtils.h
+SOURCE=.\UpdateGUI.h
# End Source File
+# End Group
+# Begin Group "7-zip Common"
+
+# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\Common\SetProperties.cpp
+SOURCE=..\..\Common\FilePathAutoRename.cpp
# End Source File
# Begin Source File
-SOURCE=..\Common\SetProperties.h
+SOURCE=..\..\Common\FilePathAutoRename.h
# End Source File
# Begin Source File
-SOURCE=..\Common\SortUtils.cpp
+SOURCE=..\..\Common\FileStreams.cpp
# End Source File
# Begin Source File
-SOURCE=..\Common\SortUtils.h
+SOURCE=..\..\Common\FileStreams.h
# End Source File
# Begin Source File
-SOURCE=..\Common\TempFiles.cpp
+SOURCE=..\..\Common\StreamUtils.cpp
# End Source File
# Begin Source File
-SOURCE=..\Common\TempFiles.h
+SOURCE=..\..\Common\StreamUtils.h
# End Source File
+# End Group
+# Begin Group "Compress"
+
+# PROP Default_Filter ""
+# Begin Group "LZMA Bench"
+
+# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\Common\Update.cpp
+SOURCE=..\..\Compress\LZMA_Alone\LzmaBench.cpp
# End Source File
# Begin Source File
-SOURCE=..\Common\Update.h
+SOURCE=..\..\Compress\LZMA_Alone\LzmaBench.h
# End Source File
+# End Group
# Begin Source File
-SOURCE=..\Common\UpdateAction.cpp
+SOURCE=..\..\Compress\Copy\CopyCoder.cpp
# End Source File
# Begin Source File
-SOURCE=..\Common\UpdateAction.h
+SOURCE=..\..\Compress\Copy\CopyCoder.h
# End Source File
+# End Group
+# Begin Group "C"
+
+# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\Common\UpdateCallback.cpp
+SOURCE=..\..\..\..\C\7zCrc.c
+
+!IF "$(CFG)" == "GUI - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "GUI - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "GUI - Win32 ReleaseU"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "GUI - Win32 DebugU"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
# End Source File
# Begin Source File
-SOURCE=..\Common\UpdateCallback.h
+SOURCE=..\..\..\..\C\7zCrc.h
# End Source File
# Begin Source File
-SOURCE=..\Common\UpdatePair.cpp
+SOURCE=..\..\..\..\C\Alloc.c
+# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
-SOURCE=..\Common\UpdatePair.h
+SOURCE=..\..\..\..\C\Alloc.h
# End Source File
+# End Group
+# Begin Group "Common"
+
+# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\Common\UpdateProduce.cpp
+SOURCE=..\..\..\Common\CommandLineParser.cpp
# End Source File
# Begin Source File
-SOURCE=..\Common\UpdateProduce.h
+SOURCE=..\..\..\Common\CommandLineParser.h
# End Source File
# Begin Source File
-SOURCE=..\Common\WorkDir.cpp
+SOURCE=..\..\..\Common\CRC.cpp
# End Source File
# Begin Source File
-SOURCE=..\Common\WorkDir.h
+SOURCE=..\..\..\Common\IntToString.cpp
# End Source File
# Begin Source File
-SOURCE=..\Common\ZipRegistry.cpp
+SOURCE=..\..\..\Common\IntToString.h
# End Source File
# Begin Source File
-SOURCE=..\Common\ZipRegistry.h
+SOURCE=..\..\..\Common\Lang.cpp
# End Source File
-# End Group
-# Begin Group "Explorer"
-
-# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\Explorer\MyMessages.cpp
+SOURCE=..\..\..\Common\Lang.h
# End Source File
# Begin Source File
-SOURCE=..\Explorer\MyMessages.h
+SOURCE=..\..\..\Common\ListFileUtils.cpp
# End Source File
-# End Group
-# Begin Group "Dialogs"
+# Begin Source File
-# PROP Default_Filter ""
-# Begin Group "Progress"
+SOURCE=..\..\..\Common\ListFileUtils.h
+# End Source File
+# Begin Source File
-# PROP Default_Filter ""
+SOURCE=..\..\..\Common\NewHandler.cpp
+# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\Resource\ProgressDialog2\ProgressDialog.cpp
+SOURCE=..\..\..\Common\NewHandler.h
# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\Resource\ProgressDialog2\ProgressDialog.h
+SOURCE=..\..\..\Common\StdInStream.cpp
# End Source File
-# End Group
-# Begin Group "Messages"
+# Begin Source File
-# PROP Default_Filter ""
+SOURCE=..\..\..\Common\StdInStream.h
+# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\Resource\MessagesDialog\MessagesDialog.cpp
+SOURCE=..\..\..\Common\String.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\Resource\MessagesDialog\MessagesDialog.h
+SOURCE=..\..\..\Common\String.h
# End Source File
-# End Group
-# Begin Group "Overwtite"
+# Begin Source File
-# PROP Default_Filter ""
+SOURCE=..\..\..\Common\StringConvert.cpp
+# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\Resource\OverwriteDialog\OverwriteDialog.cpp
+SOURCE=..\..\..\Common\StringConvert.h
# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\Resource\OverwriteDialog\OverwriteDialog.h
+SOURCE=..\..\..\Common\StringToInt.cpp
# End Source File
-# End Group
-# Begin Group "Password"
+# Begin Source File
-# PROP Default_Filter ""
+SOURCE=..\..\..\Common\StringToInt.h
+# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\Resource\PasswordDialog\PasswordDialog.cpp
+SOURCE=..\..\..\Common\TextConfig.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\Resource\PasswordDialog\PasswordDialog.h
+SOURCE=..\..\..\Common\TextConfig.h
# End Source File
-# End Group
-# Begin Group "Compress Dialog"
+# Begin Source File
-# PROP Default_Filter ""
+SOURCE=..\..\..\Common\UTFConvert.cpp
+# End Source File
# Begin Source File
-SOURCE=.\CompressDialog.cpp
+SOURCE=..\..\..\Common\UTFConvert.h
# End Source File
# Begin Source File
-SOURCE=.\CompressDialog.h
+SOURCE=..\..\..\Common\Vector.cpp
# End Source File
-# End Group
-# Begin Group "Extract Dialog"
+# Begin Source File
-# PROP Default_Filter ""
+SOURCE=..\..\..\Common\Vector.h
+# End Source File
# Begin Source File
-SOURCE=.\ExtractDialog.cpp
+SOURCE=..\..\..\Common\Wildcard.cpp
# End Source File
# Begin Source File
-SOURCE=.\ExtractDialog.h
+SOURCE=..\..\..\Common\Wildcard.h
# End Source File
# End Group
-# End Group
-# Begin Group "FM Common"
+# Begin Group "Windows"
+
+# PROP Default_Filter ""
+# Begin Group "Control"
# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\..\FileManager\ExtractCallback.cpp
+SOURCE=..\..\..\Windows\Control\ComboBox.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\ExtractCallback.h
+SOURCE=..\..\..\Windows\Control\ComboBox.h
# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\FolderInterface.h
+SOURCE=..\..\..\Windows\Control\Dialog.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\FormatUtils.cpp
+SOURCE=..\..\..\Windows\Control\Dialog.h
# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\FormatUtils.h
+SOURCE=..\..\..\Windows\Control\Edit.h
# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\HelpUtils.cpp
+SOURCE=..\..\..\Windows\Control\ListView.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\HelpUtils.h
+SOURCE=..\..\..\Windows\Control\ListView.h
# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\LangUtils.cpp
+SOURCE=..\..\..\Windows\Control\ProgressBar.h
# End Source File
+# End Group
# Begin Source File
-SOURCE=..\..\FileManager\LangUtils.h
+SOURCE=..\..\..\Windows\CommonDialog.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\OpenCallback.cpp
+SOURCE=..\..\..\Windows\CommonDialog.h
# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\OpenCallback.h
+SOURCE=..\..\..\Windows\DLL.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\ProgramLocation.cpp
+SOURCE=..\..\..\Windows\DLL.h
# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\ProgramLocation.h
+SOURCE=..\..\..\Windows\Error.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\RegistryUtils.cpp
+SOURCE=..\..\..\Windows\Error.h
# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\RegistryUtils.h
+SOURCE=..\..\..\Windows\FileDir.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\SplitUtils.cpp
+SOURCE=..\..\..\Windows\FileDir.h
# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\SplitUtils.h
+SOURCE=..\..\..\Windows\FileFind.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\StringUtils.cpp
+SOURCE=..\..\..\Windows\FileFind.h
# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\StringUtils.h
+SOURCE=..\..\..\Windows\FileIO.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\UpdateCallback100.cpp
+SOURCE=..\..\..\Windows\FileIO.h
# End Source File
# Begin Source File
-SOURCE=..\..\FileManager\UpdateCallback100.h
+SOURCE=..\..\..\Windows\FileName.cpp
# End Source File
-# End Group
-# Begin Group "Engine"
-
-# PROP Default_Filter ""
# Begin Source File
-SOURCE=.\ExtractGUI.cpp
+SOURCE=..\..\..\Windows\FileName.h
# End Source File
# Begin Source File
-SOURCE=.\ExtractGUI.h
+SOURCE=..\..\..\Windows\MemoryLock.cpp
# End Source File
# Begin Source File
-SOURCE=.\GUI.cpp
+SOURCE=..\..\..\Windows\MemoryLock.h
# End Source File
# Begin Source File
-SOURCE=.\OpenCallbackGUI.cpp
+SOURCE=..\..\..\Windows\PropVariant.cpp
# End Source File
# Begin Source File
-SOURCE=.\OpenCallbackGUI.h
+SOURCE=..\..\..\Windows\PropVariant.h
# End Source File
# Begin Source File
-SOURCE=.\UpdateCallbackGUI.cpp
+SOURCE=..\..\..\Windows\PropVariantConversions.cpp
# End Source File
# Begin Source File
-SOURCE=.\UpdateCallbackGUI.h
+SOURCE=..\..\..\Windows\PropVariantConversions.h
# End Source File
# Begin Source File
-SOURCE=.\UpdateGUI.cpp
+SOURCE=..\..\..\Windows\Registry.cpp
# End Source File
# Begin Source File
-SOURCE=.\UpdateGUI.h
+SOURCE=..\..\..\Windows\Registry.h
# End Source File
-# End Group
-# Begin Group "7-zip Common"
-
-# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\..\Common\FilePathAutoRename.cpp
+SOURCE=..\..\..\Windows\ResourceString.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\Common\FilePathAutoRename.h
+SOURCE=..\..\..\Windows\ResourceString.h
# End Source File
# Begin Source File
-SOURCE=..\..\Common\FileStreams.cpp
+SOURCE=..\..\..\Windows\Shell.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\Common\FileStreams.h
+SOURCE=..\..\..\Windows\Shell.h
# End Source File
# Begin Source File
-SOURCE=..\..\Common\StreamUtils.cpp
+SOURCE=..\..\..\Windows\Synchronization.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\Common\StreamUtils.h
+SOURCE=..\..\..\Windows\Synchronization.h
# End Source File
-# End Group
-# Begin Group "Compress"
+# Begin Source File
-# PROP Default_Filter ""
+SOURCE=..\..\..\Windows\System.h
+# End Source File
# Begin Source File
-SOURCE=..\..\Compress\Copy\CopyCoder.cpp
+SOURCE=..\..\..\Windows\Window.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\Compress\Copy\CopyCoder.h
+SOURCE=..\..\..\Windows\Window.h
# End Source File
# End Group
# End Target
diff --git a/CPP/7zip/UI/GUI/Resource/BenchmarkDialog/BenchmarkDialog.cpp b/CPP/7zip/UI/GUI/Resource/BenchmarkDialog/BenchmarkDialog.cpp
new file mode 100755
index 00000000..15d6ee39
--- /dev/null
+++ b/CPP/7zip/UI/GUI/Resource/BenchmarkDialog/BenchmarkDialog.cpp
@@ -0,0 +1,584 @@
+// BenchmarkDialog.cpp
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+#include "Common/StringToInt.h"
+#include "Common/Exception.h"
+#include "Windows/Thread.h"
+#include "Windows/Error.h"
+#include "Windows/System.h"
+#include "../../../../FileManager/HelpUtils.h"
+#include "resource.h"
+#include "BenchmarkDialog.h"
+
+using namespace NWindows;
+
+// const int kNumBenchDictionaryBitsStart = 21;
+
+static LPCWSTR kHelpTopic = L"fm/benchmark.htm";
+
+static const UINT_PTR kTimerID = 4;
+static const UINT kTimerElapse = 1000;
+
+#ifdef LANG
+#include "../../../../FileManager/LangUtils.h"
+#endif
+
+using namespace NWindows;
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDC_BENCHMARK_DICTIONARY, 0x02000D0C },
+ { IDC_BENCHMARK_MEMORY, 0x03080001 },
+ { IDC_BENCHMARK_NUM_THREADS, 0x02000D12 },
+ { IDC_BENCHMARK_SPEED_LABEL, 0x03080004 },
+ { IDC_BENCHMARK_RATING_LABEL, 0x03080005 },
+ { IDC_BENCHMARK_COMPRESSING, 0x03080002 },
+ { IDC_BENCHMARK_DECOMPRESSING, 0x03080003 },
+ { IDC_BENCHMARK_CURRENT, 0x03080007 },
+ { IDC_BENCHMARK_RESULTING, 0x03080008 },
+ { IDC_BENCHMARK_CURRENT2, 0x03080007 },
+ { IDC_BENCHMARK_RESULTING2, 0x03080008 },
+ { IDC_BENCHMARK_TOTAL_RATING, 0x03080006 },
+ { IDC_BENCHMARK_ELAPSED, 0x02000C01 },
+ { IDC_BENCHMARK_SIZE, 0x02000C03 },
+ { IDC_BENCHMARK_PASSES, 0x03080009 },
+ // { IDC_BENCHMARK_ERRORS, 0x0308000A },
+ { IDC_BENCHMARK_USAGE_LABEL, 0x0308000B },
+ { IDC_BENCHMARK_RPU_LABEL, 0x0308000C },
+ { IDC_BENCHMARK_COMBO_NUM_THREADS, 0x02000D12},
+
+ { IDC_BUTTON_STOP, 0x02000714 },
+ { IDC_BUTTON_RESTART, 0x02000715 },
+ { IDHELP, 0x02000720 },
+ { IDCANCEL, 0x02000710 }
+};
+#endif
+
+static void MyMessageBoxError(HWND hwnd, LPCWSTR message)
+{
+ MessageBoxW(hwnd, message, L"7-Zip", MB_ICONERROR);
+}
+
+const LPCTSTR kProcessingString = TEXT("...");
+const LPCTSTR kMB = TEXT(" MB");
+const LPCTSTR kMIPS = TEXT(" MIPS");
+const LPCTSTR kKBs = TEXT(" KB/s");
+
+static const int kMinDicLogSize = 21;
+static const UInt32 kMinDicSize = (1 << kMinDicLogSize);
+static const UInt32 kMaxDicSize =
+ #ifdef _WIN64
+ (1 << 30);
+ #else
+ (1 << 27);
+ #endif
+
+static const int kDefaultDictionary = 22;
+
+bool CBenchmarkDialog::OnInit()
+{
+ #ifdef LANG
+ LangSetWindowText(HWND(*this), 0x03080000);
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+
+ _syncInfo.Init();
+
+ m_Dictionary.Attach(GetItem(IDC_BENCHMARK_COMBO_DICTIONARY));
+ int cur = 0;
+ // _syncInfo.DictionarySize = (1 << kNumBenchDictionaryBitsStart);
+
+ UInt32 numCPUs = NSystem::GetNumberOfProcessors();
+ if (numCPUs < 1)
+ numCPUs = 1;
+ numCPUs = MyMin(numCPUs, (UInt32)(1 << 8));
+ cur = 0;
+ bool setDefaultThreads = (_syncInfo.NumThreads == (UInt32)(-1));
+ if (setDefaultThreads)
+ {
+ _syncInfo.NumThreads = numCPUs;
+ if (_syncInfo.NumThreads > 1)
+ _syncInfo.NumThreads &= ~1;
+ }
+
+ UInt64 ramSize = NSystem::GetRamSize();
+ bool setDefaultDictionary = (_syncInfo.DictionarySize == (UInt32)(-1));
+ if (setDefaultDictionary)
+ {
+ int dicSizeLog;
+ for (dicSizeLog = 25; dicSizeLog >= kBenchMinDicLogSize; dicSizeLog--)
+ if (GetBenchMemoryUsage(_syncInfo.NumThreads, ((UInt32)1 << dicSizeLog)) + (8 << 20) <= ramSize)
+ break;
+ _syncInfo.DictionarySize = (1 << dicSizeLog);
+ }
+ if (_syncInfo.DictionarySize < kMinDicSize)
+ _syncInfo.DictionarySize = kMinDicSize;
+ if (_syncInfo.DictionarySize > kMaxDicSize)
+ _syncInfo.DictionarySize = kMaxDicSize;
+
+ for (int i = kMinDicLogSize; i <= 30; i++)
+ for (int j = 0; j < 2; j++)
+ {
+ UInt32 dictionary = (1 << i) + (j << (i - 1));
+ if (dictionary > kMaxDicSize)
+ continue;
+ TCHAR s[40];
+ ConvertUInt64ToString((dictionary >> 20), s);
+ lstrcat(s, kMB);
+ int index = (int)m_Dictionary.AddString(s);
+ m_Dictionary.SetItemData(index, dictionary);
+ if (dictionary <= _syncInfo.DictionarySize)
+ cur = index;
+ }
+ m_Dictionary.SetCurSel(cur);
+
+ m_NumThreads.Attach(GetItem(IDC_BENCHMARK_COMBO_NUM_THREADS));
+ for (UInt32 num = 1; ;)
+ {
+ if (num > numCPUs * 2)
+ break;
+ TCHAR s[40];
+ ConvertUInt64ToString(num, s);
+ int index = (int)m_NumThreads.AddString(s);
+ m_NumThreads.SetItemData(index, num);
+ if (num <= numCPUs && setDefaultThreads)
+ {
+ _syncInfo.NumThreads = num;
+ cur = index;
+ }
+ if (num > 1)
+ num++;
+ num++;
+ }
+ m_NumThreads.SetCurSel(cur);
+
+ OnChangeSettings();
+
+ _syncInfo._startEvent.Set();
+ _timer = SetTimer(kTimerID, kTimerElapse);
+ return CModalDialog::OnInit();
+}
+
+UInt32 CBenchmarkDialog::GetNumberOfThreads()
+{
+ return (UInt32)m_NumThreads.GetItemData(m_NumThreads.GetCurSel());
+}
+
+UInt32 CBenchmarkDialog::OnChangeDictionary()
+{
+ UInt32 dictionary = (UInt32)m_Dictionary.GetItemData(m_Dictionary.GetCurSel());
+ UInt64 memUsage = GetBenchMemoryUsage(GetNumberOfThreads(), dictionary);
+ memUsage = (memUsage + (1 << 20) - 1) >> 20;
+ TCHAR s[40];
+ ConvertUInt64ToString(memUsage, s);
+ lstrcat(s, kMB);
+ SetItemText(IDC_BENCHMARK_MEMORY_VALUE, s);
+ return dictionary;
+}
+
+static const UInt32 g_IDs[] =
+{
+ IDC_BENCHMARK_COMPRESSING_USAGE,
+ IDC_BENCHMARK_COMPRESSING_USAGE2,
+ IDC_BENCHMARK_COMPRESSING_SPEED,
+ IDC_BENCHMARK_COMPRESSING_SPEED2,
+ IDC_BENCHMARK_COMPRESSING_RATING,
+ IDC_BENCHMARK_COMPRESSING_RATING2,
+ IDC_BENCHMARK_COMPRESSING_RPU,
+ IDC_BENCHMARK_COMPRESSING_RPU2,
+
+ IDC_BENCHMARK_DECOMPRESSING_SPEED,
+ IDC_BENCHMARK_DECOMPRESSING_SPEED2,
+ IDC_BENCHMARK_DECOMPRESSING_RATING,
+ IDC_BENCHMARK_DECOMPRESSING_RATING2,
+ IDC_BENCHMARK_DECOMPRESSING_USAGE,
+ IDC_BENCHMARK_DECOMPRESSING_USAGE2,
+ IDC_BENCHMARK_DECOMPRESSING_RPU,
+ IDC_BENCHMARK_DECOMPRESSING_RPU2,
+
+ IDC_BENCHMARK_TOTAL_USAGE_VALUE,
+ IDC_BENCHMARK_TOTAL_RATING_VALUE,
+ IDC_BENCHMARK_TOTAL_RPU_VALUE
+};
+
+void CBenchmarkDialog::OnChangeSettings()
+{
+ EnableItem(IDC_BUTTON_STOP, true);
+ UInt32 dictionary = OnChangeDictionary();
+ TCHAR s[40] = { TEXT('/'), TEXT(' '), 0 };
+ ConvertUInt64ToString(NSystem::GetNumberOfProcessors(), s + 2);
+ SetItemText(IDC_BENCHMARK_HARDWARE_THREADS, s);
+ for (int i = 0; i < sizeof(g_IDs) / sizeof(g_IDs[0]); i++)
+ SetItemText(g_IDs[i], kProcessingString);
+ _startTime = GetTickCount();
+ PrintTime();
+ NWindows::NSynchronization::CCriticalSectionLock lock(_syncInfo.CS);
+ _syncInfo.Init();
+ _syncInfo.DictionarySize = dictionary;
+ _syncInfo.Changed = true;
+ _syncInfo.NumThreads = GetNumberOfThreads();
+}
+
+void CBenchmarkDialog::OnRestartButton()
+{
+ OnChangeSettings();
+}
+
+void CBenchmarkDialog::OnStopButton()
+{
+ EnableItem(IDC_BUTTON_STOP, false);
+ _syncInfo.Pause();
+}
+
+void CBenchmarkDialog::OnHelp()
+{
+ ShowHelpWindow(NULL, kHelpTopic);
+}
+
+void CBenchmarkDialog::OnCancel()
+{
+ _syncInfo.Stop();
+ KillTimer(_timer);
+ CModalDialog::OnCancel();
+}
+
+static void GetTimeString(UInt64 timeValue, TCHAR *s)
+{
+ wsprintf(s, TEXT("%02d:%02d:%02d"),
+ UInt32(timeValue / 3600),
+ UInt32((timeValue / 60) % 60),
+ UInt32(timeValue % 60));
+}
+
+void CBenchmarkDialog::PrintTime()
+{
+ UInt32 curTime = ::GetTickCount();
+ UInt32 elapsedTime = (curTime - _startTime);
+ UInt32 elapsedSec = elapsedTime / 1000;
+ if (elapsedSec != 0 && _syncInfo.WasPaused())
+ return;
+ TCHAR s[40];
+ GetTimeString(elapsedSec, s);
+ SetItemText(IDC_BENCHMARK_ELAPSED_VALUE, s);
+}
+
+void CBenchmarkDialog::PrintRating(UInt64 rating, UINT controlID)
+{
+ TCHAR s[40];
+ ConvertUInt64ToString(rating / 1000000, s);
+ lstrcat(s, kMIPS);
+ SetItemText(controlID, s);
+}
+
+void CBenchmarkDialog::PrintUsage(UInt64 usage, UINT controlID)
+{
+ TCHAR s[40];
+ ConvertUInt64ToString((usage + 5000) / 10000, s);
+ lstrcat(s, TEXT("%"));
+ SetItemText(controlID, s);
+}
+
+void CBenchmarkDialog::PrintResults(
+ UInt32 dictionarySize,
+ const CBenchInfo2 &info,
+ UINT usageID, UINT speedID, UINT rpuID, UINT ratingID,
+ bool decompressMode)
+{
+ if (info.GlobalTime == 0)
+ return;
+
+ UInt64 size = info.UnpackSize;
+ TCHAR s[40];
+ {
+ UInt64 speed = size * info.GlobalFreq / info.GlobalTime;
+ ConvertUInt64ToString(speed / 1024, s);
+ lstrcat(s, kKBs);
+ SetItemText(speedID, s);
+ }
+ UInt64 rating;
+ if (decompressMode)
+ rating = GetDecompressRating(info.GlobalTime, info.GlobalFreq, size, info.PackSize, 1);
+ else
+ rating = GetCompressRating(dictionarySize, info.GlobalTime, info.GlobalFreq, size * info.NumIterations);
+
+ PrintRating(rating, ratingID);
+ PrintRating(GetRatingPerUsage(info, rating), rpuID);
+ PrintUsage(GetUsage(info), usageID);
+}
+
+bool CBenchmarkDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
+{
+ PrintTime();
+ NWindows::NSynchronization::CCriticalSectionLock lock(_syncInfo.CS);
+
+ TCHAR s[40];
+ ConvertUInt64ToString((_syncInfo.ProcessedSize >> 20), s);
+ lstrcat(s, kMB);
+ SetItemText(IDC_BENCHMARK_SIZE_VALUE, s);
+
+ ConvertUInt64ToString(_syncInfo.NumPasses, s);
+ SetItemText(IDC_BENCHMARK_PASSES_VALUE, s);
+
+ /*
+ ConvertUInt64ToString(_syncInfo.NumErrors, s);
+ SetItemText(IDC_BENCHMARK_ERRORS_VALUE, s);
+ */
+
+ {
+ UInt32 dicSizeTemp = (UInt32)MyMax(_syncInfo.ProcessedSize, UInt64(1) << 20);
+ dicSizeTemp = MyMin(dicSizeTemp, _syncInfo.DictionarySize),
+ PrintResults(dicSizeTemp,
+ _syncInfo.CompressingInfoTemp,
+ IDC_BENCHMARK_COMPRESSING_USAGE,
+ IDC_BENCHMARK_COMPRESSING_SPEED,
+ IDC_BENCHMARK_COMPRESSING_RPU,
+ IDC_BENCHMARK_COMPRESSING_RATING);
+ }
+
+ {
+ PrintResults(
+ _syncInfo.DictionarySize,
+ _syncInfo.CompressingInfo,
+ IDC_BENCHMARK_COMPRESSING_USAGE2,
+ IDC_BENCHMARK_COMPRESSING_SPEED2,
+ IDC_BENCHMARK_COMPRESSING_RPU2,
+ IDC_BENCHMARK_COMPRESSING_RATING2);
+ }
+
+ {
+ PrintResults(
+ _syncInfo.DictionarySize,
+ _syncInfo.DecompressingInfoTemp,
+ IDC_BENCHMARK_DECOMPRESSING_USAGE,
+ IDC_BENCHMARK_DECOMPRESSING_SPEED,
+ IDC_BENCHMARK_DECOMPRESSING_RPU,
+ IDC_BENCHMARK_DECOMPRESSING_RATING,
+ true);
+ }
+ {
+ PrintResults(
+ _syncInfo.DictionarySize,
+ _syncInfo.DecompressingInfo,
+ IDC_BENCHMARK_DECOMPRESSING_USAGE2,
+ IDC_BENCHMARK_DECOMPRESSING_SPEED2,
+ IDC_BENCHMARK_DECOMPRESSING_RPU2,
+ IDC_BENCHMARK_DECOMPRESSING_RATING2,
+ true);
+ if (_syncInfo.DecompressingInfo.GlobalTime > 0 &&
+ _syncInfo.CompressingInfo.GlobalTime > 0)
+ {
+ UInt64 comprRating = GetCompressRating(_syncInfo.DictionarySize,
+ _syncInfo.CompressingInfo.GlobalTime, _syncInfo.CompressingInfo.GlobalFreq, _syncInfo.CompressingInfo.UnpackSize);
+ UInt64 decomprRating = GetDecompressRating(_syncInfo.DecompressingInfo.GlobalTime,
+ _syncInfo.DecompressingInfo.GlobalFreq, _syncInfo.DecompressingInfo.UnpackSize,
+ _syncInfo.DecompressingInfo.PackSize, 1);
+ PrintRating((comprRating + decomprRating) / 2, IDC_BENCHMARK_TOTAL_RATING_VALUE);
+ PrintRating((
+ GetRatingPerUsage(_syncInfo.CompressingInfo, comprRating) +
+ GetRatingPerUsage(_syncInfo.DecompressingInfo, decomprRating)) / 2, IDC_BENCHMARK_TOTAL_RPU_VALUE);
+ PrintUsage((GetUsage(_syncInfo.CompressingInfo) + GetUsage(_syncInfo.DecompressingInfo)) / 2, IDC_BENCHMARK_TOTAL_USAGE_VALUE);
+ }
+ }
+ return true;
+}
+
+bool CBenchmarkDialog::OnCommand(int code, int itemID, LPARAM lParam)
+{
+ if (code == CBN_SELCHANGE &&
+ (itemID == IDC_BENCHMARK_COMBO_DICTIONARY ||
+ itemID == IDC_BENCHMARK_COMBO_NUM_THREADS))
+ {
+ OnChangeSettings();
+ return true;
+ }
+ return CModalDialog::OnCommand(code, itemID, lParam);
+}
+
+bool CBenchmarkDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
+ switch(buttonID)
+ {
+ case IDC_BUTTON_RESTART:
+ OnRestartButton();
+ return true;
+ case IDC_BUTTON_STOP:
+ OnStopButton();
+ return true;
+ }
+ return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
+}
+
+struct CThreadBenchmark
+{
+ CProgressSyncInfo *SyncInfo;
+ UInt64 _startTime;
+ #ifdef EXTERNAL_LZMA
+ CCodecs *codecs;
+ #endif
+ // UInt32 dictionarySize;
+ // UInt32 numThreads;
+
+ HRESULT Process();
+ HRESULT Result;
+ static DWORD WINAPI MyThreadFunction(void *param)
+ {
+ ((CThreadBenchmark *)param)->Result = ((CThreadBenchmark *)param)->Process();
+ return 0;
+ }
+};
+
+struct CBenchCallback: public IBenchCallback
+{
+ UInt32 dictionarySize;
+ CProgressSyncInfo *SyncInfo;
+ HRESULT SetEncodeResult(const CBenchInfo &info, bool final);
+ HRESULT SetDecodeResult(const CBenchInfo &info, bool final);
+};
+
+HRESULT CBenchCallback::SetEncodeResult(const CBenchInfo &info, bool final)
+{
+ NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
+ if (SyncInfo->Changed || SyncInfo->Paused || SyncInfo->Stopped)
+ return E_ABORT;
+ SyncInfo->ProcessedSize = info.UnpackSize;
+ if (final && SyncInfo->CompressingInfo.GlobalTime == 0)
+ {
+ (CBenchInfo&)SyncInfo->CompressingInfo = info;
+ if (SyncInfo->CompressingInfo.GlobalTime == 0)
+ SyncInfo->CompressingInfo.GlobalTime = 1;
+ }
+ else
+ (CBenchInfo&)SyncInfo->CompressingInfoTemp = info;
+
+ return S_OK;
+}
+
+HRESULT CBenchCallback::SetDecodeResult(const CBenchInfo &info, bool final)
+{
+ NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
+ if (SyncInfo->Changed || SyncInfo->Paused || SyncInfo->Stopped)
+ return E_ABORT;
+ CBenchInfo info2 = info;
+ if (info2.NumIterations == 0)
+ info2.NumIterations = 1;
+
+ info2.GlobalTime /= info2.NumIterations;
+ info2.UserTime /= info2.NumIterations;
+
+ if (final && SyncInfo->DecompressingInfo.GlobalTime == 0)
+ {
+ (CBenchInfo&)SyncInfo->DecompressingInfo = info2;
+ if (SyncInfo->DecompressingInfo.GlobalTime == 0)
+ SyncInfo->DecompressingInfo.GlobalTime = 1;
+ }
+ else
+ (CBenchInfo&)SyncInfo->DecompressingInfoTemp = info2;
+ return S_OK;
+}
+
+HRESULT CThreadBenchmark::Process()
+{
+ try
+ {
+ SyncInfo->WaitCreating();
+ for (;;)
+ {
+ if (SyncInfo->WasStopped())
+ return 0;
+ if (SyncInfo->WasPaused())
+ {
+ Sleep(200);
+ continue;
+ }
+ UInt32 dictionarySize;
+ UInt32 numThreads;
+ {
+ NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
+ if (SyncInfo->Stopped || SyncInfo->Paused)
+ continue;
+ if (SyncInfo->Changed)
+ SyncInfo->Init();
+ dictionarySize = SyncInfo->DictionarySize;
+ numThreads = SyncInfo->NumThreads;
+ }
+
+ CBenchCallback callback;
+ callback.dictionarySize = dictionarySize;
+ callback.SyncInfo = SyncInfo;
+ HRESULT result;
+ try
+ {
+ result = LzmaBench(
+ #ifdef EXTERNAL_LZMA
+ codecs,
+ #endif
+ numThreads, dictionarySize, &callback);
+ }
+ catch(...)
+ {
+ result = E_FAIL;
+ }
+
+ if (result != S_OK)
+ {
+ if (result != E_ABORT)
+ {
+ // SyncInfo->NumErrors++;
+ {
+ NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
+ SyncInfo->Pause();
+ }
+ CSysString message;
+ if (result == S_FALSE)
+ message = TEXT("Decoding error");
+ else
+ message = NError::MyFormatMessage(result);
+ MessageBox(0, message, TEXT("7-Zip"), MB_ICONERROR);
+ }
+ }
+ else
+ {
+ NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
+ SyncInfo->NumPasses++;
+ }
+ }
+ // return S_OK;
+ }
+ catch(CSystemException &e)
+ {
+ MessageBox(0, NError::MyFormatMessage(e.ErrorCode), TEXT("7-Zip"), MB_ICONERROR);
+ return E_FAIL;
+ }
+ catch(...)
+ {
+ MyMessageBoxError(0, L"Some error");
+ return E_FAIL;
+ }
+}
+
+HRESULT Benchmark(
+ #ifdef EXTERNAL_LZMA
+ CCodecs *codecs,
+ #endif
+ UInt32 numThreads, UInt32 dictionarySize)
+{
+ CThreadBenchmark benchmarker;
+ #ifdef EXTERNAL_LZMA
+ benchmarker.codecs = codecs;
+ #endif
+
+ CBenchmarkDialog benchmarkDialog;
+ benchmarkDialog._syncInfo.DictionarySize = dictionarySize;
+ benchmarkDialog._syncInfo.NumThreads = numThreads;
+
+ benchmarker.SyncInfo = &benchmarkDialog._syncInfo;
+ CThread thread;
+ if (!thread.Create(CThreadBenchmark::MyThreadFunction, &benchmarker))
+ return E_FAIL;
+ benchmarkDialog.Create(0);
+ thread.Wait();
+ return S_OK;
+}
diff --git a/CPP/7zip/UI/GUI/Resource/BenchmarkDialog/BenchmarkDialog.h b/CPP/7zip/UI/GUI/Resource/BenchmarkDialog/BenchmarkDialog.h
new file mode 100755
index 00000000..716d0f55
--- /dev/null
+++ b/CPP/7zip/UI/GUI/Resource/BenchmarkDialog/BenchmarkDialog.h
@@ -0,0 +1,126 @@
+// BenchmarkDialog.h
+
+#ifndef __BENCHMARKDIALOG_H
+#define __BENCHMARKDIALOG_H
+
+#include "resource.h"
+
+#include "Windows/Control/Dialog.h"
+#include "Windows/Control/ComboBox.h"
+#include "Windows/Synchronization.h"
+#include "../../../../Compress/LZMA_Alone/LzmaBench.h"
+
+#ifdef EXTERNAL_LZMA
+#include "../../../../UI/Common/LoadCodecs.h"
+#endif
+
+struct CBenchInfo2 : public CBenchInfo
+{
+ void Init() { GlobalTime = UserTime = 0; }
+};
+
+class CProgressSyncInfo
+{
+public:
+ bool Stopped;
+ bool Paused;
+ bool Changed;
+ UInt32 DictionarySize;
+ UInt32 NumThreads;
+ UInt64 NumPasses;
+ // UInt64 NumErrors;
+ NWindows::NSynchronization::CManualResetEvent _startEvent;
+ NWindows::NSynchronization::CCriticalSection CS;
+
+ CBenchInfo2 CompressingInfoTemp;
+ CBenchInfo2 CompressingInfo;
+ UInt64 ProcessedSize;
+
+ CBenchInfo2 DecompressingInfoTemp;
+ CBenchInfo2 DecompressingInfo;
+
+ void Init()
+ {
+ Changed = false;
+ Stopped = false;
+ Paused = false;
+ CompressingInfoTemp.Init();
+ CompressingInfo.Init();
+ ProcessedSize = 0;
+
+ DecompressingInfoTemp.Init();
+ DecompressingInfo.Init();
+
+ NumPasses = 0;
+ // NumErrors = 0;
+ }
+ void Stop()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(CS);
+ Stopped = true;
+ }
+ bool WasStopped()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(CS);
+ return Stopped;
+ }
+ void Pause()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(CS);
+ Paused = true;
+ }
+ void Start()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(CS);
+ Paused = false;
+ }
+ bool WasPaused()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(CS);
+ return Paused;
+ }
+ void WaitCreating() { _startEvent.Lock(); }
+};
+
+class CBenchmarkDialog:
+ public NWindows::NControl::CModalDialog
+{
+ NWindows::NControl::CComboBox m_Dictionary;
+ NWindows::NControl::CComboBox m_NumThreads;
+ UINT_PTR _timer;
+ UINT32 _startTime;
+
+ bool OnTimer(WPARAM timerID, LPARAM callback);
+ virtual bool OnInit();
+ void OnRestartButton();
+ void OnStopButton();
+ void OnHelp();
+ virtual void OnCancel();
+ bool OnButtonClicked(int buttonID, HWND buttonHWND);
+ bool OnCommand(int code, int itemID, LPARAM lParam);
+
+ void PrintTime();
+ void PrintRating(UInt64 rating, UINT controlID);
+ void PrintUsage(UInt64 usage, UINT controlID);
+ void PrintResults(
+ UINT32 dictionarySize,
+ const CBenchInfo2 &info, UINT usageID, UINT speedID, UINT rpuID, UINT ratingID,
+ bool decompressMode = false);
+
+ UInt32 GetNumberOfThreads();
+ UInt32 OnChangeDictionary();
+ void OnChangeSettings();
+public:
+ CProgressSyncInfo _syncInfo;
+
+ CBenchmarkDialog(): _timer(0) {}
+ INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_DIALOG_BENCHMARK, wndParent); }
+};
+
+HRESULT Benchmark(
+ #ifdef EXTERNAL_LZMA
+ CCodecs *codecs,
+ #endif
+ UInt32 dictionarySize, UInt32 numThreads);
+
+#endif
diff --git a/CPP/7zip/UI/GUI/Resource/BenchmarkDialog/StdAfx.h b/CPP/7zip/UI/GUI/Resource/BenchmarkDialog/StdAfx.h
new file mode 100755
index 00000000..a444ca31
--- /dev/null
+++ b/CPP/7zip/UI/GUI/Resource/BenchmarkDialog/StdAfx.h
@@ -0,0 +1,16 @@
+// stdafx.h
+
+#ifndef __STDAFX_H
+#define __STDAFX_H
+
+#define _WIN32_WINNT 0x0400
+
+// it's for Windows NT supporting (MENUITEMINFOW)
+#define WINVER 0x0400
+
+#include <windows.h>
+#include <commctrl.h>
+
+#include "Common/NewHandler.h"
+
+#endif
diff --git a/CPP/7zip/UI/GUI/Resource/BenchmarkDialog/resource.h b/CPP/7zip/UI/GUI/Resource/BenchmarkDialog/resource.h
new file mode 100755
index 00000000..6ef52188
--- /dev/null
+++ b/CPP/7zip/UI/GUI/Resource/BenchmarkDialog/resource.h
@@ -0,0 +1,54 @@
+#define IDD_DIALOG_BENCHMARK 800
+#define IDC_BUTTON_STOP 1001
+#define IDC_BUTTON_RESTART 1002
+#define IDC_BENCHMARK_DICTIONARY 1010
+#define IDC_BENCHMARK_COMBO_DICTIONARY 1011
+#define IDC_BENCHMARK_MEMORY 1012
+#define IDC_BENCHMARK_MEMORY_VALUE 1013
+#define IDC_BENCHMARK_NUM_THREADS 1014
+#define IDC_BENCHMARK_COMBO_NUM_THREADS 1015
+#define IDC_BENCHMARK_HARDWARE_THREADS 1016
+
+#define IDC_BENCHMARK_SPEED_LABEL 1020
+#define IDC_BENCHMARK_RATING_LABEL 1021
+#define IDC_BENCHMARK_COMPRESSING 1022
+#define IDC_BENCHMARK_DECOMPRESSING 1023
+#define IDC_BENCHMARK_CURRENT 1024
+#define IDC_BENCHMARK_RESULTING 1025
+#define IDC_BENCHMARK_CURRENT2 1026
+#define IDC_BENCHMARK_RESULTING2 1027
+#define IDC_BENCHMARK_USAGE_LABEL 1028
+#define IDC_BENCHMARK_RPU_LABEL 1029
+
+#define IDC_BENCHMARK_COMPRESSING_SPEED 1030
+#define IDC_BENCHMARK_COMPRESSING_SPEED2 1031
+#define IDC_BENCHMARK_COMPRESSING_RATING 1032
+#define IDC_BENCHMARK_COMPRESSING_RATING2 1033
+#define IDC_BENCHMARK_COMPRESSING_USAGE 1034
+#define IDC_BENCHMARK_COMPRESSING_USAGE2 1035
+#define IDC_BENCHMARK_COMPRESSING_RPU 1036
+#define IDC_BENCHMARK_COMPRESSING_RPU2 1037
+
+
+#define IDC_BENCHMARK_DECOMPRESSING_SPEED 1040
+#define IDC_BENCHMARK_DECOMPRESSING_SPEED2 1041
+#define IDC_BENCHMARK_DECOMPRESSING_RATING 1042
+#define IDC_BENCHMARK_DECOMPRESSING_RATING2 1043
+#define IDC_BENCHMARK_DECOMPRESSING_USAGE 1044
+#define IDC_BENCHMARK_DECOMPRESSING_USAGE2 1045
+#define IDC_BENCHMARK_DECOMPRESSING_RPU 1046
+#define IDC_BENCHMARK_DECOMPRESSING_RPU2 1047
+
+
+#define IDC_BENCHMARK_TOTAL_RATING 1050
+
+#define IDC_BENCHMARK_TOTAL_RATING_VALUE 1051
+#define IDC_BENCHMARK_TOTAL_RPU_VALUE 1052
+#define IDC_BENCHMARK_TOTAL_USAGE_VALUE 1053
+
+#define IDC_BENCHMARK_ELAPSED 1060
+#define IDC_BENCHMARK_ELAPSED_VALUE 1061
+#define IDC_BENCHMARK_SIZE 1062
+#define IDC_BENCHMARK_SIZE_VALUE 1063
+#define IDC_BENCHMARK_PASSES 1066
+#define IDC_BENCHMARK_PASSES_VALUE 1067
diff --git a/CPP/7zip/UI/GUI/Resource/BenchmarkDialog/resource.rc b/CPP/7zip/UI/GUI/Resource/BenchmarkDialog/resource.rc
new file mode 100755
index 00000000..43b59be8
--- /dev/null
+++ b/CPP/7zip/UI/GUI/Resource/BenchmarkDialog/resource.rc
@@ -0,0 +1,116 @@
+#include "resource.h"
+#include "../../../../GuiCommon.rc"
+
+#define xSize2 330
+#define ySize2 228
+
+#define xSize (xSize2 + marg + marg)
+#define ySize (ySize2 + marg + marg)
+
+#undef g0XSize
+#undef g1XPos
+#undef g1XSize
+#undef g2XSize
+#undef g3XPos
+#undef g3XSize
+
+#define bXPos1 (xSize - marg - bXSize)
+#define bXPos2 (bXPos1 - 10 - bXSize)
+
+#define bYPos (ySize - marg - bYSize)
+
+#define gSize 160
+#define gSpace 24
+
+#define g0XSize 90
+#define g1XSize 44
+#define g1XPos (marg + g0XSize)
+#define gc2XPos (g1XPos + g1XSize + 10)
+#define gc2XSize 80
+
+#define g10XPos (marg + marg)
+
+#define gRatingSize 60
+#define gSpeedSize 60
+#define gUsageSize 60
+#define gRpuSize 60
+
+#define gRatingPos (xSize - marg - marg - gRatingSize)
+#define gRpuPos (gRatingPos - gRpuSize)
+#define gUsagePos (gRpuPos - gUsageSize)
+#define gSpeedPos (gUsagePos - gSpeedSize)
+
+#define gLabelSize (gUsagePos - g10XPos)
+#define gTotalRatingSize (gUsageSize + gRpuSize + gRatingSize + marg + marg)
+#define gTotalRatingPos (xSize - marg - gTotalRatingSize)
+
+#define g2XSize 58
+#define g3XSize 36
+#define g3XPos (marg + g2XSize)
+
+
+IDD_DIALOG_BENCHMARK DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE | WS_MINIMIZEBOX
+CAPTION "Benchmark"
+MY_FONT
+BEGIN
+ PUSHBUTTON "&Restart", IDC_BUTTON_RESTART, bXPos1, marg, bXSize, bYSize
+ PUSHBUTTON "&Stop", IDC_BUTTON_STOP, bXPos1, 27, bXSize, bYSize
+
+ PUSHBUTTON "&Help", IDHELP, bXPos2, bYPos, bXSize,bYSize
+ PUSHBUTTON "Cancel", IDCANCEL, bXPos1, bYPos, bXSize, bYSize
+
+ LTEXT "&Dictionary size:", IDC_BENCHMARK_DICTIONARY, marg, marg + 1, g0XSize, 8
+ COMBOBOX IDC_BENCHMARK_COMBO_DICTIONARY, g1XPos, marg, g1XSize, 140, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+
+ LTEXT "&Number of CPU threads:", IDC_BENCHMARK_NUM_THREADS, marg, 24, g0XSize, 8
+ COMBOBOX IDC_BENCHMARK_COMBO_NUM_THREADS, g1XPos, 23, g1XSize, 140, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+
+ LTEXT "Memory usage:", IDC_BENCHMARK_MEMORY, gc2XPos, marg + 1, gc2XSize, 8
+ LTEXT "0 MB", IDC_BENCHMARK_MEMORY_VALUE, gc2XPos + gc2XSize, marg + 1, 40, 8
+ LTEXT "1", IDC_BENCHMARK_HARDWARE_THREADS, gc2XPos, 24, 40, 8
+
+ RTEXT "CPU Usage", IDC_BENCHMARK_USAGE_LABEL, gUsagePos, 53, gUsageSize, 8
+ RTEXT "Speed", IDC_BENCHMARK_SPEED_LABEL, gSpeedPos, 53, gSpeedSize, 8
+ RTEXT "Rating / Usage", IDC_BENCHMARK_RPU_LABEL, gRpuPos, 53, gRpuSize, 8
+ RTEXT "Rating", IDC_BENCHMARK_RATING_LABEL, gRatingPos, 53, gRatingSize, 8
+
+ GROUPBOX "Compressing", IDC_BENCHMARK_COMPRESSING, marg, 64, xSize2, 40
+
+ LTEXT "Current", IDC_BENCHMARK_CURRENT, g10XPos, 76, gLabelSize, 8
+ RTEXT "100%", IDC_BENCHMARK_COMPRESSING_USAGE, gUsagePos, 76, gUsageSize, 8
+ RTEXT "100 KB/s", IDC_BENCHMARK_COMPRESSING_SPEED, gSpeedPos, 76, gSpeedSize, 8
+ RTEXT "0", IDC_BENCHMARK_COMPRESSING_RPU, gRpuPos, 76, gRpuSize, 8
+ RTEXT "0", IDC_BENCHMARK_COMPRESSING_RATING, gRatingPos, 76, gRatingSize, 8
+
+ LTEXT "Resulting", IDC_BENCHMARK_RESULTING, g10XPos, 89, gLabelSize, 8
+ RTEXT "100%", IDC_BENCHMARK_COMPRESSING_USAGE2, gUsagePos, 89, gUsageSize, 8
+ RTEXT "100 KB/s", IDC_BENCHMARK_COMPRESSING_SPEED2, gSpeedPos, 89, gSpeedSize, 8
+ RTEXT "0", IDC_BENCHMARK_COMPRESSING_RPU2, gRpuPos, 89, gRpuSize, 8
+ RTEXT "0", IDC_BENCHMARK_COMPRESSING_RATING2, gRatingPos, 89, gRatingSize, 8
+
+ GROUPBOX "Decompressing", IDC_BENCHMARK_DECOMPRESSING, marg, 111, xSize2, 40
+
+ LTEXT "Current", IDC_BENCHMARK_CURRENT2, g10XPos, 123, gLabelSize, 8
+ RTEXT "100%", IDC_BENCHMARK_DECOMPRESSING_USAGE, gUsagePos, 123, gUsageSize, 8
+ RTEXT "100 KB/s", IDC_BENCHMARK_DECOMPRESSING_SPEED, gSpeedPos, 123, gSpeedSize, 8
+ RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RPU, gRpuPos, 123, gRpuSize, 8
+ RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RATING, gRatingPos, 123, gRatingSize, 8
+
+ LTEXT "Resulting", IDC_BENCHMARK_RESULTING2, g10XPos, 136, gLabelSize, 8
+ RTEXT "100%", IDC_BENCHMARK_DECOMPRESSING_USAGE2, gUsagePos, 136, gUsageSize, 8
+ RTEXT "100 KB/s", IDC_BENCHMARK_DECOMPRESSING_SPEED2, gSpeedPos, 136, gSpeedSize, 8
+ RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RPU2, gRpuPos, 136, gRpuSize, 8
+ RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RATING2, gRatingPos, 136, gRatingSize, 8
+
+ GROUPBOX "Total Rating", IDC_BENCHMARK_TOTAL_RATING, gTotalRatingPos, 163, gTotalRatingSize, 38
+ RTEXT "0", IDC_BENCHMARK_TOTAL_USAGE_VALUE, gUsagePos, 181, gUsageSize, 8
+ RTEXT "0", IDC_BENCHMARK_TOTAL_RPU_VALUE, gRpuPos, 181, gRpuSize, 8
+ RTEXT "0", IDC_BENCHMARK_TOTAL_RATING_VALUE, gRatingPos, 181, gRatingSize, 8
+
+ LTEXT "Elapsed time:", IDC_BENCHMARK_ELAPSED, marg, 163, g2XSize, 8
+ LTEXT "Size:", IDC_BENCHMARK_SIZE, marg, 176, g2XSize, 8
+ LTEXT "Passes:", IDC_BENCHMARK_PASSES, marg, 189, g2XSize, 8
+ RTEXT "00:00:00", IDC_BENCHMARK_ELAPSED_VALUE, g3XPos, 163, g3XSize, 8
+ RTEXT "0", IDC_BENCHMARK_SIZE_VALUE, g3XPos, 176, g3XSize, 8
+ RTEXT "0", IDC_BENCHMARK_PASSES_VALUE, g3XPos, 189, g3XSize, 8
+END
diff --git a/CPP/7zip/UI/GUI/UpdateGUI.cpp b/CPP/7zip/UI/GUI/UpdateGUI.cpp
index e39e7faf..1150804e 100755
--- a/CPP/7zip/UI/GUI/UpdateGUI.cpp
+++ b/CPP/7zip/UI/GUI/UpdateGUI.cpp
@@ -36,8 +36,9 @@ static const wchar_t *kSFXExtension = L"exe";
struct CThreadUpdating
{
- CUpdateCallbackGUI *UpdateCallbackGUI;
+ CCodecs *codecs;
+ CUpdateCallbackGUI *UpdateCallbackGUI;
const NWildcard::CCensor *WildcardCensor;
CUpdateOptions *Options;
COpenCallbackGUI *OpenCallback;
@@ -50,7 +51,7 @@ struct CThreadUpdating
UpdateCallbackGUI->ProgressDialog.WaitCreating();
try
{
- Result = UpdateArchive(*WildcardCensor, *Options,
+ Result = UpdateArchive(codecs, *WildcardCensor, *Options,
*ErrorInfo, OpenCallback, UpdateCallbackGUI);
}
catch(const UString &s)
@@ -81,8 +82,7 @@ struct CThreadUpdating
}
};
-static void AddProp(CObjectVector<CProperty> &properties,
- const UString &name, const UString &value)
+static void AddProp(CObjectVector<CProperty> &properties, const UString &name, const UString &value)
{
CProperty prop;
prop.Name = name;
@@ -90,16 +90,14 @@ static void AddProp(CObjectVector<CProperty> &properties,
properties.Add(prop);
}
-static void AddProp(CObjectVector<CProperty> &properties,
- const UString &name, UInt32 value)
+static void AddProp(CObjectVector<CProperty> &properties, const UString &name, UInt32 value)
{
wchar_t tmp[32];
ConvertUInt64ToString(value, tmp);
AddProp(properties, name, tmp);
}
-static void AddProp(CObjectVector<CProperty> &properties,
- const UString &name, bool value)
+static void AddProp(CObjectVector<CProperty> &properties, const UString &name, bool value)
{
AddProp(properties, name, value ? UString(L"on"): UString(L"off"));
}
@@ -149,6 +147,16 @@ static void ParseAndAddPropertires(CObjectVector<CProperty> &properties,
}
}
+static UString GetNumInBytesString(UInt64 v)
+{
+ wchar_t s[32];
+ ConvertUInt64ToString(v, s);
+ size_t len = wcslen(s);
+ s[len++] = L'B';
+ s[len] = L'\0';
+ return s;
+}
+
static void SetOutProperties(
CObjectVector<CProperty> &properties,
bool is7z,
@@ -158,8 +166,8 @@ static void SetOutProperties(
UInt32 dictionary,
bool orderMode,
UInt32 order,
- bool solidModeIsAllowed, bool solidMode,
- bool multiThreadIsAllowed, bool multiThread,
+ bool solidIsSpecified, UInt64 solidBlockSize,
+ bool multiThreadIsAllowed, UInt32 numThreads,
const UString &encryptionMethod,
bool encryptHeadersIsAllowed, bool encryptHeaders,
bool /* sfxMode */)
@@ -179,12 +187,7 @@ static void SetOutProperties(
name += L"mem";
else
name += L"d";
- wchar_t s[32];
- ConvertUInt64ToString(dictionary, s);
- size_t len = wcslen(s);
- s[len++] = L'B';
- s[len] = L'\0';
- AddProp(properties, name, UString(s));
+ AddProp(properties, name, GetNumInBytesString(dictionary));
}
if (order != (UInt32)(Int32)-1)
{
@@ -204,20 +207,19 @@ static void SetOutProperties(
if (encryptHeadersIsAllowed)
AddProp(properties, L"he", encryptHeaders);
- if (solidModeIsAllowed)
- AddProp(properties, L"s", solidMode);
+ if (solidIsSpecified)
+ AddProp(properties, L"s", GetNumInBytesString(solidBlockSize));
if (multiThreadIsAllowed)
- AddProp(properties, L"mt", multiThread);
+ AddProp(properties, L"mt", numThreads);
}
-static HRESULT ShowDialog(const NWildcard::CCensor &censor,
+static HRESULT ShowDialog(
+ CCodecs *codecs,
+ const NWildcard::CCensor &censor,
CUpdateOptions &options, CUpdateCallbackGUI *callback)
{
if (options.Commands.Size() != 1)
throw "It must be one command";
- CObjectVector<CArchiverInfo> archivers;
- CArchiverInfo archiverInfo;
- ReadArchiverInfoList(archivers);
UString currentDirPrefix;
{
if (!NDirectory::MyGetCurrentDirectory(currentDirPrefix))
@@ -253,9 +255,9 @@ static HRESULT ShowDialog(const NWildcard::CCensor &censor,
CCompressDialog dialog;
NCompressDialog::CInfo &di = dialog.Info;
- for(int i = 0; i < archivers.Size(); i++)
+ for(int i = 0; i < codecs->Formats.Size(); i++)
{
- const CArchiverInfo &ai = archivers[i];
+ const CArcInfoEx &ai = codecs->Formats[i];
if (ai.UpdateEnabled && (oneFile || !ai.KeepName))
dialog.m_ArchiverInfoList.Add(ai);
}
@@ -272,9 +274,6 @@ static HRESULT ShowDialog(const NWildcard::CCensor &censor,
di.CurrentDirPrefix = currentDirPrefix;
di.SFXMode = options.SfxMode;
- di.Solid = true;
- di.MultiThread = false;
-
if (callback->PasswordIsDefined)
di.Password = callback->Password;
@@ -311,7 +310,7 @@ static HRESULT ShowDialog(const NWildcard::CCensor &censor,
default:
throw 1091756;
}
- archiverInfo = dialog.m_ArchiverInfoList[di.ArchiverInfoIndex];
+ const CArcInfoEx &archiverInfo = dialog.m_ArchiverInfoList[di.ArchiverInfoIndex];
callback->PasswordIsDefined = (!di.Password.IsEmpty());
if (callback->PasswordIsDefined)
callback->Password = di.Password;
@@ -329,8 +328,8 @@ static HRESULT ShowDialog(const NWildcard::CCensor &censor,
di.Method,
di.Dictionary,
di.OrderMode, di.Order,
- di.SolidIsAllowed, di.Solid,
- di.MultiThreadIsAllowed, di.MultiThread,
+ di.SolidIsSpecified, di.SolidBlockSize,
+ di.MultiThreadIsAllowed, di.NumThreads,
di.EncryptionMethod,
di.EncryptHeadersIsAllowed, di.EncryptHeaders,
di.SFXMode);
@@ -339,10 +338,9 @@ static HRESULT ShowDialog(const NWildcard::CCensor &censor,
if (di.SFXMode)
options.SfxMode = true;
- options.MethodMode.FilePath = archiverInfo.FilePath;
- options.MethodMode.ClassID = archiverInfo.ClassID;
+ options.MethodMode.FormatIndex = archiverInfo.FormatIndex;
- options.ArchivePath.VolExtension = archiverInfo.GetMainExtension();
+ options.ArchivePath.VolExtension = archiverInfo.GetMainExt();
if(di.SFXMode)
options.ArchivePath.BaseExtension = kSFXExtension;
else
@@ -363,6 +361,7 @@ static HRESULT ShowDialog(const NWildcard::CCensor &censor,
}
HRESULT UpdateGUI(
+ CCodecs *codecs,
const NWildcard::CCensor &censor,
CUpdateOptions &options,
bool showDialog,
@@ -372,13 +371,15 @@ HRESULT UpdateGUI(
{
if (showDialog)
{
- RINOK(ShowDialog(censor, options, callback));
+ RINOK(ShowDialog(codecs, censor, options, callback));
}
if (options.SfxMode && options.SfxModule.IsEmpty())
options.SfxModule = kDefaultSfxModule;
CThreadUpdating tu;
+ tu.codecs = codecs;
+
tu.UpdateCallbackGUI = callback;
tu.UpdateCallbackGUI->Init();
diff --git a/CPP/7zip/UI/GUI/UpdateGUI.h b/CPP/7zip/UI/GUI/UpdateGUI.h
index c5061aca..0d9d7bcd 100755
--- a/CPP/7zip/UI/GUI/UpdateGUI.h
+++ b/CPP/7zip/UI/GUI/UpdateGUI.h
@@ -10,6 +10,7 @@
#include "../../FileManager/UpdateCallback100.h"
HRESULT UpdateGUI(
+ CCodecs *codecs,
const NWildcard::CCensor &censor,
CUpdateOptions &options,
bool showDialog,
diff --git a/CPP/7zip/UI/GUI/makefile b/CPP/7zip/UI/GUI/makefile
index bc6af149..cac56df0 100755
--- a/CPP/7zip/UI/GUI/makefile
+++ b/CPP/7zip/UI/GUI/makefile
@@ -1,6 +1,13 @@
PROG = 7zG.exe
LIBS = $(LIBS) user32.lib advapi32.lib oleaut32.lib shell32.lib comctl32.lib htmlhelp.lib ole32.lib comdlg32.lib
-CFLAGS = $(CFLAGS) -I ../../../ -DLANG -DCOMPRESS_MT -DWIN_LONG_PATH
+CFLAGS = $(CFLAGS) -I ../../../ \
+ -DLANG \
+ -DCOMPRESS_MT \
+ -DWIN_LONG_PATH \
+ -DEXTERNAL_LZMA \
+ -DEXTERNAL_CODECS \
+ -DBENCH_MT \
+ -D_7ZIP_LARGE_PAGES \
GUI_OBJS = \
$O\CompressDialog.obj \
@@ -12,8 +19,8 @@ GUI_OBJS = \
$O\UpdateGUI.obj \
COMMON_OBJS = \
- $O\Alloc.obj \
$O\CommandLineParser.obj \
+ $O\CRC.obj \
$O\IntToString.obj \
$O\Lang.obj \
$O\ListFileUtils.obj \
@@ -58,11 +65,11 @@ UI_COMMON_OBJS = \
$O\ArchiveCommandLine.obj \
$O\ArchiveExtractCallback.obj \
$O\ArchiveOpenCallback.obj \
- $O\ArchiverInfo.obj \
$O\DefaultName.obj \
$O\EnumDirItems.obj \
$O\Extract.obj \
$O\ExtractingFilePath.obj \
+ $O\LoadCodecs.obj \
$O\OpenArchive.obj \
$O\PropIDUtils.obj \
$O\SetProperties.obj \
@@ -76,6 +83,9 @@ UI_COMMON_OBJS = \
$O\WorkDir.obj \
$O\ZipRegistry.obj \
+LZMA_BENCH_OBJS = \
+ $O\LzmaBench.obj \
+
FM_OBJS = \
$O\ExtractCallback.obj \
$O\FormatUtils.obj \
@@ -88,6 +98,11 @@ FM_OBJS = \
$O\StringUtils.obj \
$O\UpdateCallback100.obj \
+C_OBJS = \
+ $O\Alloc.obj \
+
+!include "../../Crc2.mak"
+
OBJS = \
$O\StdAfx.obj \
$(GUI_OBJS) \
@@ -102,7 +117,11 @@ OBJS = \
$O\OverwriteDialog.obj \
$O\PasswordDialog.obj \
$O\ProgressDialog.obj \
+ $O\BenchmarkDialog.obj \
$O\CopyCoder.obj \
+ $(LZMA_BENCH_OBJS) \
+ $(C_OBJS) \
+ $(CRC_OBJS) \
$O\resource.res
!include "../../../Build.mak"
@@ -131,5 +150,14 @@ $O\PasswordDialog.obj: ../../FileManager/Resource/PasswordDialog/$(*B).cpp
$(COMPL)
$O\ProgressDialog.obj: ../../FileManager/Resource/ProgressDialog2/$(*B).cpp
$(COMPL)
+$O\BenchmarkDialog.obj: Resource/BenchmarkDialog/$(*B).cpp
+ $(COMPL)
+
+
$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
$(COMPL)
+$(LZMA_BENCH_OBJS): ../../Compress/LZMA_Alone/$(*B).cpp
+ $(COMPL)
+$(C_OBJS): ../../../../C/$(*B).c
+ $(COMPL_O2)
+!include "../../Crc.mak"
diff --git a/CPP/7zip/UI/GUI/resource.h b/CPP/7zip/UI/GUI/resource.h
index d88af787..d505afe0 100755
--- a/CPP/7zip/UI/GUI/resource.h
+++ b/CPP/7zip/UI/GUI/resource.h
@@ -17,6 +17,9 @@
#define IDS_METHOD_FASTEST 85
#define IDS_METHOD_ULTRA 86
+#define IDS_COMPRESS_NON_SOLID 88
+#define IDS_COMPRESS_SOLID 89
+
#define IDS_COMPRESS_UPDATE_MODE_ADD 90
#define IDS_COMPRESS_UPDATE_MODE_UPDATE 91
#define IDS_COMPRESS_UPDATE_MODE_FRESH 92
diff --git a/CPP/7zip/UI/GUI/resource.rc b/CPP/7zip/UI/GUI/resource.rc
index 19f7e61b..ba93ac43 100755
--- a/CPP/7zip/UI/GUI/resource.rc
+++ b/CPP/7zip/UI/GUI/resource.rc
@@ -27,6 +27,9 @@ BEGIN
IDS_METHOD_FAST "Fast"
IDS_METHOD_FASTEST "Fastest"
IDS_METHOD_ULTRA "Ultra"
+ IDS_COMPRESS_NON_SOLID "Non-solid"
+ IDS_COMPRESS_SOLID "Solid"
+
IDS_COMPRESS_UPDATE_MODE_ADD "Add and replace files"
IDS_COMPRESS_UPDATE_MODE_UPDATE "Update and add files"
IDS_COMPRESS_UPDATE_MODE_FRESH "Freshen existing files"
@@ -55,3 +58,4 @@ END
#include "../Resource/Extract/resource.rc"
#include "../Resource/ExtractDialog/resource.rc"
#include "../Resource/CompressDialog/resource.rc"
+#include "Resource/BenchmarkDialog/resource.rc"
diff --git a/CPP/7zip/UI/Resource/CompressDialog/resource.h b/CPP/7zip/UI/Resource/CompressDialog/resource.h
index 847bb3f9..a7401e2f 100755
--- a/CPP/7zip/UI/Resource/CompressDialog/resource.h
+++ b/CPP/7zip/UI/Resource/CompressDialog/resource.h
@@ -12,10 +12,17 @@
#define IDC_COMPRESS_COMBO_METHOD 1078
#define IDC_COMPRESS_COMBO_DICTIONARY 1079
#define IDC_COMPRESS_COMBO_ORDER 1080
+
+#define IDC_COMPRESS_COMBO_SOLID 1081
+#define IDC_COMPRESS_COMBO_THREADS 1082
+#define IDC_COMPRESS_HARDWARE_THREADS 1083
+
#define IDC_COMPRESS_SFX 1090
#define IDC_COMPRESS_EDIT_PARAMETERS 1091
-#define IDC_COMPRESS_SOLID 1092
-#define IDC_COMPRESS_MULTI_THREAD 1093
+
+// #define IDC_COMPRESS_SOLID 1092
+// #define IDC_COMPRESS_MULTI_THREAD 1093
+
#define IDC_STATIC_COMPRESS_ARCHIVE 1097
#define IDC_STATIC_COMPRESS_FORMAT 1098
#define IDC_STATIC_COMPRESS_LEVEL 1099
@@ -27,6 +34,9 @@
#define IDC_STATIC_COMPRESS_DICTIONARY 1105
#define IDC_STATIC_COMPRESS_ORDER 1106
+#define IDC_STATIC_COMPRESS_SOLID 1107
+#define IDC_STATIC_COMPRESS_THREADS 1108
+
#define IDC_COMPRESS_ENCRYPTION 1110
#define IDC_STATIC_COMPRESS_PASSWORD1 1111
#define IDC_COMPRESS_EDIT_PASSWORD1 1112
diff --git a/CPP/7zip/UI/Resource/CompressDialog/resource.rc b/CPP/7zip/UI/Resource/CompressDialog/resource.rc
index 9019a1af..109c7e14 100755
--- a/CPP/7zip/UI/Resource/CompressDialog/resource.rc
+++ b/CPP/7zip/UI/Resource/CompressDialog/resource.rc
@@ -1,8 +1,8 @@
#include "resource.h"
#include "../../../GuiCommon.rc"
-#define xSize2 344
-#define ySize2 295
+#define xSize2 380
+#define ySize2 305
#define xSize (xSize2 + marg + marg)
#define ySize (ySize2 + marg + marg)
@@ -24,10 +24,10 @@
#undef bXPos3
#undef bYPos
-#define gSize 160
+#define gSize 180
#define gSpace 24
-#define g0XSize 82
+#define g0XSize 100
#define g1XPos (marg + g0XSize)
#define g1XSize (gSize - g0XSize)
@@ -69,24 +69,26 @@ BEGIN
LTEXT "&Word size:",IDC_STATIC_COMPRESS_ORDER, marg, 125, g0XSize, 8
COMBOBOX IDC_COMPRESS_COMBO_ORDER, g1XPos, 123, g1XSize, 141, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ LTEXT "&Solid Block size:",IDC_STATIC_COMPRESS_SOLID, marg, 146, g0XSize, 8
+ COMBOBOX IDC_COMPRESS_COMBO_SOLID, g1XPos, 144, g1XSize, 140, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+
+ LTEXT "&Number of CPU threads:",IDC_STATIC_COMPRESS_THREADS, marg, 167, g0XSize, 8
+ COMBOBOX IDC_COMPRESS_COMBO_THREADS, g1XPos, 165, g1XSize - 35, 140, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ RTEXT "1", IDC_COMPRESS_HARDWARE_THREADS, g1XPos + g1XSize - 35 + 10, 167, 25, 8
+
- LTEXT "Memory usage for Compressing:", IDC_STATIC_COMPRESS_MEMORY, marg, 149, g2XSize, 8
- RTEXT "0", IDC_STATIC_COMPRESS_MEMORY_VALUE, g3XPos, 149, g3XSize, 8
+ LTEXT "Memory usage for Compressing:", IDC_STATIC_COMPRESS_MEMORY, marg, 190, g2XSize, 8
+ RTEXT "0", IDC_STATIC_COMPRESS_MEMORY_VALUE, g3XPos, 190, g3XSize, 8
- LTEXT "Memory usage for Decompressing:", IDC_STATIC_COMPRESS_MEMORY_DE, marg, 163, g2XSize, 8
- RTEXT "0",IDC_STATIC_COMPRESS_MEMORY_DE_VALUE, g3XPos, 163, g3XSize, 8
-
+ LTEXT "Memory usage for Decompressing:", IDC_STATIC_COMPRESS_MEMORY_DE, marg, 206, g2XSize, 8
+ RTEXT "0",IDC_STATIC_COMPRESS_MEMORY_DE_VALUE, g3XPos, 206, g3XSize, 8
- CONTROL "Create &Solid archive", IDC_COMPRESS_SOLID,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,
- marg, 181, gSize, 10
- CONTROL "Multi-threading", IDC_COMPRESS_MULTI_THREAD, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
- marg, 195, gSize, 10
- LTEXT "Split to &volumes, bytes:", IDC_STATIC_COMPRESS_VOLUME, marg, 215, gSize, 8
- COMBOBOX IDC_COMPRESS_COMBO_VOLUME, marg, 227, gSize, 73, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
+ LTEXT "Split to &volumes, bytes:", IDC_STATIC_COMPRESS_VOLUME, marg, 225, gSize, 8
+ COMBOBOX IDC_COMPRESS_COMBO_VOLUME, marg, 237, gSize, 73, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
- LTEXT "&Parameters:",IDC_STATIC_COMPRESS_PARAMETERS, marg, 250, xSize2, 8
- EDITTEXT IDC_COMPRESS_EDIT_PARAMETERS, marg, 262, xSize2, 14, ES_AUTOHSCROLL
+ LTEXT "&Parameters:",IDC_STATIC_COMPRESS_PARAMETERS, marg, 260, xSize2, 8
+ EDITTEXT IDC_COMPRESS_EDIT_PARAMETERS, marg, 272, xSize2, 14, ES_AUTOHSCROLL
LTEXT "&Update mode:",IDC_STATIC_COMPRESS_UPDATE_MODE, g4XPos, 39, g4XSize, 8
COMBOBOX IDC_COMPRESS_COMBO_UPDATE_MODE, g4XPos, 51, g4XSize, 80, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP