Update to 7-Zip Version 22.00

See: https://sourceforge.net/p/sevenzip/discussion/45797/thread/9c2d9061ce/
This commit is contained in:
Tino Reichardt
2022-08-07 09:59:33 +02:00
parent 6a4fe97fc3
commit 57558682a8
211 changed files with 15251 additions and 2482 deletions

View File

@@ -2,11 +2,19 @@
#include "StdAfx.h"
#if defined(_MSC_VER)
#include <winternl.h>
#else
// mingw
#include <ddk/winddk.h>
#endif
#include "../../../Common/ComTry.h"
#include "../../../Common/Defs.h"
#include "../../../Common/StringConvert.h"
#include "../../../Common/UTFConvert.h"
#include "../../../Windows/DLL.h"
#include "../../../Windows/FileDir.h"
#include "../../../Windows/FileIO.h"
#include "../../../Windows/FileName.h"
@@ -56,12 +64,15 @@ static const Byte kProps[] =
kpidMTime,
kpidCTime,
kpidATime,
#ifdef FS_SHOW_LINKS_INFO
kpidChangeTime,
#endif
kpidAttrib,
kpidPackSize,
#ifdef FS_SHOW_LINKS_INFO
#ifdef FS_SHOW_LINKS_INFO
kpidINode,
kpidLinks,
#endif
#endif
kpidComment,
kpidNumSubDirs,
kpidNumSubFiles,
@@ -199,19 +210,23 @@ HRESULT CFSFolder::LoadSubItems(int dirItem, const FString &relPrefix)
*/
}
#ifndef UNDER_CE
#ifndef UNDER_CE
fi.Reparse.Free();
fi.PackSize_Defined = false;
#ifdef FS_SHOW_LINKS_INFO
#ifdef FS_SHOW_LINKS_INFO
fi.FileInfo_Defined = false;
fi.FileInfo_WasRequested = false;
fi.FileIndex = 0;
fi.NumLinks = 0;
#endif
fi.ChangeTime_Defined = false;
fi.ChangeTime_WasRequested = false;
#endif
fi.PackSize = fi.Size;
#ifdef FS_SHOW_LINKS_INFO
if (fi.HasReparsePoint())
{
fi.FileInfo_WasRequested = true;
@@ -221,8 +236,9 @@ HRESULT CFSFolder::LoadSubItems(int dirItem, const FString &relPrefix)
fi.FileIndex = (((UInt64)info.nFileIndexHigh) << 32) + info.nFileIndexLow;
fi.FileInfo_Defined = true;
}
#endif
#endif
#endif // UNDER_CE
/* unsigned fileIndex = */ Files.Add(fi);
@@ -396,7 +412,9 @@ STDMETHODIMP_(UInt64) CFSFolder::GetItemSize(UInt32 index)
#endif
#ifdef FS_SHOW_LINKS_INFO
bool CFSFolder::ReadFileInfo(CDirItem &di)
{
di.FileInfo_WasRequested = true;
@@ -409,7 +427,71 @@ bool CFSFolder::ReadFileInfo(CDirItem &di)
di.FileInfo_Defined = true;
return true;
}
#endif
typedef struct
{
LARGE_INTEGER CreationTime;
LARGE_INTEGER LastAccessTime;
LARGE_INTEGER LastWriteTime;
LARGE_INTEGER ChangeTime;
ULONG FileAttributes;
UInt32 Reserved; // it's expected for alignment
}
MY__FILE_BASIC_INFORMATION;
typedef enum
{
MY__FileDirectoryInformation = 1,
MY__FileFullDirectoryInformation,
MY__FileBothDirectoryInformation,
MY__FileBasicInformation
}
MY__FILE_INFORMATION_CLASS;
typedef NTSTATUS (WINAPI * Func_NtQueryInformationFile)(
HANDLE handle, IO_STATUS_BLOCK *io,
void *ptr, LONG len, MY__FILE_INFORMATION_CLASS cls);
#define MY__STATUS_SUCCESS 0
static Func_NtQueryInformationFile f_NtQueryInformationFile;
static bool g_NtQueryInformationFile_WasRequested = false;
void CFSFolder::ReadChangeTime(CDirItem &di)
{
di.ChangeTime_WasRequested = true;
if (!g_NtQueryInformationFile_WasRequested)
{
g_NtQueryInformationFile_WasRequested = true;
f_NtQueryInformationFile = (Func_NtQueryInformationFile)
My_GetProcAddress(::GetModuleHandleW(L"ntdll.dll"),
"NtQueryInformationFile");
}
if (!f_NtQueryInformationFile)
return;
NIO::CInFile file;
if (!file.Open_for_ReadAttributes(_path + GetRelPath(di)))
return;
MY__FILE_BASIC_INFORMATION fbi;
IO_STATUS_BLOCK IoStatusBlock;
const NTSTATUS status = f_NtQueryInformationFile(file.GetHandle(), &IoStatusBlock,
&fbi, sizeof(fbi), MY__FileBasicInformation);
if (status != MY__STATUS_SUCCESS)
return;
if (IoStatusBlock.Information != sizeof(fbi))
return;
di.ChangeTime.dwLowDateTime = fbi.ChangeTime.u.LowPart;
di.ChangeTime.dwHighDateTime = fbi.ChangeTime.u.HighPart;
di.ChangeTime_Defined = true;
}
#endif // FS_SHOW_LINKS_INFO
STDMETHODIMP CFSFolder::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
{
@@ -492,7 +574,14 @@ STDMETHODIMP CFSFolder::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
prop = fi.FileIndex;
#endif
break;
case kpidChangeTime:
if (!fi.ChangeTime_WasRequested)
ReadChangeTime(fi);
if (fi.ChangeTime_Defined)
prop = fi.ChangeTime;
break;
#endif
case kpidAttrib: prop = (UInt32)fi.Attrib; break;

View File

@@ -18,6 +18,7 @@ namespace NFsFolder {
class CFSFolder;
#define FS_SHOW_LINKS_INFO
// #define FS_SHOW_CHANGE_TIME
struct CDirItem: public NWindows::NFile::NFind::CFileInfo
{
@@ -26,10 +27,13 @@ struct CDirItem: public NWindows::NFile::NFind::CFileInfo
#endif
#ifdef FS_SHOW_LINKS_INFO
FILETIME ChangeTime;
UInt64 FileIndex;
UInt32 NumLinks;
bool FileInfo_Defined;
bool FileInfo_WasRequested;
bool ChangeTime_Defined;
bool ChangeTime_WasRequested;
#endif
#ifndef UNDER_CE
@@ -158,6 +162,7 @@ private:
#ifdef FS_SHOW_LINKS_INFO
bool ReadFileInfo(CDirItem &di);
void ReadChangeTime(CDirItem &di);
#endif
public:

View File

@@ -12,7 +12,20 @@ void ShowHelpWindow(LPCSTR)
#else
// #define USE_EXTERNAL_HELP
#if defined(_MSC_VER)
#endif
#ifdef USE_EXTERNAL_HELP
#include "../../../Windows/ProcessUtils.h"
#include "../../../Windows/FileDir.h"
#include "../../../Windows/FileName.h"
#else
#include <HtmlHelp.h>
#endif
#include "../../../Common/StringConvert.h"
@@ -25,8 +38,37 @@ void ShowHelpWindow(LPCSTR topicFile)
FString path = NWindows::NDLL::GetModuleDirPrefix();
path += kHelpFileName;
path += topicFile;
#ifdef USE_EXTERNAL_HELP
FString prog;
#ifdef UNDER_CE
prog = "\\Windows\\";
#else
if (!NWindows::NFile::NDir::GetWindowsDir(prog))
return;
NWindows::NFile::NName::NormalizeDirPathPrefix(prog);
#endif
prog += "hh.exe";
UString params;
params += '"';
params += fs2us(path);
params += '"';
NWindows::CProcess process;
const WRes wres = process.Create(fs2us(prog), params, NULL); // curDir);
if (wres != 0)
{
/*
HRESULT hres = HRESULT_FROM_WIN32(wres);
ErrorMessageHRESULT(hres, imageName);
return hres;
*/
}
#else
// HWND hwnd = NULL;
HtmlHelp(NULL, GetSystemString(fs2us(path)), HH_DISPLAY_TOPIC, 0);
#endif
}
#endif

View File

@@ -32,6 +32,7 @@ static const UInt32 kLangIDs[] =
IDX_SYSTEM_CASCADED_MENU,
IDX_SYSTEM_ICON_IN_MENU,
IDX_EXTRACT_ELIM_DUP,
IDT_SYSTEM_ZONE,
IDT_SYSTEM_CONTEXT_MENU_ITEMS
};
@@ -80,6 +81,16 @@ extern bool g_Is_Wow64;
#define KEY_WOW64_32KEY (0x0200)
#endif
static void LoadLang_Spec(UString &s, UInt32 id, const char *eng)
{
LangString(id, s);
if (s.IsEmpty())
s = eng;
s.RemoveChar(L'&');
}
bool CMenuPage::OnInit()
{
_initMode = true;
@@ -176,6 +187,44 @@ bool CMenuPage::OnInit()
CheckButton(IDX_EXTRACT_ELIM_DUP, ci.ElimDup.Val);
_listView.Attach(GetItem(IDL_SYSTEM_OPTIONS));
_zoneCombo.Attach(GetItem(IDC_SYSTEM_ZONE));
{
unsigned wz = ci.WriteZone;
if (wz == (UInt32)(Int32)-1)
wz = 0;
for (unsigned i = 0; i <= 3; i++)
{
unsigned val = i;
UString s;
if (i == 3)
{
if (wz < 3)
break;
val = wz;
}
else
{
#define MY_IDYES 406
#define MY_IDNO 407
if (i == 0)
LoadLang_Spec(s, MY_IDNO, "No");
else if (i == 1)
LoadLang_Spec(s, MY_IDYES, "Yes");
else
LangString(IDT_ZONE_FOR_OFFICE, s);
}
if (s.IsEmpty())
s.Add_UInt32(val);
if (i == 0)
s.Insert(0, L"* ");
const int index = (int)_zoneCombo.AddString(s);
_zoneCombo.SetItemData(index, val);
if (val == wz)
_zoneCombo.SetCurSel(index);
}
}
const UInt32 newFlags = LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT;
_listView.SetExtendedListViewStyle(newFlags, newFlags);
@@ -266,7 +315,11 @@ LONG CMenuPage::OnApply()
#endif
if (_cascaded_Changed || _menuIcons_Changed || _elimDup_Changed || _flags_Changed)
if (_cascaded_Changed
|| _menuIcons_Changed
|| _elimDup_Changed
|| _writeZone_Changed
|| _flags_Changed)
{
CContextMenuInfo ci;
ci.Cascaded.Val = IsButtonCheckedBool(IDX_SYSTEM_CASCADED_MENU);
@@ -278,6 +331,13 @@ LONG CMenuPage::OnApply()
ci.ElimDup.Val = IsButtonCheckedBool(IDX_EXTRACT_ELIM_DUP);
ci.ElimDup.Def = _elimDup_Changed;
{
int zoneIndex = (int)_zoneCombo.GetItemData_of_CurSel();
if (zoneIndex <= 0)
zoneIndex = -1;
ci.WriteZone = (UInt32)(Int32)zoneIndex;
}
ci.Flags = 0;
for (unsigned i = 0; i < ARRAY_SIZE(kMenuItems); i++)
@@ -321,6 +381,7 @@ bool CMenuPage::OnButtonClicked(int buttonID, HWND buttonHWND)
case IDX_SYSTEM_CASCADED_MENU: _cascaded_Changed = true; break;
case IDX_SYSTEM_ICON_IN_MENU: _menuIcons_Changed = true; break;
case IDX_EXTRACT_ELIM_DUP: _elimDup_Changed = true; break;
// case IDX_EXTRACT_WRITE_ZONE: _writeZone_Changed = true; break;
default:
return CPropertyPage::OnButtonClicked(buttonID, buttonHWND);
@@ -330,6 +391,19 @@ bool CMenuPage::OnButtonClicked(int buttonID, HWND buttonHWND)
return true;
}
bool CMenuPage::OnCommand(int code, int itemID, LPARAM param)
{
if (code == CBN_SELCHANGE && itemID == IDC_SYSTEM_ZONE)
{
_writeZone_Changed = true;
Changed();
return true;
}
return CPropertyPage::OnCommand(code, itemID, param);
}
bool CMenuPage::OnNotify(UINT controlID, LPNMHDR lParam)
{
if (lParam->hwndFrom == HWND(_listView))

View File

@@ -4,6 +4,7 @@
#define __MENU_PAGE_H
#include "../../../Windows/Control/PropertyPage.h"
#include "../../../Windows/Control/ComboBox.h"
#include "../../../Windows/Control/ListView.h"
struct CShellDll
@@ -24,6 +25,7 @@ class CMenuPage: public NWindows::NControl::CPropertyPage
bool _cascaded_Changed;
bool _menuIcons_Changed;
bool _elimDup_Changed;
bool _writeZone_Changed;
bool _flags_Changed;
void Clear_MenuChanged()
@@ -31,6 +33,7 @@ class CMenuPage: public NWindows::NControl::CPropertyPage
_cascaded_Changed = false;
_menuIcons_Changed = false;
_elimDup_Changed = false;
_writeZone_Changed = false;
_flags_Changed = false;
}
@@ -39,6 +42,7 @@ class CMenuPage: public NWindows::NControl::CPropertyPage
#endif
NWindows::NControl::CListView _listView;
NWindows::NControl::CComboBox _zoneCombo;
virtual bool OnInit();
virtual void OnNotifyHelp();
@@ -46,6 +50,7 @@ class CMenuPage: public NWindows::NControl::CPropertyPage
virtual bool OnItemChanged(const NMLISTVIEW *info);
virtual LONG OnApply();
virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
virtual bool OnCommand(int code, int itemID, LPARAM param);
public:
};

View File

@@ -1,6 +1,8 @@
#include "../GUI/ExtractDialogRes.h"
#define y 82
#define y 96
#define zoneX 90
CAPTION "7-Zip ZS"
BEGIN
@@ -10,8 +12,17 @@ BEGIN
CONTROL "Icons in context menu", IDX_SYSTEM_ICON_IN_MENU, MY_CHECKBOX, m, m + 42, xc, 10
CONTROL "Eliminate duplication of root folder", IDX_EXTRACT_ELIM_DUP, MY_CHECKBOX, m, m + 56, xc, 10
LTEXT "Context menu items:", IDT_SYSTEM_CONTEXT_MENU_ITEMS, m, m + 70, xc, 8
LTEXT "Propagate Zone.Id stream:", IDT_SYSTEM_ZONE, m, m + 70, xc - zoneX, 8
COMBOBOX IDC_SYSTEM_ZONE, m + xc - zoneX, m + 70 - 2, zoneX, 50, MY_COMBO
LTEXT "Context menu items:", IDT_SYSTEM_CONTEXT_MENU_ITEMS, m, m + 84, xc, 8
CONTROL "List", IDL_SYSTEM_OPTIONS, "SysListView32",
LVS_REPORT | LVS_SINGLESEL | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,
m, m + y, xc, yc - y
END
STRINGTABLE
BEGIN
IDT_ZONE_FOR_OFFICE "For Office files"
END

View File

@@ -8,4 +8,8 @@
#define IDX_SYSTEM_INTEGRATE_TO_MENU_2 2310
#define IDT_SYSTEM_ZONE 3440
#define IDT_ZONE_FOR_OFFICE 3441
#define IDL_SYSTEM_OPTIONS 100
#define IDC_SYSTEM_ZONE 101

View File

@@ -380,7 +380,8 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position)
kTimestampPrintLevel_MIN,
kTimestampPrintLevel_SEC,
// 1,2,3,4,5,6,
kTimestampPrintLevel_NTFS
kTimestampPrintLevel_NTFS,
kTimestampPrintLevel_NS
};
unsigned last = kMenuID_Time;

View File

@@ -20,6 +20,7 @@
#include "../Common/ArchiveName.h"
#include "../Common/CompressCall.h"
#include "../Common/ZipRegistry.h"
#include "../Agent/IFolderArchive.h"
@@ -971,9 +972,13 @@ void CPanel::ExtractArchives()
outFolder += '*';
outFolder.Add_PathSepar();
CContextMenuInfo ci;
ci.Load();
::ExtractArchives(paths, outFolder
, true // showDialog
, false // elimDup
, ci.WriteZone
);
}

View File

@@ -244,6 +244,9 @@ struct CCopyToOptions
bool replaceAltStreamChars;
bool showErrorMessages;
bool NeedRegistryZone;
NExtract::NZoneIdMode::EEnum ZoneIdMode;
UString folder;
UStringVector hashMethods;
@@ -258,6 +261,8 @@ struct CCopyToOptions
includeAltStreams(true),
replaceAltStreamChars(false),
showErrorMessages(false),
NeedRegistryZone(true),
ZoneIdMode(NExtract::NZoneIdMode::kNone),
VirtFileSystemSpec(NULL),
VirtFileSystem(NULL)
{}

View File

@@ -4,6 +4,8 @@
#include "../../../Common/MyException.h"
#include "../Common/ZipRegistry.h"
#include "../GUI/HashGUI.h"
#include "ExtractCallback.h"
@@ -70,6 +72,15 @@ HRESULT CPanelCopyThread::ProcessVirt()
HRESULT result2;
{
CMyComPtr<IFolderSetZoneIdMode> setZoneMode;
FolderOperations.QueryInterface(IID_IFolderSetZoneIdMode, &setZoneMode);
if (setZoneMode)
{
RINOK(setZoneMode->SetZoneIdMode(options->ZoneIdMode));
}
}
if (options->testMode)
{
CMyComPtr<IArchiveFolder> archiveFolder;
@@ -126,6 +137,14 @@ HRESULT CPanel::CopyTo(CCopyToOptions &options, const CRecordVector<UInt32> &ind
UStringVector *messages,
bool &usePassword, UString &password)
{
if (options.NeedRegistryZone && !options.testMode)
{
CContextMenuInfo ci;
ci.Load();
if (ci.WriteZone != (UInt32)(Int32)-1)
options.ZoneIdMode = (NExtract::NZoneIdMode::EEnum)(int)(Int32)ci.WriteZone;
}
if (IsHashFolder())
{
if (!options.testMode)
@@ -221,7 +240,7 @@ HRESULT CPanel::CopyTo(CCopyToOptions &options, const CRecordVector<UInt32> &ind
title = LangString(titleID);
}
UString progressWindowTitle ("7-Zip"); // LangString(IDS_APP_TITLE);
const UString progressWindowTitle ("7-Zip"); // LangString(IDS_APP_TITLE);
extracter.MainWindow = GetParent();
extracter.MainTitle = progressWindowTitle;

View File

@@ -351,6 +351,7 @@ HRESULT CApp::CalculateCrc2(const UString &methodName)
options.streamMode = true;
options.showErrorMessages = true;
options.hashMethods.Add(methodName);
options.NeedRegistryZone = false;
UStringVector messages;
return srcPanel.CopyTo(options, indices, &messages);

View File

@@ -1403,7 +1403,7 @@ static THREAD_FUNC_DECL MyThreadFunction(void *param)
}
/*
#if defined(_WIN32) && !defined(UNDER_CE)
static const FChar * const k_ZoneId_StreamName = FTEXT(":Zone.Identifier");
#endif
@@ -1441,6 +1441,7 @@ static bool WriteZoneFile(CFSTR fileName, const CByteBuffer &buf)
}
#endif
*/
/*
class CBufSeqOutStream_WithFile:
@@ -1654,6 +1655,7 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
password = fl.Password;
}
/*
#if defined(_WIN32) && !defined(UNDER_CE)
CByteBuffer zoneBuf;
#ifndef _UNICODE
@@ -1666,16 +1668,25 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
ReadZoneFile(fl.FilePath + k_ZoneId_StreamName, zoneBuf);
}
#endif
*/
CVirtFileSystem *virtFileSystemSpec = NULL;
CMyComPtr<ISequentialOutStream> virtFileSystem;
bool isAltStream = IsItem_AltStream(index);
const bool isAltStream = IsItem_AltStream(index);
CCopyToOptions options;
options.includeAltStreams = true;
options.replaceAltStreamChars = isAltStream;
{
// CContextMenuInfo ci;
// ci.Load();
// if (ci.WriteZone != (UInt32)(Int32)-1)
// we use kAll when we unpack just one file.
options.ZoneIdMode = NExtract::NZoneIdMode::kAll;
options.NeedRegistryZone = false;
}
if (tryAsArchive)
{
@@ -1706,7 +1717,7 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
options.folder = fs2us(tempDirNorm);
options.showErrorMessages = true;
HRESULT result = CopyTo(options, indices, &messages, usePassword, password);
const HRESULT result = CopyTo(options, indices, &messages, usePassword, password);
if (_parentFolders.Size() > 0)
{
@@ -1759,6 +1770,7 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
}
/*
#if defined(_WIN32) && !defined(UNDER_CE)
if (zoneBuf.Size() != 0)
{
@@ -1768,6 +1780,7 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
}
}
#endif
*/
if (tryAsArchive)

View File

@@ -29,6 +29,7 @@ static bool GetColumnVisible(PROPID propID, bool isFsFolder)
switch (propID)
{
case kpidATime:
case kpidChangeTime:
case kpidAttrib:
case kpidPackSize:
case kpidINode:
@@ -56,6 +57,7 @@ static int GetColumnAlign(PROPID propID, VARTYPE varType)
case kpidCTime:
case kpidATime:
case kpidMTime:
case kpidChangeTime:
return LVCFMT_LEFT;
}
@@ -201,7 +203,7 @@ HRESULT CPanel::InitColumns()
for (i = 0; i < _listViewInfo.Columns.Size(); i++)
{
const CColumnInfo &columnInfo = _listViewInfo.Columns[i];
int index = _columns.FindItem_for_PropID(columnInfo.PropID);
const int index = _columns.FindItem_for_PropID(columnInfo.PropID);
if (index >= 0)
{
CPropColumn &item = _columns[index];
@@ -650,7 +652,7 @@ HRESULT CPanel::RefreshListCtrl(const CSelectedState &state)
relPath += name;
if (relPath == state.FocusedName)
cursorIndex = listViewItemCount;
if (state.SelectedNames.FindInSorted(relPath) >= 0)
if (state.SelectedNames.FindInSorted(relPath) != -1)
selected = true;
}

View File

@@ -111,7 +111,7 @@ static void AddPropertyString(PROPID propID, const wchar_t *nameBSTR,
val = ConvertSizeToString(v);
}
else
ConvertPropertyToString2(val, prop, propID);
ConvertPropertyToString2(val, prop, propID, 9); // we send 9 - is ns precision
}
if (!val.IsEmpty())

View File

@@ -97,4 +97,11 @@ BEGIN
IDS_PROP_READ_ONLY "Read-only"
IDS_PROP_OUT_NAME "Out Name"
IDS_PROP_COPY_LINK "Copy Link"
IDS_PROP_ARC_FILE_NAME "ArcFileName"
IDS_PROP_IS_HASH "IsHash"
IDS_PROP_CHANGE_TIME "Metadata Changed"
IDS_PROP_USER_ID "User ID"
IDS_PROP_GROUP_ID "Group ID"
IDS_PROP_DEVICE_MAJOR "Device Major"
IDS_PROP_DEVICE_MINOR "Device Minor"
END

View File

@@ -93,3 +93,10 @@
#define IDS_PROP_READ_ONLY 1093
#define IDS_PROP_OUT_NAME 1094
#define IDS_PROP_COPY_LINK 1095
#define IDS_PROP_ARC_FILE_NAME 1096
#define IDS_PROP_IS_HASH 1097
#define IDS_PROP_CHANGE_TIME 1098
#define IDS_PROP_USER_ID 1099
#define IDS_PROP_GROUP_ID 1100
#define IDS_PROP_DEVICE_MAJOR 1101
#define IDS_PROP_DEVICE_MINOR 1102