mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-06 23:14:54 -06:00
21.06
This commit is contained in:
@@ -18,8 +18,9 @@ const unsigned kNumPanelsMax = 2;
|
||||
|
||||
extern bool g_IsSmallScreen;
|
||||
|
||||
const int kMenuCmdID_Plugin_Start = 1000; // must be large them context menu IDs
|
||||
const int kMenuCmdID_Toolbar_Start = 1500;
|
||||
// must be larger than context menu IDs
|
||||
const int kMenuCmdID_Toolbar_Start = 1070;
|
||||
const int kMenuCmdID_Plugin_Start = 1100;
|
||||
|
||||
enum
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ LONG g_DllRefCount;
|
||||
LONG g_DllRefCount = 0;
|
||||
|
||||
static const UINT kSevenZipStartMenuID = kMenuCmdID_Plugin_Start;
|
||||
static const UINT kSystemStartMenuID = kMenuCmdID_Plugin_Start + 100;
|
||||
static const UINT kSystemStartMenuID = kMenuCmdID_Plugin_Start + 400;
|
||||
|
||||
void CPanel::InvokeSystemCommand(const char *command)
|
||||
{
|
||||
@@ -993,11 +993,19 @@ bool CPanel::InvokePluginCommand(unsigned id,
|
||||
IContextMenu *sevenZipContextMenu, IContextMenu *systemContextMenu)
|
||||
{
|
||||
UInt32 offset;
|
||||
bool isSystemMenu = (id >= kSystemStartMenuID);
|
||||
const bool isSystemMenu = (id >= kSystemStartMenuID);
|
||||
if (isSystemMenu)
|
||||
{
|
||||
if (!systemContextMenu)
|
||||
return false;
|
||||
offset = id - kSystemStartMenuID;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!sevenZipContextMenu)
|
||||
return false;
|
||||
offset = id - kSevenZipStartMenuID;
|
||||
}
|
||||
|
||||
#ifdef use_CMINVOKECOMMANDINFOEX
|
||||
CMINVOKECOMMANDINFOEX
|
||||
|
||||
@@ -2,17 +2,20 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Common/StringConvert.h"
|
||||
// #include "../../../Common/IntToString.h"
|
||||
// #include "../../../Common/StringConvert.h"
|
||||
|
||||
#ifndef UNDER_CE
|
||||
#include "../../../Windows/MemoryLock.h"
|
||||
// #include "../../../Windows/System.h"
|
||||
#endif
|
||||
|
||||
// #include "../Common/ZipRegistry.h"
|
||||
|
||||
#include "HelpUtils.h"
|
||||
#include "LangUtils.h"
|
||||
#include "RegistryUtils.h"
|
||||
#include "SettingsPage.h"
|
||||
|
||||
#include "SettingsPageRes.h"
|
||||
|
||||
using namespace NWindows;
|
||||
@@ -27,16 +30,87 @@ static const UInt32 kLangIDs[] =
|
||||
IDX_SETTINGS_SINGLE_CLICK,
|
||||
IDX_SETTINGS_ALTERNATIVE_SELECTION,
|
||||
IDX_SETTINGS_LARGE_PAGES
|
||||
// , IDT_COMPRESS_MEMORY
|
||||
};
|
||||
|
||||
#define kSettingsTopic "FM/options.htm#settings"
|
||||
|
||||
extern bool IsLargePageSupported();
|
||||
|
||||
/*
|
||||
static void AddMemSize(UString &res, UInt64 size, bool needRound = false)
|
||||
{
|
||||
char c;
|
||||
unsigned moveBits = 0;
|
||||
if (needRound)
|
||||
{
|
||||
UInt64 rn = 0;
|
||||
if (size >= (1 << 31))
|
||||
rn = (1 << 28) - 1;
|
||||
UInt32 kRound = (1 << 20) - 1;
|
||||
if (rn < kRound)
|
||||
rn = kRound;
|
||||
size += rn;
|
||||
size &= ~rn;
|
||||
}
|
||||
if (size >= ((UInt64)1 << 31) && (size & 0x3FFFFFFF) == 0)
|
||||
{ moveBits = 30; c = 'G'; }
|
||||
else
|
||||
{ moveBits = 20; c = 'M'; }
|
||||
res.Add_UInt64(size >> moveBits);
|
||||
res.Add_Space();
|
||||
if (moveBits != 0)
|
||||
res += c;
|
||||
res += 'B';
|
||||
}
|
||||
|
||||
|
||||
int CSettingsPage::AddMemComboItem(UInt64 size, UInt64 percents, bool isDefault)
|
||||
{
|
||||
UString sUser;
|
||||
UString sRegistry;
|
||||
if (size == 0)
|
||||
{
|
||||
UString s;
|
||||
s.Add_UInt64(percents);
|
||||
s += '%';
|
||||
if (isDefault)
|
||||
sUser = "* ";
|
||||
else
|
||||
sRegistry = s;
|
||||
sUser += s;
|
||||
}
|
||||
else
|
||||
{
|
||||
AddMemSize(sUser, size);
|
||||
sRegistry = sUser;
|
||||
for (;;)
|
||||
{
|
||||
int pos = sRegistry.Find(L' ');
|
||||
if (pos < 0)
|
||||
break;
|
||||
sRegistry.Delete(pos);
|
||||
}
|
||||
if (!sRegistry.IsEmpty())
|
||||
if (sRegistry.Back() == 'B')
|
||||
sRegistry.DeleteBack();
|
||||
}
|
||||
const int index = (int)_memCombo.AddString(sUser);
|
||||
_memCombo.SetItemData(index, _memLimitStrings.Size());
|
||||
_memLimitStrings.Add(sRegistry);
|
||||
return index;
|
||||
}
|
||||
*/
|
||||
|
||||
bool CSettingsPage::OnInit()
|
||||
{
|
||||
_wasChanged = false;
|
||||
_largePages_wasChanged = false;
|
||||
/*
|
||||
_wasChanged_MemLimit = false;
|
||||
_memLimitStrings.Clear();
|
||||
_memCombo.Attach(GetItem(IDC_SETTINGS_MEM));
|
||||
*/
|
||||
|
||||
LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs));
|
||||
|
||||
@@ -57,6 +131,55 @@ bool CSettingsPage::OnInit()
|
||||
CheckButton(IDX_SETTINGS_LARGE_PAGES, ReadLockMemoryEnable());
|
||||
else
|
||||
EnableItem(IDX_SETTINGS_LARGE_PAGES, false);
|
||||
|
||||
|
||||
/*
|
||||
NCompression::CMemUse mu;
|
||||
bool needSetCur = NCompression::MemLimit_Load(mu);
|
||||
UInt64 curMemLimit;
|
||||
{
|
||||
AddMemComboItem(0, 90, true);
|
||||
_memCombo.SetCurSel(0);
|
||||
}
|
||||
if (mu.IsPercent)
|
||||
{
|
||||
const int index = AddMemComboItem(0, mu.Val);
|
||||
_memCombo.SetCurSel(index);
|
||||
needSetCur = false;
|
||||
}
|
||||
{
|
||||
_ramSize = (UInt64)(sizeof(size_t)) << 29;
|
||||
_ramSize_Defined = NSystem::GetRamSize(_ramSize);
|
||||
UString s;
|
||||
if (_ramSize_Defined)
|
||||
{
|
||||
s += "/ ";
|
||||
AddMemSize(s, _ramSize, true);
|
||||
}
|
||||
SetItemText(IDT_SETTINGS_MEM_RAM, s);
|
||||
|
||||
curMemLimit = mu.GetBytes(_ramSize);
|
||||
|
||||
// size = 100 << 20; // for debug only;
|
||||
for (unsigned i = (27) * 2;; i++)
|
||||
{
|
||||
UInt64 size = (UInt64)(2 + (i & 1)) << (i / 2);
|
||||
if (i > (20 + sizeof(size_t) * 3 * 1 - 1) * 2)
|
||||
size = (UInt64)(Int64)-1;
|
||||
if (needSetCur && (size >= curMemLimit))
|
||||
{
|
||||
const int index = AddMemComboItem(curMemLimit);
|
||||
_memCombo.SetCurSel(index);
|
||||
needSetCur = false;
|
||||
if (size == curMemLimit)
|
||||
continue;
|
||||
}
|
||||
if (size == (UInt64)(Int64)-1)
|
||||
break;
|
||||
AddMemComboItem(size);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// EnableSubItems();
|
||||
|
||||
@@ -70,6 +193,14 @@ void CSettingsPage::EnableSubItems()
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
static void AddSize_MB(UString &s, UInt64 size)
|
||||
{
|
||||
s.Add_UInt64((size + (1 << 20) - 1) >> 20);
|
||||
s += " MB";
|
||||
}
|
||||
*/
|
||||
|
||||
LONG CSettingsPage::OnApply()
|
||||
{
|
||||
if (_wasChanged)
|
||||
@@ -86,10 +217,9 @@ LONG CSettingsPage::OnApply()
|
||||
st.ShowSystemMenu = IsButtonCheckedBool(IDX_SETTINGS_SHOW_SYSTEM_MENU);
|
||||
|
||||
st.Save();
|
||||
|
||||
_wasChanged = false;
|
||||
}
|
||||
|
||||
|
||||
#ifndef UNDER_CE
|
||||
if (_largePages_wasChanged)
|
||||
{
|
||||
@@ -102,7 +232,66 @@ LONG CSettingsPage::OnApply()
|
||||
_largePages_wasChanged = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
if (_wasChanged_MemLimit)
|
||||
{
|
||||
const unsigned index = (int)_memCombo.GetItemData_of_CurSel();
|
||||
const UString str = _memLimitStrings[index];
|
||||
|
||||
bool needSave = true;
|
||||
|
||||
NCompression::CMemUse mu;
|
||||
|
||||
if (_ramSize_Defined)
|
||||
mu.Parse(str);
|
||||
if (mu.IsDefined)
|
||||
{
|
||||
const UInt64 usage64 = mu.GetBytes(_ramSize);
|
||||
if (_ramSize <= usage64)
|
||||
{
|
||||
UString s2 = LangString(IDT_COMPRESS_MEMORY);
|
||||
if (s2.IsEmpty())
|
||||
GetItemText(IDT_COMPRESS_MEMORY, s2);
|
||||
UString s;
|
||||
|
||||
s += "The selected value is not safe for system performance.";
|
||||
s.Add_LF();
|
||||
s += "The memory consumption for compression operation will exceed RAM size.";
|
||||
s.Add_LF();
|
||||
s.Add_LF();
|
||||
AddSize_MB(s, usage64);
|
||||
|
||||
if (!s2.IsEmpty())
|
||||
{
|
||||
s += " : ";
|
||||
s += s2;
|
||||
}
|
||||
|
||||
s.Add_LF();
|
||||
AddSize_MB(s, _ramSize);
|
||||
s += " : RAM";
|
||||
|
||||
s.Add_LF();
|
||||
s.Add_LF();
|
||||
s += "Are you sure you want set that unsafe value for memory usage?";
|
||||
|
||||
int res = MessageBoxW(*this, s, L"7-Zip", MB_YESNOCANCEL | MB_ICONQUESTION);
|
||||
if (res != IDYES)
|
||||
needSave = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (needSave)
|
||||
{
|
||||
NCompression::MemLimit_Save(str);
|
||||
_wasChanged_MemLimit = false;
|
||||
}
|
||||
else
|
||||
return PSNRET_INVALID_NOCHANGEPAGE;
|
||||
}
|
||||
*/
|
||||
|
||||
return PSNRET_NOERROR;
|
||||
}
|
||||
|
||||
@@ -111,6 +300,25 @@ void CSettingsPage::OnNotifyHelp()
|
||||
ShowHelpWindow(kSettingsTopic);
|
||||
}
|
||||
|
||||
/*
|
||||
bool CSettingsPage::OnCommand(int code, int itemID, LPARAM param)
|
||||
{
|
||||
if (code == CBN_SELCHANGE)
|
||||
{
|
||||
switch (itemID)
|
||||
{
|
||||
case IDC_SETTINGS_MEM:
|
||||
{
|
||||
_wasChanged_MemLimit = true;
|
||||
Changed();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return CPropertyPage::OnCommand(code, itemID, param);
|
||||
}
|
||||
*/
|
||||
|
||||
bool CSettingsPage::OnButtonClicked(int buttonID, HWND buttonHWND)
|
||||
{
|
||||
switch (buttonID)
|
||||
|
||||
@@ -4,20 +4,30 @@
|
||||
#define __SETTINGS_PAGE_H
|
||||
|
||||
#include "../../../Windows/Control/PropertyPage.h"
|
||||
#include "../../../Windows/Control/ComboBox.h"
|
||||
#include "../../../Windows/Control/Edit.h"
|
||||
|
||||
class CSettingsPage: public NWindows::NControl::CPropertyPage
|
||||
{
|
||||
bool _wasChanged;
|
||||
|
||||
bool _largePages_wasChanged;
|
||||
/*
|
||||
bool _wasChanged_MemLimit;
|
||||
NWindows::NControl::CComboBox _memCombo;
|
||||
UStringVector _memLimitStrings;
|
||||
UInt64 _ramSize;
|
||||
UInt64 _ramSize_Defined;
|
||||
|
||||
int AddMemComboItem(UInt64 size, UInt64 percents = 0, bool isDefault = false);
|
||||
*/
|
||||
|
||||
// void EnableSubItems();
|
||||
// bool OnCommand(int code, int itemID, LPARAM param);
|
||||
bool OnButtonClicked(int buttonID, HWND buttonHWND);
|
||||
public:
|
||||
virtual bool OnInit();
|
||||
virtual void OnNotifyHelp();
|
||||
virtual LONG OnApply();
|
||||
public:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "../../GuiCommon.rc"
|
||||
|
||||
#define xc 240
|
||||
#define yc 120
|
||||
#define yc 250
|
||||
|
||||
IDD_SETTINGS MY_PAGE
|
||||
#include "SettingsPage2.rc"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// #define g1xs 60
|
||||
|
||||
CAPTION "Settings"
|
||||
BEGIN
|
||||
CONTROL "Show "".."" item", IDX_SETTINGS_SHOW_DOTS, MY_CHECKBOX, m, 8, xc, 10
|
||||
@@ -10,4 +12,8 @@ BEGIN
|
||||
CONTROL "Show system &menu", IDX_SETTINGS_SHOW_SYSTEM_MENU, MY_CHECKBOX, m, 100, xc, 10
|
||||
|
||||
CONTROL "Use &large memory pages", IDX_SETTINGS_LARGE_PAGES, MY_CHECKBOX, m, 122, xc, 10
|
||||
|
||||
// LTEXT "Memory usage for Compressing:", IDT_COMPRESS_MEMORY, m, 140, xc, 8
|
||||
// COMBOBOX IDC_SETTINGS_MEM, m , 152, g1xs, yc - 152, MY_COMBO
|
||||
// LTEXT "/ RAM", IDT_SETTINGS_MEM_RAM, m + g1xs + m, 154, xc - g1xs - m, MY_TEXT_NOPREFIX
|
||||
END
|
||||
|
||||
@@ -9,3 +9,9 @@
|
||||
#define IDX_SETTINGS_SINGLE_CLICK 2506
|
||||
#define IDX_SETTINGS_ALTERNATIVE_SELECTION 2507
|
||||
#define IDX_SETTINGS_LARGE_PAGES 2508
|
||||
|
||||
|
||||
// #define IDT_SETTINGS_MEM 100
|
||||
// #define IDC_SETTINGS_MEM 101
|
||||
// #define IDT_SETTINGS_MEM_RAM 102
|
||||
// #define IDT_COMPRESS_MEMORY 4017
|
||||
|
||||
@@ -126,6 +126,18 @@ static void WriteFile(const FString &path, bool createAlways, const CFileDataInf
|
||||
}
|
||||
|
||||
|
||||
static UInt64 FILETIME_to_UInt64(const FILETIME &ft)
|
||||
{
|
||||
return ft.dwLowDateTime | ((UInt64)ft.dwHighDateTime << 32);
|
||||
}
|
||||
|
||||
static void UInt64_TO_FILETIME(UInt64 v, FILETIME &ft)
|
||||
{
|
||||
ft.dwLowDateTime = (DWORD)v;
|
||||
ft.dwHighDateTime = (DWORD)(v >> 32);
|
||||
}
|
||||
|
||||
|
||||
void CApp::VerCtrl(unsigned id)
|
||||
{
|
||||
const CPanel &panel = GetFocusedPanel();
|
||||
@@ -297,6 +309,55 @@ void CApp::VerCtrl(unsigned id)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const UInt64 timeStampOriginal = FILETIME_to_UInt64(fdi.Info.ftLastWriteTime);
|
||||
UInt64 timeStamp2 = 0;
|
||||
if (fdi2.IsOpen)
|
||||
timeStamp2 = FILETIME_to_UInt64(fdi2.Info.ftLastWriteTime);
|
||||
|
||||
if (timeStampOriginal > timeStamp2)
|
||||
{
|
||||
const UInt64 k_Ntfs_prec = 10000000;
|
||||
UInt64 timeStamp = timeStampOriginal;
|
||||
const UInt32 k_precs[] = { 60 * 60, 60, 2, 1 };
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(k_precs); i++)
|
||||
{
|
||||
timeStamp = timeStampOriginal;
|
||||
const UInt64 prec = k_Ntfs_prec * k_precs[i];
|
||||
// timeStamp += prec - 1; // for rounding up
|
||||
timeStamp /= prec;
|
||||
timeStamp *= prec;
|
||||
if (timeStamp > timeStamp2)
|
||||
break;
|
||||
}
|
||||
|
||||
if (timeStamp != timeStampOriginal
|
||||
&& timeStamp > timeStamp2)
|
||||
{
|
||||
FILETIME mTime;
|
||||
UInt64_TO_FILETIME(timeStamp, mTime);
|
||||
// NDir::SetFileAttrib(path, 0);
|
||||
{
|
||||
NIO::COutFile outFile;
|
||||
if (!outFile.Open(path, OPEN_EXISTING))
|
||||
{
|
||||
panel.MessageBox_LastError();
|
||||
return;
|
||||
// if (::GetLastError() != ERROR_SUCCESS)
|
||||
// throw "open error";
|
||||
}
|
||||
else
|
||||
{
|
||||
const UInt64 cTime = FILETIME_to_UInt64(fdi.Info.ftCreationTime);
|
||||
if (cTime > timeStamp)
|
||||
outFile.SetTime(&mTime, NULL, &mTime);
|
||||
else
|
||||
outFile.SetMTime(&mTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!SetFileAttrib(path, fdi.Info.dwFileAttributes | FILE_ATTRIBUTE_READONLY))
|
||||
{
|
||||
panel.MessageBox_LastError();
|
||||
|
||||
Reference in New Issue
Block a user