mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-11 06:07:12 -06:00
4.36 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
191cf6781a
commit
8304895f29
@@ -202,6 +202,7 @@ public:
|
||||
{ OnCopy(true, false, GetFocusedPanelIndex()); }
|
||||
void Delete(bool toRecycleBin)
|
||||
{ GetFocusedPanel().DeleteItems(toRecycleBin); }
|
||||
void CalculateCrc();
|
||||
void Split();
|
||||
void Combine();
|
||||
void Properties()
|
||||
|
||||
@@ -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" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /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" /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"
|
||||
@@ -355,6 +355,10 @@ SOURCE=.\PanelCopy.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PanelCrc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PanelDrag.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -77,6 +77,7 @@ static CIDLangPair kIDLangPairs[] =
|
||||
{ IDM_DELETE, 0x03000233 },
|
||||
{ IDM_FILE_PROPERTIES, 0x03000240 },
|
||||
{ IDM_FILE_COMMENT, 0x03000241 },
|
||||
{ IDM_FILE_CRC, 0x03000242 },
|
||||
{ IDM_FILE_SPLIT, 0x03000270 },
|
||||
{ IDM_FILE_COMBINE, 0x03000271 },
|
||||
{ IDM_CREATE_FOLDER, 0x03000250 },
|
||||
@@ -500,6 +501,9 @@ bool ExecuteFileCommand(int id)
|
||||
g_App.Delete(!shift);
|
||||
break;
|
||||
}
|
||||
case IDM_FILE_CRC:
|
||||
g_App.CalculateCrc();
|
||||
break;
|
||||
case IDM_FILE_SPLIT:
|
||||
g_App.Split();
|
||||
break;
|
||||
|
||||
@@ -632,6 +632,8 @@ bool CPanel::OnCommand(int code, int itemID, LPARAM lParam, LRESULT &result)
|
||||
return CWindow2::OnCommand(code, itemID, lParam, result);
|
||||
}
|
||||
|
||||
void CPanel::MessageBoxInfo(LPCWSTR message, LPCWSTR caption)
|
||||
{ ::MessageBoxW(HWND(*this), message, caption, MB_OK); }
|
||||
void CPanel::MessageBox(LPCWSTR message, LPCWSTR caption)
|
||||
{ ::MessageBoxW(HWND(*this), message, caption, MB_OK | MB_ICONSTOP); }
|
||||
void CPanel::MessageBox(LPCWSTR message)
|
||||
|
||||
@@ -434,6 +434,7 @@ public:
|
||||
|
||||
void RefreshListCtrl();
|
||||
|
||||
void MessageBoxInfo(LPCWSTR message, LPCWSTR caption);
|
||||
void MessageBox(LPCWSTR message);
|
||||
void MessageBox(LPCWSTR message, LPCWSTR caption);
|
||||
void MessageBoxMyError(LPCWSTR message);
|
||||
|
||||
354
7zip/FileManager/PanelCrc.cpp
Executable file
354
7zip/FileManager/PanelCrc.cpp
Executable file
@@ -0,0 +1,354 @@
|
||||
// PanelSplitFile.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#include "Common/Alloc.h"
|
||||
#include "Common/CRC.h"
|
||||
#include "Common/IntToString.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/FileIO.h"
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/Thread.h"
|
||||
#include "Windows/Error.h"
|
||||
|
||||
#include "Resource/ProgressDialog2/ProgressDialog.h"
|
||||
#include "Resource/OverwriteDialog/resource.h"
|
||||
|
||||
#include "App.h"
|
||||
#include "FormatUtils.h"
|
||||
#include "LangUtils.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NName;
|
||||
|
||||
static const UInt32 kBufSize = (1 << 15);
|
||||
|
||||
struct CDirEnumerator
|
||||
{
|
||||
UString BasePrefix;
|
||||
UStringVector FileNames;
|
||||
|
||||
CObjectVector<NFind::CEnumeratorW> Enumerators;
|
||||
UStringVector Prefixes;
|
||||
int Index;
|
||||
bool GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &fullPath, DWORD &errorCode);
|
||||
void Init();
|
||||
};
|
||||
|
||||
void CDirEnumerator::Init()
|
||||
{
|
||||
Enumerators.Clear();
|
||||
Prefixes.Clear();
|
||||
Index = 0;
|
||||
}
|
||||
|
||||
bool CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &resPath, DWORD &errorCode)
|
||||
{
|
||||
filled = false;
|
||||
while(true)
|
||||
{
|
||||
if (Enumerators.IsEmpty())
|
||||
{
|
||||
if (Index >= FileNames.Size())
|
||||
return true;
|
||||
const UString &path = FileNames[Index];
|
||||
if (!NFind::FindFile(BasePrefix + path, fileInfo))
|
||||
{
|
||||
errorCode = ::GetLastError();
|
||||
resPath = path;
|
||||
return false;
|
||||
}
|
||||
Index++;
|
||||
resPath.Empty();
|
||||
break;
|
||||
}
|
||||
bool found;
|
||||
if (!Enumerators.Back().Next(fileInfo, found))
|
||||
{
|
||||
errorCode = ::GetLastError();
|
||||
resPath = Prefixes.Back();
|
||||
return false;
|
||||
}
|
||||
if (found)
|
||||
{
|
||||
resPath = Prefixes.Back();
|
||||
break;
|
||||
}
|
||||
Enumerators.DeleteBack();
|
||||
Prefixes.DeleteBack();
|
||||
}
|
||||
resPath += fileInfo.Name;
|
||||
if (fileInfo.IsDirectory())
|
||||
{
|
||||
UString prefix = resPath + (UString)(wchar_t)kDirDelimiter;
|
||||
Enumerators.Add(NFind::CEnumeratorW(BasePrefix + prefix + (UString)(wchar_t)kAnyStringWildcard));
|
||||
Prefixes.Add(prefix);
|
||||
}
|
||||
filled = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
struct CThreadCrc
|
||||
{
|
||||
class CMyBuffer
|
||||
{
|
||||
void *_data;
|
||||
public:
|
||||
CMyBuffer(): _data(0) {}
|
||||
operator void *() { return _data; }
|
||||
bool Allocate(size_t size)
|
||||
{
|
||||
if (_data != 0)
|
||||
return false;
|
||||
_data = ::MidAlloc(size);
|
||||
return _data != 0;
|
||||
}
|
||||
~CMyBuffer() { ::MidFree(_data); }
|
||||
};
|
||||
|
||||
CProgressDialog *ProgressDialog;
|
||||
|
||||
CDirEnumerator DirEnumerator;
|
||||
|
||||
UInt64 NumFiles;
|
||||
UInt64 NumFolders;
|
||||
UInt64 DataSize;
|
||||
UInt32 DataCrcSum;
|
||||
UInt32 DataNameCrcSum;
|
||||
|
||||
HRESULT Result;
|
||||
DWORD ErrorCode;
|
||||
UString ErrorPath;
|
||||
UString Error;
|
||||
bool ThereIsError;
|
||||
|
||||
void Process2()
|
||||
{
|
||||
DataSize = NumFolders = NumFiles = DataCrcSum = DataNameCrcSum = 0;
|
||||
ProgressDialog->WaitCreating();
|
||||
|
||||
CMyBuffer bufferObject;
|
||||
if (!bufferObject.Allocate(kBufSize))
|
||||
{
|
||||
Error = L"Can not allocate memory";
|
||||
ThereIsError = true;
|
||||
return;
|
||||
}
|
||||
Byte *buffer = (Byte *)(void *)bufferObject;
|
||||
|
||||
UInt64 totalSize = 0;
|
||||
|
||||
DirEnumerator.Init();
|
||||
|
||||
UString scanningStr = LangString(IDS_SCANNING, 0x03020800);
|
||||
scanningStr += L" ";
|
||||
|
||||
while (true)
|
||||
{
|
||||
NFile::NFind::CFileInfoW fileInfo;
|
||||
bool filled;
|
||||
UString resPath;
|
||||
if (!DirEnumerator.GetNextFile(fileInfo, filled, resPath, ErrorCode))
|
||||
{
|
||||
ThereIsError = true;
|
||||
ErrorPath = resPath;
|
||||
return;
|
||||
}
|
||||
if (!filled)
|
||||
break;
|
||||
if (!fileInfo.IsDirectory())
|
||||
totalSize += fileInfo.Size;
|
||||
ProgressDialog->ProgressSynch.SetCurrentFileName(scanningStr + resPath);
|
||||
ProgressDialog->ProgressSynch.SetProgress(totalSize, 0);
|
||||
Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(0);
|
||||
if (Result != S_OK)
|
||||
return;
|
||||
}
|
||||
|
||||
ProgressDialog->ProgressSynch.SetProgress(totalSize, 0);
|
||||
|
||||
DirEnumerator.Init();
|
||||
|
||||
while(true)
|
||||
{
|
||||
NFile::NFind::CFileInfoW fileInfo;
|
||||
bool filled;
|
||||
UString resPath;
|
||||
if (!DirEnumerator.GetNextFile(fileInfo, filled, resPath, ErrorCode))
|
||||
{
|
||||
ThereIsError = true;
|
||||
ErrorPath = resPath;
|
||||
return;
|
||||
}
|
||||
if (!filled)
|
||||
break;
|
||||
|
||||
CCRC crc;
|
||||
if (fileInfo.IsDirectory())
|
||||
NumFolders++;
|
||||
else
|
||||
{
|
||||
NFile::NIO::CInFile inFile;
|
||||
if (!inFile.Open(DirEnumerator.BasePrefix + resPath))
|
||||
{
|
||||
ErrorCode = ::GetLastError();
|
||||
ThereIsError = true;
|
||||
ErrorPath = resPath;
|
||||
return;
|
||||
}
|
||||
NumFiles++;
|
||||
ProgressDialog->ProgressSynch.SetCurrentFileName(resPath);
|
||||
while(true)
|
||||
{
|
||||
UInt32 processedSize;
|
||||
if (!inFile.Read(buffer, kBufSize, processedSize))
|
||||
{
|
||||
ErrorCode = ::GetLastError();
|
||||
ThereIsError = true;
|
||||
ErrorPath = resPath;
|
||||
return;
|
||||
}
|
||||
if (processedSize == 0)
|
||||
break;
|
||||
crc.Update(buffer, processedSize);
|
||||
DataSize += processedSize;
|
||||
Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(DataSize);
|
||||
if (Result != S_OK)
|
||||
return;
|
||||
}
|
||||
DataCrcSum += crc.GetDigest();
|
||||
}
|
||||
for (int i = 0; i < resPath.Length(); i++)
|
||||
{
|
||||
wchar_t c = resPath[i];
|
||||
crc.UpdateByte(c & 0xFF);
|
||||
crc.UpdateByte((c >> 8) & 0xFF);
|
||||
}
|
||||
DataNameCrcSum += crc.GetDigest();
|
||||
Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(DataSize);
|
||||
if (Result != S_OK)
|
||||
return;
|
||||
}
|
||||
}
|
||||
DWORD Process()
|
||||
{
|
||||
try { Process2(); }
|
||||
catch(...) { Error = L"Error"; ThereIsError = true;}
|
||||
ProgressDialog->MyClose();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static DWORD WINAPI MyThreadFunction(void *param)
|
||||
{
|
||||
return ((CThreadCrc *)param)->Process();
|
||||
}
|
||||
};
|
||||
|
||||
static void ConvertUInt32ToHex(UInt32 value, wchar_t *s)
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
int t = value & 0xF;
|
||||
value >>= 4;
|
||||
s[7 - i] = (wchar_t)((t < 10) ? (L'0' + t) : (L'A' + (t - 10)));
|
||||
}
|
||||
s[8] = L'\0';
|
||||
}
|
||||
|
||||
void CApp::CalculateCrc()
|
||||
{
|
||||
int srcPanelIndex = GetFocusedPanelIndex();
|
||||
CPanel &srcPanel = Panels[srcPanelIndex];
|
||||
if (!srcPanel.IsFSFolder())
|
||||
{
|
||||
srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
|
||||
return;
|
||||
}
|
||||
CRecordVector<UInt32> indices;
|
||||
srcPanel.GetOperatedItemIndices(indices);
|
||||
if (indices.IsEmpty())
|
||||
return;
|
||||
|
||||
CThreadCrc combiner;
|
||||
for (int i = 0; i < indices.Size(); i++)
|
||||
combiner.DirEnumerator.FileNames.Add(srcPanel.GetItemName(indices[i]));
|
||||
combiner.DirEnumerator.BasePrefix = srcPanel._currentFolderPrefix;
|
||||
|
||||
CProgressDialog progressDialog;
|
||||
combiner.ProgressDialog = &progressDialog;
|
||||
combiner.ErrorCode = 0;
|
||||
combiner.Result = S_OK;
|
||||
combiner.ThereIsError = false;
|
||||
|
||||
UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
|
||||
UString title = LangString(IDS_CHECKSUM_CALCULATING, 0x03020710);
|
||||
|
||||
progressDialog.MainWindow = _window;
|
||||
progressDialog.MainTitle = progressWindowTitle;
|
||||
progressDialog.MainAddTitle = title + UString(L" ");
|
||||
|
||||
CThread thread;
|
||||
if (!thread.Create(CThreadCrc::MyThreadFunction, &combiner))
|
||||
throw 271824;
|
||||
progressDialog.Create(title, _window);
|
||||
|
||||
if (combiner.Result != S_OK)
|
||||
{
|
||||
if (combiner.Result != E_ABORT)
|
||||
srcPanel.MessageBoxError(combiner.Result);
|
||||
}
|
||||
else if (combiner.ThereIsError)
|
||||
{
|
||||
if (combiner.Error.IsEmpty())
|
||||
{
|
||||
UString message = combiner.DirEnumerator.BasePrefix + combiner.ErrorPath;
|
||||
message += L"\n";
|
||||
message += NError::MyFormatMessageW(combiner.ErrorCode);
|
||||
srcPanel.MessageBoxMyError(message);
|
||||
}
|
||||
else
|
||||
srcPanel.MessageBoxMyError(combiner.Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
UString s;
|
||||
{
|
||||
wchar_t sz[32];
|
||||
|
||||
s += LangString(IDS_FILES_COLON, 0x02000320);
|
||||
s += L" ";
|
||||
ConvertUInt64ToString(combiner.NumFiles, sz);
|
||||
s += sz;
|
||||
s += L"\n";
|
||||
|
||||
s += LangString(IDS_FOLDERS_COLON, 0x02000321);
|
||||
s += L" ";
|
||||
ConvertUInt64ToString(combiner.NumFolders, sz);
|
||||
s += sz;
|
||||
s += L"\n";
|
||||
|
||||
s += LangString(IDS_SIZE_COLON, 0x02000322);
|
||||
s += L" ";
|
||||
ConvertUInt64ToString(combiner.DataSize, sz);
|
||||
s += MyFormatNew(IDS_FILE_SIZE, 0x02000982, sz);;
|
||||
s += L"\n";
|
||||
|
||||
s += LangString(IDS_CHECKSUM_CRC_DATA, 0x03020721);
|
||||
s += L" ";
|
||||
ConvertUInt32ToHex(combiner.DataCrcSum, sz);
|
||||
s += sz;
|
||||
s += L"\n";
|
||||
|
||||
s += LangString(IDS_CHECKSUM_CRC_DATA_NAMES, 0x03020722);
|
||||
s += L" ";
|
||||
ConvertUInt32ToHex(combiner.DataNameCrcSum, sz);
|
||||
s += sz;
|
||||
}
|
||||
srcPanel.MessageBoxInfo(s, LangString(IDS_CHECKSUM_INFORMATION, 0x03020720));
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,11 @@
|
||||
#include "../../../GuiCommon.rc"
|
||||
|
||||
#define xSize2 238
|
||||
#define ySize2 204
|
||||
#define ySize2 214
|
||||
#define xSize (xSize2 + marg + marg)
|
||||
#define ySize (ySize2 + marg + marg)
|
||||
#define gSpace 30
|
||||
#define g0Size 105
|
||||
#define g0Size 110
|
||||
#define gYSize (ySize2 - 20 - bYSize)
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ FM_OBJS = \
|
||||
$O\OptionsDialog.obj \
|
||||
$O\Panel.obj \
|
||||
$O\PanelCopy.obj \
|
||||
$O\PanelCrc.obj \
|
||||
$O\PanelDrag.obj \
|
||||
$O\PanelFolderChange.obj \
|
||||
$O\PanelItemOpen.obj \
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#define IDM_FILE_COMBINE 239
|
||||
#define IDM_FILE_PROPERTIES 240
|
||||
#define IDM_FILE_COMMENT 241
|
||||
#define IDM_FILE_CRC 242
|
||||
#define IDM_CREATE_FOLDER 250
|
||||
#define IDM_CREATE_FILE 251
|
||||
#define IDM_EDIT_CUT 320
|
||||
@@ -105,6 +106,10 @@
|
||||
#define IDS_SELECT_MASK 2252
|
||||
#define IDS_FOLDERS_HISTORY 2260
|
||||
#define IDS_N_SELECTED_ITEMS 2270
|
||||
#define IDS_FILES_COLON 2274
|
||||
#define IDS_FOLDERS_COLON 2275
|
||||
#define IDS_SIZE_COLON 2276
|
||||
|
||||
#define IDS_TOO_MANY_ITEMS 2279
|
||||
#define IDS_WANT_UPDATE_MODIFIED_FILE 2280
|
||||
#define IDS_CANNOT_UPDATE_FILE 2281
|
||||
@@ -135,3 +140,10 @@
|
||||
#define IDS_COMBINE 4030
|
||||
#define IDS_COMBINE_TO 4031
|
||||
#define IDS_COMBINING 4032
|
||||
|
||||
#define IDS_CHECKSUM_CALCULATING 4040
|
||||
#define IDS_CHECKSUM_INFORMATION 4041
|
||||
#define IDS_CHECKSUM_CRC_DATA 4042
|
||||
#define IDS_CHECKSUM_CRC_DATA_NAMES 4043
|
||||
|
||||
#define IDS_SCANNING 4050
|
||||
|
||||
@@ -33,6 +33,7 @@ BEGIN
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "P&roperties\tAlt+Enter", IDM_FILE_PROPERTIES
|
||||
MENUITEM "Comme&nt\tCtrl+Z", IDM_FILE_COMMENT
|
||||
MENUITEM "Calculate checksum", IDM_FILE_CRC
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Create Folder\tF7", IDM_CREATE_FOLDER
|
||||
MENUITEM "Create File\tCtrl+N", IDM_CREATE_FILE
|
||||
@@ -138,6 +139,13 @@ BEGIN
|
||||
IDS_COMBINE "Combine Files"
|
||||
IDS_COMBINE_TO "&Combine to:"
|
||||
IDS_COMBINING "Combining..."
|
||||
IDS_CHECKSUM_CALCULATING "Checksum calculating..."
|
||||
IDS_CHECKSUM_INFORMATION "Checksum information"
|
||||
IDS_CHECKSUM_CRC_DATA "CRC checksum for data:"
|
||||
IDS_CHECKSUM_CRC_DATA_NAMES "CRC checksum for data and names:"
|
||||
|
||||
IDS_SCANNING "Scanning..."
|
||||
|
||||
IDS_OPERATION_IS_NOT_SUPPORTED "Operation is not supported."
|
||||
|
||||
IDS_CONFIRM_FILE_DELETE "Confirm File Delete"
|
||||
@@ -166,6 +174,10 @@ BEGIN
|
||||
IDS_SELECT_MASK "Mask:"
|
||||
IDS_FOLDERS_HISTORY "Folders History"
|
||||
IDS_N_SELECTED_ITEMS "{0} object(s) selected"
|
||||
IDS_FILES_COLON "Files:"
|
||||
IDS_FOLDERS_COLON "Folders:"
|
||||
IDS_SIZE_COLON "Size:"
|
||||
|
||||
IDS_PROPERTY_TOTAL_SIZE "Total Size"
|
||||
IDS_PROPERTY_FREE_SPACE "Free Space"
|
||||
IDS_PROPERTY_CLUSTER_SIZE "Cluster Size"
|
||||
|
||||
Reference in New Issue
Block a user