mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-07 09:15:00 -06:00
4.65
This commit is contained in:
committed by
Kornel Lesiński
parent
1dc92281fa
commit
8874e4fbc9
@@ -2,23 +2,25 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/IntToString.h"
|
||||
#include "Common/MyInitGuid.h"
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/IntToString.h"
|
||||
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/PropVariantConversions.h"
|
||||
#include "Windows/DLL.h"
|
||||
#include "Windows/FileDir.h"
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/PropVariantConversions.h"
|
||||
|
||||
#include "../../Common/FileStreams.h"
|
||||
|
||||
#include "../../Archive/IArchive.h"
|
||||
|
||||
#include "../../IPassword.h"
|
||||
#include "../../MyVersion.h"
|
||||
|
||||
|
||||
// use another CLSIDs, if you want to support other formats (zip, rar, ...).
|
||||
// {23170F69-40C1-278A-1000-000110070000}
|
||||
DEFINE_GUID(CLSID_CFormat7z,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x07, 0x00, 0x00);
|
||||
@@ -687,8 +689,9 @@ int MY_CDECL main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
AString command = argv[1];
|
||||
command.MakeLower();
|
||||
UString archiveName = GetUnicodeString(argv[2], CP_OEMCP);
|
||||
if (command.CompareNoCase("a") == 0)
|
||||
if (command.Compare("a") == 0)
|
||||
{
|
||||
// create archive command
|
||||
if (argc < 4)
|
||||
@@ -764,9 +767,9 @@ int MY_CDECL main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
bool listCommand;
|
||||
if (command.CompareNoCase("l") == 0)
|
||||
if (command.Compare("l") == 0)
|
||||
listCommand = true;
|
||||
else if (command.CompareNoCase("x") == 0)
|
||||
else if (command.Compare("x") == 0)
|
||||
listCommand = false;
|
||||
else
|
||||
{
|
||||
|
||||
@@ -531,8 +531,11 @@ HRESULT EnumerateInArchiveItems(const NWildcard::CCensor &censor,
|
||||
CArcItem ai;
|
||||
|
||||
RINOK(GetArchiveItemPath(archive, i, ai.Name));
|
||||
// check it: defaultItemName !!!
|
||||
if (ai.Name.IsEmpty())
|
||||
ai.Name = defaultItemName;
|
||||
RINOK(IsArchiveItemFolder(archive, i, ai.IsDir));
|
||||
ai.Censored = censor.CheckPath(ai.Name.IsEmpty() ? defaultItemName : ai.Name, !ai.IsDir);
|
||||
ai.Censored = censor.CheckPath(ai.Name, !ai.IsDir);
|
||||
RINOK(GetArchiveItemFileTime(archive, i, archiveFileInfo.MTime, ai.MTime));
|
||||
|
||||
{
|
||||
|
||||
@@ -77,7 +77,7 @@ STDMETHODIMP CExtractCallbackConsole::AskOverwrite(
|
||||
case NUserAnswerMode::kNoAll: *answer = NOverwriteAnswer::kNoToAll; break;
|
||||
case NUserAnswerMode::kYesAll: *answer = NOverwriteAnswer::kYesToAll; break;
|
||||
case NUserAnswerMode::kYes: *answer = NOverwriteAnswer::kYes; break;
|
||||
case NUserAnswerMode::kAutoRename: *answer = NOverwriteAnswer::kAutoRename; break;
|
||||
case NUserAnswerMode::kAutoRenameAll: *answer = NOverwriteAnswer::kAutoRename; break;
|
||||
default: return E_FAIL;
|
||||
}
|
||||
return S_OK;
|
||||
|
||||
@@ -11,16 +11,14 @@ static const char kYes = 'Y';
|
||||
static const char kNo = 'N';
|
||||
static const char kYesAll = 'A';
|
||||
static const char kNoAll = 'S';
|
||||
static const char kAutoRename = 'U';
|
||||
static const char kAutoRenameAll = 'U';
|
||||
static const char kQuit = 'Q';
|
||||
|
||||
static const char *kFirstQuestionMessage = "?\n";
|
||||
static const char *kHelpQuestionMessage =
|
||||
"(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename / (Q)uit? ";
|
||||
"(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit? ";
|
||||
|
||||
// return true if pressed Quite;
|
||||
// in: anAll
|
||||
// out: anAll, anYes;
|
||||
|
||||
NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream)
|
||||
{
|
||||
@@ -41,8 +39,8 @@ NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream)
|
||||
return NUserAnswerMode::kYesAll;
|
||||
case kNoAll:
|
||||
return NUserAnswerMode::kNoAll;
|
||||
case kAutoRename:
|
||||
return NUserAnswerMode::kAutoRename;
|
||||
case kAutoRenameAll:
|
||||
return NUserAnswerMode::kAutoRenameAll;
|
||||
case kQuit:
|
||||
return NUserAnswerMode::kQuit;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ enum EEnum
|
||||
kNo,
|
||||
kYesAll,
|
||||
kNoAll,
|
||||
kAutoRename,
|
||||
kAutoRenameAll,
|
||||
kQuit
|
||||
};
|
||||
}
|
||||
|
||||
@@ -35,38 +35,27 @@ static CSysString GetFullContextMenuKeyName(const CSysString &keyName)
|
||||
static CSysString GetFullDragDropMenuKeyName(const CSysString &keyName)
|
||||
{ return (keyName + kDragDropMenuKeyName); }
|
||||
|
||||
static bool CheckContextMenuHandlerCommon(const CSysString &keyName)
|
||||
static bool CheckHandlerCommon(const CSysString &keyName)
|
||||
{
|
||||
NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
|
||||
CKey key;
|
||||
if (key.Open(HKEY_CLASSES_ROOT, GetFullContextMenuKeyName(keyName), KEY_READ)
|
||||
!= ERROR_SUCCESS)
|
||||
if (key.Open(HKEY_CLASSES_ROOT, keyName, KEY_READ) != ERROR_SUCCESS)
|
||||
return false;
|
||||
CSysString value;
|
||||
if (key.QueryValue(NULL, value) != ERROR_SUCCESS)
|
||||
return false;
|
||||
return (value.CompareNoCase(kExtensionCLSID) == 0);
|
||||
}
|
||||
|
||||
static bool CheckDragDropMenuHandlerCommon(const CSysString &keyName)
|
||||
{
|
||||
NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
|
||||
CKey key;
|
||||
if (key.Open(HKEY_CLASSES_ROOT, GetFullDragDropMenuKeyName(keyName), KEY_READ) != ERROR_SUCCESS)
|
||||
return false;
|
||||
CSysString value;
|
||||
if (key.QueryValue(NULL, value) != ERROR_SUCCESS)
|
||||
return false;
|
||||
return (value.CompareNoCase(kExtensionCLSID) == 0);
|
||||
value.MakeUpper();
|
||||
return (value.Compare(kExtensionCLSID) == 0);
|
||||
}
|
||||
|
||||
bool CheckContextMenuHandler()
|
||||
{
|
||||
return CheckContextMenuHandlerCommon(kRootKeyNameForFile) &&
|
||||
// CheckContextMenuHandlerCommon(kRootKeyNameForFolder) &&
|
||||
CheckContextMenuHandlerCommon(kRootKeyNameForDirectory) &&
|
||||
CheckDragDropMenuHandlerCommon(kRootKeyNameForDirectory) &&
|
||||
CheckDragDropMenuHandlerCommon(kRootKeyNameForDrive);
|
||||
return
|
||||
// CheckHandlerCommon(GetFullContextMenuKeyName(kRootKeyNameForFolder)) &&
|
||||
CheckHandlerCommon(GetFullContextMenuKeyName(kRootKeyNameForDirectory)) &&
|
||||
CheckHandlerCommon(GetFullContextMenuKeyName(kRootKeyNameForFile)) &&
|
||||
CheckHandlerCommon(GetFullDragDropMenuKeyName(kRootKeyNameForDirectory)) &&
|
||||
CheckHandlerCommon(GetFullDragDropMenuKeyName(kRootKeyNameForDrive));
|
||||
}
|
||||
|
||||
static void DeleteContextMenuHandlerCommon(const CSysString &keyName)
|
||||
|
||||
@@ -151,7 +151,7 @@ static void CreateToolbar(
|
||||
imageList.Create(
|
||||
LargeButtons ? 48: 24,
|
||||
LargeButtons ? 36: 24,
|
||||
ILC_MASK, 0, 0);
|
||||
ILC_MASK | ILC_COLOR32, 0, 0);
|
||||
toolBar.SetImageList(0, imageList);
|
||||
}
|
||||
|
||||
|
||||
@@ -657,6 +657,34 @@ SOURCE=..\..\..\..\C\Alloc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Sha256.c
|
||||
|
||||
!IF "$(CFG)" == "FM - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "FM - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "FM - Win32 ReleaseU"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "FM - Win32 DebugU"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Sha256.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Sort.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
|
||||
@@ -2,30 +2,31 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../../../../C/Alloc.h"
|
||||
#include "../../../../C/7zCrc.h"
|
||||
#include "../../../../C/Sha256.h"
|
||||
}
|
||||
|
||||
#include "Common/IntToString.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/FileIO.h"
|
||||
#include "Windows/Error.h"
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/FileIO.h"
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/Thread.h"
|
||||
#include "Windows/Error.h"
|
||||
|
||||
#include "ProgressDialog2.h"
|
||||
#include "OverwriteDialogRes.h"
|
||||
#include "ProgressDialog2.h"
|
||||
|
||||
#include "App.h"
|
||||
#include "FormatUtils.h"
|
||||
#include "LangUtils.h"
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NName;
|
||||
@@ -125,10 +126,12 @@ struct CThreadCrc
|
||||
|
||||
CDirEnumerator DirEnumerator;
|
||||
|
||||
UInt64 NumFilesScan;
|
||||
UInt64 NumFiles;
|
||||
UInt64 NumFolders;
|
||||
UInt64 DataSize;
|
||||
UInt32 DataCrcSum;
|
||||
Byte Sha256Sum[SHA256_DIGEST_SIZE];
|
||||
UInt32 DataNameCrcSum;
|
||||
|
||||
HRESULT Result;
|
||||
@@ -139,7 +142,8 @@ struct CThreadCrc
|
||||
|
||||
void Process2()
|
||||
{
|
||||
DataSize = NumFolders = NumFiles = DataCrcSum = DataNameCrcSum = 0;
|
||||
DataSize = NumFolders = NumFiles = NumFilesScan = DataCrcSum = DataNameCrcSum = 0;
|
||||
memset(Sha256Sum, 0, SHA256_DIGEST_SIZE);
|
||||
ProgressDialog->WaitCreating();
|
||||
|
||||
CMyBuffer bufferObject;
|
||||
@@ -172,14 +176,17 @@ struct CThreadCrc
|
||||
if (!filled)
|
||||
break;
|
||||
if (!fileInfo.IsDir())
|
||||
{
|
||||
totalSize += fileInfo.Size;
|
||||
NumFilesScan++;
|
||||
}
|
||||
ProgressDialog->ProgressSynch.SetCurrentFileName(scanningStr + resPath);
|
||||
ProgressDialog->ProgressSynch.SetProgress(totalSize, 0);
|
||||
Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(0);
|
||||
if (Result != S_OK)
|
||||
return;
|
||||
}
|
||||
|
||||
ProgressDialog->ProgressSynch.SetNumFilesTotal(NumFilesScan);
|
||||
ProgressDialog->ProgressSynch.SetProgress(totalSize, 0);
|
||||
|
||||
DirEnumerator.Init();
|
||||
@@ -199,6 +206,9 @@ struct CThreadCrc
|
||||
break;
|
||||
|
||||
UInt32 crc = CRC_INIT_VAL;
|
||||
CSha256 sha256;
|
||||
Sha256_Init(&sha256);
|
||||
|
||||
if (fileInfo.IsDir())
|
||||
NumFolders++;
|
||||
else
|
||||
@@ -211,8 +221,9 @@ struct CThreadCrc
|
||||
ErrorPath = resPath;
|
||||
return;
|
||||
}
|
||||
NumFiles++;
|
||||
ProgressDialog->ProgressSynch.SetCurrentFileName(resPath);
|
||||
ProgressDialog->ProgressSynch.SetNumFilesCur(NumFiles);
|
||||
NumFiles++;
|
||||
for (;;)
|
||||
{
|
||||
UInt32 processedSize;
|
||||
@@ -226,12 +237,17 @@ struct CThreadCrc
|
||||
if (processedSize == 0)
|
||||
break;
|
||||
crc = CrcUpdate(crc, buffer, processedSize);
|
||||
if (NumFilesScan == 1)
|
||||
Sha256_Update(&sha256, buffer, processedSize);
|
||||
|
||||
DataSize += processedSize;
|
||||
Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(DataSize);
|
||||
if (Result != S_OK)
|
||||
return;
|
||||
}
|
||||
DataCrcSum += CRC_GET_DIGEST(crc);
|
||||
if (NumFilesScan == 1)
|
||||
Sha256_Final(&sha256, Sha256Sum);
|
||||
}
|
||||
for (int i = 0; i < resPath.Length(); i++)
|
||||
{
|
||||
@@ -259,13 +275,22 @@ struct CThreadCrc
|
||||
}
|
||||
};
|
||||
|
||||
static void ConvertByteToHex(unsigned value, wchar_t *s)
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
unsigned t = value & 0xF;
|
||||
value >>= 4;
|
||||
s[1 - i] = (wchar_t)((t < 10) ? (L'0' + t) : (L'A' + (t - 10)));
|
||||
}
|
||||
}
|
||||
|
||||
static void ConvertUInt32ToHex(UInt32 value, wchar_t *s)
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
for (int i = 6; i >= 0; i -= 2)
|
||||
{
|
||||
int t = value & 0xF;
|
||||
value >>= 4;
|
||||
s[7 - i] = (wchar_t)((t < 10) ? (L'0' + t) : (L'A' + (t - 10)));
|
||||
ConvertByteToHex(value & 0xFF, s + i);
|
||||
value >>= 8;
|
||||
}
|
||||
s[8] = L'\0';
|
||||
}
|
||||
@@ -360,6 +385,19 @@ void CApp::CalculateCrc()
|
||||
s += L" ";
|
||||
ConvertUInt32ToHex(combiner.DataNameCrcSum, sz);
|
||||
s += sz;
|
||||
s += L"\n";
|
||||
|
||||
if (combiner.NumFiles == 1 && combiner.NumFilesScan == 1)
|
||||
{
|
||||
s += L"SHA-256: ";
|
||||
for (int i = 0; i < SHA256_DIGEST_SIZE; i++)
|
||||
{
|
||||
wchar_t s2[4];
|
||||
ConvertByteToHex(combiner.Sha256Sum[i], s2);
|
||||
s2[2] = 0;
|
||||
s += s2;
|
||||
}
|
||||
}
|
||||
}
|
||||
srcPanel.MessageBoxInfo(s, LangString(IDS_CHECKSUM_INFORMATION, 0x03020720));
|
||||
}
|
||||
|
||||
@@ -126,7 +126,8 @@ static bool CheckShellExtensionInfo2(const CSysString &extension, UString &iconP
|
||||
if (extKey.QueryValue(NULL, programNameValue) != ERROR_SUCCESS)
|
||||
return false;
|
||||
CSysString extProgramKeyName = GetExtProgramKeyName(extension);
|
||||
if (programNameValue.CompareNoCase(extProgramKeyName) != 0)
|
||||
UString programNameValueU = GetUnicodeString(programNameValue);
|
||||
if (programNameValueU.CompareNoCase(GetUnicodeString(extProgramKeyName)) != 0)
|
||||
return false;
|
||||
CKey iconKey;
|
||||
if (extKey.Open(HKEY_CLASSES_ROOT, extProgramKeyName + CSysString(TEXT(CHAR_PATH_SEPARATOR)) + kDefaultIconKeyName, KEY_READ) != ERROR_SUCCESS)
|
||||
|
||||
@@ -149,6 +149,7 @@ AGENT_OBJS = \
|
||||
|
||||
C_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
$O\Sha256.obj \
|
||||
$O\Sort.obj \
|
||||
$O\Threads.obj \
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ using namespace NFile;
|
||||
using namespace NName;
|
||||
using namespace NDirectory;
|
||||
|
||||
static const int kHistorySize = 8;
|
||||
static const int kHistorySize = 20;
|
||||
|
||||
static LPCWSTR kExeExt = L".exe";
|
||||
static LPCWSTR k7zFormat = L"7z";
|
||||
@@ -1315,7 +1315,7 @@ UInt64 CCompressDialog::GetMemoryUsage(UInt32 dictionary, UInt64 &decompressMemo
|
||||
UInt64 size1 = (UInt64)hs * 4;
|
||||
size1 += (UInt64)dictionary * 11 / 2;
|
||||
if (level >= 5)
|
||||
size1 += dictionary * 4;
|
||||
size1 += (UInt64)dictionary * 4;
|
||||
size1 += (2 << 20);
|
||||
|
||||
UInt32 numThreads1 = 1;
|
||||
|
||||
Reference in New Issue
Block a user