Make Upper- or lowercase hash output an option. (fix #177)

This commit is contained in:
Tino Reichardt
2021-04-06 12:13:41 +02:00
parent 3df8bc1293
commit f090495d25
9 changed files with 33 additions and 5 deletions

View File

@@ -9,6 +9,10 @@
#include "../../Common/FileStreams.h"
#include "../../Common/StreamUtils.h"
#ifdef WANT_OPTIONAL_LOWERCASE
#include "../FileManager/RegistryUtils.h"
#endif
#include "EnumDirItems.h"
#include "HashCalc.h"
@@ -309,10 +313,15 @@ HRESULT HashCalc(
return callback->AfterLastFile(hb);
}
static inline char GetHex(unsigned v)
{
return (char)((v < 10) ? ('0' + v) : ('a' + (v - 10)));
#ifdef WANT_OPTIONAL_LOWERCASE
if (WantLowercaseHashes())
{
return (char)((v < 10) ? ('0' + v) : ('a' + (v - 10)));
}
#endif
return (char)((v < 10) ? ('0' + v) : ('A' + (v - 10)));
}
void AddHashHexToString(char *dest, const Byte *data, UInt32 size)

View File

@@ -0,0 +1,6 @@
// HashCalc2.cpp
#include "StdAfx.h"
#define WANT_OPTIONAL_LOWERCASE
#include "HashCalc.cpp"

View File

@@ -41,6 +41,7 @@ static LPCTSTR const kArcHistory = TEXT("WantArcHistory");
static LPCTSTR const kPathHistory = TEXT("WantPathHistory");
static LPCTSTR const kCopyHistory = TEXT("WantCopyHistory");
static LPCTSTR const kFolderHistory = TEXT("WantFolderHistory");
static LPCTSTR const kLowercaseHashes = TEXT("LowercaseHashes");
static LPCTSTR const kFlatViewName = TEXT("FlatViewArc");
// static LPCTSTR const kShowDeletedFiles = TEXT("ShowDeleted");
@@ -147,6 +148,7 @@ void CFmSettings::Save() const
SaveOption(kPathHistory, PathHistory);
SaveOption(kCopyHistory, CopyHistory);
SaveOption(kFolderHistory, FolderHistory);
SaveOption(kLowercaseHashes, LowercaseHashes);
// SaveOption(kUnderline, Underline);
SaveOption(kShowSystemMenu, ShowSystemMenu);
@@ -164,6 +166,7 @@ void CFmSettings::Load()
PathHistory = false;
CopyHistory = false;
FolderHistory = false;
LowercaseHashes = false;
// Underline = false;
ShowSystemMenu = false;
@@ -181,6 +184,7 @@ void CFmSettings::Load()
ReadOption(key, kPathHistory, PathHistory);
ReadOption(key, kCopyHistory, CopyHistory);
ReadOption(key, kFolderHistory, FolderHistory);
ReadOption(key, kLowercaseHashes, LowercaseHashes);
// ReadOption(key, kUnderline, Underline);
ReadOption(key, kShowSystemMenu, ShowSystemMenu );
@@ -198,6 +202,7 @@ bool WantArcHistory() { return ReadFMOption(kArcHistory); }
bool WantPathHistory() { return ReadFMOption(kPathHistory); }
bool WantCopyHistory() { return ReadFMOption(kCopyHistory); }
bool WantFolderHistory() { return ReadFMOption(kFolderHistory); }
bool WantLowercaseHashes() { return ReadFMOption(kLowercaseHashes); }
static CSysString GetFlatViewName(UInt32 panelIndex)
{

View File

@@ -27,6 +27,7 @@ struct CFmSettings
bool PathHistory;
bool CopyHistory;
bool FolderHistory;
bool LowercaseHashes;
// bool Underline;
bool ShowSystemMenu;
@@ -45,6 +46,7 @@ bool WantArcHistory();
bool WantPathHistory();
bool WantCopyHistory();
bool WantFolderHistory();
bool WantLowercaseHashes();
void SaveFlatView(UInt32 panelIndex, bool enable);
bool ReadFlatView(UInt32 panelIndex);

View File

@@ -30,7 +30,8 @@ static const UInt32 kLangIDs[] =
IDX_SETTINGS_WANT_ARC_HISTORY,
IDX_SETTINGS_WANT_PATH_HISTORY,
IDX_SETTINGS_WANT_COPY_HISTORY,
IDX_SETTINGS_WANT_FOLDER_HISTORY
IDX_SETTINGS_WANT_FOLDER_HISTORY,
IDX_SETTINGS_LOWERCASE_HASHES
};
#define kSettingsTopic "FM/options.htm#settings"
@@ -66,6 +67,7 @@ bool CSettingsPage::OnInit()
CheckButton(IDX_SETTINGS_WANT_PATH_HISTORY, st.PathHistory);
CheckButton(IDX_SETTINGS_WANT_COPY_HISTORY, st.CopyHistory);
CheckButton(IDX_SETTINGS_WANT_FOLDER_HISTORY, st.FolderHistory);
CheckButton(IDX_SETTINGS_LOWERCASE_HASHES, st.LowercaseHashes);
// EnableSubItems();
return CPropertyPage::OnInit();
@@ -93,6 +95,7 @@ LONG CSettingsPage::OnApply()
st.PathHistory = IsButtonCheckedBool(IDX_SETTINGS_WANT_PATH_HISTORY);
st.CopyHistory = IsButtonCheckedBool(IDX_SETTINGS_WANT_COPY_HISTORY);
st.FolderHistory = IsButtonCheckedBool(IDX_SETTINGS_WANT_FOLDER_HISTORY);
st.LowercaseHashes = IsButtonCheckedBool(IDX_SETTINGS_LOWERCASE_HASHES);
// st.Underline = IsButtonCheckedBool(IDX_SETTINGS_UNDERLINE);
st.ShowSystemMenu = IsButtonCheckedBool(IDX_SETTINGS_SHOW_SYSTEM_MENU);
@@ -142,6 +145,7 @@ bool CSettingsPage::OnButtonClicked(int buttonID, HWND buttonHWND)
case IDX_SETTINGS_WANT_PATH_HISTORY:
case IDX_SETTINGS_WANT_COPY_HISTORY:
case IDX_SETTINGS_WANT_FOLDER_HISTORY:
case IDX_SETTINGS_LOWERCASE_HASHES:
_wasChanged = true;
break;

View File

@@ -14,4 +14,5 @@ BEGIN
CONTROL "Want PathHistory", IDX_SETTINGS_WANT_PATH_HISTORY, MY_CHECKBOX, m, 144, xc, 10
CONTROL "Want CopyHistory", IDX_SETTINGS_WANT_COPY_HISTORY, MY_CHECKBOX, m, 158, xc, 10
CONTROL "Want FolderHistory", IDX_SETTINGS_WANT_FOLDER_HISTORY, MY_CHECKBOX, m, 172, xc, 10
CONTROL "Use Lowercase Hashes", IDX_SETTINGS_LOWERCASE_HASHES, MY_CHECKBOX, m, 186, xc, 10
END

View File

@@ -13,3 +13,4 @@
#define IDX_SETTINGS_WANT_PATH_HISTORY 2510
#define IDX_SETTINGS_WANT_COPY_HISTORY 2511
#define IDX_SETTINGS_WANT_FOLDER_HISTORY 2512
#define IDX_SETTINGS_LOWERCASE_HASHES 2513

View File

@@ -69,7 +69,7 @@ UI_COMMON_OBJS = \
$O\DefaultName.obj \
$O\EnumDirItems.obj \
$O\ExtractingFilePath.obj \
$O\HashCalc.obj \
$O\HashCalc2.obj \
$O\LoadCodecs.obj \
$O\OpenArchive.obj \
$O\PropIDUtils.obj \

View File

@@ -85,7 +85,7 @@ UI_COMMON_OBJS = \
$O\EnumDirItems.obj \
$O\Extract.obj \
$O\ExtractingFilePath.obj \
$O\HashCalc.obj \
$O\HashCalc2.obj \
$O\LoadCodecs.obj \
$O\OpenArchive.obj \
$O\PropIDUtils.obj \