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

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/7zip/FileManager')
-rwxr-xr-xCPP/7zip/FileManager/FM.cpp21
-rwxr-xr-xCPP/7zip/FileManager/FM.dsp180
-rwxr-xr-xCPP/7zip/FileManager/FilePlugins.cpp18
-rwxr-xr-xCPP/7zip/FileManager/FilePlugins.h2
-rwxr-xr-xCPP/7zip/FileManager/IFolder.h17
-rwxr-xr-xCPP/7zip/FileManager/MyLoadMenu.cpp4
-rwxr-xr-xCPP/7zip/FileManager/PanelCrc.cpp20
-rwxr-xr-xCPP/7zip/FileManager/PanelSplitFile.cpp6
-rwxr-xr-xCPP/7zip/FileManager/PhysDriveFolder.cpp125
-rwxr-xr-xCPP/7zip/FileManager/PhysDriveFolder.h3
-rwxr-xr-xCPP/7zip/FileManager/RegistryAssociations.cpp49
-rwxr-xr-xCPP/7zip/FileManager/RegistryAssociations.h4
-rwxr-xr-xCPP/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.cpp976
-rwxr-xr-xCPP/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.h136
-rwxr-xr-xCPP/7zip/FileManager/Resource/BenchmarkDialog/StdAfx.h16
-rwxr-xr-xCPP/7zip/FileManager/Resource/BenchmarkDialog/resource.h34
-rwxr-xr-xCPP/7zip/FileManager/Resource/BenchmarkDialog/resource.rc87
-rwxr-xr-xCPP/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp4
-rwxr-xr-xCPP/7zip/FileManager/Resource/SystemPage/SystemPage.cpp45
-rwxr-xr-xCPP/7zip/FileManager/Resource/SystemPage/resource.rc7
-rwxr-xr-xCPP/7zip/FileManager/makefile29
-rwxr-xr-xCPP/7zip/FileManager/resource.rc1
22 files changed, 311 insertions, 1473 deletions
diff --git a/CPP/7zip/FileManager/FM.cpp b/CPP/7zip/FileManager/FM.cpp
index c64f0b51..17670423 100755
--- a/CPP/7zip/FileManager/FM.cpp
+++ b/CPP/7zip/FileManager/FM.cpp
@@ -1,13 +1,17 @@
-// FAM.cpp
+// FM.cpp
#include "StdAfx.h"
#include "resource.h"
#include "Panel.h"
+extern "C"
+{
+ #include "../../../C/Alloc.h"
+}
+
#include "Common/Defs.h"
#include "Common/StringConvert.h"
-#include "Common/Alloc.h"
// #include "Common/CommandLineParser.h"
#include "Windows/Control/Toolbar.h"
@@ -33,8 +37,6 @@ using namespace NFile;
using namespace NFind;
// using namespace NCommandLineParser;
-// NWindows::NCOM::CComInitializer aComInitializer;
-
#define MAX_LOADSTRING 100
#define MENU_HEIGHT 26
@@ -602,8 +604,17 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
g_App.CreateDragTarget();
bool archiveIsOpened;
bool encrypted;
+ bool needOpenFile = false;
+ if (!g_MainPath.IsEmpty() /* && g_OpenArchive */)
+ {
+ NFile::NFind::CFileInfoW fileInfo;
+ if (NFile::NFind::FindFile(g_MainPath, fileInfo))
+ if (!fileInfo.IsDirectory())
+ needOpenFile = true;
+ }
g_App.Create(hWnd, g_MainPath, xSizes, archiveIsOpened, encrypted);
- if (!archiveIsOpened && g_OpenArchive)
+
+ if (needOpenFile && !archiveIsOpened)
{
UString message;
if (encrypted)
diff --git a/CPP/7zip/FileManager/FM.dsp b/CPP/7zip/FileManager/FM.dsp
index 75c95ead..f84d19d1 100755
--- a/CPP/7zip/FileManager/FM.dsp
+++ b/CPP/7zip/FileManager/FM.dsp
@@ -489,18 +489,6 @@ SOURCE=.\Resource\AboutDialog\AboutDialog.cpp
SOURCE=.\Resource\AboutDialog\AboutDialog.h
# End Source File
# End Group
-# Begin Group "Benchmark"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\Resource\BenchmarkDialog\BenchmarkDialog.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Resource\BenchmarkDialog\BenchmarkDialog.h
-# End Source File
-# End Group
# Begin Group "Split"
# PROP Default_Filter ""
@@ -606,9 +594,93 @@ SOURCE=.\UpdateCallback100.cpp
SOURCE=.\UpdateCallback100.h
# End Source File
# End Group
-# Begin Group "SDK"
+# Begin Group "UI Common"
# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\UI\Common\ArchiveName.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\UI\Common\ArchiveName.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\UI\Common\CompressCall.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\UI\Common\CompressCall.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\UI\Common\PropIDUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\UI\Common\PropIDUtils.h
+# End Source File
+# 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\StreamObjects.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\StreamObjects.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
+# 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 Group "Windows"
# PROP Default_Filter ""
@@ -894,14 +966,6 @@ SOURCE=..\..\Windows\Window.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
@@ -922,10 +986,6 @@ SOURCE=..\..\Common\CRC.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\Common\CRC.h
-# End Source File
-# Begin Source File
-
SOURCE=..\..\Common\Defs.h
# End Source File
# Begin Source File
@@ -1049,76 +1109,6 @@ SOURCE=..\..\Common\Wildcard.cpp
SOURCE=..\..\Common\Wildcard.h
# End Source File
# End Group
-# End Group
-# Begin Group "UI Common"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\UI\Common\ArchiveName.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\UI\Common\ArchiveName.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\UI\Common\CompressCall.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\UI\Common\CompressCall.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\UI\Common\PropIDUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\UI\Common\PropIDUtils.h
-# End Source File
-# 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\StreamObjects.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\StreamObjects.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=.\7zFM.exe.manifest
diff --git a/CPP/7zip/FileManager/FilePlugins.cpp b/CPP/7zip/FileManager/FilePlugins.cpp
index 524b6aa7..0ae8279d 100755
--- a/CPP/7zip/FileManager/FilePlugins.cpp
+++ b/CPP/7zip/FileManager/FilePlugins.cpp
@@ -59,17 +59,15 @@ void CExtDatabase::Read()
if (pluginLibrary.LoadAndCreateManager(pluginInfo.FilePath,
pluginInfo.ClassID, &folderManager) != S_OK)
continue;
- CMyComBSTR typesString;
- if (folderManager->GetTypes(&typesString) != S_OK)
- continue;
- UStringVector types;
- SplitString((const wchar_t *)typesString, types);
- for (int typeIndex = 0; typeIndex < types.Size(); typeIndex++)
+ CMyComBSTR extBSTR;
+ if (folderManager->GetExtensions(&extBSTR) != S_OK)
+ return;
+ const UString ext2 = (const wchar_t *)extBSTR;
+ UStringVector exts;
+ SplitString(ext2, exts);
+ for (int i = 0; i < exts.Size(); i++)
{
- CMyComBSTR extTemp;
- if (folderManager->GetExtension(types[typeIndex], &extTemp) != S_OK)
- continue;
- const UString ext = (const wchar_t *)extTemp;
+ const UString &ext = exts[i];
int index = FindExtInfoBig(ext);
if (index < 0)
{
diff --git a/CPP/7zip/FileManager/FilePlugins.h b/CPP/7zip/FileManager/FilePlugins.h
index 805cac2a..1becb9d1 100755
--- a/CPP/7zip/FileManager/FilePlugins.h
+++ b/CPP/7zip/FileManager/FilePlugins.h
@@ -23,7 +23,7 @@ struct CExtInfoBig
for (int i = 0; i < PluginsPairs.Size(); i++)
if (PluginsPairs[i].Index == pluginIndex)
return i;
- return -1;
+ return -1;
}
};
diff --git a/CPP/7zip/FileManager/IFolder.h b/CPP/7zip/FileManager/IFolder.h
index aa50a39d..4758ea5b 100755
--- a/CPP/7zip/FileManager/IFolder.h
+++ b/CPP/7zip/FileManager/IFolder.h
@@ -155,18 +155,23 @@ DEFINE_GUID(IID_ ## i, \
0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x09, 0x00, x, 0x00, 0x00); \
struct i: public IUnknown
-FOLDER_MANAGER_INTERFACE(IFolderManager, 0x00)
+// old interfaces 00, 01
+
+FOLDER_MANAGER_INTERFACE(IFolderManager, 0x02)
{
STDMETHOD(OpenFolderFile)(const wchar_t *filePath, IFolderFolder **resultFolder, IProgress *progress) PURE;
- STDMETHOD(GetTypes)(BSTR *types) PURE;
- STDMETHOD(GetExtension)(const wchar_t *type, BSTR *extension) PURE;
- STDMETHOD(CreateFolderFile)(const wchar_t *type, const wchar_t *filePath, IProgress *progress) PURE;
+ STDMETHOD(GetExtensions)(BSTR *extensions) PURE;
+ STDMETHOD(GetIconPath)(const wchar_t *ext, BSTR *iconPath, Int32 *iconIndex) PURE;
+ // STDMETHOD(GetTypes)(BSTR *types) PURE;
+ // STDMETHOD(GetExtensions)(const wchar_t *type, BSTR *extensions) PURE;
+ // STDMETHOD(CreateFolderFile)(const wchar_t *type, const wchar_t *filePath, IProgress *progress) PURE;
};
-FOLDER_MANAGER_INTERFACE(IFolderManagerGetIconPath, 0x01)
+/*
+FOLDER_MANAGER_INTERFACE(IFolderManagerGetIconPath, 0x03)
{
- STDMETHOD(GetIconPath)(const wchar_t *type, BSTR *iconPath) PURE;
};
+*;/
/*
FOLDER_INTERFACE(IFolderExtract, 0x05, 0x0A);
diff --git a/CPP/7zip/FileManager/MyLoadMenu.cpp b/CPP/7zip/FileManager/MyLoadMenu.cpp
index 8be1e28f..41b0ace0 100755
--- a/CPP/7zip/FileManager/MyLoadMenu.cpp
+++ b/CPP/7zip/FileManager/MyLoadMenu.cpp
@@ -12,7 +12,7 @@
#include "resource.h"
#include "App.h"
#include "Resource/AboutDialog/AboutDialog.h"
-#include "Resource/BenchmarkDialog/BenchmarkDialog.h"
+#include "../UI/Common/CompressCall.h"
#include "HelpUtils.h"
#include "LangUtils.h"
@@ -662,7 +662,7 @@ bool OnMenuCommand(HWND hWnd, int id)
break;
case IDM_BENCHMARK:
- Benchmark(hWnd);
+ Benchmark();
break;
// Help
case IDM_HELP_CONTENTS:
diff --git a/CPP/7zip/FileManager/PanelCrc.cpp b/CPP/7zip/FileManager/PanelCrc.cpp
index 12dcee55..7a190840 100755
--- a/CPP/7zip/FileManager/PanelCrc.cpp
+++ b/CPP/7zip/FileManager/PanelCrc.cpp
@@ -4,8 +4,12 @@
#include "resource.h"
-#include "Common/Alloc.h"
-#include "Common/CRC.h"
+extern "C"
+{
+ #include "../../../C/Alloc.h"
+ #include "../../../C/7zCrc.h"
+}
+
#include "Common/IntToString.h"
#include "Common/StringConvert.h"
@@ -194,7 +198,7 @@ struct CThreadCrc
if (!filled)
break;
- CCRC crc;
+ UInt32 crc = CRC_INIT_VAL;
if (fileInfo.IsDirectory())
NumFolders++;
else
@@ -221,21 +225,21 @@ struct CThreadCrc
}
if (processedSize == 0)
break;
- crc.Update(buffer, processedSize);
+ crc = CrcUpdate(crc, buffer, processedSize);
DataSize += processedSize;
Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(DataSize);
if (Result != S_OK)
return;
}
- DataCrcSum += crc.GetDigest();
+ DataCrcSum += CRC_GET_DIGEST(crc);
}
for (int i = 0; i < resPath.Length(); i++)
{
wchar_t c = resPath[i];
- crc.UpdateByte((Byte)(c & 0xFF));
- crc.UpdateByte((Byte)((c >> 8) & 0xFF));
+ crc = CRC_UPDATE_BYTE(crc, ((Byte)(c & 0xFF)));
+ crc = CRC_UPDATE_BYTE(crc, ((Byte)((c >> 8) & 0xFF)));
}
- DataNameCrcSum += crc.GetDigest();
+ DataNameCrcSum += CRC_GET_DIGEST(crc);
Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(DataSize);
if (Result != S_OK)
return;
diff --git a/CPP/7zip/FileManager/PanelSplitFile.cpp b/CPP/7zip/FileManager/PanelSplitFile.cpp
index 8e095628..7d4309d8 100755
--- a/CPP/7zip/FileManager/PanelSplitFile.cpp
+++ b/CPP/7zip/FileManager/PanelSplitFile.cpp
@@ -4,7 +4,11 @@
#include "resource.h"
-#include "Common/Alloc.h"
+extern "C"
+{
+ #include "../../../C/Alloc.h"
+}
+
#include "Common/Types.h"
#include "Common/IntToString.h"
diff --git a/CPP/7zip/FileManager/PhysDriveFolder.cpp b/CPP/7zip/FileManager/PhysDriveFolder.cpp
index b69d3cb3..fc5045eb 100755
--- a/CPP/7zip/FileManager/PhysDriveFolder.cpp
+++ b/CPP/7zip/FileManager/PhysDriveFolder.cpp
@@ -2,10 +2,12 @@
#include "StdAfx.h"
-#include "PhysDriveFolder.h"
-
-#include "Common/Alloc.h"
+extern "C"
+{
+ #include "../../../C/Alloc.h"
+}
+#include "PhysDriveFolder.h"
#include "Windows/PropVariant.h"
#include "Windows/FileDevice.h"
#include "Windows/FileSystem.h"
@@ -22,12 +24,6 @@ static STATPROPSTG kProperties[] =
{ NULL, kpidSize, VT_UI8}
};
-CPhysDriveFolder::~CPhysDriveFolder()
-{
- if (_buffer != 0)
- MyFree(_buffer);
-}
-
HRESULT CPhysDriveFolder::Init(const UString &path)
{
_prefix = L"\\\\.\\";
@@ -186,6 +182,65 @@ HRESULT CPhysDriveFolder::GetLength(UInt64 &length) const
return S_OK;
}
+struct CPhysTempBuffer
+{
+ void *buffer;
+ CPhysTempBuffer(): buffer(0) {}
+ ~CPhysTempBuffer() { MyFree(buffer); }
+};
+
+HRESULT CopyFileSpec(LPCWSTR fromPath, LPCWSTR toPath, bool writeToDisk, UInt64 fileSize, UInt32 bufferSize, IProgress *progress)
+{
+ NFile::NIO::CInFile inFile;
+ if (!inFile.Open(fromPath))
+ return GetLastError();
+ if (fileSize == (UInt64)(Int64)-1)
+ {
+ if (!inFile.GetLength(fileSize))
+ ::GetLastError();
+ }
+ NFile::NIO::COutFile outFile;
+ if (writeToDisk)
+ {
+ if (!outFile.Open(toPath, FILE_SHARE_WRITE, OPEN_EXISTING, 0))
+ return GetLastError();
+ }
+ else
+ if (!outFile.Create(toPath, true))
+ return GetLastError();
+ CPhysTempBuffer tempBuffer;
+ tempBuffer.buffer = MyAlloc(bufferSize);
+ if (tempBuffer.buffer == 0)
+ return E_OUTOFMEMORY;
+
+ for (UInt64 pos = 0; pos < fileSize;)
+ {
+ RINOK(progress->SetCompleted(&pos));
+ UInt64 rem = fileSize - pos;
+ UInt32 curSize = (UInt32)MyMin(rem, (UInt64)bufferSize);
+ UInt32 processedSize;
+ if (!inFile.Read(tempBuffer.buffer, curSize, processedSize))
+ return GetLastError();
+ if (processedSize == 0)
+ break;
+ curSize = processedSize;
+ if (writeToDisk)
+ {
+ const UInt32 kMask = 0x1FF;
+ curSize = (curSize + kMask) & ~kMask;
+ if (curSize > bufferSize)
+ return E_FAIL;
+ }
+
+ if (!outFile.Write(tempBuffer.buffer, curSize, processedSize))
+ return GetLastError();
+ if (curSize != processedSize)
+ return E_FAIL;
+ pos += curSize;
+ }
+ return S_OK;
+}
+
STDMETHODIMP CPhysDriveFolder::CopyTo(const UInt32 * /* indices */, UInt32 numItems,
const wchar_t *path, IFolderOperationsExtractCallback *callback)
{
@@ -217,41 +272,9 @@ STDMETHODIMP CPhysDriveFolder::CopyTo(const UInt32 * /* indices */, UInt32 numIt
return S_OK;
RINOK(callback->SetCurrentFilePath(GetFullPathWithName()));
-
- NFile::NDevice::CInFile inFile;
- if (!inFile.Open(GetFullPath()))
- return GetLastError();
- NFile::NIO::COutFile outFile;
- if (!outFile.Create(destPathResult, true))
- return GetLastError();
- if (_buffer == 0)
- {
- _buffer = MyAlloc(kBufferSize);
- if (_buffer == 0)
- return E_OUTOFMEMORY;
- }
- UInt64 pos = 0;
- UInt32 bufferSize = kBufferSize;
- if (_driveType == DRIVE_REMOVABLE)
- bufferSize = (18 << 10) * 4;
- pos = 0;
- while(pos < fileSize)
- {
- RINOK(callback->SetCompleted(&pos));
- UInt32 curSize = (UInt32)MyMin(fileSize - pos, (UInt64)bufferSize);
- UInt32 processedSize;
- if (!inFile.Read(_buffer, curSize, processedSize))
- return GetLastError();
- if (processedSize == 0)
- break;
- curSize = processedSize;
- if (!outFile.Write(_buffer, curSize, processedSize))
- return GetLastError();
- if (curSize != processedSize)
- return E_FAIL;
- pos += curSize;
- }
- return S_OK;
+
+ UInt32 bufferSize = (_driveType == DRIVE_REMOVABLE) ? (18 << 10) * 4 : kBufferSize;
+ return CopyFileSpec(GetFullPath(), destPathResult, false, fileSize, bufferSize, callback);
}
/////////////////////////////////////////////////
@@ -267,8 +290,16 @@ STDMETHODIMP CPhysDriveFolder::MoveTo(
}
STDMETHODIMP CPhysDriveFolder::CopyFrom(
- const wchar_t * /* fromFolderPath */,
- const wchar_t ** /* itemsPaths */, UInt32 /* numItems */, IProgress * /* progress */)
+ const wchar_t * fromFolderPath,
+ const wchar_t ** itemsPaths, UInt32 numItems, IProgress *callback)
{
- return E_NOTIMPL;
+ if (numItems == 0)
+ return S_OK;
+ if (numItems != 1)
+ return E_INVALIDARG;
+ if (_driveType != DRIVE_REMOVABLE /* && _driveType != DRIVE_CDROM */)
+ return E_NOTIMPL;
+ UInt32 bufferSize = (_driveType == DRIVE_REMOVABLE) ? (18 << 10) * 4 : kBufferSize;
+ // MessageBoxW(0, fromFolderPath, itemsPaths[0], 0);
+ return CopyFileSpec((UString)fromFolderPath + itemsPaths[0], GetFullPath(), true, (UInt64)(Int64)-1, bufferSize, callback);
}
diff --git a/CPP/7zip/FileManager/PhysDriveFolder.h b/CPP/7zip/FileManager/PhysDriveFolder.h
index 076b0718..db339af4 100755
--- a/CPP/7zip/FileManager/PhysDriveFolder.h
+++ b/CPP/7zip/FileManager/PhysDriveFolder.h
@@ -73,7 +73,6 @@ private:
UString GetFullPath() const { return _prefix + _path; }
UString GetFullPathWithName() const { return GetFullPath() + L'\\' + _name; }
CMyComPtr<IFolderFolder> _parentFolder;
- void *_buffer;
UINT _driveType;
DISK_GEOMETRY geom;
@@ -82,8 +81,6 @@ private:
public:
HRESULT Init(const UString &path);
HRESULT GetLength(UInt64 &size) const;
- CPhysDriveFolder(): _buffer(0) {}
- ~CPhysDriveFolder();
};
#endif
diff --git a/CPP/7zip/FileManager/RegistryAssociations.cpp b/CPP/7zip/FileManager/RegistryAssociations.cpp
index b4b35c67..fe5cfae8 100755
--- a/CPP/7zip/FileManager/RegistryAssociations.cpp
+++ b/CPP/7zip/FileManager/RegistryAssociations.cpp
@@ -5,6 +5,8 @@
#include "RegistryAssociations.h"
#include "Common/StringConvert.h"
+#include "Common/IntToString.h"
+#include "Common/StringToInt.h"
#include "Windows/COM.h"
#include "Windows/Synchronization.h"
@@ -114,8 +116,10 @@ static CSysString GetExtProgramKeyName(const CSysString &extension)
return CSysString(TEXT("7-Zip.")) + extension;
}
-static bool CheckShellExtensionInfo2(const CSysString &extension)
+static bool CheckShellExtensionInfo2(const CSysString &extension, UString &iconPath, int &iconIndex)
{
+ iconIndex = -1;
+ iconPath.Empty();
NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
CKey extKey;
if (extKey.Open(HKEY_CLASSES_ROOT, GetExtensionKeyName(extension), KEY_READ) != ERROR_SUCCESS)
@@ -124,13 +128,34 @@ static bool CheckShellExtensionInfo2(const CSysString &extension)
if (extKey.QueryValue(NULL, programNameValue) != ERROR_SUCCESS)
return false;
CSysString extProgramKeyName = GetExtProgramKeyName(extension);
- return (programNameValue.CompareNoCase(extProgramKeyName) == 0);
+ if (programNameValue.CompareNoCase(extProgramKeyName) != 0)
+ return false;
+ CKey iconKey;
+ if (extKey.Open(HKEY_CLASSES_ROOT, extProgramKeyName + CSysString(TEXT('\\')) + kDefaultIconKeyName, KEY_READ) != ERROR_SUCCESS)
+ return false;
+ UString value;
+ if (extKey.QueryValue(NULL, value) == ERROR_SUCCESS)
+ {
+ int pos = value.ReverseFind(L',');
+ iconPath = value;
+ if (pos >= 0)
+ {
+ const wchar_t *end;
+ UInt64 index = ConvertStringToUInt64((const wchar_t *)value + pos + 1, &end);
+ if (*end == 0)
+ {
+ iconIndex = (int)index;
+ iconPath = value.Left(pos);
+ }
+ }
+ }
+ return true;
}
-bool CheckShellExtensionInfo(const CSysString &extension)
+bool CheckShellExtensionInfo(const CSysString &extension, UString &iconPath, int &iconIndex)
{
NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
- if (!CheckShellExtensionInfo2(extension))
+ if (!CheckShellExtensionInfo2(extension, iconPath, iconIndex))
return false;
CKey extProgKey;
return (extProgKey.Open(HKEY_CLASSES_ROOT, GetExtProgramKeyName(extension), KEY_READ) == ERROR_SUCCESS);
@@ -156,7 +181,9 @@ static void DeleteShellExtensionProgramKey(const CSysString &extension)
void DeleteShellExtensionInfo(const CSysString &extension)
{
- if (CheckShellExtensionInfo2(extension))
+ UString iconPath;
+ int iconIndex;
+ if (CheckShellExtensionInfo2(extension, iconPath, iconIndex))
DeleteShellExtensionKey(extension);
DeleteShellExtensionProgramKey(extension);
}
@@ -164,7 +191,7 @@ void DeleteShellExtensionInfo(const CSysString &extension)
void AddShellExtensionInfo(const CSysString &extension,
const UString &programTitle,
const UString &programOpenCommand,
- const UString &iconPath,
+ const UString &iconPath, int iconIndex,
const void *shellNewData, int shellNewDataSize)
{
DeleteShellExtensionKey(extension);
@@ -188,7 +215,15 @@ void AddShellExtensionInfo(const CSysString &extension,
{
CKey iconKey;
iconKey.Create(programKey, kDefaultIconKeyName);
- iconKey.SetValue(NULL, iconPath);
+ UString iconPathFull = iconPath;
+ if (iconIndex >= 0)
+ {
+ iconPathFull += L",";
+ wchar_t s[32];
+ ConvertUInt64ToString((UInt64)iconIndex, s);
+ iconPathFull += s;
+ }
+ iconKey.SetValue(NULL, iconPathFull);
}
CKey shellKey;
diff --git a/CPP/7zip/FileManager/RegistryAssociations.h b/CPP/7zip/FileManager/RegistryAssociations.h
index c225aca4..91613f79 100755
--- a/CPP/7zip/FileManager/RegistryAssociations.h
+++ b/CPP/7zip/FileManager/RegistryAssociations.h
@@ -18,7 +18,7 @@ namespace NRegistryAssociations {
void ReadInternalAssociations(CObjectVector<CExtInfo> &items);
void WriteInternalAssociations(const CObjectVector<CExtInfo> &items);
- bool CheckShellExtensionInfo(const CSysString &extension);
+ bool CheckShellExtensionInfo(const CSysString &extension, UString &iconPath, int &iconIndex);
// void ReadCompressionInfo(NZipSettings::NCompression::CInfo &anInfo,
void DeleteShellExtensionInfo(const CSysString &extension);
@@ -26,7 +26,7 @@ namespace NRegistryAssociations {
void AddShellExtensionInfo(const CSysString &extension,
const UString &programTitle,
const UString &programOpenCommand,
- const UString &iconPath,
+ const UString &iconPath, int iconIndex,
const void *shellNewData, int shellNewDataSize);
diff --git a/CPP/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.cpp b/CPP/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.cpp
deleted file mode 100755
index 1083fc4c..00000000
--- a/CPP/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.cpp
+++ /dev/null
@@ -1,976 +0,0 @@
-// BenchmarkDialog.cpp
-
-#include "StdAfx.h"
-
-#include "Common/IntToString.h"
-#include "Common/StringToInt.h"
-#include "Common/Exception.h"
-#include "Common/Alloc.h"
-#include "Windows/Thread.h"
-#include "Windows/PropVariant.h"
-#include "Windows/Error.h"
-#include "Windows/DLL.h"
-#include "Windows/FileFind.h"
-#include "../../ProgramLocation.h"
-#include "../../HelpUtils.h"
-#include "../../../Common/StreamObjects.h"
-#include "resource.h"
-#include "BenchmarkDialog.h"
-#include "Common/CRC.h"
-
-using namespace NWindows;
-
-static LPCWSTR kHelpTopic = L"fm/benchmark.htm";
-
-static const UINT_PTR kTimerID = 4;
-static const UINT kTimerElapse = 1000;
-
-static const UInt32 kAdditionalSize = (6 << 20);
-static const UInt32 kCompressedAdditionalSize = (1 << 10);
-static const int kSubBits = 8;
-
-#ifdef LANG
-#include "../../LangUtils.h"
-#endif
-
-using namespace NWindows;
-
-#ifdef LANG
-static CIDLangPair kIDLangPairs[] =
-{
- { IDC_BENCHMARK_DICTIONARY, 0x02000D0C },
- { IDC_BENCHMARK_MEMORY, 0x03080001 },
- { IDC_BENCHMARK_MULTITHREADING, 0x02000D09 },
- { 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_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);
-}
-
-UInt64 GetTimeCount()
-{
- return GetTickCount();
- /*
- LARGE_INTEGER value;
- if (::QueryPerformanceCounter(&value))
- return value.QuadPart;
- return GetTickCount();
- */
-}
-
-UInt64 GetFreq()
-{
- return 1000;
- /*
- LARGE_INTEGER value;
- if (::QueryPerformanceFrequency(&value))
- return value.QuadPart;
- return 1000;
- */
-}
-
-class CRandomGenerator
-{
- UInt32 A1;
- UInt32 A2;
-public:
- CRandomGenerator() { Init(); }
- void Init() { A1 = 362436069; A2 = 521288629;}
- UInt32 GetRnd()
- {
- return
- ((A1 = 36969 * (A1 & 0xffff) + (A1 >> 16)) << 16) ^
- ((A2 = 18000 * (A2 & 0xffff) + (A2 >> 16)) );
- }
-};
-
-class CBitRandomGenerator
-{
- CRandomGenerator RG;
- UInt32 Value;
- int NumBits;
-public:
- void Init()
- {
- Value = 0;
- NumBits = 0;
- }
- UInt32 GetRnd(int numBits)
- {
- if (NumBits > numBits)
- {
- UInt32 result = Value & ((1 << numBits) - 1);
- Value >>= numBits;
- NumBits -= numBits;
- return result;
- }
- numBits -= NumBits;
- UInt32 result = (Value << numBits);
- Value = RG.GetRnd();
- result |= Value & ((1 << numBits) - 1);
- Value >>= numBits;
- NumBits = 32 - numBits;
- return result;
- }
-};
-
-class CBenchRandomGenerator
-{
- CBitRandomGenerator RG;
- UInt32 Pos;
- UInt32 Rep0;
-public:
- UInt32 BufferSize;
- Byte *Buffer;
- CBenchRandomGenerator(): Buffer(0) {}
- ~CBenchRandomGenerator() { Free(); }
- void Free()
- {
- ::MidFree(Buffer);
- Buffer = 0;
- }
- bool Alloc(UInt32 bufferSize)
- {
- if (Buffer != 0 && BufferSize == bufferSize)
- return true;
- Free();
- Buffer = (Byte *)::MidAlloc(bufferSize);
- Pos = 0;
- BufferSize = bufferSize;
- return (Buffer != 0);
- }
- UInt32 GetRndBit() { return RG.GetRnd(1); }
- /*
- UInt32 GetLogRand(int maxLen)
- {
- UInt32 len = GetRnd() % (maxLen + 1);
- return GetRnd() & ((1 << len) - 1);
- }
- */
- UInt32 GetLogRandBits(int numBits)
- {
- UInt32 len = RG.GetRnd(numBits);
- return RG.GetRnd(len);
- }
- UInt32 GetOffset()
- {
- if (GetRndBit() == 0)
- return GetLogRandBits(4);
- return (GetLogRandBits(4) << 10) | RG.GetRnd(10);
- }
- UInt32 GetLen1() { return RG.GetRnd(1 + RG.GetRnd(2)); }
- UInt32 GetLen2() { return RG.GetRnd(2 + RG.GetRnd(2)); }
- void Generate()
- {
- RG.Init();
- Rep0 = 1;
- while(Pos < BufferSize)
- {
- if (GetRndBit() == 0 || Pos < 1)
- Buffer[Pos++] = Byte(RG.GetRnd(8));
- else
- {
- UInt32 len;
- if (RG.GetRnd(3) == 0)
- len = 1 + GetLen1();
- else
- {
- do
- Rep0 = GetOffset();
- while (Rep0 >= Pos);
- Rep0++;
- len = 2 + GetLen2();
- }
- for (UInt32 i = 0; i < len && Pos < BufferSize; i++, Pos++)
- Buffer[Pos] = Buffer[Pos - Rep0];
- }
- }
- }
-};
-
-const LPCTSTR kProcessingString = TEXT("...");
-const LPCTSTR kMB = TEXT(" MB");
-const LPCTSTR kMIPS = TEXT(" MIPS");
-const LPCTSTR kKBs = TEXT(" KB/s");
-
-bool CBenchmarkDialog::OnInit()
-{
- #ifdef LANG
- LangSetWindowText(HWND(*this), 0x03080000);
- LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
- #endif
-
- m_Dictionary.Attach(GetItem(IDC_BENCHMARK_COMBO_DICTIONARY));
- for (int i = kNumBenchDictionaryBitsStart; i <= 30; i++)
- for (int j = 0; j < 2; j++)
- {
- UInt32 dictionary = (1 << i) + (j << (i - 1));
- if(dictionary >
- #ifdef _WIN64
- (1 << 30)
- #else
- (1 << 27)
- #endif
- )
- continue;
- TCHAR s[40];
- ConvertUInt64ToString((dictionary >> 20), s);
- lstrcat(s, kMB);
- int index = (int)m_Dictionary.AddString(s);
- m_Dictionary.SetItemData(index, dictionary);
- }
- m_Dictionary.SetCurSel(0);
- OnChangeSettings();
-
- _syncInfo.Init();
- _syncInfo.InitSettings();
-
- _syncInfo._startEvent.Set();
- _timer = SetTimer(kTimerID, kTimerElapse);
- return CModalDialog::OnInit();
-}
-
-static UInt64 GetLZMAUsage(UInt32 dictionary)
-{
- UInt32 hs = dictionary - 1;
- hs |= (hs >> 1);
- hs |= (hs >> 2);
- hs |= (hs >> 4);
- hs |= (hs >> 8);
- hs >>= 1;
- hs |= 0xFFFF;
- if (hs > (1 << 24))
- hs >>= 1;
- hs++;
- return ((hs + (1 << 16)) + (UInt64)dictionary * 2) * 4 + (UInt64)dictionary * 3 / 2 + (1 << 20);
-}
-
-static UInt64 GetMemoryUsage(UInt32 dictionary, bool mtMode)
-{
- const UInt32 kBufferSize = dictionary + kAdditionalSize;
- const UInt32 kCompressedBufferSize = (kBufferSize / 2) + kCompressedAdditionalSize;
- return (mtMode ? (6 << 20) : 0 )+ kBufferSize + kCompressedBufferSize +
- GetLZMAUsage(dictionary) + dictionary + (2 << 20);
-}
-
-UInt32 CBenchmarkDialog::OnChangeDictionary()
-{
- UInt32 dictionary = (UInt32)m_Dictionary.GetItemData(m_Dictionary.GetCurSel());
- UInt64 memUsage = GetMemoryUsage(dictionary, IsButtonCheckedBool(IDC_BENCHMARK_MULTITHREADING));
- memUsage = (memUsage + (1 << 20) - 1) >> 20;
- TCHAR s[40];
- ConvertUInt64ToString(memUsage, s);
- lstrcat(s, kMB);
- SetItemText(IDC_BENCHMARK_MEMORY_VALUE, s);
- return dictionary;
-}
-
-void CBenchmarkDialog::OnChangeSettings()
-{
- EnableItem(IDC_BUTTON_STOP, true);
- UInt32 dictionary = OnChangeDictionary();
- SetItemText(IDC_BENCHMARK_COMPRESSING_SPEED, kProcessingString);
- SetItemText(IDC_BENCHMARK_COMPRESSING_SPEED2, kProcessingString);
- SetItemText(IDC_BENCHMARK_COMPRESSING_RATING, kProcessingString);
- SetItemText(IDC_BENCHMARK_COMPRESSING_RATING2, kProcessingString);
- SetItemText(IDC_BENCHMARK_DECOMPRESSING_SPEED, kProcessingString);
- SetItemText(IDC_BENCHMARK_DECOMPRESSING_SPEED2, kProcessingString);
- SetItemText(IDC_BENCHMARK_DECOMPRESSING_RATING, kProcessingString);
- SetItemText(IDC_BENCHMARK_DECOMPRESSING_RATING2, kProcessingString);
- SetItemText(IDC_BENCHMARK_TOTAL_RATING_VALUE, kProcessingString);
- _startTime = GetTickCount();
- PrintTime();
- NWindows::NSynchronization::CCriticalSectionLock lock(_syncInfo.CS);
- _syncInfo.Init();
- _syncInfo.DictionarySize = dictionary;
- _syncInfo.Changed = true;
- _syncInfo.MultiThread = IsButtonCheckedBool(IDC_BENCHMARK_MULTITHREADING);
-}
-
-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;
- TCHAR s[40];
- GetTimeString(elapsedSec, s);
- SetItemText(IDC_BENCHMARK_ELAPSED_VALUE, s);
-}
-
-static UInt32 GetLogSize(UInt32 size)
-{
- for (int i = kSubBits; i < 32; i++)
- for (UInt32 j = 0; j < (1 << kSubBits); j++)
- if (size <= (((UInt32)1) << i) + (j << (i - kSubBits)))
- return (i << kSubBits) + j;
- return (32 << kSubBits);
-}
-
-static UInt64 GetCompressRating(UInt32 dictionarySize,
- UInt64 elapsedTime, UInt64 size)
-{
- if (elapsedTime == 0)
- elapsedTime = 1;
- UInt64 t = GetLogSize(dictionarySize) - (18 << kSubBits);
- UInt64 numCommandsForOne = 1060 + ((t * t * 10) >> (2 * kSubBits));
- UInt64 numCommands = (UInt64)(size) * numCommandsForOne;
- return numCommands * GetFreq() / elapsedTime;
-}
-
-static UInt64 GetDecompressRating(UInt64 elapsedTime,
- UInt64 outSize, UInt64 inSize)
-{
- if (elapsedTime == 0)
- elapsedTime = 1;
- UInt64 numCommands = inSize * 220 + outSize * 20;
- return numCommands * GetFreq() / elapsedTime;
-}
-
-static UInt64 GetTotalRating(
- UInt32 dictionarySize,
- UInt64 elapsedTimeEn, UInt64 sizeEn,
- UInt64 elapsedTimeDe,
- UInt64 inSizeDe, UInt64 outSizeDe)
-{
- return (GetCompressRating(dictionarySize, elapsedTimeEn, sizeEn) +
- GetDecompressRating(elapsedTimeDe, inSizeDe, outSizeDe)) / 2;
-}
-
-void CBenchmarkDialog::PrintRating(UInt64 rating, UINT controlID)
-{
- TCHAR s[40];
- ConvertUInt64ToString(rating / 1000000, s);
- lstrcat(s, kMIPS);
- SetItemText(controlID, s);
-}
-
-void CBenchmarkDialog::PrintResults(
- UInt32 dictionarySize,
- UInt64 elapsedTime,
- UInt64 size, UINT speedID, UINT ratingID,
- bool decompressMode, UInt64 secondSize)
-{
- TCHAR s[40];
- UInt64 speed = size * GetFreq() / elapsedTime;
- ConvertUInt64ToString(speed / 1024, s);
- lstrcat(s, kKBs);
- SetItemText(speedID, s);
- UInt64 rating;
- if (decompressMode)
- rating = GetDecompressRating(elapsedTime, size, secondSize);
- else
- rating = GetCompressRating(dictionarySize, elapsedTime, size);
- PrintRating(rating, ratingID);
-}
-
-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);
-
- UInt64 elapsedTime = _syncInfo.CompressingInfoTemp.Time;
- if (elapsedTime >= 1)
- {
- UInt32 dicSizeTemp = (UInt32)MyMax(_syncInfo.ProcessedSize, UInt64(1) << 20);
- dicSizeTemp = MyMin(dicSizeTemp, _syncInfo.DictionarySize),
- PrintResults(dicSizeTemp, elapsedTime,
- _syncInfo.CompressingInfoTemp.InSize,
- IDC_BENCHMARK_COMPRESSING_SPEED,
- IDC_BENCHMARK_COMPRESSING_RATING);
- }
-
- if (_syncInfo.CompressingInfo.Time >= 1)
- {
- PrintResults(
- _syncInfo.DictionarySize,
- _syncInfo.CompressingInfo.Time,
- _syncInfo.CompressingInfo.InSize,
- IDC_BENCHMARK_COMPRESSING_SPEED2,
- IDC_BENCHMARK_COMPRESSING_RATING2);
- }
-
- if (_syncInfo.DecompressingInfoTemp.Time >= 1)
- {
- PrintResults(
- _syncInfo.DictionarySize,
- _syncInfo.DecompressingInfoTemp.Time,
- _syncInfo.DecompressingInfoTemp.OutSize,
- IDC_BENCHMARK_DECOMPRESSING_SPEED,
- IDC_BENCHMARK_DECOMPRESSING_RATING,
- true,
- _syncInfo.DecompressingInfoTemp.InSize);
- }
- if (_syncInfo.DecompressingInfo.Time >= 1)
- {
- PrintResults(
- _syncInfo.DictionarySize,
- _syncInfo.DecompressingInfo.Time,
- _syncInfo.DecompressingInfo.OutSize,
- IDC_BENCHMARK_DECOMPRESSING_SPEED2,
- IDC_BENCHMARK_DECOMPRESSING_RATING2,
- true,
- _syncInfo.DecompressingInfo.InSize);
- if (_syncInfo.CompressingInfo.Time >= 1)
- {
- PrintRating(GetTotalRating(
- _syncInfo.DictionarySize,
- _syncInfo.CompressingInfo.Time,
- _syncInfo.CompressingInfo.InSize,
- _syncInfo.DecompressingInfo.Time,
- _syncInfo.DecompressingInfo.OutSize,
- _syncInfo.DecompressingInfo.InSize),
- IDC_BENCHMARK_TOTAL_RATING_VALUE);
- }
- }
- return true;
-}
-
-bool CBenchmarkDialog::OnCommand(int code, int itemID, LPARAM lParam)
-{
- if (code == CBN_SELCHANGE && itemID == IDC_BENCHMARK_COMBO_DICTIONARY)
- {
- 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;
- case IDC_BENCHMARK_MULTITHREADING:
- OnChangeSettings();
- return true;
- }
- return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
-}
-
-class CBenchmarkInStream:
- public ISequentialInStream,
- public CMyUnknownImp
-{
- const Byte *Data;
- UInt32 Pos;
- UInt32 Size;
-public:
- MY_UNKNOWN_IMP
- void Init(const Byte *data, UInt32 size)
- {
- Data = data;
- Size = size;
- Pos = 0;
- }
- STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
-};
-
-STDMETHODIMP CBenchmarkInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
-{
- UInt32 remain = Size - Pos;
- if (size > remain)
- size = remain;
- for (UInt32 i = 0; i < size; i++)
- {
- ((Byte *)data)[i] = Data[Pos + i];
- }
- Pos += size;
- if(processedSize != NULL)
- *processedSize = size;
- return S_OK;
-}
-
-class CBenchmarkOutStream:
- public ISequentialOutStream,
- public CMyUnknownImp
-{
- UInt32 BufferSize;
-public:
- UInt32 Pos;
- Byte *Buffer;
- CBenchmarkOutStream(): Buffer(0) {}
- ~CBenchmarkOutStream() { Free(); }
- void Free()
- {
- ::MidFree(Buffer);
- Buffer = 0;
- }
-
- bool Alloc(UInt32 bufferSize)
- {
- if (Buffer != 0 && BufferSize == bufferSize)
- return true;
- Free();
- Buffer = (Byte *)::MidAlloc(bufferSize);
- Init();
- BufferSize = bufferSize;
- return (Buffer != 0);
- }
-
- void Init()
- {
- Pos = 0;
- }
-
- MY_UNKNOWN_IMP
- STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
-};
-
-STDMETHODIMP CBenchmarkOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
-{
- UInt32 i;
- for (i = 0; i < size && Pos < BufferSize; i++)
- Buffer[Pos++] = ((const Byte *)data)[i];
- if(processedSize != NULL)
- *processedSize = i;
- if (i != size)
- {
- MessageBoxW(0, L"Buffer is full", L"7-zip error", 0);
- return E_FAIL;
- }
- return S_OK;
-}
-
-class CCompareOutStream:
- public ISequentialOutStream,
- public CMyUnknownImp
-{
-public:
- CCRC CRC;
- MY_UNKNOWN_IMP
- void Init() { CRC.Init(); }
- STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
-};
-
-STDMETHODIMP CCompareOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
-{
- CRC.Update(data, size);
- if(processedSize != NULL)
- *processedSize = size;
- return S_OK;
-}
-
-typedef UInt32 (WINAPI * CreateObjectPointer)(const GUID *clsID,
- const GUID *interfaceID, void **outObject);
-
-struct CDecoderProgressInfo:
- public ICompressProgressInfo,
- public CMyUnknownImp
-{
- CProgressSyncInfo *SyncInfo;
- MY_UNKNOWN_IMP
- STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
-};
-
-STDMETHODIMP CDecoderProgressInfo::SetRatioInfo(
- const UInt64 * /* inSize */, const UInt64 * /* outSize */)
-{
- NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
- if (SyncInfo->Changed)
- return E_ABORT;
- return S_OK;
-}
-
-struct CThreadBenchmark:
- public ICompressProgressInfo,
- public CMyUnknownImp
-{
- CProgressSyncInfo *SyncInfo;
- UInt64 _startTime;
- UInt64 _approvedStart;
- NDLL::CLibrary Library;
- CMyComPtr<ICompressCoder> Encoder;
- CMyComPtr<ICompressCoder> Decoder;
- HRESULT Process();
- HRESULT Result;
- static DWORD WINAPI MyThreadFunction(void *param)
- {
- ((CThreadBenchmark *)param)->Result = ((CThreadBenchmark *)param)->Process();
- return 0;
- }
- MY_UNKNOWN_IMP
- STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
-};
-
-HRESULT CThreadBenchmark::Process()
-{
- try
- {
- SyncInfo->WaitCreating();
- CBenchRandomGenerator randomGenerator;
- CMyComPtr<ICompressWriteCoderProperties> writeCoderProperties;
- Encoder.QueryInterface(IID_ICompressWriteCoderProperties,
- &writeCoderProperties);
- CMyComPtr<ICompressSetDecoderProperties2> compressSetDecoderProperties;
- Decoder.QueryInterface(
- IID_ICompressSetDecoderProperties2, &compressSetDecoderProperties);
- CSequentialOutStreamImp *propStreamSpec = 0;
- CMyComPtr<ISequentialOutStream> propStream;
- if (writeCoderProperties != NULL)
- {
- propStreamSpec = new CSequentialOutStreamImp;
- propStream = propStreamSpec;
- }
-
- CMyComPtr<ICompressSetCoderProperties> setCoderProperties;
- Encoder.QueryInterface(IID_ICompressSetCoderProperties,
- &setCoderProperties);
-
- CDecoderProgressInfo *decoderProgressInfoSpec = new
- CDecoderProgressInfo;
- CMyComPtr<ICompressProgressInfo> decoderProgress = decoderProgressInfoSpec;
- decoderProgressInfoSpec->SyncInfo = SyncInfo;
-
- for (;;)
- {
- if (SyncInfo->WasStopped())
- return 0;
- if (SyncInfo->WasPaused())
- {
- Sleep(200);
- continue;
- }
- UInt32 dictionarySize;
- bool multiThread;
- {
- NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
- dictionarySize = SyncInfo->DictionarySize;
- multiThread = SyncInfo->MultiThread;
- if (SyncInfo->Changed)
- SyncInfo->Init();
- }
-
- const UInt32 kBufferSize = dictionarySize + kAdditionalSize;
- const UInt32 kCompressedBufferSize = (kBufferSize / 2) + kCompressedAdditionalSize;
-
- if (setCoderProperties)
- {
- PROPID propIDs[] =
- {
- NCoderPropID::kDictionarySize,
- NCoderPropID::kMultiThread
- };
- const int kNumProps = sizeof(propIDs) / sizeof(propIDs[0]);
- NWindows::NCOM::CPropVariant properties[kNumProps];
- properties[0] = UInt32(dictionarySize);
- properties[1] = bool(multiThread);
- HRESULT res = setCoderProperties->SetCoderProperties(propIDs,
- properties, kNumProps);
- if (res != S_OK)
- {
- // SyncInfo->Pause();
- MessageBox(0, NError::MyFormatMessage(res), TEXT("7-Zip"), MB_ICONERROR);
- return res;
- }
- }
-
- if (propStream)
- {
- propStreamSpec->Init();
- writeCoderProperties->WriteCoderProperties(propStream);
- }
-
- if (!randomGenerator.Alloc(kBufferSize))
- return E_OUTOFMEMORY;
-
- randomGenerator.Generate();
- CCRC crc;
-
- // randomGenerator.BufferSize
- crc.Update(randomGenerator.Buffer, randomGenerator.BufferSize);
-
- {
- NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
- if (SyncInfo->Changed)
- continue;
- }
-
- CBenchmarkInStream *inStreamSpec = new CBenchmarkInStream;
- CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
- CBenchmarkOutStream *outStreamSpec = new CBenchmarkOutStream;
- CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
- if (!outStreamSpec->Alloc(kCompressedBufferSize))
- return E_OUTOFMEMORY;
-
- {
- // this code is for reducing time of memory allocationg
- inStreamSpec->Init(randomGenerator.Buffer, MyMin((UInt32)1, randomGenerator.BufferSize));
- outStreamSpec->Init();
- /* HRESULT result = */ Encoder->Code(inStream, outStream, 0, 0, NULL);
- }
-
- inStreamSpec->Init(randomGenerator.Buffer, randomGenerator.BufferSize);
- outStreamSpec->Init();
-
- _approvedStart = dictionarySize;
- _startTime = ::GetTimeCount();
- HRESULT result = Encoder->Code(inStream, outStream, 0, 0, this);
- UInt64 tickCount = ::GetTimeCount() - _startTime;
- UInt32 compressedSize = outStreamSpec->Pos;
- {
- NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
- if (result == S_OK)
- {
- if (SyncInfo->ApprovedInfo.InSize != 0)
- {
- SyncInfo->CompressingInfoTemp.InSize = kBufferSize - SyncInfo->ApprovedInfo.InSize;
- SyncInfo->CompressingInfoTemp.OutSize = compressedSize - SyncInfo->ApprovedInfo.OutSize;
- SyncInfo->CompressingInfoTemp.Time = tickCount - SyncInfo->ApprovedInfo.Time;
- if (SyncInfo->CompressingInfo.Time == 0)
- SyncInfo->CompressingInfo = SyncInfo->CompressingInfoTemp;
- }
- }
- SyncInfo->ApprovedInfo.Init();
- }
- if(result != S_OK)
- {
- if (result != E_ABORT)
- {
- SyncInfo->Pause();
- MessageBox(0, NError::MyFormatMessage(result), TEXT("7-Zip"), MB_ICONERROR);
- }
- continue;
- }
- {
- NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
- SyncInfo->NumPasses++;
- }
-
- ///////////////////////
- // Decompressing
-
-
- CCompareOutStream *outCompareStreamSpec = new CCompareOutStream;
- CMyComPtr<ISequentialOutStream> outCompareStream = outCompareStreamSpec;
-
- for (int i = 0; i < 2; i++)
- {
- inStreamSpec->Init(outStreamSpec->Buffer, compressedSize);
- outCompareStreamSpec->Init();
-
- if (compressSetDecoderProperties)
- {
- RINOK(compressSetDecoderProperties->SetDecoderProperties2(
- propStreamSpec->GetBuffer(), (UInt32)propStreamSpec->GetSize()));
- }
-
- UInt64 outSize = kBufferSize;
- UInt64 startTime = ::GetTimeCount();
- result = Decoder->Code(inStream, outCompareStream, 0, &outSize, decoderProgress);
- tickCount = ::GetTimeCount() - startTime;
- {
- NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
- if (result == S_OK)
- {
- SyncInfo->DecompressingInfoTemp.InSize = compressedSize;
- SyncInfo->DecompressingInfoTemp.OutSize = kBufferSize;
- SyncInfo->DecompressingInfoTemp.Time = tickCount;
- if (SyncInfo->DecompressingInfo.Time == 0 && i >= 1)
- SyncInfo->DecompressingInfo = SyncInfo->DecompressingInfoTemp;
- if (outCompareStreamSpec->CRC.GetDigest() != crc.GetDigest())
- {
- SyncInfo->NumErrors++;
- break;
- }
- }
- else
- {
- if(result != E_ABORT)
- {
- SyncInfo->NumErrors++;
- break;
- }
- }
- }
- }
- }
- }
- 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;
- }
-}
-
-STDMETHODIMP CThreadBenchmark::SetRatioInfo(
- const UInt64 *inSize, const UInt64 *outSize)
-{
- NSynchronization::CCriticalSectionLock lock(SyncInfo->CS);
- if (SyncInfo->Changed || SyncInfo->WasPaused() || SyncInfo->WasStopped())
- return E_ABORT;
- CProgressInfo ci;
- ci.InSize = *inSize;
- ci.OutSize = *outSize;
- ci.Time = ::GetTimeCount() - _startTime;
- SyncInfo->ProcessedSize = *inSize;
-
- UInt64 deltaTime = ci.Time - SyncInfo->CompressingInfoPrev.Time;
- if (deltaTime >= GetFreq())
- {
- SyncInfo->CompressingInfoTemp.Time = deltaTime;
- SyncInfo->CompressingInfoTemp.InSize = ci.InSize - SyncInfo->CompressingInfoPrev.InSize;
- SyncInfo->CompressingInfoTemp.OutSize = ci.InSize - SyncInfo->CompressingInfoPrev.OutSize;
- SyncInfo->CompressingInfoPrev = ci;
- }
- if (*inSize >= _approvedStart && SyncInfo->ApprovedInfo.InSize == 0)
- SyncInfo->ApprovedInfo = ci;
- return S_OK;
-}
-
-static bool GetCoderPath(UString &path)
-{
- if (!GetProgramFolderPath(path))
- return false;
- path += L"Codecs\\LZMA.dll";
- return true;
-}
-
-typedef UInt32 (WINAPI *GetMethodPropertyFunc)(
- UInt32 index, PROPID propID, PROPVARIANT *value);
-
-static bool LoadCoder(
- const UString &filePath,
- NWindows::NDLL::CLibrary &library,
- CLSID &encoder, CLSID &decoder)
-{
- if (!library.Load(filePath))
- return false;
- GetMethodPropertyFunc getMethodProperty = (GetMethodPropertyFunc)
- library.GetProcAddress("GetMethodProperty");
- if (getMethodProperty == NULL)
- return false;
-
- NWindows::NCOM::CPropVariant propVariant;
- if (getMethodProperty (0, NMethodPropID::kEncoder, &propVariant) != S_OK)
- return false;
- if (propVariant.vt != VT_BSTR)
- return false;
- encoder = *(const GUID *)propVariant.bstrVal;
- propVariant.Clear();
-
- if (getMethodProperty (0, NMethodPropID::kDecoder, &propVariant) != S_OK)
- return false;
- if (propVariant.vt != VT_BSTR)
- return false;
- decoder = *(const GUID *)propVariant.bstrVal;
- propVariant.Clear();
- return true;
-}
-
-void Benchmark(HWND hwnd)
-{
- UString path;
- if (!GetCoderPath(path))
- {
- MyMessageBoxError(hwnd, L"Can't find LZMA.dll");
- return;
- }
- CLSID encoder;
- CLSID decoder;
- CThreadBenchmark benchmarker;
- if (!LoadCoder(path, benchmarker.Library, encoder, decoder))
- {
- MyMessageBoxError(hwnd, L"Can't load LZMA.dll");
- return;
- }
-
- CreateObjectPointer createObject = (CreateObjectPointer)
- benchmarker.Library.GetProcAddress("CreateObject");
- if (createObject == NULL)
- {
- MyMessageBoxError(hwnd, L"Incorrect LZMA.dll");
- return;
- }
- if (createObject(&encoder, &IID_ICompressCoder, (void **)&benchmarker.Encoder) != S_OK)
- {
- MyMessageBoxError(hwnd, L"Can't create codec");
- return;
- }
- if (createObject(&decoder, &IID_ICompressCoder, (void **)&benchmarker.Decoder) != S_OK)
- {
- MyMessageBoxError(hwnd, L"Can't create codec");
- return;
- }
-
- CBenchmarkDialog benchmarkDialog;
- benchmarker.SyncInfo = &benchmarkDialog._syncInfo;
- CThread thread;
- if (!thread.Create(CThreadBenchmark::MyThreadFunction, &benchmarker))
- {
- MyMessageBoxError(hwnd, L"error");
- return;
- }
- benchmarkDialog.Create(hwnd);
- WaitForSingleObject(thread, INFINITE);
-}
diff --git a/CPP/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.h b/CPP/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.h
deleted file mode 100755
index 244e7fe5..00000000
--- a/CPP/7zip/FileManager/Resource/BenchmarkDialog/BenchmarkDialog.h
+++ /dev/null
@@ -1,136 +0,0 @@
-// BenchmarkDialog.h
-
-#ifndef __BENCHMARKDIALOG_H
-#define __BENCHMARKDIALOG_H
-
-#include "resource.h"
-
-#include "Common/MyCom.h"
-#include "Windows/Control/Dialog.h"
-#include "Windows/Control/ComboBox.h"
-#include "Windows/Synchronization.h"
-#include "../../../ICoder.h"
-
-const int kNumBenchDictionaryBitsStart = 21;
-
-struct CProgressInfo
-{
- UINT64 InSize;
- UINT64 OutSize;
- UINT64 Time;
- void Init()
- {
- InSize = 0;
- OutSize = 0;
- Time = 0;
- }
-};
-
-class CProgressSyncInfo
-{
- bool Stopped;
- bool Paused;
-public:
- bool Changed;
- UINT32 DictionarySize;
- bool MultiThread;
- UINT64 NumPasses;
- UINT64 NumErrors;
- NWindows::NSynchronization::CManualResetEvent _startEvent;
- NWindows::NSynchronization::CCriticalSection CS;
-
- CProgressInfo ApprovedInfo;
- CProgressInfo CompressingInfoPrev;
- CProgressInfo CompressingInfoTemp;
- CProgressInfo CompressingInfo;
- UINT64 ProcessedSize;
-
- CProgressInfo DecompressingInfoTemp;
- CProgressInfo DecompressingInfo;
-
- void Init()
- {
- Changed = false;
- ApprovedInfo.Init();
- CompressingInfoPrev.Init();
- CompressingInfoTemp.Init();
- CompressingInfo.Init();
- ProcessedSize = 0;
-
- DecompressingInfoTemp.Init();
- DecompressingInfo.Init();
-
- Stopped = false;
- Paused = false;
- NumPasses = 0;
- NumErrors = 0;
- }
- void InitSettings()
- {
- DictionarySize = (1 << kNumBenchDictionaryBitsStart);
- MultiThread = false;
- }
- 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;
- 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 PrintResults(
- UINT32 dictionarySize,
- UINT64 elapsedTime,
- UINT64 size, UINT speedID, UINT ratingID,
- bool decompressMode = false, UINT64 secondSize = 0);
-
- UINT32 OnChangeDictionary();
- void OnChangeSettings();
-public:
- CProgressSyncInfo _syncInfo;
-
- CBenchmarkDialog(): _timer(0) {}
- INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_DIALOG_BENCHMARK, wndParent); }
-};
-
-void Benchmark(HWND hwnd);
-
-#endif
diff --git a/CPP/7zip/FileManager/Resource/BenchmarkDialog/StdAfx.h b/CPP/7zip/FileManager/Resource/BenchmarkDialog/StdAfx.h
deleted file mode 100755
index a444ca31..00000000
--- a/CPP/7zip/FileManager/Resource/BenchmarkDialog/StdAfx.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// 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/FileManager/Resource/BenchmarkDialog/resource.h b/CPP/7zip/FileManager/Resource/BenchmarkDialog/resource.h
deleted file mode 100755
index d720058d..00000000
--- a/CPP/7zip/FileManager/Resource/BenchmarkDialog/resource.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#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_MULTITHREADING 1014
-#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_COMPRESSING_SPEED 1030
-#define IDC_BENCHMARK_COMPRESSING_SPEED2 1031
-#define IDC_BENCHMARK_COMPRESSING_RATING 1032
-#define IDC_BENCHMARK_COMPRESSING_RATING2 1033
-#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_TOTAL_RATING 1050
-#define IDC_BENCHMARK_TOTAL_RATING_VALUE 1051
-#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_ERRORS 1064
-#define IDC_BENCHMARK_ERRORS_VALUE 1065
-#define IDC_BENCHMARK_PASSES 1066
-#define IDC_BENCHMARK_PASSES_VALUE 1067
diff --git a/CPP/7zip/FileManager/Resource/BenchmarkDialog/resource.rc b/CPP/7zip/FileManager/Resource/BenchmarkDialog/resource.rc
deleted file mode 100755
index 5ab220e5..00000000
--- a/CPP/7zip/FileManager/Resource/BenchmarkDialog/resource.rc
+++ /dev/null
@@ -1,87 +0,0 @@
-#include "resource.h"
-#include "../../../GuiCommon.rc"
-
-#define xSize2 210
-#define ySize2 228
-
-#define xSize (xSize2 + marg + marg)
-#define ySize (ySize2 + marg + marg)
-
-#define bXPos1 (xSize - marg - bXSize)
-#define bXPos2 (bXPos1 - 10 - bXSize)
-
-#define bYPos (ySize - marg - bYSize)
-
-#define gSize 160
-#define gSpace 24
-
-#define g0XSize 75
-#define g1XSize 44
-#define g1XPos (marg + g0XSize)
-
-#define g10XPos (marg + marg)
-#define gRatingSize 51
-#define gSpeedSize 64
-#define gRatingPos (xSize - marg - marg - gRatingSize)
-#define gSpeedPos (gRatingPos - gSpeedSize)
-#define gLabelSize (gSpeedPos - g10XPos)
-#define gTotalRatingSize (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 "Memory usage:", IDC_BENCHMARK_MEMORY, marg, 25, g0XSize, 8
- LTEXT "0 MB", IDC_BENCHMARK_MEMORY_VALUE, g1XPos,25,g1XSize,8
- CONTROL "Multi-threading", IDC_BENCHMARK_MULTITHREADING, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
- marg, 41, g0XSize, 10
-
- RTEXT "Speed", IDC_BENCHMARK_SPEED_LABEL, gSpeedPos, 53, gSpeedSize, 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 KB/s", IDC_BENCHMARK_COMPRESSING_SPEED, gSpeedPos, 76, gSpeedSize, 8
- RTEXT "0", IDC_BENCHMARK_COMPRESSING_RATING, gRatingPos, 76, gRatingSize, 8
-
- LTEXT "Resulting", IDC_BENCHMARK_RESULTING, g10XPos, 89, gLabelSize, 8
- RTEXT "100 KB/s", IDC_BENCHMARK_COMPRESSING_SPEED2, gSpeedPos, 89, gSpeedSize, 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 KB/s", IDC_BENCHMARK_DECOMPRESSING_SPEED, gSpeedPos, 123, gSpeedSize, 8
- RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RATING, gRatingPos, 123, gRatingSize, 8
-
- LTEXT "Resulting", IDC_BENCHMARK_RESULTING2, g10XPos, 136, gLabelSize, 8
- RTEXT "100 KB/s", IDC_BENCHMARK_DECOMPRESSING_SPEED2, gSpeedPos, 136, gSpeedSize, 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_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
- LTEXT "Errors:", IDC_BENCHMARK_ERRORS, marg, 202, 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
- RTEXT "0", IDC_BENCHMARK_ERRORS_VALUE, g3XPos, 202, g3XSize, 8
-END
diff --git a/CPP/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp b/CPP/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp
index ea0f6fd6..81504ca5 100755
--- a/CPP/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp
+++ b/CPP/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp
@@ -25,12 +25,12 @@ static CIDLangPair kIDLangPairs[] =
#ifndef _SFX
CProgressDialog::~CProgressDialog()
{
- AddToTitle(TEXT(""));
+ AddToTitle(L"");
}
void CProgressDialog::AddToTitle(LPCWSTR s)
{
if (MainWindow != 0)
- ::MySetWindowText(MainWindow, UString(s) + MainTitle);
+ MySetWindowText(MainWindow, UString(s) + MainTitle);
}
#endif
diff --git a/CPP/7zip/FileManager/Resource/SystemPage/SystemPage.cpp b/CPP/7zip/FileManager/Resource/SystemPage/SystemPage.cpp
index ca3b7432..80bed2c3 100755
--- a/CPP/7zip/FileManager/Resource/SystemPage/SystemPage.cpp
+++ b/CPP/7zip/FileManager/Resource/SystemPage/SystemPage.cpp
@@ -9,6 +9,7 @@
#include "Windows/Defs.h"
#include "Windows/Control/ListView.h"
+#include "Windows/FileFind.h"
#include "../../IFolder.h"
#include "../../HelpUtils.h"
@@ -85,7 +86,11 @@ bool CSystemPage::OnInit()
item.iSubItem = 0;
int itemIndex = _listViewExt.InsertItem(&item);
- extInfo.Associated = NRegistryAssociations::CheckShellExtensionInfo(GetSystemString(extInfo.Ext));
+ UString iconPath;
+ int iconIndex;
+ extInfo.Associated = NRegistryAssociations::CheckShellExtensionInfo(GetSystemString(extInfo.Ext), iconPath, iconIndex);
+ if (extInfo.Associated && !NWindows::NFile::NFind::DoesFileExist(iconPath))
+ extInfo.Associated = false;
_listViewExt.SetCheckState(itemIndex, extInfo.Associated);
SetMainPluginText(itemIndex, i);
@@ -125,33 +130,29 @@ static UString GetProgramCommand()
}
static UString GetIconPath(const UString &filePath,
- const CLSID &clsID, const UString &extension)
+ const CLSID &clsID, const UString &extension, Int32 &iconIndex)
{
CPluginLibrary library;
CMyComPtr<IFolderManager> folderManager;
CMyComPtr<IFolderFolder> folder;
if (library.LoadAndCreateManager(filePath, clsID, &folderManager) != S_OK)
return UString();
- CMyComBSTR typesString;
- if (folderManager->GetTypes(&typesString) != S_OK)
+ CMyComBSTR extBSTR;
+ if (folderManager->GetExtensions(&extBSTR) != S_OK)
return UString();
- UStringVector types;
- SplitString((const wchar_t *)typesString, types);
- for (int typeIndex = 0; typeIndex < types.Size(); typeIndex++)
+ const UString ext2 = (const wchar_t *)extBSTR;
+ UStringVector exts;
+ SplitString(ext2, exts);
+ for (int i = 0; i < exts.Size(); i++)
{
- const UString &type = types[typeIndex];
- CMyComBSTR extTemp;
- if (folderManager->GetExtension(type, &extTemp) != S_OK)
- continue;
- if (extension.CompareNoCase((const wchar_t *)extTemp) == 0)
+ const UString &plugExt = exts[i];
+ if (extension.CompareNoCase((const wchar_t *)plugExt) == 0)
{
- CMyComPtr<IFolderManagerGetIconPath> getIconPath;
- if (folderManager.QueryInterface(IID_IFolderManagerGetIconPath, &getIconPath) != S_OK)
- break;
CMyComBSTR iconPathTemp;
- if (getIconPath->GetIconPath(type, &iconPathTemp) != S_OK)
+ if (folderManager->GetIconPath(plugExt, &iconPathTemp, &iconIndex) != S_OK)
break;
- return (const wchar_t *)iconPathTemp;
+ if (iconPathTemp != 0)
+ return (const wchar_t *)iconPathTemp;
}
}
return UString();
@@ -171,16 +172,14 @@ LONG CSystemPage::OnApply()
UString title = extInfo.Ext + UString(L" Archive");
UString command = GetProgramCommand();
UString iconPath;
+ Int32 iconIndex = -1;
if (!extInfo.PluginsPairs.IsEmpty())
{
const CPluginInfo &plugin = _extDatabase.Plugins[extInfo.PluginsPairs[0].Index];
- iconPath = GetIconPath(plugin.FilePath, plugin.ClassID, extInfo.Ext);
+ iconPath = GetIconPath(plugin.FilePath, plugin.ClassID, extInfo.Ext, iconIndex);
}
- NRegistryAssociations::AddShellExtensionInfo(
- GetSystemString(extInfo.Ext),
- title,
- command,
- iconPath, NULL, 0);
+ NRegistryAssociations::AddShellExtensionInfo(GetSystemString(extInfo.Ext),
+ title, command, iconPath, iconIndex, NULL, 0);
}
else
NRegistryAssociations::DeleteShellExtensionInfo(GetSystemString(extInfo.Ext));
diff --git a/CPP/7zip/FileManager/Resource/SystemPage/resource.rc b/CPP/7zip/FileManager/Resource/SystemPage/resource.rc
index cf19d11b..caa9fcbb 100755
--- a/CPP/7zip/FileManager/Resource/SystemPage/resource.rc
+++ b/CPP/7zip/FileManager/Resource/SystemPage/resource.rc
@@ -6,7 +6,7 @@
#define xSize (xSize2 + marg + marg)
#define ySize (ySize2 + marg + marg)
#define gSpace 30
-#define g0Size 110
+#define g0Size 160
#define gYSize (ySize2 - 20 - bYSize)
@@ -16,11 +16,8 @@ MY_FONT
BEGIN
LTEXT "Associate 7-Zip with:", IDC_SYSTEM_STATIC_ASSOCIATE, marg, marg, xSize2, 8
CONTROL "List1", IDC_SYSTEM_LIST_ASSOCIATE, "SysListView32",
- LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | WS_BORDER | WS_TABSTOP,
+ LVS_LIST | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | WS_BORDER | WS_TABSTOP,
marg, 20, g0Size, gYSize
- CONTROL "List1", IDC_SYSTEM_LIST_PLUGINS, "SysListView32",
- LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | NOT WS_VISIBLE | WS_BORDER | WS_TABSTOP,
- marg + g0Size + gSpace, 20, xSize2 - gSpace - g0Size, gYSize
PUSHBUTTON "Select all", IDC_SYSTEM_SELECT_ALL, marg, (ySize - marg - bYSize), 90, bYSize
END
diff --git a/CPP/7zip/FileManager/makefile b/CPP/7zip/FileManager/makefile
index 42619e0a..da745fe2 100755
--- a/CPP/7zip/FileManager/makefile
+++ b/CPP/7zip/FileManager/makefile
@@ -1,6 +1,8 @@
PROG = 7zFM.exe
LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib shell32.lib ole32.lib comctl32.lib htmlhelp.lib Mpr.lib Gdi32.lib comdlg32.lib
-CFLAGS = $(CFLAGS) -I../../ -DLANG -DWIN_LONG_PATH
+CFLAGS = $(CFLAGS) -I../../ \
+ -DLANG \
+ -DWIN_LONG_PATH \
FM_OBJS = \
$O\App.obj \
@@ -49,7 +51,6 @@ FM_OBJS = \
$O\ViewSettings.obj \
COMMON_OBJS = \
- $O\Alloc.obj \
$O\CRC.obj \
$O\IntToString.obj \
$O\Lang.obj \
@@ -108,7 +109,9 @@ UI_COMMON_OBJS = \
C_OBJS = \
$O\Sort.obj \
+ $O\Alloc.obj \
+!include "../Crc2.mak"
OBJS = \
$O\StdAfx.obj \
@@ -119,7 +122,6 @@ OBJS = \
$(7ZIP_COMMON_OBJS) \
$(UI_COMMON_OBJS) \
$O\AboutDialog.obj \
- $O\BenchmarkDialog.obj \
$O\ComboDialog.obj \
$O\CopyDialog.obj \
$O\EditPage.obj \
@@ -133,8 +135,9 @@ OBJS = \
$O\SettingsPage.obj \
$O\SplitDialog.obj \
$O\SystemPage.obj \
- $O\resource.res \
+ $(CRC_OBJS) \
$(C_OBJS) \
+ $O\resource.res \
!include "../../Build.mak"
@@ -153,8 +156,6 @@ $(UI_COMMON_OBJS): ../UI/Common/$(*B).cpp
$O\AboutDialog.obj: Resource/AboutDialog/AboutDialog.cpp
$(COMPL)
-$O\BenchmarkDialog.obj: Resource/BenchmarkDialog/BenchmarkDialog.cpp
- $(COMPL)
$O\ComboDialog.obj: Resource/ComboDialog/ComboDialog.cpp
$(COMPL)
$O\CopyDialog.obj: Resource/CopyDialog/CopyDialog.cpp
@@ -185,3 +186,19 @@ $(C_OBJS): ../../../C/$(*B).c
$(COMPL_O2)
+!IF "$(CPU)" != "IA64"
+!IF "$(CPU)" != "AMD64"
+$O\7zCrcT8U.obj: ../../../Asm/x86/$(*B).asm
+ $(COMPL_ASM)
+!ELSE
+$O\7zCrcT8U.obj: ../../../Asm/x64/$(*B).asm
+ $(COMPL_ASM)
+!ENDIF
+$O\7zCrcT8.obj: ../../../C/$(*B).c
+ $(COMPL_O2)
+!ELSE
+$(CRC_OBJS): ../../../C/$(*B).c
+ $(COMPL_O2)
+!ENDIF
+
+
diff --git a/CPP/7zip/FileManager/resource.rc b/CPP/7zip/FileManager/resource.rc
index ed56cd48..43494581 100755
--- a/CPP/7zip/FileManager/resource.rc
+++ b/CPP/7zip/FileManager/resource.rc
@@ -222,7 +222,6 @@ END
#include "Resource/PasswordDialog/resource.rc"
#include "Resource/SplitDialog/resource.rc"
#include "Resource/ProgressDialog2/resource.rc"
-#include "Resource/BenchmarkDialog/resource.rc"
#include "Resource/AboutDialog/resource.rc"
#include "Resource/LangPage/resource.rc"
#include "Resource/PluginsPage/resource.rc"