Skip to content

Commit

Permalink
Added ability to stop on first mismatch when checking hashes.
Browse files Browse the repository at this point in the history
  • Loading branch information
lazyhamster committed Mar 10, 2023
1 parent cf963c0 commit 0779dca
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 7 deletions.
1 change: 0 additions & 1 deletion source/FarCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ static int optUsePrefix = TRUE;
static int optHashUppercase = FALSE;
static int optListDefaultCodepage = CP_UTF8;
static int optRememberLastUsedAlgo = FALSE;
static int optIgnoreMissingFiles = FALSE;
static wchar_t optPrefix[32] = L"check";

#define EDR_SKIP 0
Expand Down
15 changes: 11 additions & 4 deletions source/IntChecker2-Far3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
#include <InitGuid.h>
#include "Far3Guids.h"

#include "FarCommon.h"
#include "farhelpers/Far3Menu.hpp"
#include "farhelpers/Far3Panel.hpp"

#include "FarCommon.h"

static std::wstring AnsiPageName = FormatString(L"ANSI (%d)", GetACP());
static std::wstring OemPageName = FormatString(L"OEM (%d)", GetOEMCP());

Expand Down Expand Up @@ -336,7 +337,7 @@ static void DisplayValidationResults(Far3Panel& panel, std::vector<std::wstring>
}
}

static bool AskValidationFileParams(UINT &codepage, int &ignoreMissingFiles)
static bool AskValidationFileParams(UINT &codepage, bool &ignoreMissingFiles, bool &stopOnFirstFail)
{
const wchar_t* codePageNames[] = {L"UTF-8", AnsiPageName.c_str(), OemPageName.c_str()};
const UINT codePageValues[] = {CP_UTF8, CP_ACP, CP_OEMCP};
Expand All @@ -352,6 +353,7 @@ static bool AskValidationFileParams(UINT &codepage, int &ignoreMissingFiles)
auto cpBox = dlgBuilder.AddComboBox(&selectedCP, NULL, 10, codePageNames, _countof(codePageNames), DIF_DROPDOWNLIST);
dlgBuilder.AddTextBefore(cpBox, MSG_GEN_CODEPAGE);
dlgBuilder.AddCheckbox(MSG_DLG_IGNORE_MISSING, &ignoreMissingFiles);
dlgBuilder.AddCheckbox(MSG_DLG_STOP_ON_FIRST_MISMATCH, &stopOnFirstFail);
dlgBuilder.AddOKCancel(MSG_BTN_RUN, MSG_BTN_CANCEL);

if (dlgBuilder.ShowDialog())
Expand All @@ -368,9 +370,10 @@ static bool AskValidationFileParams(UINT &codepage, int &ignoreMissingFiles)
static bool RunValidateFiles(const wchar_t* hashListPath, bool silent, bool showParamsDialog)
{
UINT fileCodepage = optListDefaultCodepage;
int ignoreMissingFiles = optIgnoreMissingFiles;
bool ignoreMissingFiles = false;
bool stopOnFirstFail = false;

if (!silent && showParamsDialog && !AskValidationFileParams(fileCodepage, ignoreMissingFiles))
if (!silent && showParamsDialog && !AskValidationFileParams(fileCodepage, ignoreMissingFiles, stopOnFirstFail))
return false;

HashList hashes;
Expand Down Expand Up @@ -427,7 +430,11 @@ static bool RunValidateFiles(const wchar_t* hashListPath, bool silent, bool show
if (RunGeneration(strFullFilePath, fileInfo.Filename, fileInfo.HashAlgo, false, progressCtx, hashValueStr, fAborted, fAutoSkipErrors))
{
if (!SameHash(fileInfo.HashStr, hashValueStr))
{
vMismatches.push_back(fileInfo.Filename);
if (stopOnFirstFail)
break;
}
}
else if (fAborted)
{
Expand Down
1 change: 1 addition & 0 deletions source/Lang.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ enum
MSG_DLG_PROGRESS_NUMFILES,
MSG_DLG_PROGRESS_NUMBYTES,
MSG_DLG_IGNORE_MISSING,
MSG_DLG_STOP_ON_FIRST_MISMATCH,
MSG_DLG_INVALID_PARAMS,
MSG_DLG_SELECT_PARAMS,
MSG_DLG_BENCHMARKING,
Expand Down
3 changes: 2 additions & 1 deletion source/Text/IntCheckerEng.lng
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
"Select algorithm"
"Files:"
"Bytes:"
"Ignore missing files"
"&Ignore missing files"
"&Stop on first mismatch"
"Invalid parameters selected"
"Select parameters"
"Benchmarking %s"
Expand Down
1 change: 1 addition & 0 deletions source/Text/IntCheckerPol.lng
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"Plików:"
"Bajtów:"
"&Ignoruj brakujące pliki"
"*&Stop on first mismatch"
"Wybrano nieprawidłowy parametr"
"Wybierz parametry"
"Testuję %s"
Expand Down
1 change: 1 addition & 0 deletions source/Text/IntCheckerRus.lng
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"Файлов:"
"Байт:"
"Игнорировать отсутствующие файлы"
"Остановиться на первом несовпадении"
"Заданы неправильные параметры"
"Выберите параметры"
"Тестирую %s"
Expand Down
3 changes: 2 additions & 1 deletion source/Text/IntCheckerSpa.lng
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
"Seleccionar algoritmo"
"Archivos:"
"Bytes:"
"*Ignore missing files"
"*&Ignore missing files"
"*&Stop on first mismatch"
"*Invalid parameters selected"
"*Select parameters"
"*Benchmarking %s"
Expand Down
1 change: 1 addition & 0 deletions source/Text/history_en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Changes history:

2.8.2
- Fixed loading of hash lists in BSD format for several algorithms.
- Added ability to stop on first mismatch when checking hashes.

2.8.1
- Only CRC32 and SHA1 can be used in panel comparision mode now (no need to use all algorithms).
Expand Down
1 change: 1 addition & 0 deletions source/Text/history_ru.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

2.8.2
- ���������� �������� ���-������ � ������� BSD ��� ��������� ����������.
- ��������� ����������� ��������� ��� ������ ������������ ��� �������� ������.

2.8.1
- ��� ������ ��������� ������� ��������� ������ CRC32 � SHA1 (��� ������ ������������ ��� ���������).
Expand Down

0 comments on commit 0779dca

Please sign in to comment.