aboutsummaryrefslogtreecommitdiff
path: root/CPP/7zip/UI/FileManager
diff options
context:
space:
mode:
authorIgor Pavlov <87184205+ip7z@users.noreply.github.com>2023-06-21 00:00:00 +0000
committerIgor Pavlov <87184205+ip7z@users.noreply.github.com>2023-12-17 14:59:19 +0500
commit5b39dc76f1bc82f941d5c800ab9f34407a06b53a (patch)
treefe5e17420300b715021a76328444088d32047963 /CPP/7zip/UI/FileManager
parent93be7d4abfd4233228f58ee1fbbcd76d91be66a4 (diff)
download7zip-23.01.tar.gz
7zip-23.01.tar.bz2
7zip-23.01.zip
23.0123.01
Diffstat (limited to 'CPP/7zip/UI/FileManager')
-rw-r--r--CPP/7zip/UI/FileManager/7zFM.exe.manifest3
-rw-r--r--CPP/7zip/UI/FileManager/AboutDialog.cpp12
-rw-r--r--CPP/7zip/UI/FileManager/AboutDialog.h12
-rw-r--r--CPP/7zip/UI/FileManager/AltStreamsFolder.cpp301
-rw-r--r--CPP/7zip/UI/FileManager/AltStreamsFolder.h58
-rw-r--r--CPP/7zip/UI/FileManager/App.cpp66
-rw-r--r--CPP/7zip/UI/FileManager/App.h134
-rw-r--r--CPP/7zip/UI/FileManager/AppState.h4
-rw-r--r--CPP/7zip/UI/FileManager/BrowseDialog.cpp419
-rw-r--r--CPP/7zip/UI/FileManager/BrowseDialog.h19
-rw-r--r--CPP/7zip/UI/FileManager/ComboDialog.cpp4
-rw-r--r--CPP/7zip/UI/FileManager/ComboDialog.h12
-rw-r--r--CPP/7zip/UI/FileManager/CopyDialog.cpp15
-rw-r--r--CPP/7zip/UI/FileManager/CopyDialog.h14
-rw-r--r--CPP/7zip/UI/FileManager/DialogSize.h4
-rw-r--r--CPP/7zip/UI/FileManager/EditDialog.cpp16
-rw-r--r--CPP/7zip/UI/FileManager/EditDialog.h10
-rw-r--r--CPP/7zip/UI/FileManager/EditPage.cpp30
-rw-r--r--CPP/7zip/UI/FileManager/EditPage.h18
-rw-r--r--CPP/7zip/UI/FileManager/EnumFormatEtc.cpp41
-rw-r--r--CPP/7zip/UI/FileManager/EnumFormatEtc.h4
-rw-r--r--CPP/7zip/UI/FileManager/ExtractCallback.cpp161
-rw-r--r--CPP/7zip/UI/FileManager/ExtractCallback.h159
-rw-r--r--CPP/7zip/UI/FileManager/FM.cpp117
-rw-r--r--CPP/7zip/UI/FileManager/FM.dsp32
-rw-r--r--CPP/7zip/UI/FileManager/FM.mak8
-rw-r--r--CPP/7zip/UI/FileManager/FSDrives.cpp134
-rw-r--r--CPP/7zip/UI/FileManager/FSDrives.h23
-rw-r--r--CPP/7zip/UI/FileManager/FSFolder.cpp241
-rw-r--r--CPP/7zip/UI/FileManager/FSFolder.h77
-rw-r--r--CPP/7zip/UI/FileManager/FSFolderCopy.cpp266
-rw-r--r--CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp69
-rw-r--r--CPP/7zip/UI/FileManager/FileFolderPluginOpen.h6
-rw-r--r--CPP/7zip/UI/FileManager/FilePlugins.cpp27
-rw-r--r--CPP/7zip/UI/FileManager/FilePlugins.h12
-rw-r--r--CPP/7zip/UI/FileManager/FoldersPage.cpp20
-rw-r--r--CPP/7zip/UI/FileManager/FoldersPage.h14
-rw-r--r--CPP/7zip/UI/FileManager/FormatUtils.h4
-rw-r--r--CPP/7zip/UI/FileManager/HelpUtils.cpp10
-rw-r--r--CPP/7zip/UI/FileManager/HelpUtils.h4
-rw-r--r--CPP/7zip/UI/FileManager/IFolder.h277
-rw-r--r--CPP/7zip/UI/FileManager/LangPage.cpp271
-rw-r--r--CPP/7zip/UI/FileManager/LangPage.h27
-rw-r--r--CPP/7zip/UI/FileManager/LangPage.rc11
-rw-r--r--CPP/7zip/UI/FileManager/LangPageRes.h1
-rw-r--r--CPP/7zip/UI/FileManager/LangUtils.cpp71
-rw-r--r--CPP/7zip/UI/FileManager/LangUtils.h18
-rw-r--r--CPP/7zip/UI/FileManager/LinkDialog.cpp39
-rw-r--r--CPP/7zip/UI/FileManager/LinkDialog.h14
-rw-r--r--CPP/7zip/UI/FileManager/ListViewDialog.cpp16
-rw-r--r--CPP/7zip/UI/FileManager/ListViewDialog.h14
-rw-r--r--CPP/7zip/UI/FileManager/MenuPage.cpp26
-rw-r--r--CPP/7zip/UI/FileManager/MenuPage.h22
-rw-r--r--CPP/7zip/UI/FileManager/MessagesDialog.cpp10
-rw-r--r--CPP/7zip/UI/FileManager/MessagesDialog.h10
-rw-r--r--CPP/7zip/UI/FileManager/MyCom2.h61
-rw-r--r--CPP/7zip/UI/FileManager/MyLoadMenu.cpp358
-rw-r--r--CPP/7zip/UI/FileManager/MyLoadMenu.h8
-rw-r--r--CPP/7zip/UI/FileManager/MyWindowsNew.h53
-rw-r--r--CPP/7zip/UI/FileManager/NetFolder.cpp56
-rw-r--r--CPP/7zip/UI/FileManager/NetFolder.h20
-rw-r--r--CPP/7zip/UI/FileManager/OpenCallback.cpp81
-rw-r--r--CPP/7zip/UI/FileManager/OpenCallback.h69
-rw-r--r--CPP/7zip/UI/FileManager/OptionsDialog.cpp10
-rw-r--r--CPP/7zip/UI/FileManager/OverwriteDialog.cpp12
-rw-r--r--CPP/7zip/UI/FileManager/OverwriteDialog.h12
-rw-r--r--CPP/7zip/UI/FileManager/Panel.cpp198
-rw-r--r--CPP/7zip/UI/FileManager/Panel.h223
-rw-r--r--CPP/7zip/UI/FileManager/PanelCopy.cpp84
-rw-r--r--CPP/7zip/UI/FileManager/PanelCrc.cpp46
-rw-r--r--CPP/7zip/UI/FileManager/PanelDrag.cpp2822
-rw-r--r--CPP/7zip/UI/FileManager/PanelFolderChange.cpp88
-rw-r--r--CPP/7zip/UI/FileManager/PanelItemOpen.cpp144
-rw-r--r--CPP/7zip/UI/FileManager/PanelItems.cpp221
-rw-r--r--CPP/7zip/UI/FileManager/PanelKey.cpp34
-rw-r--r--CPP/7zip/UI/FileManager/PanelListNotify.cpp86
-rw-r--r--CPP/7zip/UI/FileManager/PanelMenu.cpp263
-rw-r--r--CPP/7zip/UI/FileManager/PanelOperations.cpp52
-rw-r--r--CPP/7zip/UI/FileManager/PanelSelect.cpp46
-rw-r--r--CPP/7zip/UI/FileManager/PanelSort.cpp28
-rw-r--r--CPP/7zip/UI/FileManager/PanelSplitFile.cpp64
-rw-r--r--CPP/7zip/UI/FileManager/PasswordDialog.cpp10
-rw-r--r--CPP/7zip/UI/FileManager/PasswordDialog.h12
-rw-r--r--CPP/7zip/UI/FileManager/PluginInterface.h47
-rw-r--r--CPP/7zip/UI/FileManager/PluginLoader.h13
-rw-r--r--CPP/7zip/UI/FileManager/ProgramLocation.h4
-rw-r--r--CPP/7zip/UI/FileManager/ProgressDialog.cpp18
-rw-r--r--CPP/7zip/UI/FileManager/ProgressDialog.h33
-rw-r--r--CPP/7zip/UI/FileManager/ProgressDialog2.cpp127
-rw-r--r--CPP/7zip/UI/FileManager/ProgressDialog2.h47
-rw-r--r--CPP/7zip/UI/FileManager/PropertyName.h4
-rw-r--r--CPP/7zip/UI/FileManager/PropertyName.rc2
-rw-r--r--CPP/7zip/UI/FileManager/PropertyNameRes.h2
-rw-r--r--CPP/7zip/UI/FileManager/RegistryAssociations.cpp6
-rw-r--r--CPP/7zip/UI/FileManager/RegistryAssociations.h4
-rw-r--r--CPP/7zip/UI/FileManager/RegistryPlugins.cpp168
-rw-r--r--CPP/7zip/UI/FileManager/RegistryPlugins.h27
-rw-r--r--CPP/7zip/UI/FileManager/RegistryUtils.cpp5
-rw-r--r--CPP/7zip/UI/FileManager/RegistryUtils.h4
-rw-r--r--CPP/7zip/UI/FileManager/RootFolder.cpp58
-rw-r--r--CPP/7zip/UI/FileManager/RootFolder.h19
-rw-r--r--CPP/7zip/UI/FileManager/SettingsPage.cpp12
-rw-r--r--CPP/7zip/UI/FileManager/SettingsPage.h14
-rw-r--r--CPP/7zip/UI/FileManager/SplitDialog.cpp12
-rw-r--r--CPP/7zip/UI/FileManager/SplitDialog.h14
-rw-r--r--CPP/7zip/UI/FileManager/SplitUtils.cpp2
-rw-r--r--CPP/7zip/UI/FileManager/SplitUtils.h4
-rw-r--r--CPP/7zip/UI/FileManager/StdAfx.h80
-rw-r--r--CPP/7zip/UI/FileManager/StringUtils.cpp26
-rw-r--r--CPP/7zip/UI/FileManager/StringUtils.h8
-rw-r--r--CPP/7zip/UI/FileManager/SysIconUtils.cpp97
-rw-r--r--CPP/7zip/UI/FileManager/SysIconUtils.h13
-rw-r--r--CPP/7zip/UI/FileManager/SystemPage.cpp36
-rw-r--r--CPP/7zip/UI/FileManager/SystemPage.h16
-rw-r--r--CPP/7zip/UI/FileManager/TextPairs.cpp14
-rw-r--r--CPP/7zip/UI/FileManager/TextPairs.h6
-rw-r--r--CPP/7zip/UI/FileManager/UpdateCallback100.cpp36
-rw-r--r--CPP/7zip/UI/FileManager/UpdateCallback100.h30
-rw-r--r--CPP/7zip/UI/FileManager/VerCtrl.cpp6
-rw-r--r--CPP/7zip/UI/FileManager/ViewSettings.cpp59
-rw-r--r--CPP/7zip/UI/FileManager/ViewSettings.h4
-rw-r--r--CPP/7zip/UI/FileManager/makefile3
-rw-r--r--CPP/7zip/UI/FileManager/resource.h10
-rw-r--r--CPP/7zip/UI/FileManager/resource.rc72
124 files changed, 6443 insertions, 3287 deletions
diff --git a/CPP/7zip/UI/FileManager/7zFM.exe.manifest b/CPP/7zip/UI/FileManager/7zFM.exe.manifest
index 6a13c92..69c7f0b 100644
--- a/CPP/7zip/UI/FileManager/7zFM.exe.manifest
+++ b/CPP/7zip/UI/FileManager/7zFM.exe.manifest
@@ -17,4 +17,7 @@
17 <dpiAware>true</dpiAware> 17 <dpiAware>true</dpiAware>
18 </asmv3:windowsSettings> 18 </asmv3:windowsSettings>
19 </asmv3:application> 19 </asmv3:application>
20<application xmlns="urn:schemas-microsoft-com:asm.v3">
21<windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
22<ws2:longPathAware>true</ws2:longPathAware></windowsSettings></application>
20</assembly> 23</assembly>
diff --git a/CPP/7zip/UI/FileManager/AboutDialog.cpp b/CPP/7zip/UI/FileManager/AboutDialog.cpp
index 082902e..efc74cc 100644
--- a/CPP/7zip/UI/FileManager/AboutDialog.cpp
+++ b/CPP/7zip/UI/FileManager/AboutDialog.cpp
@@ -14,10 +14,12 @@
14#include "HelpUtils.h" 14#include "HelpUtils.h"
15#include "LangUtils.h" 15#include "LangUtils.h"
16 16
17#ifdef Z7_LANG
17static const UInt32 kLangIDs[] = 18static const UInt32 kLangIDs[] =
18{ 19{
19 IDT_ABOUT_INFO 20 IDT_ABOUT_INFO
20}; 21};
22#endif
21 23
22#define kHomePageURL TEXT("https://www.7-zip.org/") 24#define kHomePageURL TEXT("https://www.7-zip.org/")
23#define kHelpTopic "start.htm" 25#define kHelpTopic "start.htm"
@@ -29,7 +31,7 @@ extern CCodecs *g_CodecsObj;
29 31
30bool CAboutDialog::OnInit() 32bool CAboutDialog::OnInit()
31{ 33{
32 #ifdef EXTERNAL_CODECS 34 #ifdef Z7_EXTERNAL_CODECS
33 if (g_CodecsObj) 35 if (g_CodecsObj)
34 { 36 {
35 UString s; 37 UString s;
@@ -39,11 +41,13 @@ bool CAboutDialog::OnInit()
39 } 41 }
40 #endif 42 #endif
41 43
42 LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); 44 #ifdef Z7_LANG
45 LangSetWindowText(*this, IDD_ABOUT);
46 LangSetDlgItems(*this, kLangIDs, Z7_ARRAY_SIZE(kLangIDs));
47 #endif
43 SetItemText(IDT_ABOUT_VERSION, UString("7-Zip " MY_VERSION_CPU)); 48 SetItemText(IDT_ABOUT_VERSION, UString("7-Zip " MY_VERSION_CPU));
44 SetItemText(IDT_ABOUT_DATE, LLL(MY_DATE)); 49 SetItemText(IDT_ABOUT_DATE, LLL(MY_DATE));
45 50
46 LangSetWindowText(*this, IDD_ABOUT);
47 NormalizePosition(); 51 NormalizePosition();
48 return CModalDialog::OnInit(); 52 return CModalDialog::OnInit();
49} 53}
@@ -53,7 +57,7 @@ void CAboutDialog::OnHelp()
53 ShowHelpWindow(kHelpTopic); 57 ShowHelpWindow(kHelpTopic);
54} 58}
55 59
56bool CAboutDialog::OnButtonClicked(int buttonID, HWND buttonHWND) 60bool CAboutDialog::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
57{ 61{
58 LPCTSTR url; 62 LPCTSTR url;
59 switch (buttonID) 63 switch (buttonID)
diff --git a/CPP/7zip/UI/FileManager/AboutDialog.h b/CPP/7zip/UI/FileManager/AboutDialog.h
index 39fd3ba..1d11d74 100644
--- a/CPP/7zip/UI/FileManager/AboutDialog.h
+++ b/CPP/7zip/UI/FileManager/AboutDialog.h
@@ -1,7 +1,7 @@
1// AboutDialog.h 1// AboutDialog.h
2 2
3#ifndef __ABOUT_DIALOG_H 3#ifndef ZIP7_INC_ABOUT_DIALOG_H
4#define __ABOUT_DIALOG_H 4#define ZIP7_INC_ABOUT_DIALOG_H
5 5
6#include "../../../Windows/Control/Dialog.h" 6#include "../../../Windows/Control/Dialog.h"
7 7
@@ -10,10 +10,10 @@
10class CAboutDialog: public NWindows::NControl::CModalDialog 10class CAboutDialog: public NWindows::NControl::CModalDialog
11{ 11{
12public: 12public:
13 virtual bool OnInit(); 13 virtual bool OnInit() Z7_override;
14 virtual void OnHelp(); 14 virtual void OnHelp() Z7_override;
15 virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); 15 virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
16 INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_ABOUT, wndParent); } 16 INT_PTR Create(HWND wndParent = NULL) { return CModalDialog::Create(IDD_ABOUT, wndParent); }
17}; 17};
18 18
19#endif 19#endif
diff --git a/CPP/7zip/UI/FileManager/AltStreamsFolder.cpp b/CPP/7zip/UI/FileManager/AltStreamsFolder.cpp
index e1c99d3..b3d354d 100644
--- a/CPP/7zip/UI/FileManager/AltStreamsFolder.cpp
+++ b/CPP/7zip/UI/FileManager/AltStreamsFolder.cpp
@@ -2,10 +2,32 @@
2 2
3#include "StdAfx.h" 3#include "StdAfx.h"
4 4
5#ifdef __MINGW32_VERSION
6// #if !defined(_MSC_VER) && (__GNUC__) && (__GNUC__ < 10)
7// for old mingw
8#include <ddk/ntddk.h>
9#else
10#ifndef Z7_OLD_WIN_SDK
11 #if !defined(_M_IA64)
12 #include <winternl.h>
13 #endif
14#else
15typedef LONG NTSTATUS;
16typedef struct _IO_STATUS_BLOCK {
17 union {
18 NTSTATUS Status;
19 PVOID Pointer;
20 };
21 ULONG_PTR Information;
22} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
23#endif
24#endif
25
5#include "../../../Common/ComTry.h" 26#include "../../../Common/ComTry.h"
6#include "../../../Common/StringConvert.h" 27#include "../../../Common/StringConvert.h"
7#include "../../../Common/Wildcard.h" 28#include "../../../Common/Wildcard.h"
8 29
30#include "../../../Windows/DLL.h"
9#include "../../../Windows/ErrorMsg.h" 31#include "../../../Windows/ErrorMsg.h"
10#include "../../../Windows/FileDir.h" 32#include "../../../Windows/FileDir.h"
11#include "../../../Windows/FileIO.h" 33#include "../../../Windows/FileIO.h"
@@ -54,7 +76,7 @@ static unsigned GetFsParentPrefixSize(const FString &path)
54{ 76{
55 if (IsNetworkShareRootPath(path)) 77 if (IsNetworkShareRootPath(path))
56 return 0; 78 return 0;
57 unsigned prefixSize = GetRootPrefixSize(path); 79 const unsigned prefixSize = GetRootPrefixSize(path);
58 if (prefixSize == 0 || prefixSize >= path.Len()) 80 if (prefixSize == 0 || prefixSize >= path.Len())
59 return 0; 81 return 0;
60 FString parentPath = path; 82 FString parentPath = path;
@@ -70,7 +92,7 @@ static unsigned GetFsParentPrefixSize(const FString &path)
70 } 92 }
71 if ((unsigned)pos + 1 < prefixSize) 93 if ((unsigned)pos + 1 < prefixSize)
72 return 0; 94 return 0;
73 return pos + 1; 95 return (unsigned)pos + 1;
74} 96}
75 97
76HRESULT CAltStreamsFolder::Init(const FString &path /* , IFolderFolder *parentFolder */) 98HRESULT CAltStreamsFolder::Init(const FString &path /* , IFolderFolder *parentFolder */)
@@ -115,7 +137,7 @@ HRESULT CAltStreamsFolder::Init(const FString &path /* , IFolderFolder *parentFo
115 return S_OK; 137 return S_OK;
116} 138}
117 139
118STDMETHODIMP CAltStreamsFolder::LoadItems() 140Z7_COM7F_IMF(CAltStreamsFolder::LoadItems())
119{ 141{
120 Int32 dummy; 142 Int32 dummy;
121 WasChanged(&dummy); 143 WasChanged(&dummy);
@@ -152,7 +174,7 @@ STDMETHODIMP CAltStreamsFolder::LoadItems()
152 return S_OK; 174 return S_OK;
153} 175}
154 176
155STDMETHODIMP CAltStreamsFolder::GetNumberOfItems(UInt32 *numItems) 177Z7_COM7F_IMF(CAltStreamsFolder::GetNumberOfItems(UInt32 *numItems))
156{ 178{
157 *numItems = Streams.Size(); 179 *numItems = Streams.Size();
158 return S_OK; 180 return S_OK;
@@ -160,16 +182,16 @@ STDMETHODIMP CAltStreamsFolder::GetNumberOfItems(UInt32 *numItems)
160 182
161#ifdef USE_UNICODE_FSTRING 183#ifdef USE_UNICODE_FSTRING
162 184
163STDMETHODIMP CAltStreamsFolder::GetItemPrefix(UInt32 /* index */, const wchar_t **name, unsigned *len) 185Z7_COM7F_IMF(CAltStreamsFolder::GetItemPrefix(UInt32 /* index */, const wchar_t **name, unsigned *len))
164{ 186{
165 *name = 0; 187 *name = NULL;
166 *len = 0; 188 *len = 0;
167 return S_OK; 189 return S_OK;
168} 190}
169 191
170STDMETHODIMP CAltStreamsFolder::GetItemName(UInt32 index, const wchar_t **name, unsigned *len) 192Z7_COM7F_IMF(CAltStreamsFolder::GetItemName(UInt32 index, const wchar_t **name, unsigned *len))
171{ 193{
172 *name = 0; 194 *name = NULL;
173 *len = 0; 195 *len = 0;
174 { 196 {
175 const CAltStream &ss = Streams[index]; 197 const CAltStream &ss = Streams[index];
@@ -179,7 +201,7 @@ STDMETHODIMP CAltStreamsFolder::GetItemName(UInt32 index, const wchar_t **name,
179 return S_OK; 201 return S_OK;
180} 202}
181 203
182STDMETHODIMP_(UInt64) CAltStreamsFolder::GetItemSize(UInt32 index) 204Z7_COM7F_IMF2(UInt64, CAltStreamsFolder::GetItemSize(UInt32 index))
183{ 205{
184 return Streams[index].Size; 206 return Streams[index].Size;
185} 207}
@@ -187,7 +209,7 @@ STDMETHODIMP_(UInt64) CAltStreamsFolder::GetItemSize(UInt32 index)
187#endif 209#endif
188 210
189 211
190STDMETHODIMP CAltStreamsFolder::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value) 212Z7_COM7F_IMF(CAltStreamsFolder::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value))
191{ 213{
192 NCOM::CPropVariant prop; 214 NCOM::CPropVariant prop;
193 { 215 {
@@ -223,11 +245,11 @@ STDMETHODIMP CAltStreamsFolder::GetProperty(UInt32 index, PROPID propID, PROPVAR
223 245
224static inline const wchar_t *GetExtensionPtr(const UString &name) 246static inline const wchar_t *GetExtensionPtr(const UString &name)
225{ 247{
226 int dotPos = name.ReverseFind_Dot(); 248 const int dotPos = name.ReverseFind_Dot();
227 return name.Ptr((dotPos < 0) ? name.Len() : dotPos); 249 return name.Ptr(dotPos < 0 ? name.Len() : (unsigned)dotPos);
228} 250}
229 251
230STDMETHODIMP_(Int32) CAltStreamsFolder::CompareItems(UInt32 index1, UInt32 index2, PROPID propID, Int32 /* propIsRaw */) 252Z7_COM7F_IMF2(Int32, CAltStreamsFolder::CompareItems(UInt32 index1, UInt32 index2, PROPID propID, Int32 /* propIsRaw */))
231{ 253{
232 const CAltStream &ss1 = Streams[index1]; 254 const CAltStream &ss1 = Streams[index1];
233 const CAltStream &ss2 = Streams[index2]; 255 const CAltStream &ss2 = Streams[index2];
@@ -262,23 +284,23 @@ STDMETHODIMP_(Int32) CAltStreamsFolder::CompareItems(UInt32 index1, UInt32 index
262 return 0; 284 return 0;
263} 285}
264 286
265STDMETHODIMP CAltStreamsFolder::BindToFolder(UInt32 /* index */, IFolderFolder **resultFolder) 287Z7_COM7F_IMF(CAltStreamsFolder::BindToFolder(UInt32 /* index */, IFolderFolder **resultFolder))
266{ 288{
267 *resultFolder = 0; 289 *resultFolder = NULL;
268 return E_INVALIDARG; 290 return E_INVALIDARG;
269} 291}
270 292
271STDMETHODIMP CAltStreamsFolder::BindToFolder(const wchar_t * /* name */, IFolderFolder **resultFolder) 293Z7_COM7F_IMF(CAltStreamsFolder::BindToFolder(const wchar_t * /* name */, IFolderFolder **resultFolder))
272{ 294{
273 *resultFolder = 0; 295 *resultFolder = NULL;
274 return E_INVALIDARG; 296 return E_INVALIDARG;
275} 297}
276 298
277// static CFSTR const kSuperPrefix = FTEXT("\\\\?\\"); 299// static CFSTR const kSuperPrefix = FTEXT("\\\\?\\");
278 300
279STDMETHODIMP CAltStreamsFolder::BindToParentFolder(IFolderFolder **resultFolder) 301Z7_COM7F_IMF(CAltStreamsFolder::BindToParentFolder(IFolderFolder **resultFolder))
280{ 302{
281 *resultFolder = 0; 303 *resultFolder = NULL;
282 /* 304 /*
283 if (_parentFolder) 305 if (_parentFolder)
284 { 306 {
@@ -338,15 +360,9 @@ STDMETHODIMP CAltStreamsFolder::BindToParentFolder(IFolderFolder **resultFolder)
338 return S_OK; 360 return S_OK;
339} 361}
340 362
341STDMETHODIMP CAltStreamsFolder::GetNumberOfProperties(UInt32 *numProperties) 363IMP_IFolderFolder_Props(CAltStreamsFolder)
342{
343 *numProperties = ARRAY_SIZE(kProps);
344 return S_OK;
345}
346
347STDMETHODIMP CAltStreamsFolder::GetPropertyInfo IMP_IFolderFolder_GetProp(kProps)
348 364
349STDMETHODIMP CAltStreamsFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value) 365Z7_COM7F_IMF(CAltStreamsFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value))
350{ 366{
351 COM_TRY_BEGIN 367 COM_TRY_BEGIN
352 NWindows::NCOM::CPropVariant prop; 368 NWindows::NCOM::CPropVariant prop;
@@ -360,7 +376,7 @@ STDMETHODIMP CAltStreamsFolder::GetFolderProperty(PROPID propID, PROPVARIANT *va
360 COM_TRY_END 376 COM_TRY_END
361} 377}
362 378
363STDMETHODIMP CAltStreamsFolder::WasChanged(Int32 *wasChanged) 379Z7_COM7F_IMF(CAltStreamsFolder::WasChanged(Int32 *wasChanged))
364{ 380{
365 bool wasChangedMain = false; 381 bool wasChangedMain = false;
366 for (;;) 382 for (;;)
@@ -385,7 +401,7 @@ STDMETHODIMP CAltStreamsFolder::WasChanged(Int32 *wasChanged)
385 return S_OK; 401 return S_OK;
386} 402}
387 403
388STDMETHODIMP CAltStreamsFolder::Clone(IFolderFolder **resultFolder) 404Z7_COM7F_IMF(CAltStreamsFolder::Clone(IFolderFolder **resultFolder))
389{ 405{
390 CAltStreamsFolder *folderSpec = new CAltStreamsFolder; 406 CAltStreamsFolder *folderSpec = new CAltStreamsFolder;
391 CMyComPtr<IFolderFolder> folderNew = folderSpec; 407 CMyComPtr<IFolderFolder> folderNew = folderSpec;
@@ -436,39 +452,31 @@ static HRESULT SendMessageError(IFolderArchiveUpdateCallback *callback,
436} 452}
437*/ 453*/
438 454
439STDMETHODIMP CAltStreamsFolder::CreateFolder(const wchar_t * /* name */, IProgress * /* progress */) 455Z7_COM7F_IMF(CAltStreamsFolder::CreateFolder(const wchar_t * /* name */, IProgress * /* progress */))
440{ 456{
441 return E_NOTIMPL; 457 return E_NOTIMPL;
442} 458}
443 459
444STDMETHODIMP CAltStreamsFolder::CreateFile(const wchar_t *name, IProgress * /* progress */) 460Z7_COM7F_IMF(CAltStreamsFolder::CreateFile(const wchar_t *name, IProgress * /* progress */))
445{ 461{
446 FString absPath; 462 FString absPath;
447 GetAbsPath(name, absPath); 463 GetAbsPath(name, absPath);
448 NIO::COutFile outFile; 464 NIO::COutFile outFile;
449 if (!outFile.Create(absPath, false)) 465 if (!outFile.Create(absPath, false))
450 return ::GetLastError(); 466 return GetLastError_noZero_HRESULT();
451 return S_OK; 467 return S_OK;
452} 468}
453 469
454static DWORD Return_LastError_or_FAIL()
455{
456 DWORD errorCode = GetLastError();
457 if (errorCode == 0)
458 errorCode = (DWORD)E_FAIL;
459 return errorCode;
460}
461
462static UString GetLastErrorMessage() 470static UString GetLastErrorMessage()
463{ 471{
464 return NError::MyFormatMessage(Return_LastError_or_FAIL()); 472 return NError::MyFormatMessage(GetLastError_noZero_HRESULT());
465} 473}
466 474
467static HRESULT UpdateFile(NFsFolder::CCopyStateIO &state, CFSTR inPath, CFSTR outPath, IFolderArchiveUpdateCallback *callback) 475static HRESULT UpdateFile(NFsFolder::CCopyStateIO &state, CFSTR inPath, CFSTR outPath, IFolderArchiveUpdateCallback *callback)
468{ 476{
469 if (NFind::DoesFileOrDirExist(outPath)) 477 if (NFind::DoesFileOrDirExist(outPath))
470 { 478 {
471 RINOK(SendMessageError(callback, NError::MyFormatMessage(ERROR_ALREADY_EXISTS), FString(outPath))); 479 RINOK(SendMessageError(callback, NError::MyFormatMessage(ERROR_ALREADY_EXISTS), FString(outPath)))
472 CFileInfo fi; 480 CFileInfo fi;
473 if (fi.Find(inPath)) 481 if (fi.Find(inPath))
474 { 482 {
@@ -480,8 +488,8 @@ static HRESULT UpdateFile(NFsFolder::CCopyStateIO &state, CFSTR inPath, CFSTR ou
480 488
481 { 489 {
482 if (callback) 490 if (callback)
483 RINOK(callback->CompressOperation(fs2us(inPath))); 491 RINOK(callback->CompressOperation(fs2us(inPath)))
484 RINOK(state.MyCopyFile(inPath, outPath)); 492 RINOK(state.MyCopyFile(inPath, outPath))
485 if (state.ErrorFileIndex >= 0) 493 if (state.ErrorFileIndex >= 0)
486 { 494 {
487 if (state.ErrorMessage.IsEmpty()) 495 if (state.ErrorMessage.IsEmpty())
@@ -492,31 +500,136 @@ static HRESULT UpdateFile(NFsFolder::CCopyStateIO &state, CFSTR inPath, CFSTR ou
492 else 500 else
493 errorName = outPath; 501 errorName = outPath;
494 if (callback) 502 if (callback)
495 RINOK(SendMessageError(callback, state.ErrorMessage, errorName)); 503 RINOK(SendMessageError(callback, state.ErrorMessage, errorName))
496 } 504 }
497 if (callback) 505 if (callback)
498 RINOK(callback->OperationResult(0)); 506 RINOK(callback->OperationResult(0))
499 } 507 }
500 508
501 return S_OK; 509 return S_OK;
502} 510}
503 511
504STDMETHODIMP CAltStreamsFolder::Rename(UInt32 index, const wchar_t *newName, IProgress *progress) 512EXTERN_C_BEGIN
513
514typedef enum
505{ 515{
506 CMyComPtr<IFolderArchiveUpdateCallback> callback; 516 Z7_WIN_FileRenameInformation = 10
507 if (progress) 517}
518Z7_WIN_FILE_INFORMATION_CLASS;
519
520
521typedef struct
522{
523 // #if (_WIN32_WINNT >= _WIN32_WINNT_WIN10_RS1)
524 union
508 { 525 {
509 RINOK(progress->QueryInterface(IID_IFolderArchiveUpdateCallback, (void **)&callback)); 526 BOOLEAN ReplaceIfExists; // FileRenameInformation
510 } 527 ULONG Flags; // FileRenameInformationEx
528 } DUMMYUNIONNAME;
529 // #else
530 // BOOLEAN ReplaceIfExists;
531 // #endif
532 HANDLE RootDirectory;
533 ULONG FileNameLength;
534 WCHAR FileName[1];
535} Z7_WIN_FILE_RENAME_INFORMATION;
536
537#if (_WIN32_WINNT >= 0x0500) && !defined(_M_IA64)
538#define Z7_WIN_NTSTATUS NTSTATUS
539#define Z7_WIN_IO_STATUS_BLOCK IO_STATUS_BLOCK
540#else
541typedef LONG Z7_WIN_NTSTATUS;
542typedef struct
543{
544 union
545 {
546 Z7_WIN_NTSTATUS Status;
547 PVOID Pointer;
548 } DUMMYUNIONNAME;
549 ULONG_PTR Information;
550} Z7_WIN_IO_STATUS_BLOCK;
551#endif
552
553typedef Z7_WIN_NTSTATUS (WINAPI *Func_NtSetInformationFile)(
554 HANDLE FileHandle,
555 Z7_WIN_IO_STATUS_BLOCK *IoStatusBlock,
556 PVOID FileInformation,
557 ULONG Length,
558 Z7_WIN_FILE_INFORMATION_CLASS FileInformationClass);
559
560// NTAPI
561typedef ULONG (WINAPI *Func_RtlNtStatusToDosError)(Z7_WIN_NTSTATUS Status);
562
563#define MY_STATUS_SUCCESS 0
564
565EXTERN_C_END
566
567// static Func_NtSetInformationFile f_NtSetInformationFile;
568// static bool g_NtSetInformationFile_WasRequested = false;
511 569
512 FString destPath = _pathPrefix + us2fs(newName);
513 570
571Z7_COM7F_IMF(CAltStreamsFolder::Rename(UInt32 index, const wchar_t *newName, IProgress *progress))
572{
514 const CAltStream &ss = Streams[index]; 573 const CAltStream &ss = Streams[index];
574 const FString srcPath = _pathPrefix + us2fs(ss.Name);
575
576 const HMODULE ntdll = ::GetModuleHandleW(L"ntdll.dll");
577 // if (!g_NtSetInformationFile_WasRequested) {
578 // g_NtSetInformationFile_WasRequested = true;
579 const
580 Func_NtSetInformationFile
581 f_NtSetInformationFile = Z7_GET_PROC_ADDRESS(
582 Func_NtSetInformationFile, ntdll,
583 "NtSetInformationFile");
584 if (f_NtSetInformationFile)
585 {
586 NIO::CInFile inFile;
587 if (inFile.Open_for_FileRenameInformation(srcPath))
588 {
589 UString destPath (':');
590 destPath += newName;
591 const ULONG len = (ULONG)sizeof(wchar_t) * destPath.Len();
592 CByteBuffer buffer(sizeof(Z7_WIN_FILE_RENAME_INFORMATION) + len);
593 // buffer is 4 bytes larger than required.
594 Z7_WIN_FILE_RENAME_INFORMATION *fri = (Z7_WIN_FILE_RENAME_INFORMATION *)(void *)(Byte *)buffer;
595 memset(fri, 0, sizeof(Z7_WIN_FILE_RENAME_INFORMATION));
596 /* DOCS: If ReplaceIfExists is set to TRUE, the rename operation will succeed only
597 if a stream with the same name does not exist or is a zero-length data stream. */
598 fri->ReplaceIfExists = FALSE;
599 fri->RootDirectory = NULL;
600 fri->FileNameLength = len;
601 memcpy(fri->FileName, destPath.Ptr(), len);
602 Z7_WIN_IO_STATUS_BLOCK iosb;
603 const Z7_WIN_NTSTATUS status = f_NtSetInformationFile (inFile.GetHandle(),
604 &iosb, fri, (ULONG)buffer.Size(), Z7_WIN_FileRenameInformation);
605 if (status != MY_STATUS_SUCCESS)
606 {
607 const
608 Func_RtlNtStatusToDosError
609 f_RtlNtStatusToDosError = Z7_GET_PROC_ADDRESS(
610 Func_RtlNtStatusToDosError, ntdll,
611 "RtlNtStatusToDosError");
612 if (f_RtlNtStatusToDosError)
613 {
614 const ULONG res = f_RtlNtStatusToDosError(status);
615 if (res != ERROR_MR_MID_NOT_FOUND)
616 return HRESULT_FROM_WIN32(res);
617 }
618 }
619 return status;
620 }
621 }
622
623 CMyComPtr<IFolderArchiveUpdateCallback> callback;
624 if (progress)
625 {
626 RINOK(progress->QueryInterface(IID_IFolderArchiveUpdateCallback, (void **)&callback))
627 }
515 628
516 if (callback) 629 if (callback)
517 { 630 {
518 RINOK(callback->SetNumFiles(1)); 631 RINOK(callback->SetNumFiles(1))
519 RINOK(callback->SetTotal(ss.Size)); 632 RINOK(callback->SetTotal(ss.Size))
520 } 633 }
521 634
522 NFsFolder::CCopyStateIO state; 635 NFsFolder::CCopyStateIO state;
@@ -524,32 +637,33 @@ STDMETHODIMP CAltStreamsFolder::Rename(UInt32 index, const wchar_t *newName, IPr
524 state.TotalSize = 0; 637 state.TotalSize = 0;
525 state.DeleteSrcFile = true; 638 state.DeleteSrcFile = true;
526 639
527 return UpdateFile(state, _pathPrefix + us2fs(ss.Name), destPath, callback); 640 const FString destPath = _pathPrefix + us2fs(newName);
641 return UpdateFile(state, srcPath, destPath, callback);
528} 642}
529 643
530STDMETHODIMP CAltStreamsFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress *progress) 644Z7_COM7F_IMF(CAltStreamsFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress *progress))
531{ 645{
532 RINOK(progress->SetTotal(numItems)); 646 RINOK(progress->SetTotal(numItems))
533 for (UInt32 i = 0; i < numItems; i++) 647 for (UInt32 i = 0; i < numItems; i++)
534 { 648 {
535 const CAltStream &ss = Streams[indices[i]]; 649 const CAltStream &ss = Streams[indices[i]];
536 const FString fullPath = _pathPrefix + us2fs(ss.Name); 650 const FString fullPath = _pathPrefix + us2fs(ss.Name);
537 bool result = DeleteFileAlways(fullPath); 651 const bool result = DeleteFileAlways(fullPath);
538 if (!result) 652 if (!result)
539 return Return_LastError_or_FAIL(); 653 return GetLastError_noZero_HRESULT();
540 UInt64 completed = i; 654 const UInt64 completed = i;
541 RINOK(progress->SetCompleted(&completed)); 655 RINOK(progress->SetCompleted(&completed))
542 } 656 }
543 return S_OK; 657 return S_OK;
544} 658}
545 659
546STDMETHODIMP CAltStreamsFolder::SetProperty(UInt32 /* index */, PROPID /* propID */, 660Z7_COM7F_IMF(CAltStreamsFolder::SetProperty(UInt32 /* index */, PROPID /* propID */,
547 const PROPVARIANT * /* value */, IProgress * /* progress */) 661 const PROPVARIANT * /* value */, IProgress * /* progress */))
548{ 662{
549 return E_NOTIMPL; 663 return E_NOTIMPL;
550} 664}
551 665
552STDMETHODIMP CAltStreamsFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex) 666Z7_COM7F_IMF(CAltStreamsFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex))
553{ 667{
554 const CAltStream &ss = Streams[index]; 668 const CAltStream &ss = Streams[index];
555 *iconIndex = 0; 669 *iconIndex = 0;
@@ -561,30 +675,28 @@ STDMETHODIMP CAltStreamsFolder::GetSystemIconIndex(UInt32 index, Int32 *iconInde
561 *iconIndex = iconIndexTemp; 675 *iconIndex = iconIndexTemp;
562 return S_OK; 676 return S_OK;
563 } 677 }
564 return Return_LastError_or_FAIL(); 678 return GetLastError_noZero_HRESULT();
565} 679}
566 680
567/* 681/*
568class CGetProp: 682Z7_CLASS_IMP_COM_1(
569 public IGetProp, 683 CGetProp
570 public CMyUnknownImp 684 , IGetProp
571{ 685)
572public: 686public:
573 // const CArc *Arc; 687 // const CArc *Arc;
574 // UInt32 IndexInArc; 688 // UInt32 IndexInArc;
575 UString Name; // relative path 689 UString Name; // relative path
576 UInt64 Size; 690 UInt64 Size;
577
578 MY_UNKNOWN_IMP1(IGetProp)
579 INTERFACE_IGetProp(;)
580}; 691};
581 692
582STDMETHODIMP CGetProp::GetProp(PROPID propID, PROPVARIANT *value) 693Z7_COM7F_IMF(CGetProp::GetProp(PROPID propID, PROPVARIANT *value))
583{ 694{
584 if (propID == kpidName) 695 if (propID == kpidName)
585 { 696 {
586 COM_TRY_BEGIN 697 COM_TRY_BEGIN
587 NCOM::CPropVariant prop = Name; 698 NCOM::CPropVariant prop;
699 prop = Name;
588 prop.Detach(value); 700 prop.Detach(value);
589 return S_OK; 701 return S_OK;
590 COM_TRY_END 702 COM_TRY_END
@@ -612,7 +724,7 @@ static HRESULT CopyStream(
612 FString destPath = destPathSpec; 724 FString destPath = destPathSpec;
613 if (CompareFileNames(destPath, srcPath) == 0) 725 if (CompareFileNames(destPath, srcPath) == 0)
614 { 726 {
615 RINOK(SendMessageError(callback, "Cannot copy file onto itself", destPath)); 727 RINOK(SendMessageError(callback, "Cannot copy file onto itself", destPath))
616 return E_ABORT; 728 return E_ABORT;
617 } 729 }
618 730
@@ -624,13 +736,13 @@ static HRESULT CopyStream(
624 &srcFileInfo.MTime, &srcAltStream.Size, 736 &srcFileInfo.MTime, &srcAltStream.Size,
625 fs2us(destPath), 737 fs2us(destPath),
626 &destPathResult, 738 &destPathResult,
627 &writeAskResult)); 739 &writeAskResult))
628 740
629 if (IntToBool(writeAskResult)) 741 if (IntToBool(writeAskResult))
630 { 742 {
631 RINOK(callback->SetCurrentFilePath(fs2us(srcPath))); 743 RINOK(callback->SetCurrentFilePath(fs2us(srcPath)))
632 FString destPathNew (us2fs((LPCOLESTR)destPathResult)); 744 FString destPathNew (us2fs((LPCOLESTR)destPathResult));
633 RINOK(state.MyCopyFile(srcPath, destPathNew)); 745 RINOK(state.MyCopyFile(srcPath, destPathNew))
634 if (state.ErrorFileIndex >= 0) 746 if (state.ErrorFileIndex >= 0)
635 { 747 {
636 if (state.ErrorMessage.IsEmpty()) 748 if (state.ErrorMessage.IsEmpty())
@@ -640,7 +752,7 @@ static HRESULT CopyStream(
640 errorName = srcPath; 752 errorName = srcPath;
641 else 753 else
642 errorName = destPathNew; 754 errorName = destPathNew;
643 RINOK(SendMessageError(callback, state.ErrorMessage, errorName)); 755 RINOK(SendMessageError(callback, state.ErrorMessage, errorName))
644 return E_ABORT; 756 return E_ABORT;
645 } 757 }
646 state.StartPos += state.CurrentSize; 758 state.StartPos += state.CurrentSize;
@@ -650,22 +762,23 @@ static HRESULT CopyStream(
650 if (state.TotalSize >= srcAltStream.Size) 762 if (state.TotalSize >= srcAltStream.Size)
651 { 763 {
652 state.TotalSize -= srcAltStream.Size; 764 state.TotalSize -= srcAltStream.Size;
653 RINOK(state.Progress->SetTotal(state.TotalSize)); 765 RINOK(state.Progress->SetTotal(state.TotalSize))
654 } 766 }
655 } 767 }
656 return S_OK; 768 return S_OK;
657} 769}
658 770
659STDMETHODIMP CAltStreamsFolder::CopyTo(Int32 moveMode, const UInt32 *indices, UInt32 numItems, 771Z7_COM7F_IMF(CAltStreamsFolder::CopyTo(Int32 moveMode, const UInt32 *indices, UInt32 numItems,
660 Int32 /* includeAltStreams */, Int32 /* replaceAltStreamColon */, 772 Int32 /* includeAltStreams */, Int32 /* replaceAltStreamColon */,
661 const wchar_t *path, IFolderOperationsExtractCallback *callback) 773 const wchar_t *path, IFolderOperationsExtractCallback *callback))
662{ 774{
663 if (numItems == 0) 775 if (numItems == 0)
664 return S_OK; 776 return S_OK;
665 777
666 /* 778 /*
667 CMyComPtr<IFolderExtractToStreamCallback> ExtractToStreamCallback; 779 Z7_DECL_CMyComPtr_QI_FROM(
668 RINOK(callback->QueryInterface(IID_IFolderExtractToStreamCallback, (void **)&ExtractToStreamCallback)); 780 IFolderExtractToStreamCallback,
781 ExtractToStreamCallback, callback)
669 if (ExtractToStreamCallback) 782 if (ExtractToStreamCallback)
670 { 783 {
671 Int32 useStreams = 0; 784 Int32 useStreams = 0;
@@ -683,8 +796,8 @@ STDMETHODIMP CAltStreamsFolder::CopyTo(Int32 moveMode, const UInt32 *indices, UI
683 { 796 {
684 totalSize += Streams[indices[i]].Size; 797 totalSize += Streams[indices[i]].Size;
685 } 798 }
686 RINOK(callback->SetTotal(totalSize)); 799 RINOK(callback->SetTotal(totalSize))
687 RINOK(callback->SetNumFiles(numItems)); 800 RINOK(callback->SetNumFiles(numItems))
688 } 801 }
689 802
690 /* 803 /*
@@ -716,8 +829,8 @@ STDMETHODIMP CAltStreamsFolder::CopyTo(Int32 moveMode, const UInt32 *indices, UI
716 if (destPath.IsEmpty() /* && !ExtractToStreamCallback */) 829 if (destPath.IsEmpty() /* && !ExtractToStreamCallback */)
717 return E_INVALIDARG; 830 return E_INVALIDARG;
718 831
719 bool isAltDest = NName::IsAltPathPrefix(destPath); 832 const bool isAltDest = NName::IsAltPathPrefix(destPath);
720 bool isDirectPath = (!isAltDest && !IsPathSepar(destPath.Back())); 833 const bool isDirectPath = (!isAltDest && !IsPathSepar(destPath.Back()));
721 834
722 if (isDirectPath) 835 if (isDirectPath)
723 { 836 {
@@ -727,7 +840,7 @@ STDMETHODIMP CAltStreamsFolder::CopyTo(Int32 moveMode, const UInt32 *indices, UI
727 840
728 CFileInfo fi; 841 CFileInfo fi;
729 if (!fi.Find(_pathBaseFile)) 842 if (!fi.Find(_pathBaseFile))
730 return GetLastError(); 843 return GetLastError_noZero_HRESULT();
731 844
732 NFsFolder::CCopyStateIO state; 845 NFsFolder::CCopyStateIO state;
733 state.Progress = callback; 846 state.Progress = callback;
@@ -736,21 +849,21 @@ STDMETHODIMP CAltStreamsFolder::CopyTo(Int32 moveMode, const UInt32 *indices, UI
736 849
737 for (UInt32 i = 0; i < numItems; i++) 850 for (UInt32 i = 0; i < numItems; i++)
738 { 851 {
739 UInt32 index = indices[i]; 852 const UInt32 index = indices[i];
740 const CAltStream &ss = Streams[index]; 853 const CAltStream &ss = Streams[index];
741 FString destPath2 = destPath; 854 FString destPath2 = destPath;
742 if (!isDirectPath) 855 if (!isDirectPath)
743 destPath2 += us2fs(Get_Correct_FsFile_Name(ss.Name)); 856 destPath2 += us2fs(Get_Correct_FsFile_Name(ss.Name));
744 FString srcPath; 857 FString srcPath;
745 GetFullPath(ss, srcPath); 858 GetFullPath(ss, srcPath);
746 RINOK(CopyStream(state, srcPath, fi, ss, destPath2, callback)); 859 RINOK(CopyStream(state, srcPath, fi, ss, destPath2, callback))
747 } 860 }
748 861
749 return S_OK; 862 return S_OK;
750} 863}
751 864
752STDMETHODIMP CAltStreamsFolder::CopyFrom(Int32 /* moveMode */, const wchar_t * /* fromFolderPath */, 865Z7_COM7F_IMF(CAltStreamsFolder::CopyFrom(Int32 /* moveMode */, const wchar_t * /* fromFolderPath */,
753 const wchar_t * const * /* itemsPaths */, UInt32 /* numItems */, IProgress * /* progress */) 866 const wchar_t * const * /* itemsPaths */, UInt32 /* numItems */, IProgress * /* progress */))
754{ 867{
755 /* 868 /*
756 if (numItems == 0) 869 if (numItems == 0)
@@ -831,7 +944,7 @@ STDMETHODIMP CAltStreamsFolder::CopyFrom(Int32 /* moveMode */, const wchar_t * /
831 return E_NOTIMPL; 944 return E_NOTIMPL;
832} 945}
833 946
834STDMETHODIMP CAltStreamsFolder::CopyFromFile(UInt32 /* index */, const wchar_t * /* fullFilePath */, IProgress * /* progress */) 947Z7_COM7F_IMF(CAltStreamsFolder::CopyFromFile(UInt32 /* index */, const wchar_t * /* fullFilePath */, IProgress * /* progress */))
835{ 948{
836 return E_NOTIMPL; 949 return E_NOTIMPL;
837} 950}
diff --git a/CPP/7zip/UI/FileManager/AltStreamsFolder.h b/CPP/7zip/UI/FileManager/AltStreamsFolder.h
index ccd0a58..ccb6d6f 100644
--- a/CPP/7zip/UI/FileManager/AltStreamsFolder.h
+++ b/CPP/7zip/UI/FileManager/AltStreamsFolder.h
@@ -1,7 +1,7 @@
1// AltStreamsFolder.h 1// AltStreamsFolder.h
2 2
3#ifndef __ALT_STREAMS_FOLDER_H 3#ifndef ZIP7_INC_ALT_STREAMS_FOLDER_H
4#define __ALT_STREAMS_FOLDER_H 4#define ZIP7_INC_ALT_STREAMS_FOLDER_H
5 5
6#include "../../../Common/MyCom.h" 6#include "../../../Common/MyCom.h"
7 7
@@ -24,12 +24,12 @@ struct CAltStream
24}; 24};
25 25
26 26
27class CAltStreamsFolder: 27class CAltStreamsFolder Z7_final:
28 public IFolderFolder, 28 public IFolderFolder,
29 public IFolderCompare, 29 public IFolderCompare,
30 #ifdef USE_UNICODE_FSTRING 30 #ifdef USE_UNICODE_FSTRING
31 public IFolderGetItemName, 31 public IFolderGetItemName,
32 #endif 32 #endif
33 public IFolderWasChanged, 33 public IFolderWasChanged,
34 public IFolderOperations, 34 public IFolderOperations,
35 // public IFolderOperationsDeleteToRecycleBin, 35 // public IFolderOperationsDeleteToRecycleBin,
@@ -37,35 +37,29 @@ class CAltStreamsFolder:
37 public IFolderGetSystemIconIndex, 37 public IFolderGetSystemIconIndex,
38 public CMyUnknownImp 38 public CMyUnknownImp
39{ 39{
40public: 40 Z7_COM_QI_BEGIN2(IFolderFolder)
41 MY_QUERYINTERFACE_BEGIN2(IFolderFolder) 41 Z7_COM_QI_ENTRY(IFolderCompare)
42 MY_QUERYINTERFACE_ENTRY(IFolderCompare)
43 #ifdef USE_UNICODE_FSTRING 42 #ifdef USE_UNICODE_FSTRING
44 MY_QUERYINTERFACE_ENTRY(IFolderGetItemName) 43 Z7_COM_QI_ENTRY(IFolderGetItemName)
45 #endif 44 #endif
46 MY_QUERYINTERFACE_ENTRY(IFolderWasChanged) 45 Z7_COM_QI_ENTRY(IFolderWasChanged)
47 // MY_QUERYINTERFACE_ENTRY(IFolderOperationsDeleteToRecycleBin) 46 // Z7_COM_QI_ENTRY(IFolderOperationsDeleteToRecycleBin)
48 MY_QUERYINTERFACE_ENTRY(IFolderOperations) 47 Z7_COM_QI_ENTRY(IFolderOperations)
49 MY_QUERYINTERFACE_ENTRY(IFolderClone) 48 Z7_COM_QI_ENTRY(IFolderClone)
50 MY_QUERYINTERFACE_ENTRY(IFolderGetSystemIconIndex) 49 Z7_COM_QI_ENTRY(IFolderGetSystemIconIndex)
51 MY_QUERYINTERFACE_END 50 Z7_COM_QI_END
52 MY_ADDREF_RELEASE 51 Z7_COM_ADDREF_RELEASE
53 52
54 53 Z7_IFACE_COM7_IMP(IFolderFolder)
55 INTERFACE_FolderFolder(;) 54 Z7_IFACE_COM7_IMP(IFolderCompare)
56 INTERFACE_FolderOperations(;) 55 #ifdef USE_UNICODE_FSTRING
57 56 Z7_IFACE_COM7_IMP(IFolderGetItemName)
58 STDMETHOD_(Int32, CompareItems)(UInt32 index1, UInt32 index2, PROPID propID, Int32 propIsRaw); 57 #endif
58 Z7_IFACE_COM7_IMP(IFolderWasChanged)
59 Z7_IFACE_COM7_IMP(IFolderOperations)
60 Z7_IFACE_COM7_IMP(IFolderClone)
61 Z7_IFACE_COM7_IMP(IFolderGetSystemIconIndex)
59 62
60 #ifdef USE_UNICODE_FSTRING
61 INTERFACE_IFolderGetItemName(;)
62 #endif
63 STDMETHOD(WasChanged)(Int32 *wasChanged);
64 STDMETHOD(Clone)(IFolderFolder **resultFolder);
65
66 STDMETHOD(GetSystemIconIndex)(UInt32 index, Int32 *iconIndex);
67
68private:
69 FString _pathBaseFile; // folder 63 FString _pathBaseFile; // folder
70 FString _pathPrefix; // folder: 64 FString _pathPrefix; // folder:
71 65
@@ -81,8 +75,6 @@ public:
81 // path must be with ':' at tail 75 // path must be with ':' at tail
82 HRESULT Init(const FString &path /* , IFolderFolder *parentFolder */); 76 HRESULT Init(const FString &path /* , IFolderFolder *parentFolder */);
83 77
84 CAltStreamsFolder() {}
85
86 void GetFullPath(const CAltStream &item, FString &path) const 78 void GetFullPath(const CAltStream &item, FString &path) const
87 { 79 {
88 path = _pathPrefix; 80 path = _pathPrefix;
diff --git a/CPP/7zip/UI/FileManager/App.cpp b/CPP/7zip/UI/FileManager/App.cpp
index 512acc5..3461c92 100644
--- a/CPP/7zip/UI/FileManager/App.cpp
+++ b/CPP/7zip/UI/FileManager/App.cpp
@@ -49,7 +49,7 @@ void CPanelCallbackImp::OnTab()
49 49
50void CPanelCallbackImp::SetFocusToPath(unsigned index) 50void CPanelCallbackImp::SetFocusToPath(unsigned index)
51{ 51{
52 int newPanelIndex = index; 52 unsigned newPanelIndex = index;
53 if (g_App.NumPanels == 1) 53 if (g_App.NumPanels == 1)
54 newPanelIndex = g_App.LastFocusedPanel; 54 newPanelIndex = g_App.LastFocusedPanel;
55 _app->RefreshTitle(); 55 _app->RefreshTitle();
@@ -66,7 +66,7 @@ void CPanelCallbackImp::DragBegin() { _app->DragBegin(_index); }
66void CPanelCallbackImp::DragEnd() { _app->DragEnd(); } 66void CPanelCallbackImp::DragEnd() { _app->DragEnd(); }
67void CPanelCallbackImp::RefreshTitle(bool always) { _app->RefreshTitlePanel(_index, always); } 67void CPanelCallbackImp::RefreshTitle(bool always) { _app->RefreshTitlePanel(_index, always); }
68 68
69void CApp::ReloadLang() 69void CApp::ReloadLangItems()
70{ 70{
71 LangString(IDS_N_SELECTED_ITEMS, LangString_N_SELECTED_ITEMS); 71 LangString(IDS_N_SELECTED_ITEMS, LangString_N_SELECTED_ITEMS);
72} 72}
@@ -101,11 +101,11 @@ void CApp::SetListSettings()
101 panel._showRealFileIcons = st.ShowRealFileIcons; 101 panel._showRealFileIcons = st.ShowRealFileIcons;
102 panel._exStyle = extendedStyle; 102 panel._exStyle = extendedStyle;
103 103
104 DWORD style = (DWORD)panel._listView.GetStyle(); 104 LONG_PTR style = panel._listView.GetStyle();
105 if (st.AlternativeSelection) 105 if (st.AlternativeSelection)
106 style |= LVS_SINGLESEL; 106 style |= LVS_SINGLESEL;
107 else 107 else
108 style &= ~LVS_SINGLESEL; 108 style &= ~(LONG_PTR)(DWORD)LVS_SINGLESEL;
109 panel._listView.SetStyle(style); 109 panel._listView.SetStyle(style);
110 panel.SetExtendedStyle(); 110 panel.SetExtendedStyle();
111 } 111 }
@@ -115,7 +115,7 @@ void CApp::SetListSettings()
115#define ILC_COLOR32 0x0020 115#define ILC_COLOR32 0x0020
116#endif 116#endif
117 117
118HRESULT CApp::CreateOnePanel(int panelIndex, const UString &mainPath, const UString &arcFormat, 118HRESULT CApp::CreateOnePanel(unsigned panelIndex, const UString &mainPath, const UString &arcFormat,
119 bool needOpenArc, 119 bool needOpenArc,
120 COpenResult &openRes) 120 COpenResult &openRes)
121{ 121{
@@ -133,7 +133,7 @@ HRESULT CApp::CreateOnePanel(int panelIndex, const UString &mainPath, const UStr
133 else 133 else
134 path = mainPath; 134 path = mainPath;
135 135
136 int id = 1000 + 100 * panelIndex; 136 const unsigned id = 1000 + 100 * panelIndex; // check it
137 137
138 return Panels[panelIndex].Create(_window, _window, 138 return Panels[panelIndex].Create(_window, _window,
139 id, path, arcFormat, &m_PanelCallbackImp[panelIndex], &AppState, 139 id, path, arcFormat, &m_PanelCallbackImp[panelIndex], &AppState,
@@ -214,9 +214,9 @@ static bool SetButtonText(int commandID, const CButtonInfo *buttons, unsigned nu
214 214
215static void SetButtonText(int commandID, UString &s) 215static void SetButtonText(int commandID, UString &s)
216{ 216{
217 if (SetButtonText(commandID, g_StandardButtons, ARRAY_SIZE(g_StandardButtons), s)) 217 if (SetButtonText(commandID, g_StandardButtons, Z7_ARRAY_SIZE(g_StandardButtons), s))
218 return; 218 return;
219 SetButtonText(commandID, g_ArchiveButtons, ARRAY_SIZE(g_ArchiveButtons), s); 219 SetButtonText(commandID, g_ArchiveButtons, Z7_ARRAY_SIZE(g_ArchiveButtons), s);
220} 220}
221 221
222static void AddButton( 222static void AddButton(
@@ -241,7 +241,7 @@ static void AddButton(
241 large ? 241 large ?
242 MAKEINTRESOURCE(butInfo.BitmapResID): 242 MAKEINTRESOURCE(butInfo.BitmapResID):
243 MAKEINTRESOURCE(butInfo.Bitmap2ResID)); 243 MAKEINTRESOURCE(butInfo.Bitmap2ResID));
244 if (b != 0) 244 if (b)
245 { 245 {
246 imageList.AddMasked(b, RGB(255, 0, 255)); 246 imageList.AddMasked(b, RGB(255, 0, 255));
247 ::DeleteObject(b); 247 ::DeleteObject(b);
@@ -264,10 +264,10 @@ void CApp::ReloadToolbars()
264 CreateToolbar(_window, _buttonsImageList, _toolBar, LargeButtons); 264 CreateToolbar(_window, _buttonsImageList, _toolBar, LargeButtons);
265 unsigned i; 265 unsigned i;
266 if (ShowArchiveToolbar) 266 if (ShowArchiveToolbar)
267 for (i = 0; i < ARRAY_SIZE(g_ArchiveButtons); i++) 267 for (i = 0; i < Z7_ARRAY_SIZE(g_ArchiveButtons); i++)
268 AddButton(_buttonsImageList, _toolBar, g_ArchiveButtons[i], ShowButtonsLables, LargeButtons); 268 AddButton(_buttonsImageList, _toolBar, g_ArchiveButtons[i], ShowButtonsLables, LargeButtons);
269 if (ShowStandardToolbar) 269 if (ShowStandardToolbar)
270 for (i = 0; i < ARRAY_SIZE(g_StandardButtons); i++) 270 for (i = 0; i < Z7_ARRAY_SIZE(g_StandardButtons); i++)
271 AddButton(_buttonsImageList, _toolBar, g_StandardButtons[i], ShowButtonsLables, LargeButtons); 271 AddButton(_buttonsImageList, _toolBar, g_StandardButtons[i], ShowButtonsLables, LargeButtons);
272 272
273 _toolBar.AutoSize(); 273 _toolBar.AutoSize();
@@ -290,7 +290,7 @@ HRESULT CApp::Create(HWND hwnd, const UString &mainPath, const UString &arcForma
290 _commandBar.Create(g_hInstance, hwnd, 1); 290 _commandBar.Create(g_hInstance, hwnd, 1);
291 #endif 291 #endif
292 292
293 MyLoadMenu(); 293 MyLoadMenu(false); // needResetMenu
294 294
295 #ifdef UNDER_CE 295 #ifdef UNDER_CE
296 _commandBar.AutoSize(); 296 _commandBar.AutoSize();
@@ -317,7 +317,7 @@ HRESULT CApp::Create(HWND hwnd, const UString &mainPath, const UString &arcForma
317 for (i = 0; i < kNumPanelsMax; i++) 317 for (i = 0; i < kNumPanelsMax; i++)
318 { 318 {
319 CPanel &panel = Panels[i]; 319 CPanel &panel = Panels[i];
320 panel._ListViewMode = listMode.Panels[i]; 320 panel._listViewMode = listMode.Panels[i];
321 panel._xSize = xSizes[i]; 321 panel._xSize = xSizes[i];
322 panel._flatModeForArc = ReadFlatView(i); 322 panel._flatModeForArc = ReadFlatView(i);
323 } 323 }
@@ -342,7 +342,7 @@ HRESULT CApp::Create(HWND hwnd, const UString &mainPath, const UString &arcForma
342 342
343 RINOK(CreateOnePanel(panelIndex, path, arcFormat, 343 RINOK(CreateOnePanel(panelIndex, path, arcFormat,
344 isMainPanel && needOpenArc, 344 isMainPanel && needOpenArc,
345 *(isMainPanel ? &openRes : &openRes2))); 345 *(isMainPanel ? &openRes : &openRes2)))
346 346
347 if (isMainPanel) 347 if (isMainPanel)
348 { 348 {
@@ -366,7 +366,7 @@ HRESULT CApp::SwitchOnOffOnePanel()
366 COpenResult openRes; 366 COpenResult openRes;
367 RINOK(CreateOnePanel(1 - LastFocusedPanel, UString(), UString(), 367 RINOK(CreateOnePanel(1 - LastFocusedPanel, UString(), UString(),
368 false, // needOpenArc 368 false, // needOpenArc
369 openRes)); 369 openRes))
370 Panels[1 - LastFocusedPanel].Enable(true); 370 Panels[1 - LastFocusedPanel].Enable(true);
371 Panels[1 - LastFocusedPanel].Show(SW_SHOWNORMAL); 371 Panels[1 - LastFocusedPanel].Show(SW_SHOWNORMAL);
372 } 372 }
@@ -479,7 +479,7 @@ void AddValuePair2(UString &s, UINT resourceID, UInt64 num, UInt64 size)
479 s.Add_LF(); 479 s.Add_LF();
480} 480}
481 481
482static void AddPropValueToSum(IFolderFolder *folder, int index, PROPID propID, UInt64 &sum) 482static void AddPropValueToSum(IFolderFolder *folder, UInt32 index, PROPID propID, UInt64 &sum)
483{ 483{
484 if (sum == (UInt64)(Int64)-1) 484 if (sum == (UInt64)(Int64)-1)
485 return; 485 return;
@@ -501,7 +501,7 @@ UString CPanel::GetItemsInfoString(const CRecordVector<UInt32> &indices)
501 unsigned i; 501 unsigned i;
502 for (i = 0; i < indices.Size(); i++) 502 for (i = 0; i < indices.Size(); i++)
503 { 503 {
504 int index = indices[i]; 504 const UInt32 index = indices[i];
505 if (IsItem_Folder(index)) 505 if (IsItem_Folder(index))
506 { 506 {
507 AddPropValueToSum(_folder, index, kpidSize, foldersSize); 507 AddPropValueToSum(_folder, index, kpidSize, foldersSize);
@@ -528,7 +528,7 @@ UString CPanel::GetItemsInfoString(const CRecordVector<UInt32> &indices)
528 { 528 {
529 info.Add_LF(); 529 info.Add_LF();
530 info += " "; 530 info += " ";
531 int index = indices[i]; 531 const UInt32 index = indices[i];
532 info += GetItemRelPath(index); 532 info += GetItemRelPath(index);
533 if (IsItem_Folder(index)) 533 if (IsItem_Folder(index))
534 info.Add_PathSepar(); 534 info.Add_PathSepar();
@@ -557,9 +557,9 @@ static bool IsFsPath(const FString &path)
557} 557}
558*/ 558*/
559 559
560void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) 560void CApp::OnCopy(bool move, bool copyToSame, unsigned srcPanelIndex)
561{ 561{
562 unsigned destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex); 562 const unsigned destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
563 CPanel &srcPanel = Panels[srcPanelIndex]; 563 CPanel &srcPanel = Panels[srcPanelIndex];
564 CPanel &destPanel = Panels[destPanelIndex]; 564 CPanel &destPanel = Panels[destPanelIndex];
565 565
@@ -584,10 +584,10 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
584 { 584 {
585 if (copyToSame) 585 if (copyToSame)
586 { 586 {
587 int focusedItem = srcPanel._listView.GetFocusedItem(); 587 const int focusedItem = srcPanel._listView.GetFocusedItem();
588 if (focusedItem < 0) 588 if (focusedItem < 0)
589 return; 589 return;
590 int realIndex = srcPanel.GetRealItemIndex(focusedItem); 590 const unsigned realIndex = srcPanel.GetRealItemIndex(focusedItem);
591 if (realIndex == kParentIndex) 591 if (realIndex == kParentIndex)
592 return; 592 return;
593 indices.Add(realIndex); 593 indices.Add(realIndex);
@@ -595,7 +595,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
595 } 595 }
596 else 596 else
597 { 597 {
598 srcPanel.GetOperatedIndicesSmart(indices); 598 srcPanel.Get_ItemIndices_OperSmart(indices);
599 if (indices.Size() == 0) 599 if (indices.Size() == 0)
600 return; 600 return;
601 destPath = destPanel.GetFsPath(); 601 destPath = destPanel.GetFsPath();
@@ -607,7 +607,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
607 UStringVector copyFolders; 607 UStringVector copyFolders;
608 ReadCopyHistory(copyFolders); 608 ReadCopyHistory(copyFolders);
609 609
610 bool useFullItemPaths = srcPanel.Is_IO_FS_Folder(); // maybe we need flat also here ?? 610 const bool useFullItemPaths = srcPanel.Is_IO_FS_Folder(); // maybe we need flat also here ??
611 611
612 { 612 {
613 CCopyDialog copyDialog; 613 CCopyDialog copyDialog;
@@ -722,7 +722,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
722 UString prefix = destPath.Left(pos + 1); 722 UString prefix = destPath.Left(pos + 1);
723 if (!CreateComplexDir(us2fs(prefix))) 723 if (!CreateComplexDir(us2fs(prefix)))
724 { 724 {
725 DWORD lastError = ::GetLastError(); 725 const HRESULT lastError = GetLastError_noZero_HRESULT();
726 srcPanel.MessageBox_Error_2Lines_Message_HRESULT(prefix, lastError); 726 srcPanel.MessageBox_Error_2Lines_Message_HRESULT(prefix, lastError);
727 return; 727 return;
728 } 728 }
@@ -734,7 +734,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
734 NName::NormalizeDirPathPrefix(destPath); 734 NName::NormalizeDirPathPrefix(destPath);
735 if (!CreateComplexDir(us2fs(destPath))) 735 if (!CreateComplexDir(us2fs(destPath)))
736 { 736 {
737 DWORD lastError = ::GetLastError(); 737 const HRESULT lastError = GetLastError_noZero_HRESULT();
738 srcPanel.MessageBox_Error_2Lines_Message_HRESULT(destPath, lastError); 738 srcPanel.MessageBox_Error_2Lines_Message_HRESULT(destPath, lastError);
739 return; 739 return;
740 } 740 }
@@ -815,7 +815,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
815 filePaths.AddInReserved(s); 815 filePaths.AddInReserved(s);
816 } 816 }
817 817
818 result = destPanel.CopyFrom(move, folderPrefix, filePaths, true, 0); 818 result = destPanel.CopyFrom(move, folderPrefix, filePaths, true, NULL);
819 } 819 }
820 820
821 if (result != S_OK) 821 if (result != S_OK)
@@ -849,7 +849,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
849 srcPanel.SetFocusToList(); 849 srcPanel.SetFocusToList();
850} 850}
851 851
852void CApp::OnSetSameFolder(int srcPanelIndex) 852void CApp::OnSetSameFolder(unsigned srcPanelIndex)
853{ 853{
854 if (NumPanels <= 1) 854 if (NumPanels <= 1)
855 return; 855 return;
@@ -858,17 +858,17 @@ void CApp::OnSetSameFolder(int srcPanelIndex)
858 destPanel.BindToPathAndRefresh(srcPanel._currentFolderPrefix); 858 destPanel.BindToPathAndRefresh(srcPanel._currentFolderPrefix);
859} 859}
860 860
861void CApp::OnSetSubFolder(int srcPanelIndex) 861void CApp::OnSetSubFolder(unsigned srcPanelIndex)
862{ 862{
863 if (NumPanels <= 1) 863 if (NumPanels <= 1)
864 return; 864 return;
865 const CPanel &srcPanel = Panels[srcPanelIndex]; 865 const CPanel &srcPanel = Panels[srcPanelIndex];
866 CPanel &destPanel = Panels[1 - srcPanelIndex]; 866 CPanel &destPanel = Panels[1 - srcPanelIndex];
867 867
868 int focusedItem = srcPanel._listView.GetFocusedItem(); 868 const int focusedItem = srcPanel._listView.GetFocusedItem();
869 if (focusedItem < 0) 869 if (focusedItem < 0)
870 return; 870 return;
871 int realIndex = srcPanel.GetRealItemIndex(focusedItem); 871 const unsigned realIndex = srcPanel.GetRealItemIndex(focusedItem);
872 if (!srcPanel.IsItem_Folder(realIndex)) 872 if (!srcPanel.IsItem_Folder(realIndex))
873 return; 873 return;
874 874
@@ -933,7 +933,7 @@ void CApp::OnNotify(int /* ctrlID */, LPNMHDR pnmh)
933 if (pnmh->code == TTN_GETDISPINFO) 933 if (pnmh->code == TTN_GETDISPINFO)
934 { 934 {
935 LPNMTTDISPINFO info = (LPNMTTDISPINFO)pnmh; 935 LPNMTTDISPINFO info = (LPNMTTDISPINFO)pnmh;
936 info->hinst = 0; 936 info->hinst = NULL;
937 g_ToolTipBuffer.Empty(); 937 g_ToolTipBuffer.Empty();
938 SetButtonText((int)info->hdr.idFrom, g_ToolTipBuffer); 938 SetButtonText((int)info->hdr.idFrom, g_ToolTipBuffer);
939 g_ToolTipBufferSys = GetSystemString(g_ToolTipBuffer); 939 g_ToolTipBufferSys = GetSystemString(g_ToolTipBuffer);
@@ -944,7 +944,7 @@ void CApp::OnNotify(int /* ctrlID */, LPNMHDR pnmh)
944 if (pnmh->code == TTN_GETDISPINFOW) 944 if (pnmh->code == TTN_GETDISPINFOW)
945 { 945 {
946 LPNMTTDISPINFOW info = (LPNMTTDISPINFOW)pnmh; 946 LPNMTTDISPINFOW info = (LPNMTTDISPINFOW)pnmh;
947 info->hinst = 0; 947 info->hinst = NULL;
948 g_ToolTipBuffer.Empty(); 948 g_ToolTipBuffer.Empty();
949 SetButtonText((int)info->hdr.idFrom, g_ToolTipBuffer); 949 SetButtonText((int)info->hdr.idFrom, g_ToolTipBuffer);
950 info->lpszText = g_ToolTipBuffer.Ptr_non_const(); 950 info->lpszText = g_ToolTipBuffer.Ptr_non_const();
diff --git a/CPP/7zip/UI/FileManager/App.h b/CPP/7zip/UI/FileManager/App.h
index 3c3c5ef..fc54501 100644
--- a/CPP/7zip/UI/FileManager/App.h
+++ b/CPP/7zip/UI/FileManager/App.h
@@ -1,7 +1,7 @@
1// App.h 1// App.h
2 2
3#ifndef __APP_H 3#ifndef ZIP7_INC_APP_H
4#define __APP_H 4#define ZIP7_INC_APP_H
5 5
6#include "../../../Windows/Control/CommandBar.h" 6#include "../../../Windows/Control/CommandBar.h"
7#include "../../../Windows/Control/ImageList.h" 7#include "../../../Windows/Control/ImageList.h"
@@ -30,7 +30,7 @@ enum
30 kMenuCmdID_Toolbar_End 30 kMenuCmdID_Toolbar_End
31}; 31};
32 32
33class CPanelCallbackImp: public CPanelCallback 33class CPanelCallbackImp Z7_final: public CPanelCallback
34{ 34{
35 CApp *_app; 35 CApp *_app;
36 unsigned _index; 36 unsigned _index;
@@ -40,79 +40,26 @@ public:
40 _app = app; 40 _app = app;
41 _index = index; 41 _index = index;
42 } 42 }
43 virtual void OnTab(); 43 virtual void OnTab() Z7_override;
44 virtual void SetFocusToPath(unsigned index); 44 virtual void SetFocusToPath(unsigned index) Z7_override;
45 virtual void OnCopy(bool move, bool copyToSame); 45 virtual void OnCopy(bool move, bool copyToSame) Z7_override;
46 virtual void OnSetSameFolder(); 46 virtual void OnSetSameFolder() Z7_override;
47 virtual void OnSetSubFolder(); 47 virtual void OnSetSubFolder() Z7_override;
48 virtual void PanelWasFocused(); 48 virtual void PanelWasFocused() Z7_override;
49 virtual void DragBegin(); 49 virtual void DragBegin() Z7_override;
50 virtual void DragEnd(); 50 virtual void DragEnd() Z7_override;
51 virtual void RefreshTitle(bool always); 51 virtual void RefreshTitle(bool always) Z7_override;
52}; 52};
53 53
54class CApp;
55
56class CDropTarget:
57 public IDropTarget,
58 public CMyUnknownImp
59{
60 CMyComPtr<IDataObject> m_DataObject;
61 UStringVector m_SourcePaths;
62 int m_SelectionIndex;
63 bool m_DropIsAllowed; // = true, if data contain fillist
64 bool m_PanelDropIsAllowed; // = false, if current target_panel is source_panel.
65 // check it only if m_DropIsAllowed == true
66 int m_SubFolderIndex;
67 UString m_SubFolderName;
68
69 CPanel *m_Panel;
70 bool m_IsAppTarget; // true, if we want to drop to app window (not to panel).
71
72 bool m_SetPathIsOK;
73
74 bool IsItSameDrive() const;
75
76 void QueryGetData(IDataObject *dataObject);
77 bool IsFsFolderPath() const;
78 DWORD GetEffect(DWORD keyState, POINTL pt, DWORD allowedEffect);
79 void RemoveSelection();
80 void PositionCursor(POINTL ptl);
81 UString GetTargetPath() const;
82 bool SetPath(bool enablePath) const;
83 bool SetPath();
84
85public:
86 MY_UNKNOWN_IMP1_MT(IDropTarget)
87 STDMETHOD(DragEnter)(IDataObject * dataObject, DWORD keyState, POINTL pt, DWORD *effect);
88 STDMETHOD(DragOver)(DWORD keyState, POINTL pt, DWORD * effect);
89 STDMETHOD(DragLeave)();
90 STDMETHOD(Drop)(IDataObject * dataObject, DWORD keyState, POINTL pt, DWORD *effect);
91
92 CDropTarget():
93 m_SelectionIndex(-1),
94 m_DropIsAllowed(false),
95 m_PanelDropIsAllowed(false),
96 m_SubFolderIndex(-1),
97 m_Panel(NULL),
98 m_IsAppTarget(false),
99 m_SetPathIsOK(false),
100 App(NULL),
101 SrcPanelIndex(-1),
102 TargetPanelIndex(-1)
103 {}
104
105 CApp *App;
106 int SrcPanelIndex; // index of D&D source_panel
107 int TargetPanelIndex; // what panel to use as target_panel of Application
108};
109 54
55class CDropTarget;
110 56
111class CApp 57class CApp
112{ 58{
113public: 59public:
114 NWindows::CWindow _window; 60 NWindows::CWindow _window;
115 bool ShowSystemMenu; 61 bool ShowSystemMenu;
62 bool AutoRefresh_Mode;
116 // bool ShowDeletedFiles; 63 // bool ShowDeletedFiles;
117 unsigned NumPanels; 64 unsigned NumPanels;
118 unsigned LastFocusedPanel; 65 unsigned LastFocusedPanel;
@@ -138,45 +85,27 @@ public:
138 85
139 UString LangString_N_SELECTED_ITEMS; 86 UString LangString_N_SELECTED_ITEMS;
140 87
141 void ReloadLang(); 88 void ReloadLangItems();
142 89
143 CApp(): _window(0), NumPanels(2), LastFocusedPanel(0), 90 CApp():
144 AutoRefresh_Mode(true) 91 _window(NULL),
92 AutoRefresh_Mode(true),
93 NumPanels(2),
94 LastFocusedPanel(0)
145 { 95 {
146 SetPanels_AutoRefresh_Mode(); 96 SetPanels_AutoRefresh_Mode();
147 } 97 }
148 98
149 void CreateDragTarget() 99 void CreateDragTarget();
150 { 100 void SetFocusedPanel(unsigned index);
151 _dropTargetSpec = new CDropTarget(); 101 void DragBegin(unsigned panelIndex);
152 _dropTarget = _dropTargetSpec; 102 void DragEnd();
153 _dropTargetSpec->App = (this);
154 }
155
156 void SetFocusedPanel(unsigned index)
157 {
158 LastFocusedPanel = index;
159 _dropTargetSpec->TargetPanelIndex = LastFocusedPanel;
160 }
161
162 void DragBegin(unsigned panelIndex)
163 {
164 _dropTargetSpec->TargetPanelIndex = (NumPanels > 1) ? 1 - panelIndex : panelIndex;
165 _dropTargetSpec->SrcPanelIndex = panelIndex;
166 }
167
168 void DragEnd()
169 {
170 _dropTargetSpec->TargetPanelIndex = LastFocusedPanel;
171 _dropTargetSpec->SrcPanelIndex = -1;
172 }
173
174 103
175 void OnCopy(bool move, bool copyToSame, int srcPanelIndex); 104 void OnCopy(bool move, bool copyToSame, unsigned srcPanelIndex);
176 void OnSetSameFolder(int srcPanelIndex); 105 void OnSetSameFolder(unsigned srcPanelIndex);
177 void OnSetSubFolder(int srcPanelIndex); 106 void OnSetSubFolder(unsigned srcPanelIndex);
178 107
179 HRESULT CreateOnePanel(int panelIndex, const UString &mainPath, const UString &arcFormat, bool needOpenArc, COpenResult &openRes); 108 HRESULT CreateOnePanel(unsigned panelIndex, const UString &mainPath, const UString &arcFormat, bool needOpenArc, COpenResult &openRes);
180 HRESULT Create(HWND hwnd, const UString &mainPath, const UString &arcFormat, int xSizes[2], bool needOpenArc, COpenResult &openRes); 109 HRESULT Create(HWND hwnd, const UString &mainPath, const UString &arcFormat, int xSizes[2], bool needOpenArc, COpenResult &openRes);
181 void Read(); 110 void Read();
182 void Save(); 111 void Save();
@@ -290,7 +219,6 @@ public:
290 // void Change_ShowNtfsStrems_Mode() { Panels[LastFocusedPanel].Change_ShowNtfsStrems_Mode(); } 219 // void Change_ShowNtfsStrems_Mode() { Panels[LastFocusedPanel].Change_ShowNtfsStrems_Mode(); }
291 // void Change_ShowDeleted() { ShowDeletedFiles = !ShowDeletedFiles; } 220 // void Change_ShowDeleted() { ShowDeletedFiles = !ShowDeletedFiles; }
292 221
293 bool AutoRefresh_Mode;
294 bool Get_AutoRefresh_Mode() 222 bool Get_AutoRefresh_Mode()
295 { 223 {
296 // return Panels[LastFocusedPanel].Get_ShowNtfsStrems_Mode(); 224 // return Panels[LastFocusedPanel].Get_ShowNtfsStrems_Mode();
@@ -307,13 +235,13 @@ public:
307 Panels[i].Set_AutoRefresh_Mode(AutoRefresh_Mode); 235 Panels[i].Set_AutoRefresh_Mode(AutoRefresh_Mode);
308 } 236 }
309 237
310 void OpenBookmark(int index) { GetFocusedPanel().OpenBookmark(index); } 238 void OpenBookmark(unsigned index) { GetFocusedPanel().OpenBookmark(index); }
311 void SetBookmark(int index) { GetFocusedPanel().SetBookmark(index); } 239 void SetBookmark(unsigned index) { GetFocusedPanel().SetBookmark(index); }
312 240
313 void ReloadToolbars(); 241 void ReloadToolbars();
314 void ReadToolbar() 242 void ReadToolbar()
315 { 243 {
316 UInt32 mask = ReadToolbarsMask(); 244 const UInt32 mask = ReadToolbarsMask();
317 if (mask & ((UInt32)1 << 31)) 245 if (mask & ((UInt32)1 << 31))
318 { 246 {
319 ShowButtonsLables = !g_IsSmallScreen; 247 ShowButtonsLables = !g_IsSmallScreen;
diff --git a/CPP/7zip/UI/FileManager/AppState.h b/CPP/7zip/UI/FileManager/AppState.h
index cc88715..6630b96 100644
--- a/CPP/7zip/UI/FileManager/AppState.h
+++ b/CPP/7zip/UI/FileManager/AppState.h
@@ -1,7 +1,7 @@
1// AppState.h 1// AppState.h
2 2
3#ifndef __APP_STATE_H 3#ifndef ZIP7_INC_APP_STATE_H
4#define __APP_STATE_H 4#define ZIP7_INC_APP_STATE_H
5 5
6#include "../../../Windows/Synchronization.h" 6#include "../../../Windows/Synchronization.h"
7 7
diff --git a/CPP/7zip/UI/FileManager/BrowseDialog.cpp b/CPP/7zip/UI/FileManager/BrowseDialog.cpp
index 6d2b6b5..5170302 100644
--- a/CPP/7zip/UI/FileManager/BrowseDialog.cpp
+++ b/CPP/7zip/UI/FileManager/BrowseDialog.cpp
@@ -4,7 +4,7 @@
4 4
5#include "../../../Common/MyWindows.h" 5#include "../../../Common/MyWindows.h"
6 6
7#include <CommCtrl.h> 7#include "../../../Common/IntToString.h"
8 8
9#ifndef UNDER_CE 9#ifndef UNDER_CE
10#include "../../../Windows/CommonDialog.h" 10#include "../../../Windows/CommonDialog.h"
@@ -25,7 +25,6 @@
25#ifdef USE_MY_BROWSE_DIALOG 25#ifdef USE_MY_BROWSE_DIALOG
26 26
27#include "../../../Common/Defs.h" 27#include "../../../Common/Defs.h"
28#include "../../../Common/IntToString.h"
29#include "../../../Common/Wildcard.h" 28#include "../../../Common/Wildcard.h"
30 29
31#include "../../../Windows/FileDir.h" 30#include "../../../Windows/FileDir.h"
@@ -40,11 +39,11 @@
40#include "PropertyNameRes.h" 39#include "PropertyNameRes.h"
41#include "SysIconUtils.h" 40#include "SysIconUtils.h"
42 41
43#ifndef _SFX 42#ifndef Z7_SFX
44#include "RegistryUtils.h" 43#include "RegistryUtils.h"
45#endif 44#endif
46 45
47#endif 46#endif // USE_MY_BROWSE_DIALOG
48 47
49#include "ComboDialog.h" 48#include "ComboDialog.h"
50#include "LangUtils.h" 49#include "LangUtils.h"
@@ -56,6 +55,11 @@ using namespace NFile;
56using namespace NName; 55using namespace NName;
57using namespace NFind; 56using namespace NFind;
58 57
58static void MessageBox_Error_Global(HWND wnd, const wchar_t *message)
59{
60 ::MessageBoxW(wnd, message, L"7-Zip", MB_ICONERROR);
61}
62
59#ifdef USE_MY_BROWSE_DIALOG 63#ifdef USE_MY_BROWSE_DIALOG
60 64
61extern bool g_LVN_ITEMACTIVATE_Support; 65extern bool g_LVN_ITEMACTIVATE_Support;
@@ -63,19 +67,8 @@ extern bool g_LVN_ITEMACTIVATE_Support;
63static const int kParentIndex = -1; 67static const int kParentIndex = -1;
64static const UINT k_Message_RefreshPathEdit = WM_APP + 1; 68static const UINT k_Message_RefreshPathEdit = WM_APP + 1;
65 69
66static HRESULT GetNormalizedError()
67{
68 DWORD errorCode = GetLastError();
69 return errorCode == 0 ? E_FAIL : errorCode;
70}
71
72extern UString HResultToMessage(HRESULT errorCode); 70extern UString HResultToMessage(HRESULT errorCode);
73 71
74static void MessageBox_Error_Global(HWND wnd, const wchar_t *message)
75{
76 ::MessageBoxW(wnd, message, L"7-Zip", MB_ICONERROR);
77}
78
79static void MessageBox_HResError(HWND wnd, HRESULT errorCode, const wchar_t *name) 72static void MessageBox_HResError(HWND wnd, HRESULT errorCode, const wchar_t *name)
80{ 73{
81 UString s = HResultToMessage(errorCode); 74 UString s = HResultToMessage(errorCode);
@@ -98,17 +91,21 @@ class CBrowseDialog: public NControl::CModalDialog
98 CExtToIconMap _extToIconMap; 91 CExtToIconMap _extToIconMap;
99 int _sortIndex; 92 int _sortIndex;
100 bool _ascending; 93 bool _ascending;
94 #ifndef Z7_SFX
101 bool _showDots; 95 bool _showDots;
96 #endif
102 UString _topDirPrefix; // we don't open parent of that folder 97 UString _topDirPrefix; // we don't open parent of that folder
103 UString DirPrefix; 98 UString DirPrefix;
104 99
105 virtual bool OnInit(); 100 virtual bool OnInit() Z7_override;
106 virtual bool OnSize(WPARAM wParam, int xSize, int ySize); 101 virtual bool OnSize(WPARAM wParam, int xSize, int ySize) Z7_override;
107 virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam); 102 virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam) Z7_override;
108 virtual bool OnNotify(UINT controlID, LPNMHDR header); 103 virtual bool OnNotify(UINT controlID, LPNMHDR header) Z7_override;
109 virtual bool OnKeyDown(LPNMLVKEYDOWN keyDownInfo); 104 virtual bool OnCommand(unsigned code, unsigned itemID, LPARAM lParam) Z7_override;
110 virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); 105 virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
111 virtual void OnOK(); 106 virtual void OnOK() Z7_override;
107
108 bool OnKeyDown(LPNMLVKEYDOWN keyDownInfo);
112 109
113 void Post_RefreshPathEdit() { PostMsg(k_Message_RefreshPathEdit); } 110 void Post_RefreshPathEdit() { PostMsg(k_Message_RefreshPathEdit); }
114 111
@@ -126,59 +123,37 @@ class CBrowseDialog: public NControl::CModalDialog
126 int GetRealItemIndex(int indexInListView) const 123 int GetRealItemIndex(int indexInListView) const
127 { 124 {
128 LPARAM param; 125 LPARAM param;
129 if (!_list.GetItemParam(indexInListView, param)) 126 if (!_list.GetItemParam((unsigned)indexInListView, param))
130 return (int)-1; 127 return (int)-1;
131 return (int)param; 128 return (int)param;
132 } 129 }
133 130
134public: 131public:
132
133 bool SaveMode;
135 bool FolderMode; 134 bool FolderMode;
135 int FilterIndex; // [in / out]
136 CObjectVector<CBrowseFilterInfo> Filters;
137
138 UString FilePath; // [in / out]
136 UString Title; 139 UString Title;
137 UString FilePath; // input/ result path 140
138 bool ShowAllFiles; 141 CBrowseDialog():
139 UStringVector Filters; 142 #ifndef Z7_SFX
140 UString FilterDescription; 143 _showDots(false),
141 144 #endif
142 CBrowseDialog(): _showDots(false), FolderMode(false), ShowAllFiles(true) {} 145 SaveMode(false)
143 void SetFilter(const UString &s); 146 , FolderMode(false)
144 INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_BROWSE, parent); } 147 , FilterIndex(-1)
145 int CompareItems(LPARAM lParam1, LPARAM lParam2); 148 {}
149 INT_PTR Create(HWND parent = NULL) { return CModalDialog::Create(IDD_BROWSE, parent); }
150 int CompareItems(LPARAM lParam1, LPARAM lParam2) const;
146}; 151};
147 152
148void CBrowseDialog::SetFilter(const UString &s)
149{
150 Filters.Clear();
151 UString mask;
152 unsigned i;
153 for (i = 0; i < s.Len(); i++)
154 {
155 wchar_t c = s[i];
156 if (c == ';')
157 {
158 if (!mask.IsEmpty())
159 Filters.Add(mask);
160 mask.Empty();
161 }
162 else
163 mask += c;
164 }
165 if (!mask.IsEmpty())
166 Filters.Add(mask);
167 ShowAllFiles = Filters.IsEmpty();
168 for (i = 0; i < Filters.Size(); i++)
169 {
170 const UString &f = Filters[i];
171 if (f == L"*.*" || f == L"*")
172 {
173 ShowAllFiles = true;
174 break;
175 }
176 }
177}
178 153
179bool CBrowseDialog::OnInit() 154bool CBrowseDialog::OnInit()
180{ 155{
181 #ifdef LANG 156 #ifdef Z7_LANG
182 LangSetDlgItems(*this, NULL, 0); 157 LangSetDlgItems(*this, NULL, 0);
183 #endif 158 #endif
184 if (!Title.IsEmpty()) 159 if (!Title.IsEmpty())
@@ -187,16 +162,11 @@ bool CBrowseDialog::OnInit()
187 _filterCombo.Attach(GetItem(IDC_BROWSE_FILTER)); 162 _filterCombo.Attach(GetItem(IDC_BROWSE_FILTER));
188 _pathEdit.Attach(GetItem(IDE_BROWSE_PATH)); 163 _pathEdit.Attach(GetItem(IDE_BROWSE_PATH));
189 164
190 if (FolderMode)
191 HideItem(IDC_BROWSE_FILTER);
192 else
193 EnableItem(IDC_BROWSE_FILTER, false);
194
195 #ifndef UNDER_CE 165 #ifndef UNDER_CE
196 _list.SetUnicodeFormat(); 166 _list.SetUnicodeFormat();
197 #endif 167 #endif
198 168
199 #ifndef _SFX 169 #ifndef Z7_SFX
200 CFmSettings st; 170 CFmSettings st;
201 st.Load(); 171 st.Load();
202 if (st.SingleClick) 172 if (st.SingleClick)
@@ -205,22 +175,34 @@ bool CBrowseDialog::OnInit()
205 #endif 175 #endif
206 176
207 { 177 {
208 UString s; 178 /*
209 if (!FilterDescription.IsEmpty()) 179 Filters.Clear(); // for debug
210 s = FilterDescription; 180 if (Filters.IsEmpty() && !FolderMode)
211 else if (ShowAllFiles)
212 s = "*.*";
213 else
214 { 181 {
215 FOR_VECTOR (i, Filters) 182 CBrowseFilterInfo &f = Filters.AddNew();
216 { 183 const UString mask("*.*");
217 if (i != 0) 184 f.Masks.Add(mask);
218 s.Add_Space(); 185 // f.Description = "(";
219 s += Filters[i]; 186 f.Description += mask;
220 } 187 // f.Description += ")";
188 }
189 */
190
191 FOR_VECTOR (i, Filters)
192 {
193 _filterCombo.AddString(Filters[i].Description);
194 }
195
196 if (Filters.Size() <= 1)
197 {
198 if (FolderMode)
199 HideItem(IDC_BROWSE_FILTER);
200 else
201 EnableItem(IDC_BROWSE_FILTER, false);
221 } 202 }
222 _filterCombo.AddString(s); 203
223 _filterCombo.SetCurSel(0); 204 if (/* FilterIndex >= 0 && */ (unsigned)FilterIndex < Filters.Size())
205 _filterCombo.SetCurSel(FilterIndex);
224 } 206 }
225 207
226 _list.SetImageList(GetSysImageList(true), LVSIL_SMALL); 208 _list.SetImageList(GetSysImageList(true), LVSIL_SMALL);
@@ -261,7 +243,7 @@ bool CBrowseDialog::OnInit()
261 243
262 _topDirPrefix.Empty(); 244 _topDirPrefix.Empty();
263 { 245 {
264 int rootSize = GetRootPrefixSize(FilePath); 246 unsigned rootSize = GetRootPrefixSize(FilePath);
265 #if defined(_WIN32) && !defined(UNDER_CE) 247 #if defined(_WIN32) && !defined(UNDER_CE)
266 // We can go up from root folder to drives list 248 // We can go up from root folder to drives list
267 if (IsDrivePath(FilePath)) 249 if (IsDrivePath(FilePath))
@@ -301,7 +283,7 @@ bool CBrowseDialog::OnInit()
301 #ifndef UNDER_CE 283 #ifndef UNDER_CE
302 /* If we clear UISF_HIDEFOCUS, the focus rectangle in ListView will be visible, 284 /* If we clear UISF_HIDEFOCUS, the focus rectangle in ListView will be visible,
303 even if we use mouse for pressing the button to open this dialog. */ 285 even if we use mouse for pressing the button to open this dialog. */
304 PostMsg(MY__WM_UPDATEUISTATE, MAKEWPARAM(MY__UIS_CLEAR, MY__UISF_HIDEFOCUS)); 286 PostMsg(Z7_WIN_WM_UPDATEUISTATE, MAKEWPARAM(Z7_WIN_UIS_CLEAR, Z7_WIN_UISF_HIDEFOCUS));
305 #endif 287 #endif
306 288
307 return CModalDialog::OnInit(); 289 return CModalDialog::OnInit();
@@ -368,6 +350,24 @@ bool CBrowseDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
368 return CModalDialog::OnMessage(message, wParam, lParam); 350 return CModalDialog::OnMessage(message, wParam, lParam);
369} 351}
370 352
353
354bool CBrowseDialog::OnCommand(unsigned code, unsigned itemID, LPARAM lParam)
355{
356 if (code == CBN_SELCHANGE)
357 {
358 switch (itemID)
359 {
360 case IDC_BROWSE_FILTER:
361 {
362 Reload();
363 return true;
364 }
365 }
366 }
367 return CModalDialog::OnCommand(code, itemID, lParam);
368}
369
370
371bool CBrowseDialog::OnNotify(UINT /* controlID */, LPNMHDR header) 371bool CBrowseDialog::OnNotify(UINT /* controlID */, LPNMHDR header)
372{ 372{
373 if (header->hwndFrom != _list) 373 if (header->hwndFrom != _list)
@@ -385,7 +385,7 @@ bool CBrowseDialog::OnNotify(UINT /* controlID */, LPNMHDR header)
385 break; 385 break;
386 case LVN_COLUMNCLICK: 386 case LVN_COLUMNCLICK:
387 { 387 {
388 int index = LPNMLISTVIEW(header)->iSubItem; 388 const int index = LPNMLISTVIEW(header)->iSubItem;
389 if (index == _sortIndex) 389 if (index == _sortIndex)
390 _ascending = !_ascending; 390 _ascending = !_ascending;
391 else 391 else
@@ -413,7 +413,7 @@ bool CBrowseDialog::OnNotify(UINT /* controlID */, LPNMHDR header)
413 413
414bool CBrowseDialog::OnKeyDown(LPNMLVKEYDOWN keyDownInfo) 414bool CBrowseDialog::OnKeyDown(LPNMLVKEYDOWN keyDownInfo)
415{ 415{
416 bool ctrl = IsKeyDown(VK_CONTROL); 416 const bool ctrl = IsKeyDown(VK_CONTROL);
417 417
418 switch (keyDownInfo->wVKey) 418 switch (keyDownInfo->wVKey)
419 { 419 {
@@ -434,7 +434,8 @@ bool CBrowseDialog::OnKeyDown(LPNMLVKEYDOWN keyDownInfo)
434 return false; 434 return false;
435} 435}
436 436
437bool CBrowseDialog::OnButtonClicked(int buttonID, HWND buttonHWND) 437
438bool CBrowseDialog::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
438{ 439{
439 switch (buttonID) 440 switch (buttonID)
440 { 441 {
@@ -474,21 +475,21 @@ bool CBrowseDialog::GetParentPath(const UString &path, UString &parentPrefix, US
474 return false; 475 return false;
475 if (IS_PATH_SEPAR(s.Back())) 476 if (IS_PATH_SEPAR(s.Back()))
476 return false; 477 return false;
477 int pos = s.ReverseFind_PathSepar(); 478 const unsigned pos1 = (unsigned)(s.ReverseFind_PathSepar() + 1);
478 parentPrefix.SetFrom(s, pos + 1); 479 parentPrefix.SetFrom(s, pos1);
479 name = s.Ptr((unsigned)(pos + 1)); 480 name = s.Ptr(pos1);
480 return true; 481 return true;
481} 482}
482 483
483int CBrowseDialog::CompareItems(LPARAM lParam1, LPARAM lParam2) 484int CBrowseDialog::CompareItems(LPARAM lParam1, LPARAM lParam2) const
484{ 485{
485 if (lParam1 == kParentIndex) return -1; 486 if (lParam1 == kParentIndex) return -1;
486 if (lParam2 == kParentIndex) return 1; 487 if (lParam2 == kParentIndex) return 1;
487 const CFileInfo &f1 = _files[(int)lParam1]; 488 const CFileInfo &f1 = _files[(int)lParam1];
488 const CFileInfo &f2 = _files[(int)lParam2]; 489 const CFileInfo &f2 = _files[(int)lParam2];
489 490
490 bool isDir1 = f1.IsDir(); 491 const bool isDir1 = f1.IsDir();
491 bool isDir2 = f2.IsDir(); 492 const bool isDir2 = f2.IsDir();
492 if (isDir1 && !isDir2) return -1; 493 if (isDir1 && !isDir2) return -1;
493 if (isDir2 && !isDir1) return 1; 494 if (isDir2 && !isDir1) return 1;
494 495
@@ -509,16 +510,16 @@ static int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
509 510
510static void ConvertSizeToString(UInt64 v, wchar_t *s) 511static void ConvertSizeToString(UInt64 v, wchar_t *s)
511{ 512{
512 Byte c = 0; 513 char c = 0;
513 if (v >= ((UInt64)10000 << 20)) { v >>= 30; c = 'G'; } 514 if (v >= ((UInt64)10000 << 20)) { v >>= 30; c = 'G'; }
514 else if (v >= ((UInt64)10000 << 10)) { v >>= 20; c = 'M'; } 515 else if (v >= ((UInt64)10000 << 10)) { v >>= 20; c = 'M'; }
515 else if (v >= ((UInt64)10000 << 0)) { v >>= 10; c = 'K'; } 516 else if (v >= ((UInt64)10000 << 0)) { v >>= 10; c = 'K'; }
516 ConvertUInt64ToString(v, s); 517 s = ConvertUInt64ToString(v, s);
517 if (c != 0) 518 if (c != 0)
518 { 519 {
519 s += MyStringLen(s);
520 *s++ = ' '; 520 *s++ = ' ';
521 *s++ = c; 521 *s++ = (wchar_t)c;
522 *s++ = 'B';
522 *s++ = 0; 523 *s++ = 0;
523 } 524 }
524} 525}
@@ -536,42 +537,57 @@ HRESULT CBrowseDialog::Reload(const UString &pathPrefix, const UString &selected
536 isDrive = true; 537 isDrive = true;
537 FStringVector drives; 538 FStringVector drives;
538 if (!MyGetLogicalDriveStrings(drives)) 539 if (!MyGetLogicalDriveStrings(drives))
539 return GetNormalizedError(); 540 return GetLastError_noZero_HRESULT();
540 FOR_VECTOR (i, drives) 541 FOR_VECTOR (i, drives)
541 { 542 {
542 FString d = drives[i]; 543 const FString &d = drives[i];
543 if (d.Len() < 3 || d.Back() != '\\') 544 if (d.Len() < 2 || d.Back() != '\\')
544 return E_FAIL; 545 return E_FAIL;
545 d.DeleteBack();
546 CFileInfo &fi = files.AddNew(); 546 CFileInfo &fi = files.AddNew();
547 fi.SetAsDir(); 547 fi.SetAsDir();
548 fi.Name = d; 548 fi.Name = d;
549 fi.Name.DeleteBack();
549 } 550 }
550 } 551 }
551 else 552 else
552 #endif 553 #endif
553 { 554 {
555 const UStringVector *masks = NULL;
556 if (!Filters.IsEmpty() && _filterCombo.GetCount() > 0)
557 {
558 const int selected = _filterCombo.GetCurSel();
559 // GetItemData_of_CurSel(); // we don't use data field
560 if (/* selected >= 0 && */ (unsigned)selected < Filters.Size())
561 {
562 const UStringVector &m = Filters[selected].Masks;
563 if (m.Size() > 1 || (m.Size() == 1
564 && !m[0].IsEqualTo("*.*")
565 && !m[0].IsEqualTo("*")))
566 masks = &m;
567 }
568 }
554 CEnumerator enumerator; 569 CEnumerator enumerator;
555 enumerator.SetDirPrefix(us2fs(pathPrefix)); 570 enumerator.SetDirPrefix(us2fs(pathPrefix));
571 CFileInfo fi;
556 for (;;) 572 for (;;)
557 { 573 {
558 bool found; 574 bool found;
559 CFileInfo fi;
560 if (!enumerator.Next(fi, found)) 575 if (!enumerator.Next(fi, found))
561 return GetNormalizedError(); 576 return GetLastError_noZero_HRESULT();
562 if (!found) 577 if (!found)
563 break; 578 break;
564 if (!fi.IsDir()) 579 if (!fi.IsDir())
565 { 580 {
566 if (FolderMode) 581 if (FolderMode)
567 continue; 582 continue;
568 if (!ShowAllFiles) 583 if (masks)
569 { 584 {
570 unsigned i; 585 unsigned i;
571 for (i = 0; i < Filters.Size(); i++) 586 const unsigned numMasks = masks->Size();
572 if (DoesWildcardMatchName(Filters[i], fs2us(fi.Name))) 587 for (i = 0; i < numMasks; i++)
588 if (DoesWildcardMatchName((*masks)[i], fs2us(fi.Name)))
573 break; 589 break;
574 if (i == Filters.Size()) 590 if (i == numMasks)
575 continue; 591 continue;
576 } 592 }
577 } 593 }
@@ -590,19 +606,19 @@ HRESULT CBrowseDialog::Reload(const UString &pathPrefix, const UString &selected
590 606
591 LVITEMW item; 607 LVITEMW item;
592 608
593 int index = 0; 609 unsigned index = 0;
594 int cursorIndex = -1; 610 int cursorIndex = -1;
595 611
596 #ifndef _SFX 612 #ifndef Z7_SFX
597 if (_showDots && _topDirPrefix != DirPrefix) 613 if (_showDots && _topDirPrefix != DirPrefix)
598 { 614 {
599 item.iItem = index; 615 item.iItem = (int)index;
600 const UString itemName (".."); 616 const UString itemName ("..");
601 if (selectedName.IsEmpty()) 617 if (selectedName.IsEmpty())
602 cursorIndex = index; 618 cursorIndex = (int)index;
603 item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; 619 item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
604 int subItem = 0; 620 unsigned subItem = 0;
605 item.iSubItem = subItem++; 621 item.iSubItem = (int)(subItem++);
606 item.lParam = kParentIndex; 622 item.lParam = kParentIndex;
607 item.pszText = itemName.Ptr_non_const(); 623 item.pszText = itemName.Ptr_non_const();
608 item.iImage = _extToIconMap.GetIconIndex(FILE_ATTRIBUTE_DIRECTORY, DirPrefix); 624 item.iImage = _extToIconMap.GetIconIndex(FILE_ATTRIBUTE_DIRECTORY, DirPrefix);
@@ -617,15 +633,15 @@ HRESULT CBrowseDialog::Reload(const UString &pathPrefix, const UString &selected
617 633
618 for (unsigned i = 0; i < _files.Size(); i++, index++) 634 for (unsigned i = 0; i < _files.Size(); i++, index++)
619 { 635 {
620 item.iItem = index; 636 item.iItem = (int)index;
621 const CFileInfo &fi = _files[i]; 637 const CFileInfo &fi = _files[i];
622 const UString name = fs2us(fi.Name); 638 const UString name = fs2us(fi.Name);
623 if (!selectedName.IsEmpty() && CompareFileNames(name, selectedName) == 0) 639 if (!selectedName.IsEmpty() && CompareFileNames(name, selectedName) == 0)
624 cursorIndex = index; 640 cursorIndex = (int)index;
625 item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; 641 item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
626 int subItem = 0; 642 unsigned subItem = 0;
627 item.iSubItem = subItem++; 643 item.iSubItem = (int)(subItem++);
628 item.lParam = i; 644 item.lParam = (LPARAM)i;
629 item.pszText = name.Ptr_non_const(); 645 item.pszText = name.Ptr_non_const();
630 646
631 const UString fullPath = DirPrefix + name; 647 const UString fullPath = DirPrefix + name;
@@ -675,14 +691,14 @@ HRESULT CBrowseDialog::Reload(const UString &pathPrefix, const UString &selected
675HRESULT CBrowseDialog::Reload() 691HRESULT CBrowseDialog::Reload()
676{ 692{
677 UString selected; 693 UString selected;
678 int index = _list.GetNextSelectedItem(-1); 694 const int index = _list.GetNextSelectedItem(-1);
679 if (index >= 0) 695 if (index >= 0)
680 { 696 {
681 int fileIndex = GetRealItemIndex(index); 697 const int fileIndex = GetRealItemIndex(index);
682 if (fileIndex != kParentIndex) 698 if (fileIndex != kParentIndex)
683 selected = fs2us(_files[fileIndex].Name); 699 selected = fs2us(_files[fileIndex].Name);
684 } 700 }
685 UString dirPathTemp = DirPrefix; 701 const UString dirPathTemp = DirPrefix;
686 return Reload(dirPathTemp, selected); 702 return Reload(dirPathTemp, selected);
687} 703}
688 704
@@ -698,14 +714,14 @@ void CBrowseDialog::OpenParentFolder()
698 714
699void CBrowseDialog::SetPathEditText() 715void CBrowseDialog::SetPathEditText()
700{ 716{
701 int index = _list.GetNextSelectedItem(-1); 717 const int index = _list.GetNextSelectedItem(-1);
702 if (index < 0) 718 if (index < 0)
703 { 719 {
704 if (FolderMode) 720 if (FolderMode)
705 _pathEdit.SetText(DirPrefix); 721 _pathEdit.SetText(DirPrefix);
706 return; 722 return;
707 } 723 }
708 int fileIndex = GetRealItemIndex(index); 724 const int fileIndex = GetRealItemIndex(index);
709 if (fileIndex == kParentIndex) 725 if (fileIndex == kParentIndex)
710 { 726 {
711 if (FolderMode) 727 if (FolderMode)
@@ -745,7 +761,7 @@ void CBrowseDialog::OnCreateDir()
745 { 761 {
746 if (!NDir::CreateComplexDir(destPath)) 762 if (!NDir::CreateComplexDir(destPath))
747 { 763 {
748 MessageBox_HResError((HWND)*this, GetNormalizedError(), fs2us(destPath)); 764 MessageBox_HResError((HWND)*this, GetLastError_noZero_HRESULT(), fs2us(destPath));
749 } 765 }
750 else 766 else
751 { 767 {
@@ -759,10 +775,10 @@ void CBrowseDialog::OnCreateDir()
759 775
760void CBrowseDialog::OnItemEnter() 776void CBrowseDialog::OnItemEnter()
761{ 777{
762 int index = _list.GetNextSelectedItem(-1); 778 const int index = _list.GetNextSelectedItem(-1);
763 if (index < 0) 779 if (index < 0)
764 return; 780 return;
765 int fileIndex = GetRealItemIndex(index); 781 const int fileIndex = GetRealItemIndex(index);
766 if (fileIndex == kParentIndex) 782 if (fileIndex == kParentIndex)
767 OpenParentFolder(); 783 OpenParentFolder();
768 else 784 else
@@ -782,7 +798,7 @@ void CBrowseDialog::OnItemEnter()
782 UString s = DirPrefix; 798 UString s = DirPrefix;
783 s += fs2us(file.Name); 799 s += fs2us(file.Name);
784 s.Add_PathSepar(); 800 s.Add_PathSepar();
785 HRESULT res = Reload(s, UString()); 801 const HRESULT res = Reload(s, UString());
786 if (res != S_OK) 802 if (res != S_OK)
787 MessageBox_HResError(*this, res, s); 803 MessageBox_HResError(*this, res, s);
788 SetPathEditText(); 804 SetPathEditText();
@@ -802,10 +818,13 @@ void CBrowseDialog::FinishOnOK()
802 FilePath = fs2us(destPath); 818 FilePath = fs2us(destPath);
803 if (FolderMode) 819 if (FolderMode)
804 NormalizeDirPathPrefix(FilePath); 820 NormalizeDirPathPrefix(FilePath);
821 FilterIndex = _filterCombo.GetCurSel();
805 End(IDOK); 822 End(IDOK);
806} 823}
807 824
808#endif 825#endif // USE_MY_BROWSE_DIALOG
826
827
809 828
810bool MyBrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR path, UString &resultPath) 829bool MyBrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR path, UString &resultPath)
811{ 830{
@@ -813,12 +832,13 @@ bool MyBrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR path, UString &resultP
813 832
814 #ifndef UNDER_CE 833 #ifndef UNDER_CE
815 834
816 #ifdef USE_MY_BROWSE_DIALOG 835#ifdef USE_MY_BROWSE_DIALOG
817 if (!IsSuperOrDevicePath(path)) 836 if (!IsSuperOrDevicePath(path))
818 #endif 837 if (MyStringLen(path) < MAX_PATH)
838#endif
819 return NShell::BrowseForFolder(owner, title, path, resultPath); 839 return NShell::BrowseForFolder(owner, title, path, resultPath);
820 840
821 #endif 841 #endif // UNDER_CE
822 842
823 #ifdef USE_MY_BROWSE_DIALOG 843 #ifdef USE_MY_BROWSE_DIALOG
824 844
@@ -831,64 +851,107 @@ bool MyBrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR path, UString &resultP
831 if (dialog.Create(owner) != IDOK) 851 if (dialog.Create(owner) != IDOK)
832 return false; 852 return false;
833 resultPath = dialog.FilePath; 853 resultPath = dialog.FilePath;
834 #endif
835
836 return true; 854 return true;
855
856 #endif
837} 857}
838 858
839bool MyBrowseForFile(HWND owner, LPCWSTR title, LPCWSTR path,
840 LPCWSTR filterDescription, LPCWSTR filter, UString &resultPath)
841{
842 resultPath.Empty();
843 859
844 #ifndef UNDER_CE 860// LPCWSTR filterDescription, LPCWSTR filter,
845 861
846 #ifdef USE_MY_BROWSE_DIALOG 862bool CBrowseInfo::BrowseForFile(const CObjectVector<CBrowseFilterInfo> &filters)
847 if (!IsSuperOrDevicePath(path)) 863{
848 #endif 864#ifndef UNDER_CE
865#ifdef USE_MY_BROWSE_DIALOG
866 /* win10:
867 GetOpenFileName() for FilePath doesn't support super prefix "\\\\?\\"
868 GetOpenFileName() for FilePath doesn't support long path
869 */
870 if (!IsSuperOrDevicePath(FilePath))
871 // if (filters.Size() > 100) // for debug
872#endif
849 { 873 {
850 if (MyGetOpenFileName(owner, title, NULL, path, filterDescription, filter, resultPath)) 874 const UString filePath_Store = FilePath;
875 UString dirPrefix;
876 {
877 FString prefix, name;
878 if (NDir::GetFullPathAndSplit(us2fs(FilePath), prefix, name))
879 {
880 dirPrefix = fs2us(prefix);
881 FilePath = fs2us(name);
882 }
883 }
884 UStringVector filters2;
885 FOR_VECTOR (i, filters)
886 {
887 const CBrowseFilterInfo &fi = filters[i];
888 filters2.Add(fi.Description);
889 UString s;
890 FOR_VECTOR (k, fi.Masks)
891 {
892 if (k != 0)
893 s += ";";
894 s += fi.Masks[k];
895 }
896 filters2.Add(s);
897 }
898 if (CommonDlg_BrowseForFile(!dirPrefix.IsEmpty() ? dirPrefix.Ptr(): NULL, filters2))
851 return true; 899 return true;
852 #ifdef UNDER_CE 900 FilePath = filePath_Store;
901
902 #ifdef UNDER_CE
853 return false; 903 return false;
854 #else 904 #else
855 // maybe we must use GetLastError in WinCE. 905 // maybe we must use GetLastError in WinCE.
856 DWORD errorCode = CommDlgExtendedError(); 906 const DWORD errorCode = CommDlgExtendedError();
857 const char *errorMessage = NULL; 907 #ifdef USE_MY_BROWSE_DIALOG
858 switch (errorCode) 908 // FNERR_INVALIDFILENAME is expected error, if long path was used
859 { 909 if (errorCode != FNERR_INVALIDFILENAME
860 case 0: return false; // cancel or close obn dialog 910 || FilePath.Len() < MAX_PATH)
861 case FNERR_INVALIDFILENAME: errorMessage = "Invalid File Name"; break; 911 #endif
862 default: errorMessage = "Open Dialog Error";
863 }
864 if (!errorMessage)
865 return false;
866 { 912 {
867 UString s (errorMessage); 913 if (errorCode == 0) // cancel or close on dialog
914 return false;
915 const char *message = NULL;
916 if (errorCode == FNERR_INVALIDFILENAME)
917 message = "Invalid file name";
918 UString s ("Open Dialog Error:");
919 s.Add_LF();
920 if (message)
921 s += message;
922 else
923 {
924 char temp[16];
925 ConvertUInt32ToHex8Digits(errorCode, temp);
926 s += "Error #";
927 s += temp;
928 }
868 s.Add_LF(); 929 s.Add_LF();
869 s += path; 930 s += FilePath;
870 MessageBox_Error_Global(owner, s); 931 MessageBox_Error_Global(hwndOwner, s);
871 } 932 }
872 #endif 933 #endif // UNDER_CE
873 } 934 }
874 935
875 #endif 936#endif // UNDER_CE
876 937
877 #ifdef USE_MY_BROWSE_DIALOG 938#ifdef USE_MY_BROWSE_DIALOG
939
878 CBrowseDialog dialog; 940 CBrowseDialog dialog;
879 if (title) 941
880 dialog.Title = title;
881 if (path)
882 dialog.FilePath = path;
883 dialog.FolderMode = false; 942 dialog.FolderMode = false;
884 if (filter) 943 dialog.SaveMode = SaveMode;
885 dialog.SetFilter(filter); 944 dialog.FilterIndex = FilterIndex;
886 if (filterDescription) 945 dialog.Filters = filters;
887 dialog.FilterDescription = filterDescription; 946
888 if (dialog.Create(owner) != IDOK) 947 if (lpstrTitle)
948 dialog.Title = lpstrTitle;
949 dialog.FilePath = FilePath;
950 if (dialog.Create(hwndOwner) != IDOK)
889 return false; 951 return false;
890 resultPath = dialog.FilePath; 952 FilePath = dialog.FilePath;
891 #endif 953 FilterIndex = dialog.FilterIndex;
954#endif
892 955
893 return true; 956 return true;
894} 957}
@@ -913,7 +976,9 @@ bool CorrectFsPath(const UString &relBase, const UString &path2, UString &result
913 result.Empty(); 976 result.Empty();
914 977
915 UString path = path2; 978 UString path = path2;
979 #ifdef _WIN32
916 path.Replace(L'/', WCHAR_PATH_SEPARATOR); 980 path.Replace(L'/', WCHAR_PATH_SEPARATOR);
981 #endif
917 unsigned start = 0; 982 unsigned start = 0;
918 UString base; 983 UString base;
919 984
@@ -926,9 +991,7 @@ bool CorrectFsPath(const UString &relBase, const UString &path2, UString &result
926 return true; 991 return true;
927 } 992 }
928 #endif 993 #endif
929 int pos = GetRootPrefixSize(path); 994 start = GetRootPrefixSize(path);
930 if (pos > 0)
931 start = pos;
932 } 995 }
933 else 996 else
934 { 997 {
@@ -973,8 +1036,8 @@ bool CorrectFsPath(const UString &relBase, const UString &path2, UString &result
973 { 1036 {
974 if (start == path.Len()) 1037 if (start == path.Len())
975 break; 1038 break;
976 int slashPos = path.Find(WCHAR_PATH_SEPARATOR, start); 1039 const int slashPos = path.Find(WCHAR_PATH_SEPARATOR, start);
977 cur.SetFrom(path.Ptr(start), (slashPos < 0 ? path.Len() : slashPos) - start); 1040 cur.SetFrom(path.Ptr(start), (slashPos < 0 ? path.Len() : (unsigned)slashPos) - start);
978 if (checkExist) 1041 if (checkExist)
979 { 1042 {
980 CFileInfo fi; 1043 CFileInfo fi;
@@ -994,8 +1057,8 @@ bool CorrectFsPath(const UString &relBase, const UString &path2, UString &result
994 result += cur; 1057 result += cur;
995 if (slashPos < 0) 1058 if (slashPos < 0)
996 break; 1059 break;
1060 start = (unsigned)(slashPos + 1);
997 result.Add_PathSepar(); 1061 result.Add_PathSepar();
998 start = slashPos + 1;
999 } 1062 }
1000 1063
1001 return true; 1064 return true;
diff --git a/CPP/7zip/UI/FileManager/BrowseDialog.h b/CPP/7zip/UI/FileManager/BrowseDialog.h
index 957af2e..2ad8d54 100644
--- a/CPP/7zip/UI/FileManager/BrowseDialog.h
+++ b/CPP/7zip/UI/FileManager/BrowseDialog.h
@@ -1,12 +1,23 @@
1// BrowseDialog.h 1// BrowseDialog.h
2 2
3#ifndef __BROWSE_DIALOG_H 3#ifndef ZIP7_INC_BROWSE_DIALOG_H
4#define __BROWSE_DIALOG_H 4#define ZIP7_INC_BROWSE_DIALOG_H
5 5
6#include "../../../Common/MyString.h" 6#include "../../../Windows/CommonDialog.h"
7 7
8bool MyBrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR path, UString &resultPath); 8bool MyBrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR path, UString &resultPath);
9bool MyBrowseForFile(HWND owner, LPCWSTR title, LPCWSTR path, LPCWSTR filterDescription, LPCWSTR filter, UString &resultPath); 9
10struct CBrowseFilterInfo
11{
12 UStringVector Masks;
13 UString Description;
14};
15
16struct CBrowseInfo: public NWindows::CCommonDialogInfo
17{
18 bool BrowseForFile(const CObjectVector<CBrowseFilterInfo> &filters);
19};
20
10 21
11/* CorrectFsPath removes undesirable characters in names (dots and spaces at the end of file) 22/* CorrectFsPath removes undesirable characters in names (dots and spaces at the end of file)
12 But it doesn't change "bad" name in any of the following cases: 23 But it doesn't change "bad" name in any of the following cases:
diff --git a/CPP/7zip/UI/FileManager/ComboDialog.cpp b/CPP/7zip/UI/FileManager/ComboDialog.cpp
index 729743e..921972e 100644
--- a/CPP/7zip/UI/FileManager/ComboDialog.cpp
+++ b/CPP/7zip/UI/FileManager/ComboDialog.cpp
@@ -5,7 +5,7 @@
5 5
6#include "../../../Windows/Control/Static.h" 6#include "../../../Windows/Control/Static.h"
7 7
8#ifdef LANG 8#ifdef Z7_LANG
9#include "LangUtils.h" 9#include "LangUtils.h"
10#endif 10#endif
11 11
@@ -13,7 +13,7 @@ using namespace NWindows;
13 13
14bool CComboDialog::OnInit() 14bool CComboDialog::OnInit()
15{ 15{
16 #ifdef LANG 16 #ifdef Z7_LANG
17 LangSetDlgItems(*this, NULL, 0); 17 LangSetDlgItems(*this, NULL, 0);
18 #endif 18 #endif
19 _comboBox.Attach(GetItem(IDC_COMBO)); 19 _comboBox.Attach(GetItem(IDC_COMBO));
diff --git a/CPP/7zip/UI/FileManager/ComboDialog.h b/CPP/7zip/UI/FileManager/ComboDialog.h
index 29b28b5..bb0fda8 100644
--- a/CPP/7zip/UI/FileManager/ComboDialog.h
+++ b/CPP/7zip/UI/FileManager/ComboDialog.h
@@ -1,7 +1,7 @@
1// ComboDialog.h 1// ComboDialog.h
2 2
3#ifndef __COMBO_DIALOG_H 3#ifndef ZIP7_INC_COMBO_DIALOG_H
4#define __COMBO_DIALOG_H 4#define ZIP7_INC_COMBO_DIALOG_H
5 5
6#include "../../../Windows/Control/ComboBox.h" 6#include "../../../Windows/Control/ComboBox.h"
7#include "../../../Windows/Control/Dialog.h" 7#include "../../../Windows/Control/Dialog.h"
@@ -11,9 +11,9 @@
11class CComboDialog: public NWindows::NControl::CModalDialog 11class CComboDialog: public NWindows::NControl::CModalDialog
12{ 12{
13 NWindows::NControl::CComboBox _comboBox; 13 NWindows::NControl::CComboBox _comboBox;
14 virtual void OnOK(); 14 virtual void OnOK() Z7_override;
15 virtual bool OnInit(); 15 virtual bool OnInit() Z7_override;
16 virtual bool OnSize(WPARAM wParam, int xSize, int ySize); 16 virtual bool OnSize(WPARAM wParam, int xSize, int ySize) Z7_override;
17public: 17public:
18 // bool Sorted; 18 // bool Sorted;
19 UString Title; 19 UString Title;
@@ -22,7 +22,7 @@ public:
22 UStringVector Strings; 22 UStringVector Strings;
23 23
24 // CComboDialog(): Sorted(false) {}; 24 // CComboDialog(): Sorted(false) {};
25 INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_COMBO, parentWindow); } 25 INT_PTR Create(HWND parentWindow = NULL) { return CModalDialog::Create(IDD_COMBO, parentWindow); }
26}; 26};
27 27
28#endif 28#endif
diff --git a/CPP/7zip/UI/FileManager/CopyDialog.cpp b/CPP/7zip/UI/FileManager/CopyDialog.cpp
index 4b17110..9bc01d0 100644
--- a/CPP/7zip/UI/FileManager/CopyDialog.cpp
+++ b/CPP/7zip/UI/FileManager/CopyDialog.cpp
@@ -8,16 +8,13 @@
8 8
9#include "BrowseDialog.h" 9#include "BrowseDialog.h"
10#include "CopyDialog.h" 10#include "CopyDialog.h"
11
12#ifdef LANG
13#include "LangUtils.h" 11#include "LangUtils.h"
14#endif
15 12
16using namespace NWindows; 13using namespace NWindows;
17 14
18bool CCopyDialog::OnInit() 15bool CCopyDialog::OnInit()
19{ 16{
20 #ifdef LANG 17 #ifdef Z7_LANG
21 LangSetDlgItems(*this, NULL, 0); 18 LangSetDlgItems(*this, NULL, 0);
22 #endif 19 #endif
23 _path.Attach(GetItem(IDC_COPY)); 20 _path.Attach(GetItem(IDC_COPY));
@@ -45,15 +42,15 @@ bool CCopyDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
45 int bx1, bx2, by; 42 int bx1, bx2, by;
46 GetItemSizes(IDCANCEL, bx1, by); 43 GetItemSizes(IDCANCEL, bx1, by);
47 GetItemSizes(IDOK, bx2, by); 44 GetItemSizes(IDOK, bx2, by);
48 int y = ySize - my - by; 45 const int y = ySize - my - by;
49 int x = xSize - mx - bx1; 46 const int x = xSize - mx - bx1;
50 47
51 InvalidateRect(NULL); 48 InvalidateRect(NULL);
52 49
53 { 50 {
54 RECT r; 51 RECT r;
55 GetClientRectOfItem(IDB_COPY_SET_PATH, r); 52 GetClientRectOfItem(IDB_COPY_SET_PATH, r);
56 int bx = RECT_SIZE_X(r); 53 const int bx = RECT_SIZE_X(r);
57 MoveItem(IDB_COPY_SET_PATH, xSize - mx - bx, r.top, bx, RECT_SIZE_Y(r)); 54 MoveItem(IDB_COPY_SET_PATH, xSize - mx - bx, r.top, bx, RECT_SIZE_Y(r));
58 ChangeSubWindowSizeX(_path, xSize - mx - mx - bx - mx); 55 ChangeSubWindowSizeX(_path, xSize - mx - mx - bx - mx);
59 } 56 }
@@ -63,7 +60,7 @@ bool CCopyDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
63 GetClientRectOfItem(IDT_COPY_INFO, r); 60 GetClientRectOfItem(IDT_COPY_INFO, r);
64 NControl::CStatic staticContol; 61 NControl::CStatic staticContol;
65 staticContol.Attach(GetItem(IDT_COPY_INFO)); 62 staticContol.Attach(GetItem(IDT_COPY_INFO));
66 int yPos = r.top; 63 const int yPos = r.top;
67 staticContol.Move(mx, yPos, xSize - mx * 2, y - 2 - yPos); 64 staticContol.Move(mx, yPos, xSize - mx * 2, y - 2 - yPos);
68 } 65 }
69 66
@@ -73,7 +70,7 @@ bool CCopyDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
73 return false; 70 return false;
74} 71}
75 72
76bool CCopyDialog::OnButtonClicked(int buttonID, HWND buttonHWND) 73bool CCopyDialog::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
77{ 74{
78 switch (buttonID) 75 switch (buttonID)
79 { 76 {
diff --git a/CPP/7zip/UI/FileManager/CopyDialog.h b/CPP/7zip/UI/FileManager/CopyDialog.h
index 30fde71..3782420 100644
--- a/CPP/7zip/UI/FileManager/CopyDialog.h
+++ b/CPP/7zip/UI/FileManager/CopyDialog.h
@@ -1,7 +1,7 @@
1// CopyDialog.h 1// CopyDialog.h
2 2
3#ifndef __COPY_DIALOG_H 3#ifndef ZIP7_INC_COPY_DIALOG_H
4#define __COPY_DIALOG_H 4#define ZIP7_INC_COPY_DIALOG_H
5 5
6#include "../../../Windows/Control/ComboBox.h" 6#include "../../../Windows/Control/ComboBox.h"
7#include "../../../Windows/Control/Dialog.h" 7#include "../../../Windows/Control/Dialog.h"
@@ -13,11 +13,11 @@ const int kCopyDialog_NumInfoLines = 11;
13class CCopyDialog: public NWindows::NControl::CModalDialog 13class CCopyDialog: public NWindows::NControl::CModalDialog
14{ 14{
15 NWindows::NControl::CComboBox _path; 15 NWindows::NControl::CComboBox _path;
16 virtual void OnOK(); 16 virtual void OnOK() Z7_override;
17 virtual bool OnInit(); 17 virtual bool OnInit() Z7_override;
18 virtual bool OnSize(WPARAM wParam, int xSize, int ySize); 18 virtual bool OnSize(WPARAM wParam, int xSize, int ySize) Z7_override;
19 virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
19 void OnButtonSetPath(); 20 void OnButtonSetPath();
20 bool OnButtonClicked(int buttonID, HWND buttonHWND);
21public: 21public:
22 UString Title; 22 UString Title;
23 UString Static; 23 UString Static;
@@ -25,7 +25,7 @@ public:
25 UString Info; 25 UString Info;
26 UStringVector Strings; 26 UStringVector Strings;
27 27
28 INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_COPY, parentWindow); } 28 INT_PTR Create(HWND parentWindow = NULL) { return CModalDialog::Create(IDD_COPY, parentWindow); }
29}; 29};
30 30
31#endif 31#endif
diff --git a/CPP/7zip/UI/FileManager/DialogSize.h b/CPP/7zip/UI/FileManager/DialogSize.h
index 504541b..9f2270b 100644
--- a/CPP/7zip/UI/FileManager/DialogSize.h
+++ b/CPP/7zip/UI/FileManager/DialogSize.h
@@ -1,7 +1,7 @@
1// DialogSize.h 1// DialogSize.h
2 2
3#ifndef __DIALOG_SIZE_H 3#ifndef ZIP7_INC_DIALOG_SIZE_H
4#define __DIALOG_SIZE_H 4#define ZIP7_INC_DIALOG_SIZE_H
5 5
6#include "../../../Windows/Control/Dialog.h" 6#include "../../../Windows/Control/Dialog.h"
7 7
diff --git a/CPP/7zip/UI/FileManager/EditDialog.cpp b/CPP/7zip/UI/FileManager/EditDialog.cpp
index 7f59672..e97d9ea 100644
--- a/CPP/7zip/UI/FileManager/EditDialog.cpp
+++ b/CPP/7zip/UI/FileManager/EditDialog.cpp
@@ -4,13 +4,13 @@
4 4
5#include "EditDialog.h" 5#include "EditDialog.h"
6 6
7#ifdef LANG 7#ifdef Z7_LANG
8#include "LangUtils.h" 8#include "LangUtils.h"
9#endif 9#endif
10 10
11bool CEditDialog::OnInit() 11bool CEditDialog::OnInit()
12{ 12{
13 #ifdef LANG 13 #ifdef Z7_LANG
14 LangSetDlgItems(*this, NULL, 0); 14 LangSetDlgItems(*this, NULL, 0);
15 #endif 15 #endif
16 _edit.Attach(GetItem(IDE_EDIT)); 16 _edit.Attach(GetItem(IDE_EDIT));
@@ -22,21 +22,21 @@ bool CEditDialog::OnInit()
22 return CModalDialog::OnInit(); 22 return CModalDialog::OnInit();
23} 23}
24 24
25// #define MY_CLOSE_BUTTON__ID IDCANCEL 25// #define MY_CLOSE_BUTTON_ID IDCANCEL
26#define MY_CLOSE_BUTTON__ID IDCLOSE 26#define MY_CLOSE_BUTTON_ID IDCLOSE
27 27
28bool CEditDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) 28bool CEditDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
29{ 29{
30 int mx, my; 30 int mx, my;
31 GetMargins(8, mx, my); 31 GetMargins(8, mx, my);
32 int bx1, by; 32 int bx1, by;
33 GetItemSizes(MY_CLOSE_BUTTON__ID, bx1, by); 33 GetItemSizes(MY_CLOSE_BUTTON_ID, bx1, by);
34 34
35 // int bx2; 35 // int bx2;
36 // GetItemSizes(IDOK, bx2, by); 36 // GetItemSizes(IDOK, bx2, by);
37 37
38 int y = ySize - my - by; 38 const int y = ySize - my - by;
39 int x = xSize - mx - bx1; 39 const int x = xSize - mx - bx1;
40 40
41 /* 41 /*
42 RECT rect; 42 RECT rect;
@@ -46,7 +46,7 @@ bool CEditDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
46 */ 46 */
47 InvalidateRect(NULL); 47 InvalidateRect(NULL);
48 48
49 MoveItem(MY_CLOSE_BUTTON__ID, x, y, bx1, by); 49 MoveItem(MY_CLOSE_BUTTON_ID, x, y, bx1, by);
50 // MoveItem(IDOK, x - mx - bx2, y, bx2, by); 50 // MoveItem(IDOK, x - mx - bx2, y, bx2, by);
51 /* 51 /*
52 if (wParam == SIZE_MAXSHOW || wParam == SIZE_MAXIMIZED || wParam == SIZE_MAXHIDE) 52 if (wParam == SIZE_MAXSHOW || wParam == SIZE_MAXIMIZED || wParam == SIZE_MAXHIDE)
diff --git a/CPP/7zip/UI/FileManager/EditDialog.h b/CPP/7zip/UI/FileManager/EditDialog.h
index d820516..6970b14 100644
--- a/CPP/7zip/UI/FileManager/EditDialog.h
+++ b/CPP/7zip/UI/FileManager/EditDialog.h
@@ -1,7 +1,7 @@
1// EditDialog.h 1// EditDialog.h
2 2
3#ifndef __EDIT_DIALOG_H 3#ifndef ZIP7_INC_EDIT_DIALOG_H
4#define __EDIT_DIALOG_H 4#define ZIP7_INC_EDIT_DIALOG_H
5 5
6#include "../../../Windows/Control/Dialog.h" 6#include "../../../Windows/Control/Dialog.h"
7#include "../../../Windows/Control/Edit.h" 7#include "../../../Windows/Control/Edit.h"
@@ -11,13 +11,13 @@
11class CEditDialog: public NWindows::NControl::CModalDialog 11class CEditDialog: public NWindows::NControl::CModalDialog
12{ 12{
13 NWindows::NControl::CEdit _edit; 13 NWindows::NControl::CEdit _edit;
14 virtual bool OnInit(); 14 virtual bool OnInit() Z7_override;
15 virtual bool OnSize(WPARAM wParam, int xSize, int ySize); 15 virtual bool OnSize(WPARAM wParam, int xSize, int ySize) Z7_override;
16public: 16public:
17 UString Title; 17 UString Title;
18 UString Text; 18 UString Text;
19 19
20 INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_EDIT_DLG, wndParent); } 20 INT_PTR Create(HWND wndParent = NULL) { return CModalDialog::Create(IDD_EDIT_DLG, wndParent); }
21 21
22 CEditDialog() {} 22 CEditDialog() {}
23}; 23};
diff --git a/CPP/7zip/UI/FileManager/EditPage.cpp b/CPP/7zip/UI/FileManager/EditPage.cpp
index 0108904..a2a0321 100644
--- a/CPP/7zip/UI/FileManager/EditPage.cpp
+++ b/CPP/7zip/UI/FileManager/EditPage.cpp
@@ -12,6 +12,7 @@
12 12
13using namespace NWindows; 13using namespace NWindows;
14 14
15#ifdef Z7_LANG
15static const UInt32 kLangIDs[] = 16static const UInt32 kLangIDs[] =
16{ 17{
17 IDT_EDIT_EDITOR, 18 IDT_EDIT_EDITOR,
@@ -22,6 +23,7 @@ static const UInt32 kLangIDs_Colon[] =
22{ 23{
23 IDT_EDIT_VIEWER 24 IDT_EDIT_VIEWER
24}; 25};
26#endif
25 27
26#define kEditTopic "FM/options.htm#editor" 28#define kEditTopic "FM/options.htm#editor"
27 29
@@ -29,8 +31,10 @@ bool CEditPage::OnInit()
29{ 31{
30 _initMode = true; 32 _initMode = true;
31 33
32 LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); 34 #ifdef Z7_LANG
33 LangSetDlgItems_Colon(*this, kLangIDs_Colon, ARRAY_SIZE(kLangIDs_Colon)); 35 LangSetDlgItems(*this, kLangIDs, Z7_ARRAY_SIZE(kLangIDs));
36 LangSetDlgItems_Colon(*this, kLangIDs_Colon, Z7_ARRAY_SIZE(kLangIDs_Colon));
37 #endif
34 38
35 _ctrls[0].Ctrl = IDE_EDIT_VIEWER; _ctrls[0].Button = IDB_EDIT_VIEWER; 39 _ctrls[0].Ctrl = IDE_EDIT_VIEWER; _ctrls[0].Button = IDB_EDIT_VIEWER;
36 _ctrls[1].Ctrl = IDE_EDIT_EDITOR; _ctrls[1].Button = IDB_EDIT_EDITOR; 40 _ctrls[1].Ctrl = IDE_EDIT_EDITOR; _ctrls[1].Button = IDB_EDIT_EDITOR;
@@ -91,12 +95,20 @@ static void Edit_BrowseForFile(NWindows::NControl::CEdit &edit, HWND hwnd)
91 95
92 SplitCmdLineSmart(cmd, prg, param); 96 SplitCmdLineSmart(cmd, prg, param);
93 97
94 UString resPath; 98 CObjectVector<CBrowseFilterInfo> filters;
95 99 CBrowseFilterInfo &bfi = filters.AddNew();
96 if (MyBrowseForFile(hwnd, 0, prg, NULL, L"*.exe", resPath)) 100 bfi.Description = "*.exe";
101 bfi.Masks.Add(UString("*.exe"));
102
103 CBrowseInfo bi;
104 bi.FilterIndex = 0;
105 bi.FilePath = prg;
106 bi.hwndOwner = hwnd;
107
108 if (bi.BrowseForFile(filters))
97 { 109 {
98 resPath.Trim(); 110 cmd = bi.FilePath;
99 cmd = resPath; 111 cmd.Trim();
100 /* 112 /*
101 if (!param.IsEmpty() && !resPath.IsEmpty()) 113 if (!param.IsEmpty() && !resPath.IsEmpty())
102 { 114 {
@@ -112,7 +124,7 @@ static void Edit_BrowseForFile(NWindows::NControl::CEdit &edit, HWND hwnd)
112 } 124 }
113} 125}
114 126
115bool CEditPage::OnButtonClicked(int buttonID, HWND buttonHWND) 127bool CEditPage::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
116{ 128{
117 for (unsigned i = 0; i < 3; i++) 129 for (unsigned i = 0; i < 3; i++)
118 { 130 {
@@ -127,7 +139,7 @@ bool CEditPage::OnButtonClicked(int buttonID, HWND buttonHWND)
127 return CPropertyPage::OnButtonClicked(buttonID, buttonHWND); 139 return CPropertyPage::OnButtonClicked(buttonID, buttonHWND);
128} 140}
129 141
130bool CEditPage::OnCommand(int code, int itemID, LPARAM param) 142bool CEditPage::OnCommand(unsigned code, unsigned itemID, LPARAM param)
131{ 143{
132 if (!_initMode && code == EN_CHANGE) 144 if (!_initMode && code == EN_CHANGE)
133 { 145 {
diff --git a/CPP/7zip/UI/FileManager/EditPage.h b/CPP/7zip/UI/FileManager/EditPage.h
index 208edd8..a70fad7 100644
--- a/CPP/7zip/UI/FileManager/EditPage.h
+++ b/CPP/7zip/UI/FileManager/EditPage.h
@@ -1,7 +1,7 @@
1// EditPage.h 1// EditPage.h
2 2
3#ifndef __EDIT_PAGE_H 3#ifndef ZIP7_INC_EDIT_PAGE_H
4#define __EDIT_PAGE_H 4#define ZIP7_INC_EDIT_PAGE_H
5 5
6#include "../../../Windows/Control/PropertyPage.h" 6#include "../../../Windows/Control/PropertyPage.h"
7#include "../../../Windows/Control/Edit.h" 7#include "../../../Windows/Control/Edit.h"
@@ -10,8 +10,8 @@ struct CEditPageCtrl
10{ 10{
11 NWindows::NControl::CEdit Edit; 11 NWindows::NControl::CEdit Edit;
12 bool WasChanged; 12 bool WasChanged;
13 int Ctrl; 13 unsigned Ctrl;
14 int Button; 14 unsigned Button;
15}; 15};
16 16
17class CEditPage: public NWindows::NControl::CPropertyPage 17class CEditPage: public NWindows::NControl::CPropertyPage
@@ -20,11 +20,11 @@ class CEditPage: public NWindows::NControl::CPropertyPage
20 20
21 bool _initMode; 21 bool _initMode;
22public: 22public:
23 virtual bool OnInit(); 23 virtual bool OnInit() Z7_override;
24 virtual void OnNotifyHelp(); 24 virtual void OnNotifyHelp() Z7_override;
25 virtual bool OnCommand(int code, int itemID, LPARAM param); 25 virtual bool OnCommand(unsigned code, unsigned itemID, LPARAM param) Z7_override;
26 virtual LONG OnApply(); 26 virtual LONG OnApply() Z7_override;
27 virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); 27 virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
28}; 28};
29 29
30#endif 30#endif
diff --git a/CPP/7zip/UI/FileManager/EnumFormatEtc.cpp b/CPP/7zip/UI/FileManager/EnumFormatEtc.cpp
index 389aa3e..fc2fd6c 100644
--- a/CPP/7zip/UI/FileManager/EnumFormatEtc.cpp
+++ b/CPP/7zip/UI/FileManager/EnumFormatEtc.cpp
@@ -3,28 +3,27 @@
3#include "StdAfx.h" 3#include "StdAfx.h"
4 4
5#include "EnumFormatEtc.h" 5#include "EnumFormatEtc.h"
6#include "../../IDecl.h"
6#include "MyCom2.h" 7#include "MyCom2.h"
7 8
8class CEnumFormatEtc : 9class CEnumFormatEtc Z7_final:
9public IEnumFORMATETC, 10 public IEnumFORMATETC,
10public CMyUnknownImp 11 public CMyUnknownImp
11{ 12{
12public: 13 Z7_COM_UNKNOWN_IMP_1_MT(IEnumFORMATETC)
13 MY_UNKNOWN_IMP1_MT(IEnumFORMATETC)
14 14
15 STDMETHOD(Next)(ULONG celt, FORMATETC *rgelt, ULONG *pceltFetched); 15 STDMETHOD(Next)(ULONG celt, FORMATETC *rgelt, ULONG *pceltFetched) Z7_override;
16 STDMETHOD(Skip)(ULONG celt); 16 STDMETHOD(Skip)(ULONG celt) Z7_override;
17 STDMETHOD(Reset)(void); 17 STDMETHOD(Reset)(void) Z7_override;
18 STDMETHOD(Clone)(IEnumFORMATETC **ppEnumFormatEtc); 18 STDMETHOD(Clone)(IEnumFORMATETC **ppEnumFormatEtc) Z7_override;
19 19
20 CEnumFormatEtc(const FORMATETC *pFormatEtc, ULONG numFormats);
21 ~CEnumFormatEtc();
22
23private:
24 LONG m_RefCount; 20 LONG m_RefCount;
25 ULONG m_NumFormats; 21 ULONG m_NumFormats;
26 FORMATETC *m_Formats; 22 FORMATETC *m_Formats;
27 ULONG m_Index; 23 ULONG m_Index;
24public:
25 CEnumFormatEtc(const FORMATETC *pFormatEtc, ULONG numFormats);
26 ~CEnumFormatEtc();
28}; 27};
29 28
30static void DeepCopyFormatEtc(FORMATETC *dest, const FORMATETC *src) 29static void DeepCopyFormatEtc(FORMATETC *dest, const FORMATETC *src)
@@ -62,10 +61,10 @@ CEnumFormatEtc::~CEnumFormatEtc()
62 } 61 }
63} 62}
64 63
65STDMETHODIMP CEnumFormatEtc::Next(ULONG celt, FORMATETC *pFormatEtc, ULONG *pceltFetched) 64Z7_COMWF_B CEnumFormatEtc::Next(ULONG celt, FORMATETC *pFormatEtc, ULONG *pceltFetched)
66{ 65{
67 ULONG copied = 0; 66 ULONG copied = 0;
68 if (celt == 0 || pFormatEtc == 0) 67 if (celt == 0 || !pFormatEtc)
69 return E_INVALIDARG; 68 return E_INVALIDARG;
70 while (m_Index < m_NumFormats && copied < celt) 69 while (m_Index < m_NumFormats && copied < celt)
71 { 70 {
@@ -73,24 +72,24 @@ STDMETHODIMP CEnumFormatEtc::Next(ULONG celt, FORMATETC *pFormatEtc, ULONG *pcel
73 copied++; 72 copied++;
74 m_Index++; 73 m_Index++;
75 } 74 }
76 if (pceltFetched != 0) 75 if (pceltFetched)
77 *pceltFetched = copied; 76 *pceltFetched = copied;
78 return (copied == celt) ? S_OK : S_FALSE; 77 return (copied == celt) ? S_OK : S_FALSE;
79} 78}
80 79
81STDMETHODIMP CEnumFormatEtc::Skip(ULONG celt) 80Z7_COMWF_B CEnumFormatEtc::Skip(ULONG celt)
82{ 81{
83 m_Index += celt; 82 m_Index += celt;
84 return (m_Index <= m_NumFormats) ? S_OK : S_FALSE; 83 return (m_Index <= m_NumFormats) ? S_OK : S_FALSE;
85} 84}
86 85
87STDMETHODIMP CEnumFormatEtc::Reset(void) 86Z7_COMWF_B CEnumFormatEtc::Reset(void)
88{ 87{
89 m_Index = 0; 88 m_Index = 0;
90 return S_OK; 89 return S_OK;
91} 90}
92 91
93STDMETHODIMP CEnumFormatEtc::Clone(IEnumFORMATETC ** ppEnumFormatEtc) 92Z7_COMWF_B CEnumFormatEtc::Clone(IEnumFORMATETC ** ppEnumFormatEtc)
94{ 93{
95 HRESULT hResult = CreateEnumFormatEtc(m_NumFormats, m_Formats, ppEnumFormatEtc); 94 HRESULT hResult = CreateEnumFormatEtc(m_NumFormats, m_Formats, ppEnumFormatEtc);
96 if (hResult == S_OK) 95 if (hResult == S_OK)
@@ -101,7 +100,7 @@ STDMETHODIMP CEnumFormatEtc::Clone(IEnumFORMATETC ** ppEnumFormatEtc)
101// replacement for SHCreateStdEnumFmtEtc 100// replacement for SHCreateStdEnumFmtEtc
102HRESULT CreateEnumFormatEtc(UINT numFormats, const FORMATETC *formats, IEnumFORMATETC **enumFormat) 101HRESULT CreateEnumFormatEtc(UINT numFormats, const FORMATETC *formats, IEnumFORMATETC **enumFormat)
103{ 102{
104 if (numFormats == 0 || formats == 0 || enumFormat == 0) 103 if (numFormats == 0 || !formats || !enumFormat)
105 return E_INVALIDARG; 104 return E_INVALIDARG;
106 *enumFormat = new CEnumFormatEtc(formats, numFormats); 105 *enumFormat = new CEnumFormatEtc(formats, numFormats);
107 return (*enumFormat) ? S_OK : E_OUTOFMEMORY; 106 return (*enumFormat) ? S_OK : E_OUTOFMEMORY;
diff --git a/CPP/7zip/UI/FileManager/EnumFormatEtc.h b/CPP/7zip/UI/FileManager/EnumFormatEtc.h
index 93a53cb..12df225 100644
--- a/CPP/7zip/UI/FileManager/EnumFormatEtc.h
+++ b/CPP/7zip/UI/FileManager/EnumFormatEtc.h
@@ -1,7 +1,7 @@
1// EnumFormatEtc.h 1// EnumFormatEtc.h
2 2
3#ifndef __ENUMFORMATETC_H 3#ifndef ZIP7_INC_ENUMFORMATETC_H
4#define __ENUMFORMATETC_H 4#define ZIP7_INC_ENUMFORMATETC_H
5 5
6#include "../../../Common/MyWindows.h" 6#include "../../../Common/MyWindows.h"
7 7
diff --git a/CPP/7zip/UI/FileManager/ExtractCallback.cpp b/CPP/7zip/UI/FileManager/ExtractCallback.cpp
index 232717f..f674044 100644
--- a/CPP/7zip/UI/FileManager/ExtractCallback.cpp
+++ b/CPP/7zip/UI/FileManager/ExtractCallback.cpp
@@ -17,7 +17,7 @@
17#include "../../Common/StreamUtils.h" 17#include "../../Common/StreamUtils.h"
18#include "../Common/ExtractingFilePath.h" 18#include "../Common/ExtractingFilePath.h"
19 19
20#ifndef _SFX 20#ifndef Z7_SFX
21#include "../Common/ZipRegistry.h" 21#include "../Common/ZipRegistry.h"
22#endif 22#endif
23 23
@@ -28,7 +28,7 @@
28#include "FormatUtils.h" 28#include "FormatUtils.h"
29#include "LangUtils.h" 29#include "LangUtils.h"
30#include "OverwriteDialog.h" 30#include "OverwriteDialog.h"
31#ifndef _NO_CRYPTO 31#ifndef Z7_NO_CRYPTO
32#include "PasswordDialog.h" 32#include "PasswordDialog.h"
33#endif 33#endif
34#include "PropertyName.h" 34#include "PropertyName.h"
@@ -48,7 +48,7 @@ void CExtractCallbackImp::Init()
48 48
49 NumArchiveErrors = 0; 49 NumArchiveErrors = 0;
50 ThereAreMessageErrors = false; 50 ThereAreMessageErrors = false;
51 #ifndef _SFX 51 #ifndef Z7_SFX
52 NumFolders = NumFiles = 0; 52 NumFolders = NumFiles = 0;
53 NeedAddFile = false; 53 NeedAddFile = false;
54 #endif 54 #endif
@@ -60,29 +60,27 @@ void CExtractCallbackImp::AddError_Message(LPCWSTR s)
60 ProgressDialog->Sync.AddError_Message(s); 60 ProgressDialog->Sync.AddError_Message(s);
61} 61}
62 62
63#ifndef _SFX 63#ifndef Z7_SFX
64 64
65STDMETHODIMP CExtractCallbackImp::SetNumFiles(UInt64 65Z7_COM7F_IMF(CExtractCallbackImp::SetNumFiles(UInt64 numFiles))
66 #ifndef _SFX
67 numFiles
68 #endif
69 )
70{ 66{
71 #ifndef _SFX 67 #ifdef Z7_SFX
68 UNUSED_VAR(numFiles)
69 #else
72 ProgressDialog->Sync.Set_NumFilesTotal(numFiles); 70 ProgressDialog->Sync.Set_NumFilesTotal(numFiles);
73 #endif 71 #endif
74 return S_OK; 72 return S_OK;
75} 73}
76 74
77#endif 75#endif
78 76
79STDMETHODIMP CExtractCallbackImp::SetTotal(UInt64 total) 77Z7_COM7F_IMF(CExtractCallbackImp::SetTotal(UInt64 total))
80{ 78{
81 ProgressDialog->Sync.Set_NumBytesTotal(total); 79 ProgressDialog->Sync.Set_NumBytesTotal(total);
82 return S_OK; 80 return S_OK;
83} 81}
84 82
85STDMETHODIMP CExtractCallbackImp::SetCompleted(const UInt64 *value) 83Z7_COM7F_IMF(CExtractCallbackImp::SetCompleted(const UInt64 *value))
86{ 84{
87 return ProgressDialog->Sync.Set_NumBytesCur(value); 85 return ProgressDialog->Sync.Set_NumBytesCur(value);
88} 86}
@@ -139,7 +137,7 @@ HRESULT CExtractCallbackImp::Open_Finished()
139 return ProgressDialog->Sync.CheckStop(); 137 return ProgressDialog->Sync.CheckStop();
140} 138}
141 139
142#ifndef _NO_CRYPTO 140#ifndef Z7_NO_CRYPTO
143 141
144HRESULT CExtractCallbackImp::Open_CryptoGetTextPassword(BSTR *password) 142HRESULT CExtractCallbackImp::Open_CryptoGetTextPassword(BSTR *password)
145{ 143{
@@ -168,8 +166,8 @@ void CExtractCallbackImp::Open_Clear_PasswordWasAsked_Flag()
168#endif 166#endif
169 167
170 168
171#ifndef _SFX 169#ifndef Z7_SFX
172STDMETHODIMP CExtractCallbackImp::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) 170Z7_COM7F_IMF(CExtractCallbackImp::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize))
173{ 171{
174 ProgressDialog->Sync.Set_Ratio(inSize, outSize); 172 ProgressDialog->Sync.Set_Ratio(inSize, outSize);
175 return S_OK; 173 return S_OK;
@@ -177,13 +175,13 @@ STDMETHODIMP CExtractCallbackImp::SetRatioInfo(const UInt64 *inSize, const UInt6
177#endif 175#endif
178 176
179/* 177/*
180STDMETHODIMP CExtractCallbackImp::SetTotalFiles(UInt64 total) 178Z7_COM7F_IMF(CExtractCallbackImp::SetTotalFiles(UInt64 total)
181{ 179{
182 ProgressDialog->Sync.SetNumFilesTotal(total); 180 ProgressDialog->Sync.SetNumFilesTotal(total);
183 return S_OK; 181 return S_OK;
184} 182}
185 183
186STDMETHODIMP CExtractCallbackImp::SetCompletedFiles(const UInt64 *value) 184Z7_COM7F_IMF(CExtractCallbackImp::SetCompletedFiles(const UInt64 *value)
187{ 185{
188 if (value != NULL) 186 if (value != NULL)
189 ProgressDialog->Sync.SetNumFilesCur(*value); 187 ProgressDialog->Sync.SetNumFilesCur(*value);
@@ -191,10 +189,10 @@ STDMETHODIMP CExtractCallbackImp::SetCompletedFiles(const UInt64 *value)
191} 189}
192*/ 190*/
193 191
194STDMETHODIMP CExtractCallbackImp::AskOverwrite( 192Z7_COM7F_IMF(CExtractCallbackImp::AskOverwrite(
195 const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize, 193 const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize,
196 const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize, 194 const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize,
197 Int32 *answer) 195 Int32 *answer))
198{ 196{
199 COverwriteDialog dialog; 197 COverwriteDialog dialog;
200 198
@@ -223,7 +221,7 @@ STDMETHODIMP CExtractCallbackImp::AskOverwrite(
223} 221}
224 222
225 223
226STDMETHODIMP CExtractCallbackImp::PrepareOperation(const wchar_t *name, Int32 isFolder, Int32 askExtractMode, const UInt64 * /* position */) 224Z7_COM7F_IMF(CExtractCallbackImp::PrepareOperation(const wchar_t *name, Int32 isFolder, Int32 askExtractMode, const UInt64 * /* position */))
227{ 225{
228 _isFolder = IntToBool(isFolder); 226 _isFolder = IntToBool(isFolder);
229 _currentFilePath = name; 227 _currentFilePath = name;
@@ -241,7 +239,7 @@ STDMETHODIMP CExtractCallbackImp::PrepareOperation(const wchar_t *name, Int32 is
241 return ProgressDialog->Sync.Set_Status2(*msg, name, IntToBool(isFolder)); 239 return ProgressDialog->Sync.Set_Status2(*msg, name, IntToBool(isFolder));
242} 240}
243 241
244STDMETHODIMP CExtractCallbackImp::MessageError(const wchar_t *s) 242Z7_COM7F_IMF(CExtractCallbackImp::MessageError(const wchar_t *s))
245{ 243{
246 AddError_Message(s); 244 AddError_Message(s);
247 return S_OK; 245 return S_OK;
@@ -254,9 +252,9 @@ HRESULT CExtractCallbackImp::MessageError(const char *message, const FString &pa
254 return S_OK; 252 return S_OK;
255} 253}
256 254
257#ifndef _SFX 255#ifndef Z7_SFX
258 256
259STDMETHODIMP CExtractCallbackImp::ShowMessage(const wchar_t *s) 257Z7_COM7F_IMF(CExtractCallbackImp::ShowMessage(const wchar_t *s))
260{ 258{
261 AddError_Message(s); 259 AddError_Message(s);
262 return S_OK; 260 return S_OK;
@@ -272,25 +270,33 @@ void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, const wchar_t *fileNam
272 if (opRes == NArchive::NExtract::NOperationResult::kOK) 270 if (opRes == NArchive::NExtract::NOperationResult::kOK)
273 return; 271 return;
274 272
273 #ifndef Z7_SFX
275 UINT messageID = 0; 274 UINT messageID = 0;
275 #endif
276 UINT id = 0; 276 UINT id = 0;
277 277
278 switch (opRes) 278 switch (opRes)
279 { 279 {
280 case NArchive::NExtract::NOperationResult::kUnsupportedMethod: 280 case NArchive::NExtract::NOperationResult::kUnsupportedMethod:
281 #ifndef Z7_SFX
281 messageID = IDS_EXTRACT_MESSAGE_UNSUPPORTED_METHOD; 282 messageID = IDS_EXTRACT_MESSAGE_UNSUPPORTED_METHOD;
283 #endif
282 id = IDS_EXTRACT_MSG_UNSUPPORTED_METHOD; 284 id = IDS_EXTRACT_MSG_UNSUPPORTED_METHOD;
283 break; 285 break;
284 case NArchive::NExtract::NOperationResult::kDataError: 286 case NArchive::NExtract::NOperationResult::kDataError:
287 #ifndef Z7_SFX
285 messageID = encrypted ? 288 messageID = encrypted ?
286 IDS_EXTRACT_MESSAGE_DATA_ERROR_ENCRYPTED: 289 IDS_EXTRACT_MESSAGE_DATA_ERROR_ENCRYPTED:
287 IDS_EXTRACT_MESSAGE_DATA_ERROR; 290 IDS_EXTRACT_MESSAGE_DATA_ERROR;
291 #endif
288 id = IDS_EXTRACT_MSG_DATA_ERROR; 292 id = IDS_EXTRACT_MSG_DATA_ERROR;
289 break; 293 break;
290 case NArchive::NExtract::NOperationResult::kCRCError: 294 case NArchive::NExtract::NOperationResult::kCRCError:
295 #ifndef Z7_SFX
291 messageID = encrypted ? 296 messageID = encrypted ?
292 IDS_EXTRACT_MESSAGE_CRC_ERROR_ENCRYPTED: 297 IDS_EXTRACT_MESSAGE_CRC_ERROR_ENCRYPTED:
293 IDS_EXTRACT_MESSAGE_CRC_ERROR; 298 IDS_EXTRACT_MESSAGE_CRC_ERROR;
299 #endif
294 id = IDS_EXTRACT_MSG_CRC_ERROR; 300 id = IDS_EXTRACT_MSG_CRC_ERROR;
295 break; 301 break;
296 case NArchive::NExtract::NOperationResult::kUnavailable: 302 case NArchive::NExtract::NOperationResult::kUnavailable:
@@ -319,18 +325,19 @@ void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, const wchar_t *fileNam
319 } 325 }
320 326
321 UString msg; 327 UString msg;
322 UString msgOld;
323 328
324 #ifndef _SFX 329 #ifndef Z7_SFX
330 UString msgOld;
331 #ifdef Z7_LANG
325 if (id != 0) 332 if (id != 0)
326 LangString_OnlyFromLangFile(id, msg); 333 LangString_OnlyFromLangFile(id, msg);
327 if (messageID != 0 && msg.IsEmpty()) 334 if (messageID != 0 && msg.IsEmpty())
328 LangString_OnlyFromLangFile(messageID, msgOld); 335 LangString_OnlyFromLangFile(messageID, msgOld);
329 #endif 336 #endif
330
331 if (msg.IsEmpty() && !msgOld.IsEmpty()) 337 if (msg.IsEmpty() && !msgOld.IsEmpty())
332 s = MyFormatNew(msgOld, fileName); 338 s = MyFormatNew(msgOld, fileName);
333 else 339 else
340 #endif
334 { 341 {
335 if (msg.IsEmpty() && id != 0) 342 if (msg.IsEmpty() && id != 0)
336 LangString(id, msg); 343 LangString(id, msg);
@@ -339,7 +346,7 @@ void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, const wchar_t *fileNam
339 else 346 else
340 { 347 {
341 s += "Error #"; 348 s += "Error #";
342 s.Add_UInt32(opRes); 349 s.Add_UInt32((UInt32)opRes);
343 } 350 }
344 351
345 if (encrypted && opRes != NArchive::NExtract::NOperationResult::kWrongPassword) 352 if (encrypted && opRes != NArchive::NExtract::NOperationResult::kWrongPassword)
@@ -354,7 +361,7 @@ void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, const wchar_t *fileNam
354 } 361 }
355} 362}
356 363
357STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 opRes, Int32 encrypted) 364Z7_COM7F_IMF(CExtractCallbackImp::SetOperationResult(Int32 opRes, Int32 encrypted))
358{ 365{
359 switch (opRes) 366 switch (opRes)
360 { 367 {
@@ -369,7 +376,7 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 opRes, Int32 encrypte
369 } 376 }
370 } 377 }
371 378
372 #ifndef _SFX 379 #ifndef Z7_SFX
373 if (_isFolder) 380 if (_isFolder)
374 NumFolders++; 381 NumFolders++;
375 else 382 else
@@ -380,7 +387,7 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 opRes, Int32 encrypte
380 return S_OK; 387 return S_OK;
381} 388}
382 389
383STDMETHODIMP CExtractCallbackImp::ReportExtractResult(Int32 opRes, Int32 encrypted, const wchar_t *name) 390Z7_COM7F_IMF(CExtractCallbackImp::ReportExtractResult(Int32 opRes, Int32 encrypted, const wchar_t *name))
384{ 391{
385 if (opRes != NArchive::NExtract::NOperationResult::kOK) 392 if (opRes != NArchive::NExtract::NOperationResult::kOK)
386 { 393 {
@@ -397,8 +404,8 @@ STDMETHODIMP CExtractCallbackImp::ReportExtractResult(Int32 opRes, Int32 encrypt
397 404
398HRESULT CExtractCallbackImp::BeforeOpen(const wchar_t *name, bool /* testMode */) 405HRESULT CExtractCallbackImp::BeforeOpen(const wchar_t *name, bool /* testMode */)
399{ 406{
400 #ifndef _SFX 407 #ifndef Z7_SFX
401 RINOK(ProgressDialog->Sync.CheckStop()); 408 RINOK(ProgressDialog->Sync.CheckStop())
402 ProgressDialog->Sync.Set_TitleFileName(name); 409 ProgressDialog->Sync.Set_TitleFileName(name);
403 #endif 410 #endif
404 _currentArchivePath = name; 411 _currentArchivePath = name;
@@ -408,17 +415,17 @@ HRESULT CExtractCallbackImp::BeforeOpen(const wchar_t *name, bool /* testMode */
408HRESULT CExtractCallbackImp::SetCurrentFilePath2(const wchar_t *path) 415HRESULT CExtractCallbackImp::SetCurrentFilePath2(const wchar_t *path)
409{ 416{
410 _currentFilePath = path; 417 _currentFilePath = path;
411 #ifndef _SFX 418 #ifndef Z7_SFX
412 ProgressDialog->Sync.Set_FilePath(path); 419 ProgressDialog->Sync.Set_FilePath(path);
413 #endif 420 #endif
414 return S_OK; 421 return S_OK;
415} 422}
416 423
417#ifndef _SFX 424#ifndef Z7_SFX
418 425
419HRESULT CExtractCallbackImp::SetCurrentFilePath(const wchar_t *path) 426Z7_COM7F_IMF(CExtractCallbackImp::SetCurrentFilePath(const wchar_t *path))
420{ 427{
421 #ifndef _SFX 428 #ifndef Z7_SFX
422 if (NeedAddFile) 429 if (NeedAddFile)
423 NumFiles++; 430 NumFiles++;
424 NeedAddFile = true; 431 NeedAddFile = true;
@@ -457,7 +464,7 @@ UString GetOpenArcErrorMessage(UInt32 errorFlags)
457{ 464{
458 UString s; 465 UString s;
459 466
460 for (unsigned i = 0; i < ARRAY_SIZE(k_ErrorFlagsIds); i++) 467 for (unsigned i = 0; i < Z7_ARRAY_SIZE(k_ErrorFlagsIds); i++)
461 { 468 {
462 UInt32 f = ((UInt32)1 << i); 469 UInt32 f = ((UInt32)1 << i);
463 if ((errorFlags & f) == 0) 470 if ((errorFlags & f) == 0)
@@ -649,7 +656,7 @@ HRESULT CExtractCallbackImp::ExtractResult(HRESULT result)
649 return S_OK; 656 return S_OK;
650} 657}
651 658
652#ifndef _NO_CRYPTO 659#ifndef Z7_NO_CRYPTO
653 660
654HRESULT CExtractCallbackImp::SetPassword(const UString &password) 661HRESULT CExtractCallbackImp::SetPassword(const UString &password)
655{ 662{
@@ -658,14 +665,14 @@ HRESULT CExtractCallbackImp::SetPassword(const UString &password)
658 return S_OK; 665 return S_OK;
659} 666}
660 667
661STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password) 668Z7_COM7F_IMF(CExtractCallbackImp::CryptoGetTextPassword(BSTR *password))
662{ 669{
663 PasswordWasAsked = true; 670 PasswordWasAsked = true;
664 if (!PasswordIsDefined) 671 if (!PasswordIsDefined)
665 { 672 {
666 CPasswordDialog dialog; 673 CPasswordDialog dialog;
667 #ifndef _SFX 674 #ifndef Z7_SFX
668 bool showPassword = NExtract::Read_ShowPassword(); 675 const bool showPassword = NExtract::Read_ShowPassword();
669 dialog.ShowPassword = showPassword; 676 dialog.ShowPassword = showPassword;
670 #endif 677 #endif
671 ProgressDialog->WaitCreating(); 678 ProgressDialog->WaitCreating();
@@ -673,7 +680,7 @@ STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password)
673 return E_ABORT; 680 return E_ABORT;
674 Password = dialog.Password; 681 Password = dialog.Password;
675 PasswordIsDefined = true; 682 PasswordIsDefined = true;
676 #ifndef _SFX 683 #ifndef Z7_SFX
677 if (dialog.ShowPassword != showPassword) 684 if (dialog.ShowPassword != showPassword)
678 NExtract::Save_ShowPassword(dialog.ShowPassword); 685 NExtract::Save_ShowPassword(dialog.ShowPassword);
679 #endif 686 #endif
@@ -683,24 +690,24 @@ STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password)
683 690
684#endif 691#endif
685 692
686#ifndef _SFX 693#ifndef Z7_SFX
687 694
688STDMETHODIMP CExtractCallbackImp::AskWrite( 695Z7_COM7F_IMF(CExtractCallbackImp::AskWrite(
689 const wchar_t *srcPath, Int32 srcIsFolder, 696 const wchar_t *srcPath, Int32 srcIsFolder,
690 const FILETIME *srcTime, const UInt64 *srcSize, 697 const FILETIME *srcTime, const UInt64 *srcSize,
691 const wchar_t *destPath, 698 const wchar_t *destPath,
692 BSTR *destPathResult, 699 BSTR *destPathResult,
693 Int32 *writeAnswer) 700 Int32 *writeAnswer))
694{ 701{
695 UString destPathResultTemp = destPath; 702 UString destPathResultTemp = destPath;
696 703
697 // RINOK(StringToBstr(destPath, destPathResult)); 704 // RINOK(StringToBstr(destPath, destPathResult));
698 705
699 *destPathResult = 0; 706 *destPathResult = NULL;
700 *writeAnswer = BoolToInt(false); 707 *writeAnswer = BoolToInt(false);
701 708
702 FString destPathSys = us2fs(destPath); 709 FString destPathSys = us2fs(destPath);
703 bool srcIsFolderSpec = IntToBool(srcIsFolder); 710 const bool srcIsFolderSpec = IntToBool(srcIsFolder);
704 CFileInfo destFileInfo; 711 CFileInfo destFileInfo;
705 712
706 if (destFileInfo.Find(destPathSys)) 713 if (destFileInfo.Find(destPathSys))
@@ -709,7 +716,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
709 { 716 {
710 if (!destFileInfo.IsDir()) 717 if (!destFileInfo.IsDir())
711 { 718 {
712 RINOK(MessageError("Cannot replace file with folder with same name", destPathSys)); 719 RINOK(MessageError("Cannot replace file with folder with same name", destPathSys))
713 return E_ABORT; 720 return E_ABORT;
714 } 721 }
715 *writeAnswer = BoolToInt(false); 722 *writeAnswer = BoolToInt(false);
@@ -718,12 +725,12 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
718 725
719 if (destFileInfo.IsDir()) 726 if (destFileInfo.IsDir())
720 { 727 {
721 RINOK(MessageError("Cannot replace folder with file with same name", destPathSys)); 728 RINOK(MessageError("Cannot replace folder with file with same name", destPathSys))
722 *writeAnswer = BoolToInt(false); 729 *writeAnswer = BoolToInt(false);
723 return S_OK; 730 return S_OK;
724 } 731 }
725 732
726 switch (OverwriteMode) 733 switch ((int)OverwriteMode)
727 { 734 {
728 case NExtract::NOverwriteMode::kSkip: 735 case NExtract::NOverwriteMode::kSkip:
729 return S_OK; 736 return S_OK;
@@ -731,7 +738,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
731 { 738 {
732 Int32 overwriteResult; 739 Int32 overwriteResult;
733 UString destPathSpec = destPath; 740 UString destPathSpec = destPath;
734 int slashPos = destPathSpec.ReverseFind_PathSepar(); 741 const int slashPos = destPathSpec.ReverseFind_PathSepar();
735 destPathSpec.DeleteFrom((unsigned)(slashPos + 1)); 742 destPathSpec.DeleteFrom((unsigned)(slashPos + 1));
736 destPathSpec += fs2us(destFileInfo.Name); 743 destPathSpec += fs2us(destFileInfo.Name);
737 744
@@ -740,7 +747,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
740 &destFileInfo.MTime, &destFileInfo.Size, 747 &destFileInfo.MTime, &destFileInfo.Size,
741 srcPath, 748 srcPath,
742 srcTime, srcSize, 749 srcTime, srcSize,
743 &overwriteResult)); 750 &overwriteResult))
744 751
745 switch (overwriteResult) 752 switch (overwriteResult)
746 { 753 {
@@ -763,7 +770,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
763 { 770 {
764 if (!AutoRenamePath(destPathSys)) 771 if (!AutoRenamePath(destPathSys))
765 { 772 {
766 RINOK(MessageError("Cannot create name for file", destPathSys)); 773 RINOK(MessageError("Cannot create name for file", destPathSys))
767 return E_ABORT; 774 return E_ABORT;
768 } 775 }
769 destPathResultTemp = fs2us(destPathSys); 776 destPathResultTemp = fs2us(destPathSys);
@@ -774,7 +781,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
774 if (!NDir::DeleteFileAlways(destPathSys)) 781 if (!NDir::DeleteFileAlways(destPathSys))
775 if (GetLastError() != ERROR_FILE_NOT_FOUND) 782 if (GetLastError() != ERROR_FILE_NOT_FOUND)
776 { 783 {
777 RINOK(MessageError("Cannot delete output file", destPathSys)); 784 RINOK(MessageError("Cannot delete output file", destPathSys))
778 return E_ABORT; 785 return E_ABORT;
779 } 786 }
780 } 787 }
@@ -784,7 +791,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
784} 791}
785 792
786 793
787STDMETHODIMP CExtractCallbackImp::UseExtractToStream(Int32 *res) 794Z7_COM7F_IMF(CExtractCallbackImp::UseExtractToStream(Int32 *res))
788{ 795{
789 *res = BoolToInt(StreamMode); 796 *res = BoolToInt(StreamMode);
790 return S_OK; 797 return S_OK;
@@ -794,7 +801,7 @@ static HRESULT GetTime(IGetProp *getProp, PROPID propID, FILETIME &ft, bool &ftD
794{ 801{
795 ftDefined = false; 802 ftDefined = false;
796 NCOM::CPropVariant prop; 803 NCOM::CPropVariant prop;
797 RINOK(getProp->GetProp(propID, &prop)); 804 RINOK(getProp->GetProp(propID, &prop))
798 if (prop.vt == VT_FILETIME) 805 if (prop.vt == VT_FILETIME)
799 { 806 {
800 ft = prop.filetime; 807 ft = prop.filetime;
@@ -810,7 +817,7 @@ static HRESULT GetItemBoolProp(IGetProp *getProp, PROPID propID, bool &result)
810{ 817{
811 NCOM::CPropVariant prop; 818 NCOM::CPropVariant prop;
812 result = false; 819 result = false;
813 RINOK(getProp->GetProp(propID, &prop)); 820 RINOK(getProp->GetProp(propID, &prop))
814 if (prop.vt == VT_BOOL) 821 if (prop.vt == VT_BOOL)
815 result = VARIANT_BOOLToBool(prop.boolVal); 822 result = VARIANT_BOOLToBool(prop.boolVal);
816 else if (prop.vt != VT_EMPTY) 823 else if (prop.vt != VT_EMPTY)
@@ -819,13 +826,13 @@ static HRESULT GetItemBoolProp(IGetProp *getProp, PROPID propID, bool &result)
819} 826}
820 827
821 828
822STDMETHODIMP CExtractCallbackImp::GetStream7(const wchar_t *name, 829Z7_COM7F_IMF(CExtractCallbackImp::GetStream7(const wchar_t *name,
823 Int32 isDir, 830 Int32 isDir,
824 ISequentialOutStream **outStream, Int32 askExtractMode, 831 ISequentialOutStream **outStream, Int32 askExtractMode,
825 IGetProp *getProp) 832 IGetProp *getProp))
826{ 833{
827 COM_TRY_BEGIN 834 COM_TRY_BEGIN
828 *outStream = 0; 835 *outStream = NULL;
829 _newVirtFileWasAdded = false; 836 _newVirtFileWasAdded = false;
830 _hashStreamWasUsed = false; 837 _hashStreamWasUsed = false;
831 _needUpdateStat = false; 838 _needUpdateStat = false;
@@ -841,20 +848,20 @@ STDMETHODIMP CExtractCallbackImp::GetStream7(const wchar_t *name,
841 _filePath = name; 848 _filePath = name;
842 _isFolder = IntToBool(isDir); 849 _isFolder = IntToBool(isDir);
843 _curSize = 0; 850 _curSize = 0;
844 _curSizeDefined = false; 851 _curSize_Defined = false;
845 852
846 UInt64 size = 0; 853 UInt64 size = 0;
847 bool sizeDefined; 854 bool sizeDefined;
848 { 855 {
849 NCOM::CPropVariant prop; 856 NCOM::CPropVariant prop;
850 RINOK(getProp->GetProp(kpidSize, &prop)); 857 RINOK(getProp->GetProp(kpidSize, &prop))
851 sizeDefined = ConvertPropVariantToUInt64(prop, size); 858 sizeDefined = ConvertPropVariantToUInt64(prop, size);
852 } 859 }
853 860
854 if (sizeDefined) 861 if (sizeDefined)
855 { 862 {
856 _curSize = size; 863 _curSize = size;
857 _curSizeDefined = true; 864 _curSize_Defined = true;
858 } 865 }
859 866
860 if (askExtractMode != NArchive::NExtract::NAskMode::kExtract && 867 if (askExtractMode != NArchive::NExtract::NAskMode::kExtract &&
@@ -874,12 +881,12 @@ STDMETHODIMP CExtractCallbackImp::GetStream7(const wchar_t *name,
874 file.IsAltStream = _isAltStream; 881 file.IsAltStream = _isAltStream;
875 file.Size = 0; 882 file.Size = 0;
876 883
877 RINOK(GetTime(getProp, kpidCTime, file.CTime, file.CTimeDefined)); 884 RINOK(GetTime(getProp, kpidCTime, file.CTime, file.CTimeDefined))
878 RINOK(GetTime(getProp, kpidATime, file.ATime, file.ATimeDefined)); 885 RINOK(GetTime(getProp, kpidATime, file.ATime, file.ATimeDefined))
879 RINOK(GetTime(getProp, kpidMTime, file.MTime, file.MTimeDefined)); 886 RINOK(GetTime(getProp, kpidMTime, file.MTime, file.MTimeDefined))
880 887
881 NCOM::CPropVariant prop; 888 NCOM::CPropVariant prop;
882 RINOK(getProp->GetProp(kpidAttrib, &prop)); 889 RINOK(getProp->GetProp(kpidAttrib, &prop))
883 if (prop.vt == VT_UI4) 890 if (prop.vt == VT_UI4)
884 { 891 {
885 file.Attrib = prop.ulVal; 892 file.Attrib = prop.ulVal;
@@ -909,7 +916,7 @@ STDMETHODIMP CExtractCallbackImp::GetStream7(const wchar_t *name,
909 COM_TRY_END 916 COM_TRY_END
910} 917}
911 918
912STDMETHODIMP CExtractCallbackImp::PrepareOperation7(Int32 askExtractMode) 919Z7_COM7F_IMF(CExtractCallbackImp::PrepareOperation7(Int32 askExtractMode))
913{ 920{
914 COM_TRY_BEGIN 921 COM_TRY_BEGIN
915 _needUpdateStat = ( 922 _needUpdateStat = (
@@ -934,21 +941,21 @@ STDMETHODIMP CExtractCallbackImp::PrepareOperation7(Int32 askExtractMode)
934 COM_TRY_END 941 COM_TRY_END
935} 942}
936 943
937STDMETHODIMP CExtractCallbackImp::SetOperationResult8(Int32 opRes, Int32 encrypted, UInt64 size) 944Z7_COM7F_IMF(CExtractCallbackImp::SetOperationResult8(Int32 opRes, Int32 encrypted, UInt64 size))
938{ 945{
939 COM_TRY_BEGIN 946 COM_TRY_BEGIN
940 if (VirtFileSystem && _newVirtFileWasAdded) 947 if (VirtFileSystem && _newVirtFileWasAdded)
941 { 948 {
942 // FIXME: probably we must request file size from VirtFileSystem 949 // FIXME: probably we must request file size from VirtFileSystem
943 // _curSize = VirtFileSystem->GetLastFileSize() 950 // _curSize = VirtFileSystem->GetLastFileSize()
944 // _curSizeDefined = true; 951 // _curSize_Defined = true;
945 RINOK(VirtFileSystemSpec->CloseMemFile()); 952 RINOK(VirtFileSystemSpec->CloseMemFile())
946 } 953 }
947 if (_hashStream && _hashStreamWasUsed) 954 if (_hashStream && _hashStreamWasUsed)
948 { 955 {
949 _hashStreamSpec->_hash->Final(_isFolder, _isAltStream, _filePath); 956 _hashStreamSpec->_hash->Final(_isFolder, _isAltStream, _filePath);
950 _curSize = _hashStreamSpec->GetSize(); 957 _curSize = _hashStreamSpec->GetSize();
951 _curSizeDefined = true; 958 _curSize_Defined = true;
952 _hashStreamSpec->ReleaseStream(); 959 _hashStreamSpec->ReleaseStream();
953 _hashStreamWasUsed = false; 960 _hashStreamWasUsed = false;
954 } 961 }
@@ -965,7 +972,7 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult8(Int32 opRes, Int32 encrypt
965 972
966// static const UInt32 kBlockSize = ((UInt32)1 << 31); 973// static const UInt32 kBlockSize = ((UInt32)1 << 31);
967 974
968STDMETHODIMP CVirtFileSystem::Write(const void *data, UInt32 size, UInt32 *processedSize) 975Z7_COM7F_IMF(CVirtFileSystem::Write(const void *data, UInt32 size, UInt32 *processedSize))
969{ 976{
970 if (processedSize) 977 if (processedSize)
971 *processedSize = 0; 978 *processedSize = 0;
@@ -1002,7 +1009,7 @@ STDMETHODIMP CVirtFileSystem::Write(const void *data, UInt32 size, UInt32 *proce
1002 } 1009 }
1003 _fileMode = true; 1010 _fileMode = true;
1004 } 1011 }
1005 RINOK(FlushToDisk(false)); 1012 RINOK(FlushToDisk(false))
1006 return _outFileStream->Write(data, size, processedSize); 1013 return _outFileStream->Write(data, size, processedSize);
1007} 1014}
1008 1015
@@ -1026,7 +1033,7 @@ HRESULT CVirtFileSystem::FlushToDisk(bool closeLast)
1026 // MessageBoxMyError(UString("Can't create file ") + fs2us(tempFilePath)); 1033 // MessageBoxMyError(UString("Can't create file ") + fs2us(tempFilePath));
1027 } 1034 }
1028 _fileIsOpen = true; 1035 _fileIsOpen = true;
1029 RINOK(WriteStream(_outFileStream, file.Data, (size_t)file.Size)); 1036 RINOK(WriteStream(_outFileStream, file.Data, (size_t)file.Size))
1030 } 1037 }
1031 if (_numFlushed == Files.Size() - 1 && !closeLast) 1038 if (_numFlushed == Files.Size() - 1 && !closeLast)
1032 break; 1039 break;
diff --git a/CPP/7zip/UI/FileManager/ExtractCallback.h b/CPP/7zip/UI/FileManager/ExtractCallback.h
index 02578bb..c2aa470 100644
--- a/CPP/7zip/UI/FileManager/ExtractCallback.h
+++ b/CPP/7zip/UI/FileManager/ExtractCallback.h
@@ -1,42 +1,42 @@
1// ExtractCallback.h 1// ExtractCallback.h
2 2
3#ifndef __EXTRACT_CALLBACK_H 3#ifndef ZIP7_INC_EXTRACT_CALLBACK_H
4#define __EXTRACT_CALLBACK_H 4#define ZIP7_INC_EXTRACT_CALLBACK_H
5 5
6#include "../../../../C/Alloc.h" 6#include "../../../../C/Alloc.h"
7 7
8#include "../../../Common/MyCom.h" 8#include "../../../Common/MyCom.h"
9#include "../../../Common/StringConvert.h" 9#include "../../../Common/StringConvert.h"
10 10
11#ifndef _SFX 11#ifndef Z7_SFX
12#include "../Agent/IFolderArchive.h" 12#include "../Agent/IFolderArchive.h"
13#endif 13#endif
14 14
15#include "../Common/ArchiveExtractCallback.h" 15#include "../Common/ArchiveExtractCallback.h"
16#include "../Common/ArchiveOpenCallback.h" 16#include "../Common/ArchiveOpenCallback.h"
17 17
18#ifndef _NO_CRYPTO 18#ifndef Z7_NO_CRYPTO
19#include "../../IPassword.h" 19#include "../../IPassword.h"
20#endif 20#endif
21 21
22#ifndef _SFX 22#ifndef Z7_SFX
23#include "IFolder.h" 23#include "IFolder.h"
24#endif 24#endif
25 25
26#include "ProgressDialog2.h" 26#include "ProgressDialog2.h"
27 27
28#ifdef LANG 28#ifdef Z7_LANG
29#include "LangUtils.h" 29// #include "LangUtils.h"
30#endif 30#endif
31 31
32#ifndef _SFX 32#ifndef Z7_SFX
33 33
34class CGrowBuf 34class CGrowBuf
35{ 35{
36 Byte *_items; 36 Byte *_items;
37 size_t _size; 37 size_t _size;
38 38
39 CLASS_NO_COPY(CGrowBuf); 39 Z7_CLASS_NO_COPY(CGrowBuf)
40 40
41public: 41public:
42 bool ReAlloc_KeepData(size_t newSize, size_t keepSize) 42 bool ReAlloc_KeepData(size_t newSize, size_t keepSize)
@@ -52,7 +52,7 @@ public:
52 return true; 52 return true;
53 } 53 }
54 54
55 CGrowBuf(): _items(0), _size(0) {} 55 CGrowBuf(): _items(NULL), _size(0) {}
56 ~CGrowBuf() { MyFree(_items); } 56 ~CGrowBuf() { MyFree(_items); }
57 57
58 operator Byte *() { return _items; } 58 operator Byte *() { return _items; }
@@ -92,10 +92,11 @@ struct CVirtFile
92 IsAltStream(false) {} 92 IsAltStream(false) {}
93}; 93};
94 94
95class CVirtFileSystem: 95
96 public ISequentialOutStream, 96Z7_CLASS_IMP_NOQIB_1(
97 public CMyUnknownImp 97 CVirtFileSystem,
98{ 98 ISequentialOutStream
99)
99 UInt64 _totalAllocSize; 100 UInt64 _totalAllocSize;
100 101
101 size_t _pos; 102 size_t _pos;
@@ -156,104 +157,86 @@ public:
156 HRESULT CloseFile(const FString &path); 157 HRESULT CloseFile(const FString &path);
157 HRESULT FlushToDisk(bool closeLast); 158 HRESULT FlushToDisk(bool closeLast);
158 size_t GetPos() const { return _pos; } 159 size_t GetPos() const { return _pos; }
159
160 MY_UNKNOWN_IMP
161 STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
162}; 160};
163 161
164#endif 162#endif
165 163
166class CExtractCallbackImp: 164class CExtractCallbackImp Z7_final:
167 public IExtractCallbackUI, // it includes IFolderArchiveExtractCallback 165 public IFolderArchiveExtractCallback,
168 public IOpenCallbackUI, 166 /* IExtractCallbackUI:
167 before v23.00 : it included IFolderArchiveExtractCallback
168 since v23.00 : it doesn't include IFolderArchiveExtractCallback
169 */
170 public IExtractCallbackUI, // NON-COM interface since 23.00
171 public IOpenCallbackUI, // NON-COM interface
169 public IFolderArchiveExtractCallback2, 172 public IFolderArchiveExtractCallback2,
170 #ifndef _SFX 173 #ifndef Z7_SFX
171 public IFolderOperationsExtractCallback, 174 public IFolderOperationsExtractCallback,
172 public IFolderExtractToStreamCallback, 175 public IFolderExtractToStreamCallback,
173 public ICompressProgressInfo, 176 public ICompressProgressInfo,
174 #endif 177 #endif
175 #ifndef _NO_CRYPTO 178 #ifndef Z7_NO_CRYPTO
176 public ICryptoGetTextPassword, 179 public ICryptoGetTextPassword,
177 #endif 180 #endif
178 public CMyUnknownImp 181 public CMyUnknownImp
179{ 182{
180 HRESULT MessageError(const char *message, const FString &path); 183 Z7_COM_QI_BEGIN2(IFolderArchiveExtractCallback)
181 void Add_ArchiveName_Error(); 184 Z7_COM_QI_ENTRY(IFolderArchiveExtractCallback2)
182public: 185 #ifndef Z7_SFX
183 MY_QUERYINTERFACE_BEGIN2(IFolderArchiveExtractCallback) 186 Z7_COM_QI_ENTRY(IFolderOperationsExtractCallback)
184 MY_QUERYINTERFACE_ENTRY(IFolderArchiveExtractCallback2) 187 Z7_COM_QI_ENTRY(IFolderExtractToStreamCallback)
185 #ifndef _SFX 188 Z7_COM_QI_ENTRY(ICompressProgressInfo)
186 MY_QUERYINTERFACE_ENTRY(IFolderOperationsExtractCallback) 189 #endif
187 MY_QUERYINTERFACE_ENTRY(IFolderExtractToStreamCallback) 190 #ifndef Z7_NO_CRYPTO
188 MY_QUERYINTERFACE_ENTRY(ICompressProgressInfo) 191 Z7_COM_QI_ENTRY(ICryptoGetTextPassword)
189 #endif 192 #endif
190 #ifndef _NO_CRYPTO 193 Z7_COM_QI_END
191 MY_QUERYINTERFACE_ENTRY(ICryptoGetTextPassword) 194 Z7_COM_ADDREF_RELEASE
192 #endif 195
193 MY_QUERYINTERFACE_END 196 Z7_IFACE_IMP(IExtractCallbackUI)
194 MY_ADDREF_RELEASE 197 Z7_IFACE_IMP(IOpenCallbackUI)
195 198 Z7_IFACE_COM7_IMP(IProgress)
196 INTERFACE_IProgress(;) 199 Z7_IFACE_COM7_IMP(IFolderArchiveExtractCallback)
197 INTERFACE_IOpenCallbackUI(;) 200 Z7_IFACE_COM7_IMP(IFolderArchiveExtractCallback2)
198 INTERFACE_IFolderArchiveExtractCallback(;) 201 #ifndef Z7_SFX
199 INTERFACE_IFolderArchiveExtractCallback2(;) 202 Z7_IFACE_COM7_IMP(IFolderOperationsExtractCallback)
200 // STDMETHOD(SetTotalFiles)(UInt64 total); 203 Z7_IFACE_COM7_IMP(IFolderExtractToStreamCallback)
201 // STDMETHOD(SetCompletedFiles)(const UInt64 *value); 204 Z7_IFACE_COM7_IMP(ICompressProgressInfo)
202 205 #endif
203 INTERFACE_IExtractCallbackUI(;) 206 #ifndef Z7_NO_CRYPTO
204 207 Z7_IFACE_COM7_IMP(ICryptoGetTextPassword)
205 #ifndef _SFX 208 #endif
206 // IFolderOperationsExtractCallback
207 STDMETHOD(AskWrite)(
208 const wchar_t *srcPath,
209 Int32 srcIsFolder,
210 const FILETIME *srcTime,
211 const UInt64 *srcSize,
212 const wchar_t *destPathRequest,
213 BSTR *destPathResult,
214 Int32 *writeAnswer);
215 STDMETHOD(ShowMessage)(const wchar_t *message);
216 STDMETHOD(SetCurrentFilePath)(const wchar_t *filePath);
217 STDMETHOD(SetNumFiles)(UInt64 numFiles);
218 INTERFACE_IFolderExtractToStreamCallback(;)
219 STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
220 #endif
221 209
222 // ICryptoGetTextPassword
223 #ifndef _NO_CRYPTO
224 STDMETHOD(CryptoGetTextPassword)(BSTR *password);
225 #endif
226 210
227private:
228 UString _currentArchivePath; 211 UString _currentArchivePath;
229 bool _needWriteArchivePath; 212 bool _needWriteArchivePath;
230 213
231 UString _currentFilePath;
232 bool _isFolder; 214 bool _isFolder;
215 UString _currentFilePath;
216 UString _filePath;
233 217
218 #ifndef Z7_SFX
219 bool _needUpdateStat;
220 bool _newVirtFileWasAdded;
234 bool _isAltStream; 221 bool _isAltStream;
222 bool _curSize_Defined;
235 UInt64 _curSize; 223 UInt64 _curSize;
236 bool _curSizeDefined;
237 UString _filePath;
238 // bool _extractMode; 224 // bool _extractMode;
239 // bool _testMode; 225 // bool _testMode;
240 bool _newVirtFileWasAdded;
241 bool _needUpdateStat;
242
243
244 HRESULT SetCurrentFilePath2(const wchar_t *filePath);
245 void AddError_Message(LPCWSTR message);
246
247 #ifndef _SFX
248 bool _hashStreamWasUsed; 226 bool _hashStreamWasUsed;
249 COutStreamWithHash *_hashStreamSpec; 227 COutStreamWithHash *_hashStreamSpec;
250 CMyComPtr<ISequentialOutStream> _hashStream; 228 CMyComPtr<ISequentialOutStream> _hashStream;
251 IHashCalc *_hashCalc; // it's for stat in Test operation 229 IHashCalc *_hashCalc; // it's for stat in Test operation
252 #endif 230 #endif
231
232 HRESULT SetCurrentFilePath2(const wchar_t *filePath);
233 void AddError_Message(LPCWSTR message);
234 HRESULT MessageError(const char *message, const FString &path);
235 void Add_ArchiveName_Error();
253 236
254public: 237public:
255 238
256 #ifndef _SFX 239 #ifndef Z7_SFX
257 CVirtFileSystem *VirtFileSystemSpec; 240 CVirtFileSystem *VirtFileSystemSpec;
258 CMyComPtr<ISequentialOutStream> VirtFileSystem; 241 CMyComPtr<ISequentialOutStream> VirtFileSystem;
259 #endif 242 #endif
@@ -263,7 +246,7 @@ public:
263 bool StreamMode; 246 bool StreamMode;
264 247
265 CProgressDialog *ProgressDialog; 248 CProgressDialog *ProgressDialog;
266 #ifndef _SFX 249 #ifndef Z7_SFX
267 UInt64 NumFolders; 250 UInt64 NumFolders;
268 UInt64 NumFiles; 251 UInt64 NumFiles;
269 bool NeedAddFile; 252 bool NeedAddFile;
@@ -272,7 +255,7 @@ public:
272 bool ThereAreMessageErrors; 255 bool ThereAreMessageErrors;
273 NExtract::NOverwriteMode::EEnum OverwriteMode; 256 NExtract::NOverwriteMode::EEnum OverwriteMode;
274 257
275 #ifndef _NO_CRYPTO 258 #ifndef Z7_NO_CRYPTO
276 bool PasswordIsDefined; 259 bool PasswordIsDefined;
277 bool PasswordWasAsked; 260 bool PasswordWasAsked;
278 UString Password; 261 UString Password;
@@ -290,13 +273,13 @@ public:
290 bool MultiArcMode; 273 bool MultiArcMode;
291 274
292 CExtractCallbackImp(): 275 CExtractCallbackImp():
293 #ifndef _SFX 276 #ifndef Z7_SFX
294 _hashCalc(NULL), 277 _hashCalc(NULL),
295 #endif 278 #endif
296 ProcessAltStreams(true), 279 ProcessAltStreams(true),
297 StreamMode(false), 280 StreamMode(false),
298 OverwriteMode(NExtract::NOverwriteMode::kAsk), 281 OverwriteMode(NExtract::NOverwriteMode::kAsk),
299 #ifndef _NO_CRYPTO 282 #ifndef Z7_NO_CRYPTO
300 PasswordIsDefined(false), 283 PasswordIsDefined(false),
301 PasswordWasAsked(false), 284 PasswordWasAsked(false),
302 #endif 285 #endif
@@ -308,7 +291,7 @@ public:
308 ~CExtractCallbackImp(); 291 ~CExtractCallbackImp();
309 void Init(); 292 void Init();
310 293
311 #ifndef _SFX 294 #ifndef Z7_SFX
312 void SetHashCalc(IHashCalc *hashCalc) { _hashCalc = hashCalc; } 295 void SetHashCalc(IHashCalc *hashCalc) { _hashCalc = hashCalc; }
313 296
314 void SetHashMethods(IHashCalc *hash) 297 void SetHashMethods(IHashCalc *hash)
diff --git a/CPP/7zip/UI/FileManager/FM.cpp b/CPP/7zip/UI/FileManager/FM.cpp
index 812eff6..13189a7 100644
--- a/CPP/7zip/UI/FileManager/FM.cpp
+++ b/CPP/7zip/UI/FileManager/FM.cpp
@@ -4,8 +4,13 @@
4 4
5#include "../../../Common/MyWindows.h" 5#include "../../../Common/MyWindows.h"
6 6
7#if defined(__MINGW32__) || defined(__MINGW64__)
8#include <shlwapi.h>
9#else
7#include <Shlwapi.h> 10#include <Shlwapi.h>
11#endif
8 12
13#include "../../../../C/Compiler.h"
9#include "../../../../C/Alloc.h" 14#include "../../../../C/Alloc.h"
10#ifdef _WIN32 15#ifdef _WIN32
11#include "../../../../C/DllSecur.h" 16#include "../../../../C/DllSecur.h"
@@ -46,7 +51,9 @@ extern
46bool g_RAM_Size_Defined; 51bool g_RAM_Size_Defined;
47bool g_RAM_Size_Defined; 52bool g_RAM_Size_Defined;
48 53
49static bool g_LargePagesMode = false; 54extern
55bool g_LargePagesMode;
56bool g_LargePagesMode = false;
50// static bool g_OpenArchive = false; 57// static bool g_OpenArchive = false;
51 58
52static bool g_Maximized = false; 59static bool g_Maximized = false;
@@ -78,20 +85,23 @@ DWORD g_ComCtl32Version;
78static DWORD GetDllVersion(LPCTSTR dllName) 85static DWORD GetDllVersion(LPCTSTR dllName)
79{ 86{
80 DWORD dwVersion = 0; 87 DWORD dwVersion = 0;
81 HINSTANCE hinstDll = LoadLibrary(dllName); 88 const HMODULE hmodule = LoadLibrary(dllName);
82 if (hinstDll) 89 if (hmodule)
83 { 90 {
84 DLLGETVERSIONPROC pDllGetVersion = (DLLGETVERSIONPROC)(void *)GetProcAddress(hinstDll, "DllGetVersion"); 91 const
85 if (pDllGetVersion) 92 DLLGETVERSIONPROC f_DllGetVersion = Z7_GET_PROC_ADDRESS(
93 DLLGETVERSIONPROC, hmodule,
94 "DllGetVersion");
95 if (f_DllGetVersion)
86 { 96 {
87 DLLVERSIONINFO dvi; 97 DLLVERSIONINFO dvi;
88 ZeroMemory(&dvi, sizeof(dvi)); 98 ZeroMemory(&dvi, sizeof(dvi));
89 dvi.cbSize = sizeof(dvi); 99 dvi.cbSize = sizeof(dvi);
90 HRESULT hr = (*pDllGetVersion)(&dvi); 100 const HRESULT hr = f_DllGetVersion(&dvi);
91 if (SUCCEEDED(hr)) 101 if (SUCCEEDED(hr))
92 dwVersion = MAKELONG(dvi.dwMinorVersion, dvi.dwMajorVersion); 102 dwVersion = (DWORD)MAKELONG(dvi.dwMinorVersion, dvi.dwMajorVersion);
93 } 103 }
94 FreeLibrary(hinstDll); 104 FreeLibrary(hmodule);
95 } 105 }
96 return dwVersion; 106 return dwVersion;
97} 107}
@@ -180,7 +190,7 @@ CApp g_App;
180 190
181LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 191LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
182 192
183static const wchar_t * const kWindowClass = L"FM"; 193static const wchar_t * const kWindowClass = L"7-Zip::FM";
184 194
185#ifdef UNDER_CE 195#ifdef UNDER_CE
186#define WS_OVERLAPPEDWINDOW ( \ 196#define WS_OVERLAPPEDWINDOW ( \
@@ -222,7 +232,7 @@ static BOOL InitInstance(int nCmdShow)
222 wc.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_ICON)); 232 wc.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_ICON));
223 233
224 // wc.hCursor = LoadCursor (NULL, IDC_ARROW); 234 // wc.hCursor = LoadCursor (NULL, IDC_ARROW);
225 wc.hCursor = ::LoadCursor(0, IDC_SIZEWE); 235 wc.hCursor = ::LoadCursor(NULL, IDC_SIZEWE);
226 // wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); 236 // wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
227 wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); 237 wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
228 238
@@ -236,7 +246,8 @@ static BOOL InitInstance(int nCmdShow)
236 246
237 wc.lpszClassName = kWindowClass; 247 wc.lpszClassName = kWindowClass;
238 248
239 MyRegisterClass(&wc); 249 if (MyRegisterClass(&wc) == 0)
250 return FALSE;
240 251
241 // RECT rect; 252 // RECT rect;
242 // GetClientRect(hWnd, &rect); 253 // GetClientRect(hWnd, &rect);
@@ -305,7 +316,7 @@ static BOOL InitInstance(int nCmdShow)
305 { 316 {
306 if (windowPosIsRead) 317 if (windowPosIsRead)
307 placement.rcNormalPosition = info.rect; 318 placement.rcNormalPosition = info.rect;
308 placement.showCmd = nCmdShow; 319 placement.showCmd = (UINT)nCmdShow;
309 wnd.SetPlacement(&placement); 320 wnd.SetPlacement(&placement);
310 } 321 }
311 else 322 else
@@ -343,6 +354,8 @@ static void GetCommands(const UString &aCommandLine, UString &aCommands)
343 354
344#if defined(_WIN32) && !defined(_WIN64) && !defined(UNDER_CE) 355#if defined(_WIN32) && !defined(_WIN64) && !defined(UNDER_CE)
345 356
357extern
358bool g_Is_Wow64;
346bool g_Is_Wow64; 359bool g_Is_Wow64;
347 360
348typedef BOOL (WINAPI *Func_IsWow64Process)(HANDLE, PBOOL); 361typedef BOOL (WINAPI *Func_IsWow64Process)(HANDLE, PBOOL);
@@ -350,18 +363,27 @@ typedef BOOL (WINAPI *Func_IsWow64Process)(HANDLE, PBOOL);
350static void Set_Wow64() 363static void Set_Wow64()
351{ 364{
352 g_Is_Wow64 = false; 365 g_Is_Wow64 = false;
353 Func_IsWow64Process fnIsWow64Process = (Func_IsWow64Process)(void *)GetProcAddress( 366 const
354 GetModuleHandleA("kernel32.dll"), "IsWow64Process"); 367 Func_IsWow64Process fn = Z7_GET_PROC_ADDRESS(
355 if (fnIsWow64Process) 368 Func_IsWow64Process, GetModuleHandleA("kernel32.dll"),
369 "IsWow64Process");
370 if (fn)
356 { 371 {
357 BOOL isWow; 372 BOOL isWow;
358 if (fnIsWow64Process(GetCurrentProcess(), &isWow)) 373 if (fn(GetCurrentProcess(), &isWow))
359 g_Is_Wow64 = (isWow != FALSE); 374 g_Is_Wow64 = (isWow != FALSE);
360 } 375 }
361} 376}
362 377
363#endif 378#endif
364 379
380#if _MSC_VER > 1400 /* && _MSC_VER <= 1900 */
381 // GetVersion was declared deprecated
382 #pragma warning(disable : 4996)
383#endif
384#ifdef __clang__
385 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
386#endif
365 387
366bool IsLargePageSupported(); 388bool IsLargePageSupported();
367bool IsLargePageSupported() 389bool IsLargePageSupported()
@@ -369,18 +391,17 @@ bool IsLargePageSupported()
369 #ifdef _WIN64 391 #ifdef _WIN64
370 return true; 392 return true;
371 #else 393 #else
372 OSVERSIONINFO vi; 394
373 vi.dwOSVersionInfoSize = sizeof(vi); 395 DWORD v = GetVersion();
374 if (!::GetVersionEx(&vi)) 396 // low byte is major version:
375 return false; 397 // next byte is minor version:
376 if (vi.dwPlatformId != VER_PLATFORM_WIN32_NT) 398 v = ((v & 0xff) << 8) | ((v >> 8) & 0xFF);
377 return false; 399 return (v > 0x501);
378 if (vi.dwMajorVersion < 5) return false; 400 // if ((Byte)v < 5) return false;
379 if (vi.dwMajorVersion > 5) return true; 401 // if ((Byte)v > 5) return true;
380 if (vi.dwMinorVersion < 1) return false; 402 // return ((Byte)(v >> 8) > 1);
381 if (vi.dwMinorVersion > 1) return true; 403 /* large pages work in 5.1 (XP-32bit) if it's (g_Is_Wow64) mode;
382 // return g_Is_Wow64; 404 but here we don't enable them in (XP-32bit). */
383 return false;
384 #endif 405 #endif
385} 406}
386 407
@@ -407,12 +428,10 @@ bool g_SymLink_Supported = false;
407 428
408static void Set_SymLink_Supported() 429static void Set_SymLink_Supported()
409{ 430{
410 g_SymLink_Supported = false; 431 // g_SymLink_Supported = false;
411 OSVERSIONINFO vi; 432 const DWORD v = GetVersion();
412 vi.dwOSVersionInfoSize = sizeof(vi); 433 // low byte is major version:
413 if (!::GetVersionEx(&vi)) 434 if ((Byte)v < 6)
414 return;
415 if (vi.dwPlatformId != VER_PLATFORM_WIN32_NT || vi.dwMajorVersion < 6)
416 return; 435 return;
417 g_SymLink_Supported = true; 436 g_SymLink_Supported = true;
418 // if (g_SymLink_Supported) 437 // if (g_SymLink_Supported)
@@ -444,7 +463,7 @@ static const CSwitchForm kSwitchForms[kNumSwitches] =
444 463
445static void ErrorMessage(const wchar_t *s) 464static void ErrorMessage(const wchar_t *s)
446{ 465{
447 MessageBoxW(0, s, L"7-Zip", MB_ICONERROR); 466 MessageBoxW(NULL, s, L"7-Zip", MB_ICONERROR);
448} 467}
449 468
450static void ErrorMessage(const char *s) 469static void ErrorMessage(const char *s)
@@ -488,11 +507,15 @@ static int WINAPI WinMain2(int nCmdShow)
488 */ 507 */
489 508
490 NT_CHECK 509 NT_CHECK
510 #ifdef Z7_LARGE_PAGES
491 SetLargePageSize(); 511 SetLargePageSize();
512 #endif
492 513
493 #endif 514 #endif
494 515
516 #ifdef Z7_LANG
495 LoadLangOneTime(); 517 LoadLangOneTime();
518 #endif
496 519
497 InitCommonControls(); 520 InitCommonControls();
498 521
@@ -516,7 +539,7 @@ static int WINAPI WinMain2(int nCmdShow)
516 // NCOM::CComInitializer comInitializer; 539 // NCOM::CComInitializer comInitializer;
517 540
518 UString commandsString; 541 UString commandsString;
519 // MessageBoxW(0, GetCommandLineW(), L"", 0); 542 // MessageBoxW(NULL, GetCommandLineW(), L"", 0);
520 543
521 #ifdef UNDER_CE 544 #ifdef UNDER_CE
522 commandsString = GetCommandLineW(); 545 commandsString = GetCommandLineW();
@@ -577,7 +600,7 @@ static int WINAPI WinMain2(int nCmdShow)
577 g_MainPath = paramString; 600 g_MainPath = paramString;
578 // return WinMain2(hInstance, hPrevInstance, lpCmdLine, nCmdShow); 601 // return WinMain2(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
579 602
580 // MessageBoxW(0, paramString, L"", 0); 603 // MessageBoxW(NULL, paramString, L"", 0);
581 } 604 }
582 /* 605 /*
583 UStringVector commandStrings; 606 UStringVector commandStrings;
@@ -608,7 +631,7 @@ static int WINAPI WinMain2(int nCmdShow)
608 Set_SymLink_Supported(); 631 Set_SymLink_Supported();
609 #endif 632 #endif
610 633
611 g_App.ReloadLang(); 634 g_App.ReloadLangItems();
612 635
613 MSG msg; 636 MSG msg;
614 if (!InitInstance (nCmdShow)) 637 if (!InitInstance (nCmdShow))
@@ -654,7 +677,7 @@ static int WINAPI WinMain2(int nCmdShow)
654 // But we suppose that it's better to release DLLs here (before destructor). 677 // But we suppose that it's better to release DLLs here (before destructor).
655 FreeGlobalCodecs(); 678 FreeGlobalCodecs();
656 679
657 g_HWND = 0; 680 g_HWND = NULL;
658 #ifndef UNDER_CE 681 #ifndef UNDER_CE
659 OleUninitialize(); 682 OleUninitialize();
660 #endif 683 #endif
@@ -714,7 +737,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
714 catch(int v) 737 catch(int v)
715 { 738 {
716 AString e ("Error: "); 739 AString e ("Error: ");
717 e.Add_UInt32(v); 740 e.Add_UInt32((unsigned)v);
718 ErrorMessage(e); 741 ErrorMessage(e);
719 return 1; 742 return 1;
720 } 743 }
@@ -748,7 +771,7 @@ static void SaveWindowInfo(HWND aWnd)
748 771
749 info.numPanels = g_App.NumPanels; 772 info.numPanels = g_App.NumPanels;
750 info.currentPanel = g_App.LastFocusedPanel; 773 info.currentPanel = g_App.LastFocusedPanel;
751 info.splitterPos = g_Splitter.GetPos(); 774 info.splitterPos = (unsigned)g_Splitter.GetPos();
752 775
753 info.Save(); 776 info.Save();
754} 777}
@@ -825,23 +848,23 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
825 WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_TOOLTIPS, // | TBSTYLE_FLAT 848 WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_TOOLTIPS, // | TBSTYLE_FLAT
826 baseID + 2, 11, 849 baseID + 2, 11,
827 (HINSTANCE)HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR, 850 (HINSTANCE)HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR,
828 (LPCTBBUTTON)&tbb, ARRAY_SIZE(tbb), 851 (LPCTBBUTTON)&tbb, Z7_ARRAY_SIZE(tbb),
829 0, 0, 100, 30, sizeof (TBBUTTON))); 852 0, 0, 100, 30, sizeof (TBBUTTON)));
830 */ 853 */
831 // HCURSOR cursor = ::LoadCursor(0, IDC_SIZEWE); 854 // HCURSOR cursor = ::LoadCursor(0, IDC_SIZEWE);
832 // ::SetCursor(cursor); 855 // ::SetCursor(cursor);
833 856
834 if (g_PanelsInfoDefined) 857 if (g_PanelsInfoDefined)
835 g_Splitter.SetPos(hWnd, g_SplitterPos); 858 g_Splitter.SetPos(hWnd, (int)g_SplitterPos);
836 else 859 else
837 { 860 {
838 g_Splitter.SetRatio(hWnd, kSplitterRateMax / 2); 861 g_Splitter.SetRatio(hWnd, kSplitterRateMax / 2);
839 g_SplitterPos = g_Splitter.GetPos(); 862 g_SplitterPos = (unsigned)g_Splitter.GetPos();
840 } 863 }
841 864
842 RECT rect; 865 RECT rect;
843 ::GetClientRect(hWnd, &rect); 866 ::GetClientRect(hWnd, &rect);
844 int xSize = rect.right; 867 const int xSize = rect.right;
845 int xSizes[2]; 868 int xSizes[2];
846 xSizes[0] = g_Splitter.GetPos(); 869 xSizes[0] = g_Splitter.GetPos();
847 xSizes[1] = xSize - kSplitterWidth - xSizes[0]; 870 xSizes[1] = xSize - kSplitterWidth - xSizes[0];
@@ -954,7 +977,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
954 g_Splitter.SetPosFromRatio(hWnd); 977 g_Splitter.SetPosFromRatio(hWnd);
955 else 978 else
956 { 979 {
957 g_Splitter.SetPos(hWnd, g_SplitterPos ); 980 g_Splitter.SetPos(hWnd, (int)g_SplitterPos );
958 g_CanChangeSplitter = true; 981 g_CanChangeSplitter = true;
959 } 982 }
960 983
@@ -1047,7 +1070,7 @@ void CApp::MoveSubWindows()
1047{ 1070{
1048 HWND hWnd = _window; 1071 HWND hWnd = _window;
1049 RECT rect; 1072 RECT rect;
1050 if (hWnd == 0) 1073 if (!hWnd)
1051 return; 1074 return;
1052 ::GetClientRect(hWnd, &rect); 1075 ::GetClientRect(hWnd, &rect);
1053 int xSize = rect.right; 1076 int xSize = rect.right;
diff --git a/CPP/7zip/UI/FileManager/FM.dsp b/CPP/7zip/UI/FileManager/FM.dsp
index a12d330..1ae054d 100644
--- a/CPP/7zip/UI/FileManager/FM.dsp
+++ b/CPP/7zip/UI/FileManager/FM.dsp
@@ -45,7 +45,7 @@ RSC=rc.exe
45# PROP Ignore_Export_Lib 0 45# PROP Ignore_Export_Lib 0
46# PROP Target_Dir "" 46# PROP Target_Dir ""
47# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c 47# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
48# ADD CPP /nologo /Gz /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /FAcs /Yu"StdAfx.h" /FD /c 48# ADD CPP /nologo /Gz /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "Z7_LANG" /D "Z7_LONG_PATH" /D "Z7_EXTERNAL_CODECS" /D "Z7_DEVICE_FILE" /FAcs /Yu"StdAfx.h" /FD /c
49# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 49# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
50# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 50# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
51# ADD BASE RSC /l 0x419 /d "NDEBUG" 51# ADD BASE RSC /l 0x419 /d "NDEBUG"
@@ -72,7 +72,7 @@ LINK32=link.exe
72# PROP Ignore_Export_Lib 0 72# PROP Ignore_Export_Lib 0
73# PROP Target_Dir "" 73# PROP Target_Dir ""
74# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c 74# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
75# ADD CPP /nologo /Gz /MDd /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /GZ /c 75# ADD CPP /nologo /Gz /MDd /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "Z7_LANG" /D "Z7_LONG_PATH" /D "Z7_EXTERNAL_CODECS" /D "Z7_DEVICE_FILE" /Yu"StdAfx.h" /FD /GZ /c
76# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 76# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
77# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 77# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
78# ADD BASE RSC /l 0x419 /d "_DEBUG" 78# ADD BASE RSC /l 0x419 /d "_DEBUG"
@@ -99,7 +99,7 @@ LINK32=link.exe
99# PROP Ignore_Export_Lib 0 99# PROP Ignore_Export_Lib 0
100# PROP Target_Dir "" 100# PROP Target_Dir ""
101# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"StdAfx.h" /FD /c 101# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"StdAfx.h" /FD /c
102# ADD CPP /nologo /Gz /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /c 102# ADD CPP /nologo /Gz /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "Z7_LANG" /D "Z7_LONG_PATH" /D "Z7_EXTERNAL_CODECS" /D "Z7_DEVICE_FILE" /Yu"StdAfx.h" /FD /c
103# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 103# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
104# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 104# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
105# ADD BASE RSC /l 0x419 /d "NDEBUG" 105# ADD BASE RSC /l 0x419 /d "NDEBUG"
@@ -127,7 +127,7 @@ LINK32=link.exe
127# PROP Ignore_Export_Lib 0 127# PROP Ignore_Export_Lib 0
128# PROP Target_Dir "" 128# PROP Target_Dir ""
129# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c 129# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
130# ADD CPP /nologo /Gz /MDd /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /GZ /c 130# ADD CPP /nologo /Gz /MDd /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "Z7_LANG" /D "Z7_LONG_PATH" /D "Z7_EXTERNAL_CODECS" /D "Z7_DEVICE_FILE" /Yu"StdAfx.h" /FD /GZ /c
131# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 131# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
132# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 132# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
133# ADD BASE RSC /l 0x419 /d "_DEBUG" 133# ADD BASE RSC /l 0x419 /d "_DEBUG"
@@ -707,6 +707,10 @@ SOURCE=..\..\..\..\C\7zTypes.h
707# End Source File 707# End Source File
708# Begin Source File 708# Begin Source File
709 709
710SOURCE=..\..\..\..\C\7zWindows.h
711# End Source File
712# Begin Source File
713
710SOURCE=..\..\..\..\C\Alloc.c 714SOURCE=..\..\..\..\C\Alloc.c
711# SUBTRACT CPP /YX /Yc /Yu 715# SUBTRACT CPP /YX /Yc /Yu
712# End Source File 716# End Source File
@@ -716,6 +720,10 @@ SOURCE=..\..\..\..\C\Alloc.h
716# End Source File 720# End Source File
717# Begin Source File 721# Begin Source File
718 722
723SOURCE=..\..\..\..\C\Compiler.h
724# End Source File
725# Begin Source File
726
719SOURCE=..\..\..\..\C\CpuArch.c 727SOURCE=..\..\..\..\C\CpuArch.c
720# SUBTRACT CPP /YX /Yc /Yu 728# SUBTRACT CPP /YX /Yc /Yu
721# End Source File 729# End Source File
@@ -1112,6 +1120,10 @@ SOURCE=..\..\..\Common\MyCom.h
1112# End Source File 1120# End Source File
1113# Begin Source File 1121# Begin Source File
1114 1122
1123SOURCE=..\..\..\Common\MyInitGuid.h
1124# End Source File
1125# Begin Source File
1126
1115SOURCE=..\..\..\Common\MyString.cpp 1127SOURCE=..\..\..\Common\MyString.cpp
1116# End Source File 1128# End Source File
1117# Begin Source File 1129# Begin Source File
@@ -1132,6 +1144,10 @@ SOURCE=..\..\..\Common\MyVector.h
1132# End Source File 1144# End Source File
1133# Begin Source File 1145# Begin Source File
1134 1146
1147SOURCE=..\..\..\Common\MyWindows.h
1148# End Source File
1149# Begin Source File
1150
1135SOURCE=..\..\..\Common\NewHandler.cpp 1151SOURCE=..\..\..\Common\NewHandler.cpp
1136# End Source File 1152# End Source File
1137# Begin Source File 1153# Begin Source File
@@ -1431,6 +1447,14 @@ SOURCE=..\Explorer\MyExplorerCommand.h
1431# End Source File 1447# End Source File
1432# Begin Source File 1448# Begin Source File
1433 1449
1450SOURCE=..\Explorer\MyMessages.cpp
1451# End Source File
1452# Begin Source File
1453
1454SOURCE=..\Explorer\MyMessages.h
1455# End Source File
1456# Begin Source File
1457
1434SOURCE=..\Explorer\RegistryContextMenu.cpp 1458SOURCE=..\Explorer\RegistryContextMenu.cpp
1435# End Source File 1459# End Source File
1436# Begin Source File 1460# Begin Source File
diff --git a/CPP/7zip/UI/FileManager/FM.mak b/CPP/7zip/UI/FileManager/FM.mak
index 8b3d97a..8331285 100644
--- a/CPP/7zip/UI/FileManager/FM.mak
+++ b/CPP/7zip/UI/FileManager/FM.mak
@@ -1,12 +1,11 @@
1CFLAGS = $(CFLAGS) \ 1CFLAGS = $(CFLAGS) \
2 -DLANG \ 2 -DZ7_LANG \
3 -DNEW_FOLDER_INTERFACE \
4 3
5!IFDEF UNDER_CE 4!IFDEF UNDER_CE
6LIBS = $(LIBS) ceshell.lib Commctrl.lib 5LIBS = $(LIBS) ceshell.lib Commctrl.lib
7!ELSE 6!ELSE
8LIBS = $(LIBS) comctl32.lib htmlhelp.lib comdlg32.lib Mpr.lib Gdi32.lib 7LIBS = $(LIBS) comctl32.lib htmlhelp.lib comdlg32.lib Mpr.lib Gdi32.lib
9CFLAGS = $(CFLAGS) -DWIN_LONG_PATH -DSUPPORT_DEVICE_FILE 8CFLAGS = $(CFLAGS) -DZ7_LONG_PATH -DZ7_DEVICE_FILE
10LFLAGS = $(LFLAGS) /DELAYLOAD:mpr.dll 9LFLAGS = $(LFLAGS) /DELAYLOAD:mpr.dll
11LIBS = $(LIBS) delayimp.lib 10LIBS = $(LIBS) delayimp.lib
12!ENDIF 11!ENDIF
@@ -47,7 +46,6 @@ FM_OBJS = \
47 $O\ProgramLocation.obj \ 46 $O\ProgramLocation.obj \
48 $O\PropertyName.obj \ 47 $O\PropertyName.obj \
49 $O\RegistryAssociations.obj \ 48 $O\RegistryAssociations.obj \
50 $O\RegistryPlugins.obj \
51 $O\RegistryUtils.obj \ 49 $O\RegistryUtils.obj \
52 $O\RootFolder.obj \ 50 $O\RootFolder.obj \
53 $O\SplitUtils.obj \ 51 $O\SplitUtils.obj \
@@ -98,3 +96,5 @@ AGENT_OBJS = \
98 $O\ArchiveFolderOpen.obj \ 96 $O\ArchiveFolderOpen.obj \
99 $O\ArchiveFolderOut.obj \ 97 $O\ArchiveFolderOut.obj \
100 $O\UpdateCallbackAgent.obj \ 98 $O\UpdateCallbackAgent.obj \
99
100# we need empty line after last line above
diff --git a/CPP/7zip/UI/FileManager/FSDrives.cpp b/CPP/7zip/UI/FileManager/FSDrives.cpp
index c563907..985d7c4 100644
--- a/CPP/7zip/UI/FileManager/FSDrives.cpp
+++ b/CPP/7zip/UI/FileManager/FSDrives.cpp
@@ -41,7 +41,7 @@ FString CDriveInfo::GetDeviceFileIoName() const
41struct CPhysTempBuffer 41struct CPhysTempBuffer
42{ 42{
43 void *buffer; 43 void *buffer;
44 CPhysTempBuffer(): buffer(0) {} 44 CPhysTempBuffer(): buffer(NULL) {}
45 ~CPhysTempBuffer() { MidFree(buffer); } 45 ~CPhysTempBuffer() { MidFree(buffer); }
46}; 46};
47 47
@@ -50,22 +50,22 @@ static HRESULT CopyFileSpec(CFSTR fromPath, CFSTR toPath, bool writeToDisk, UInt
50{ 50{
51 NIO::CInFile inFile; 51 NIO::CInFile inFile;
52 if (!inFile.Open(fromPath)) 52 if (!inFile.Open(fromPath))
53 return GetLastError(); 53 return GetLastError_noZero_HRESULT();
54 if (fileSize == (UInt64)(Int64)-1) 54 if (fileSize == (UInt64)(Int64)-1)
55 { 55 {
56 if (!inFile.GetLength(fileSize)) 56 if (!inFile.GetLength(fileSize))
57 ::GetLastError(); 57 return GetLastError_noZero_HRESULT();
58 } 58 }
59 59
60 NIO::COutFile outFile; 60 NIO::COutFile outFile;
61 if (writeToDisk) 61 if (writeToDisk)
62 { 62 {
63 if (!outFile.Open(toPath, FILE_SHARE_WRITE, OPEN_EXISTING, 0)) 63 if (!outFile.Open(toPath, FILE_SHARE_WRITE, OPEN_EXISTING, 0))
64 return GetLastError(); 64 return GetLastError_noZero_HRESULT();
65 } 65 }
66 else 66 else
67 if (!outFile.Create(toPath, true)) 67 if (!outFile.Create(toPath, true))
68 return GetLastError(); 68 return GetLastError_noZero_HRESULT();
69 69
70 CPhysTempBuffer tempBuffer; 70 CPhysTempBuffer tempBuffer;
71 tempBuffer.buffer = MidAlloc(bufferSize); 71 tempBuffer.buffer = MidAlloc(bufferSize);
@@ -75,12 +75,12 @@ static HRESULT CopyFileSpec(CFSTR fromPath, CFSTR toPath, bool writeToDisk, UInt
75 for (UInt64 pos = 0; pos < fileSize;) 75 for (UInt64 pos = 0; pos < fileSize;)
76 { 76 {
77 UInt64 progressCur = progressStart + pos; 77 UInt64 progressCur = progressStart + pos;
78 RINOK(progress->SetCompleted(&progressCur)); 78 RINOK(progress->SetCompleted(&progressCur))
79 UInt64 rem = fileSize - pos; 79 UInt64 rem = fileSize - pos;
80 UInt32 curSize = (UInt32)MyMin(rem, (UInt64)bufferSize); 80 UInt32 curSize = (UInt32)MyMin(rem, (UInt64)bufferSize);
81 UInt32 processedSize; 81 UInt32 processedSize;
82 if (!inFile.Read(tempBuffer.buffer, curSize, processedSize)) 82 if (!inFile.Read(tempBuffer.buffer, curSize, processedSize))
83 return GetLastError(); 83 return GetLastError_noZero_HRESULT();
84 if (processedSize == 0) 84 if (processedSize == 0)
85 break; 85 break;
86 curSize = processedSize; 86 curSize = processedSize;
@@ -93,7 +93,7 @@ static HRESULT CopyFileSpec(CFSTR fromPath, CFSTR toPath, bool writeToDisk, UInt
93 } 93 }
94 94
95 if (!outFile.Write(tempBuffer.buffer, curSize, processedSize)) 95 if (!outFile.Write(tempBuffer.buffer, curSize, processedSize))
96 return GetLastError(); 96 return GetLastError_noZero_HRESULT();
97 if (curSize != processedSize) 97 if (curSize != processedSize)
98 return E_FAIL; 98 return E_FAIL;
99 pos += curSize; 99 pos += curSize;
@@ -125,7 +125,7 @@ static const char * const kDriveTypes[] =
125 , "RAM disk" 125 , "RAM disk"
126}; 126};
127 127
128STDMETHODIMP CFSDrives::LoadItems() 128Z7_COM7F_IMF(CFSDrives::LoadItems())
129{ 129{
130 _drives.Clear(); 130 _drives.Clear();
131 131
@@ -209,13 +209,13 @@ STDMETHODIMP CFSDrives::LoadItems()
209 return S_OK; 209 return S_OK;
210} 210}
211 211
212STDMETHODIMP CFSDrives::GetNumberOfItems(UInt32 *numItems) 212Z7_COM7F_IMF(CFSDrives::GetNumberOfItems(UInt32 *numItems))
213{ 213{
214 *numItems = _drives.Size(); 214 *numItems = _drives.Size();
215 return S_OK; 215 return S_OK;
216} 216}
217 217
218STDMETHODIMP CFSDrives::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value) 218Z7_COM7F_IMF(CFSDrives::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value))
219{ 219{
220 if (itemIndex >= (UInt32)_drives.Size()) 220 if (itemIndex >= (UInt32)_drives.Size())
221 return E_INVALIDARG; 221 return E_INVALIDARG;
@@ -239,7 +239,7 @@ STDMETHODIMP CFSDrives::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT
239 case kpidFreeSpace: if (di.KnownSizes) prop = di.FreeSpace; break; 239 case kpidFreeSpace: if (di.KnownSizes) prop = di.FreeSpace; break;
240 case kpidClusterSize: if (di.KnownSizes) prop = di.ClusterSize; break; 240 case kpidClusterSize: if (di.KnownSizes) prop = di.ClusterSize; break;
241 case kpidType: 241 case kpidType:
242 if (di.DriveType < ARRAY_SIZE(kDriveTypes)) 242 if (di.DriveType < Z7_ARRAY_SIZE(kDriveTypes))
243 prop = kDriveTypes[di.DriveType]; 243 prop = kDriveTypes[di.DriveType];
244 break; 244 break;
245 case kpidVolumeName: prop = di.VolumeName; break; 245 case kpidVolumeName: prop = di.VolumeName; break;
@@ -251,7 +251,7 @@ STDMETHODIMP CFSDrives::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT
251 251
252HRESULT CFSDrives::BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder) 252HRESULT CFSDrives::BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder)
253{ 253{
254 *resultFolder = 0; 254 *resultFolder = NULL;
255 if (_volumeMode) 255 if (_volumeMode)
256 return S_OK; 256 return S_OK;
257 NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder; 257 NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder;
@@ -260,14 +260,14 @@ HRESULT CFSDrives::BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder)
260 if (_superMode) 260 if (_superMode)
261 path = kSuperPrefix; 261 path = kSuperPrefix;
262 path += name; 262 path += name;
263 RINOK(fsFolderSpec->Init(path)); 263 RINOK(fsFolderSpec->Init(path))
264 *resultFolder = subFolder.Detach(); 264 *resultFolder = subFolder.Detach();
265 return S_OK; 265 return S_OK;
266} 266}
267 267
268STDMETHODIMP CFSDrives::BindToFolder(UInt32 index, IFolderFolder **resultFolder) 268Z7_COM7F_IMF(CFSDrives::BindToFolder(UInt32 index, IFolderFolder **resultFolder))
269{ 269{
270 *resultFolder = 0; 270 *resultFolder = NULL;
271 if (index >= (UInt32)_drives.Size()) 271 if (index >= (UInt32)_drives.Size())
272 return E_INVALIDARG; 272 return E_INVALIDARG;
273 const CDriveInfo &di = _drives[index]; 273 const CDriveInfo &di = _drives[index];
@@ -285,20 +285,20 @@ STDMETHODIMP CFSDrives::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
285 return BindToFolderSpec(di.FullSystemName, resultFolder); 285 return BindToFolderSpec(di.FullSystemName, resultFolder);
286} 286}
287 287
288STDMETHODIMP CFSDrives::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder) 288Z7_COM7F_IMF(CFSDrives::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder))
289{ 289{
290 return BindToFolderSpec(us2fs(name), resultFolder); 290 return BindToFolderSpec(us2fs(name), resultFolder);
291} 291}
292 292
293STDMETHODIMP CFSDrives::BindToParentFolder(IFolderFolder **resultFolder) 293Z7_COM7F_IMF(CFSDrives::BindToParentFolder(IFolderFolder **resultFolder))
294{ 294{
295 *resultFolder = 0; 295 *resultFolder = NULL;
296 return S_OK; 296 return S_OK;
297} 297}
298 298
299IMP_IFolderFolder_Props(CFSDrives) 299IMP_IFolderFolder_Props(CFSDrives)
300 300
301STDMETHODIMP CFSDrives::GetFolderProperty(PROPID propID, PROPVARIANT *value) 301Z7_COM7F_IMF(CFSDrives::GetFolderProperty(PROPID propID, PROPVARIANT *value))
302{ 302{
303 COM_TRY_BEGIN 303 COM_TRY_BEGIN
304 NCOM::CPropVariant prop; 304 NCOM::CPropVariant prop;
@@ -320,7 +320,7 @@ STDMETHODIMP CFSDrives::GetFolderProperty(PROPID propID, PROPVARIANT *value)
320} 320}
321 321
322 322
323STDMETHODIMP CFSDrives::GetSystemIconIndex(UInt32 index, Int32 *iconIndex) 323Z7_COM7F_IMF(CFSDrives::GetSystemIconIndex(UInt32 index, Int32 *iconIndex))
324{ 324{
325 *iconIndex = 0; 325 *iconIndex = 0;
326 const CDriveInfo &di = _drives[index]; 326 const CDriveInfo &di = _drives[index];
@@ -332,39 +332,64 @@ STDMETHODIMP CFSDrives::GetSystemIconIndex(UInt32 index, Int32 *iconIndex)
332 *iconIndex = iconIndexTemp; 332 *iconIndex = iconIndexTemp;
333 return S_OK; 333 return S_OK;
334 } 334 }
335 return GetLastError(); 335 return GetLastError_noZero_HRESULT();
336} 336}
337 337
338void CFSDrives::AddExt(FString &s, unsigned index) const 338void CFSDrives::AddExt(FString &s, unsigned index) const
339{ 339{
340 s += '.'; 340 s.Add_Dot();
341 const CDriveInfo &di = _drives[index]; 341 const CDriveInfo &di = _drives[index];
342 UString n = di.FileSystemName;
343 n.MakeLower_Ascii();
342 const char *ext; 344 const char *ext;
343 if (di.DriveType == DRIVE_CDROM) 345 if (di.DriveType == DRIVE_CDROM)
344 ext = "iso"; 346 ext = "iso";
345 else if (di.FileSystemName.IsPrefixedBy_Ascii_NoCase("NTFS"))
346 ext = "ntfs";
347 else if (di.FileSystemName.IsPrefixedBy_Ascii_NoCase("FAT"))
348 ext = "fat";
349 else 347 else
348 {
349 unsigned i;
350 for (i = 0; i < n.Len(); i++)
351 {
352 const wchar_t c = n[i];
353 if (c < 'a' || c > 'z')
354 break;
355 }
356 if (i != 0)
357 {
358 n.DeleteFrom(i);
359 s += us2fs(n);
360 return;
361 }
350 ext = "img"; 362 ext = "img";
363 }
364 /*
365 if (n.IsPrefixedBy_Ascii_NoCase("NTFS")) ext = "ntfs";
366 else if (n.IsPrefixedBy_Ascii_NoCase("UDF")) ext = "udf";
367 else if (n.IsPrefixedBy_Ascii_NoCase("exFAT")) ext = "exfat";
368 */
351 s += ext; 369 s += ext;
352} 370}
353 371
354HRESULT CFSDrives::GetFileSize(unsigned index, UInt64 &fileSize) const 372HRESULT CFSDrives::GetFileSize(unsigned index, UInt64& fileSize) const
355{ 373{
374#ifdef Z7_DEVICE_FILE
356 NIO::CInFile inFile; 375 NIO::CInFile inFile;
357 if (!inFile.Open(_drives[index].GetDeviceFileIoName())) 376 if (!inFile.Open(_drives[index].GetDeviceFileIoName()))
358 return GetLastError(); 377 return GetLastError_noZero_HRESULT();
359 if (!inFile.SizeDefined) 378 if (inFile.SizeDefined)
360 return E_FAIL; 379 {
361 fileSize = inFile.Size; 380 fileSize = inFile.Size;
362 return S_OK; 381 return S_OK;
382 }
383#else
384 UNUSED_VAR(index)
385#endif
386 fileSize = 0;
387 return E_FAIL;
363} 388}
364 389
365STDMETHODIMP CFSDrives::CopyTo(Int32 moveMode, const UInt32 *indices, UInt32 numItems, 390Z7_COM7F_IMF(CFSDrives::CopyTo(Int32 moveMode, const UInt32 *indices, UInt32 numItems,
366 Int32 /* includeAltStreams */, Int32 /* replaceAltStreamColon */, 391 Int32 /* includeAltStreams */, Int32 /* replaceAltStreamColon */,
367 const wchar_t *path, IFolderOperationsExtractCallback *callback) 392 const wchar_t *path, IFolderOperationsExtractCallback *callback))
368{ 393{
369 if (numItems == 0) 394 if (numItems == 0)
370 return S_OK; 395 return S_OK;
@@ -383,8 +408,8 @@ STDMETHODIMP CFSDrives::CopyTo(Int32 moveMode, const UInt32 *indices, UInt32 num
383 if (di.KnownSize) 408 if (di.KnownSize)
384 totalSize += di.DriveSize; 409 totalSize += di.DriveSize;
385 } 410 }
386 RINOK(callback->SetTotal(totalSize)); 411 RINOK(callback->SetTotal(totalSize))
387 RINOK(callback->SetNumFiles(numItems)); 412 RINOK(callback->SetNumFiles(numItems))
388 413
389 FString destPath = us2fs(path); 414 FString destPath = us2fs(path);
390 if (destPath.IsEmpty()) 415 if (destPath.IsEmpty())
@@ -400,8 +425,7 @@ STDMETHODIMP CFSDrives::CopyTo(Int32 moveMode, const UInt32 *indices, UInt32 num
400 } 425 }
401 426
402 UInt64 completedSize = 0; 427 UInt64 completedSize = 0;
403 RINOK(callback->SetCompleted(&completedSize)); 428 RINOK(callback->SetCompleted(&completedSize))
404
405 for (i = 0; i < numItems; i++) 429 for (i = 0; i < numItems; i++)
406 { 430 {
407 unsigned index = indices[i]; 431 unsigned index = indices[i];
@@ -429,66 +453,66 @@ STDMETHODIMP CFSDrives::CopyTo(Int32 moveMode, const UInt32 *indices, UInt32 num
429 if (!di.KnownSize) 453 if (!di.KnownSize)
430 { 454 {
431 totalSize += fileSize; 455 totalSize += fileSize;
432 RINOK(callback->SetTotal(totalSize)); 456 RINOK(callback->SetTotal(totalSize))
433 } 457 }
434 458
435 Int32 writeAskResult; 459 Int32 writeAskResult;
436 CMyComBSTR destPathResult; 460 CMyComBSTR destPathResult;
437 RINOK(callback->AskWrite(fs2us(srcPath), BoolToInt(false), NULL, &fileSize, 461 RINOK(callback->AskWrite(fs2us(srcPath), BoolToInt(false), NULL, &fileSize,
438 fs2us(destPath2), &destPathResult, &writeAskResult)); 462 fs2us(destPath2), &destPathResult, &writeAskResult))
439 463
440 if (!IntToBool(writeAskResult)) 464 if (!IntToBool(writeAskResult))
441 { 465 {
442 if (totalSize >= fileSize) 466 if (totalSize >= fileSize)
443 totalSize -= fileSize; 467 totalSize -= fileSize;
444 RINOK(callback->SetTotal(totalSize)); 468 RINOK(callback->SetTotal(totalSize))
445 continue; 469 continue;
446 } 470 }
447 471
448 RINOK(callback->SetCurrentFilePath(fs2us(srcPath))); 472 RINOK(callback->SetCurrentFilePath(fs2us(srcPath)))
449 473
450 static const UInt32 kBufferSize = (4 << 20); 474 const UInt32 kBufferSize = (4 << 20);
451 UInt32 bufferSize = (di.DriveType == DRIVE_REMOVABLE) ? (18 << 10) * 4 : kBufferSize; 475 const UInt32 bufferSize = (di.DriveType == DRIVE_REMOVABLE) ? (18 << 10) * 4 : kBufferSize;
452 RINOK(CopyFileSpec(srcPath, us2fs(destPathResult), false, fileSize, bufferSize, completedSize, callback)); 476 RINOK(CopyFileSpec(srcPath, us2fs(destPathResult), false, fileSize, bufferSize, completedSize, callback))
453 completedSize += fileSize; 477 completedSize += fileSize;
454 } 478 }
455 479
456 return S_OK; 480 return S_OK;
457} 481}
458 482
459STDMETHODIMP CFSDrives::CopyFrom(Int32 /* moveMode */, const wchar_t * /* fromFolderPath */, 483Z7_COM7F_IMF(CFSDrives::CopyFrom(Int32 /* moveMode */, const wchar_t * /* fromFolderPath */,
460 const wchar_t * const * /* itemsPaths */, UInt32 /* numItems */, IProgress * /* progress */) 484 const wchar_t * const * /* itemsPaths */, UInt32 /* numItems */, IProgress * /* progress */))
461{ 485{
462 return E_NOTIMPL; 486 return E_NOTIMPL;
463} 487}
464 488
465STDMETHODIMP CFSDrives::CopyFromFile(UInt32 /* index */, const wchar_t * /* fullFilePath */, IProgress * /* progress */) 489Z7_COM7F_IMF(CFSDrives::CopyFromFile(UInt32 /* index */, const wchar_t * /* fullFilePath */, IProgress * /* progress */))
466{ 490{
467 return E_NOTIMPL; 491 return E_NOTIMPL;
468} 492}
469 493
470STDMETHODIMP CFSDrives::CreateFolder(const wchar_t * /* name */, IProgress * /* progress */) 494Z7_COM7F_IMF(CFSDrives::CreateFolder(const wchar_t * /* name */, IProgress * /* progress */))
471{ 495{
472 return E_NOTIMPL; 496 return E_NOTIMPL;
473} 497}
474 498
475STDMETHODIMP CFSDrives::CreateFile(const wchar_t * /* name */, IProgress * /* progress */) 499Z7_COM7F_IMF(CFSDrives::CreateFile(const wchar_t * /* name */, IProgress * /* progress */))
476{ 500{
477 return E_NOTIMPL; 501 return E_NOTIMPL;
478} 502}
479 503
480STDMETHODIMP CFSDrives::Rename(UInt32 /* index */, const wchar_t * /* newName */, IProgress * /* progress */) 504Z7_COM7F_IMF(CFSDrives::Rename(UInt32 /* index */, const wchar_t * /* newName */, IProgress * /* progress */))
481{ 505{
482 return E_NOTIMPL; 506 return E_NOTIMPL;
483} 507}
484 508
485STDMETHODIMP CFSDrives::Delete(const UInt32 * /* indices */, UInt32 /* numItems */, IProgress * /* progress */) 509Z7_COM7F_IMF(CFSDrives::Delete(const UInt32 * /* indices */, UInt32 /* numItems */, IProgress * /* progress */))
486{ 510{
487 return E_NOTIMPL; 511 return E_NOTIMPL;
488} 512}
489 513
490STDMETHODIMP CFSDrives::SetProperty(UInt32 /* index */, PROPID /* propID */, 514Z7_COM7F_IMF(CFSDrives::SetProperty(UInt32 /* index */, PROPID /* propID */,
491 const PROPVARIANT * /* value */, IProgress * /* progress */) 515 const PROPVARIANT * /* value */, IProgress * /* progress */))
492{ 516{
493 return E_NOTIMPL; 517 return E_NOTIMPL;
494} 518}
diff --git a/CPP/7zip/UI/FileManager/FSDrives.h b/CPP/7zip/UI/FileManager/FSDrives.h
index f12e4da..8ae831c 100644
--- a/CPP/7zip/UI/FileManager/FSDrives.h
+++ b/CPP/7zip/UI/FileManager/FSDrives.h
@@ -1,7 +1,7 @@
1// FSDrives.h 1// FSDrives.h
2 2
3#ifndef __FS_DRIVES_H 3#ifndef ZIP7_INC_FS_DRIVES_H
4#define __FS_DRIVES_H 4#define ZIP7_INC_FS_DRIVES_H
5 5
6#include "../../../Common/MyCom.h" 6#include "../../../Common/MyCom.h"
7#include "../../../Common/MyString.h" 7#include "../../../Common/MyString.h"
@@ -28,12 +28,12 @@ struct CDriveInfo
28 CDriveInfo(): KnownSize(false), KnownSizes(false), IsPhysicalDrive(false) {} 28 CDriveInfo(): KnownSize(false), KnownSizes(false), IsPhysicalDrive(false) {}
29}; 29};
30 30
31class CFSDrives: 31Z7_CLASS_IMP_NOQIB_3(
32 public IFolderFolder, 32 CFSDrives
33 public IFolderOperations, 33 , IFolderFolder
34 public IFolderGetSystemIconIndex, 34 , IFolderOperations
35 public CMyUnknownImp 35 , IFolderGetSystemIconIndex
36{ 36)
37 CObjectVector<CDriveInfo> _drives; 37 CObjectVector<CDriveInfo> _drives;
38 bool _volumeMode; 38 bool _volumeMode;
39 bool _superMode; 39 bool _superMode;
@@ -42,13 +42,6 @@ class CFSDrives:
42 void AddExt(FString &s, unsigned index) const; 42 void AddExt(FString &s, unsigned index) const;
43 HRESULT GetFileSize(unsigned index, UInt64 &fileSize) const; 43 HRESULT GetFileSize(unsigned index, UInt64 &fileSize) const;
44public: 44public:
45 MY_UNKNOWN_IMP2(IFolderGetSystemIconIndex, IFolderOperations)
46
47 INTERFACE_FolderFolder(;)
48 INTERFACE_FolderOperations(;)
49
50 STDMETHOD(GetSystemIconIndex)(UInt32 index, Int32 *iconIndex);
51
52 void Init(bool volMode = false, bool superMode = false) 45 void Init(bool volMode = false, bool superMode = false)
53 { 46 {
54 _volumeMode = volMode; 47 _volumeMode = volMode;
diff --git a/CPP/7zip/UI/FileManager/FSFolder.cpp b/CPP/7zip/UI/FileManager/FSFolder.cpp
index f603061..06c572d 100644
--- a/CPP/7zip/UI/FileManager/FSFolder.cpp
+++ b/CPP/7zip/UI/FileManager/FSFolder.cpp
@@ -2,15 +2,24 @@
2 2
3#include "StdAfx.h" 3#include "StdAfx.h"
4 4
5#if defined(_MSC_VER) 5#ifdef __MINGW32_VERSION
6#include <winternl.h> 6// #if !defined(_MSC_VER) && (__GNUC__) && (__GNUC__ < 10)
7// for old mingw
8#include <ddk/ntddk.h>
7#else 9#else
8#if defined(__GNUC__) && (__GNUC__ >= 10) 10#ifndef Z7_OLD_WIN_SDK
9 // new mingw: 11 #if !defined(_M_IA64)
10 #include <winternl.h> 12 #include <winternl.h>
13 #endif
11#else 14#else
12 // old mingw: 15typedef LONG NTSTATUS;
13 #include <ddk/winddk.h> 16typedef struct _IO_STATUS_BLOCK {
17 union {
18 NTSTATUS Status;
19 PVOID Pointer;
20 };
21 ULONG_PTR Information;
22} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
14#endif 23#endif
15#endif 24#endif
16 25
@@ -106,7 +115,7 @@ HRESULT CFSFolder::Init(const FString &path /* , IFolderFolder *parentFolder */)
106 115
107 if (!_findChangeNotification.IsHandleAllocated()) 116 if (!_findChangeNotification.IsHandleAllocated())
108 { 117 {
109 DWORD lastError = GetLastError(); 118 const HRESULT lastError = GetLastError_noZero_HRESULT();
110 CFindFile findFile; 119 CFindFile findFile;
111 CFileInfo fi; 120 CFileInfo fi;
112 FString path2 = _path; 121 FString path2 = _path;
@@ -125,7 +134,7 @@ HRESULT CFsFolderStat::Enumerate()
125{ 134{
126 if (Progress) 135 if (Progress)
127 { 136 {
128 RINOK(Progress->SetCompleted(NULL)); 137 RINOK(Progress->SetCompleted(NULL))
129 } 138 }
130 Path.Add_PathSepar(); 139 Path.Add_PathSepar();
131 const unsigned len = Path.Len(); 140 const unsigned len = Path.Len();
@@ -139,7 +148,7 @@ HRESULT CFsFolderStat::Enumerate()
139 NumFolders++; 148 NumFolders++;
140 Path.DeleteFrom(len); 149 Path.DeleteFrom(len);
141 Path += fi.Name; 150 Path += fi.Name;
142 RINOK(Enumerate()); 151 RINOK(Enumerate())
143 } 152 }
144 else 153 else
145 { 154 {
@@ -166,7 +175,7 @@ bool MyGetCompressedFileSizeW(CFSTR path, UInt64 &size)
166 return true; 175 return true;
167 } 176 }
168 } 177 }
169 #ifdef WIN_LONG_PATH 178 #ifdef Z7_LONG_PATH
170 if (USE_SUPER_PATH) 179 if (USE_SUPER_PATH)
171 { 180 {
172 UString superPath; 181 UString superPath;
@@ -285,16 +294,16 @@ HRESULT CFSFolder::LoadSubItems(int dirItem, const FString &relPrefix)
285 294
286 const unsigned endIndex = Folders.Size(); 295 const unsigned endIndex = Folders.Size();
287 for (unsigned i = startIndex; i < endIndex; i++) 296 for (unsigned i = startIndex; i < endIndex; i++)
288 LoadSubItems(i, Folders[i]); 297 LoadSubItems((int)i, Folders[i]);
289 return S_OK; 298 return S_OK;
290} 299}
291 300
292STDMETHODIMP CFSFolder::LoadItems() 301Z7_COM7F_IMF(CFSFolder::LoadItems())
293{ 302{
294 Int32 dummy; 303 Int32 dummy;
295 WasChanged(&dummy); 304 WasChanged(&dummy);
296 Clear(); 305 Clear();
297 RINOK(LoadSubItems(-1, FString())); 306 RINOK(LoadSubItems(-1, FString()))
298 _commentsAreLoaded = false; 307 _commentsAreLoaded = false;
299 return S_OK; 308 return S_OK;
300} 309}
@@ -356,7 +365,7 @@ bool CFSFolder::SaveComments()
356 return true; 365 return true;
357} 366}
358 367
359STDMETHODIMP CFSFolder::GetNumberOfItems(UInt32 *numItems) 368Z7_COM7F_IMF(CFSFolder::GetNumberOfItems(UInt32 *numItems))
360{ 369{
361 *numItems = Files.Size() /* + Streams.Size() */; 370 *numItems = Files.Size() /* + Streams.Size() */;
362 return S_OK; 371 return S_OK;
@@ -364,9 +373,9 @@ STDMETHODIMP CFSFolder::GetNumberOfItems(UInt32 *numItems)
364 373
365#ifdef USE_UNICODE_FSTRING 374#ifdef USE_UNICODE_FSTRING
366 375
367STDMETHODIMP CFSFolder::GetItemPrefix(UInt32 index, const wchar_t **name, unsigned *len) 376Z7_COM7F_IMF(CFSFolder::GetItemPrefix(UInt32 index, const wchar_t **name, unsigned *len))
368{ 377{
369 *name = 0; 378 *name = NULL;
370 *len = 0; 379 *len = 0;
371 /* 380 /*
372 if (index >= Files.Size()) 381 if (index >= Files.Size())
@@ -383,9 +392,9 @@ STDMETHODIMP CFSFolder::GetItemPrefix(UInt32 index, const wchar_t **name, unsign
383 return S_OK; 392 return S_OK;
384} 393}
385 394
386STDMETHODIMP CFSFolder::GetItemName(UInt32 index, const wchar_t **name, unsigned *len) 395Z7_COM7F_IMF(CFSFolder::GetItemName(UInt32 index, const wchar_t **name, unsigned *len))
387{ 396{
388 *name = 0; 397 *name = NULL;
389 *len = 0; 398 *len = 0;
390 if (index < Files.Size()) 399 if (index < Files.Size())
391 { 400 {
@@ -405,7 +414,7 @@ STDMETHODIMP CFSFolder::GetItemName(UInt32 index, const wchar_t **name, unsigned
405 return S_OK; 414 return S_OK;
406} 415}
407 416
408STDMETHODIMP_(UInt64) CFSFolder::GetItemSize(UInt32 index) 417Z7_COM7F_IMF2(UInt64, CFSFolder::GetItemSize(UInt32 index))
409{ 418{
410 /* 419 /*
411 if (index >= Files.Size()) 420 if (index >= Files.Size())
@@ -434,6 +443,8 @@ bool CFSFolder::ReadFileInfo(CDirItem &di)
434} 443}
435 444
436 445
446EXTERN_C_BEGIN
447
437typedef struct 448typedef struct
438{ 449{
439 LARGE_INTEGER CreationTime; 450 LARGE_INTEGER CreationTime;
@@ -443,37 +454,57 @@ typedef struct
443 ULONG FileAttributes; 454 ULONG FileAttributes;
444 UInt32 Reserved; // it's expected for alignment 455 UInt32 Reserved; // it's expected for alignment
445} 456}
446MY__FILE_BASIC_INFORMATION; 457Z7_WIN_FILE_BASIC_INFORMATION;
447 458
448 459
449typedef enum 460typedef enum
450{ 461{
451 MY__FileDirectoryInformation = 1, 462 Z7_WIN_FileDirectoryInformation = 1,
452 MY__FileFullDirectoryInformation, 463 Z7_WIN_FileFullDirectoryInformation,
453 MY__FileBothDirectoryInformation, 464 Z7_WIN_FileBothDirectoryInformation,
454 MY__FileBasicInformation 465 Z7_WIN_FileBasicInformation
455} 466}
456MY__FILE_INFORMATION_CLASS; 467Z7_WIN_FILE_INFORMATION_CLASS;
468
457 469
470#if (_WIN32_WINNT >= 0x0500) && !defined(_M_IA64)
471#define Z7_WIN_NTSTATUS NTSTATUS
472#define Z7_WIN_IO_STATUS_BLOCK IO_STATUS_BLOCK
473#else
474typedef LONG Z7_WIN_NTSTATUS;
475typedef struct
476{
477 union
478 {
479 Z7_WIN_NTSTATUS Status;
480 PVOID Pointer;
481 } DUMMYUNIONNAME;
482 ULONG_PTR Information;
483} Z7_WIN_IO_STATUS_BLOCK;
484#endif
458 485
459typedef NTSTATUS (WINAPI * Func_NtQueryInformationFile)(
460 HANDLE handle, IO_STATUS_BLOCK *io,
461 void *ptr, LONG len, MY__FILE_INFORMATION_CLASS cls);
462 486
463#define MY__STATUS_SUCCESS 0 487typedef Z7_WIN_NTSTATUS (WINAPI * Func_NtQueryInformationFile)(
488 HANDLE handle, Z7_WIN_IO_STATUS_BLOCK *io,
489 void *ptr, LONG len, Z7_WIN_FILE_INFORMATION_CLASS cls);
490
491#define MY_STATUS_SUCCESS 0
492
493EXTERN_C_END
464 494
465static Func_NtQueryInformationFile f_NtQueryInformationFile; 495static Func_NtQueryInformationFile f_NtQueryInformationFile;
466static bool g_NtQueryInformationFile_WasRequested = false; 496static bool g_NtQueryInformationFile_WasRequested = false;
467 497
498
468void CFSFolder::ReadChangeTime(CDirItem &di) 499void CFSFolder::ReadChangeTime(CDirItem &di)
469{ 500{
470 di.ChangeTime_WasRequested = true; 501 di.ChangeTime_WasRequested = true;
471 502
472 if (!g_NtQueryInformationFile_WasRequested) 503 if (!g_NtQueryInformationFile_WasRequested)
473 { 504 {
474 g_NtQueryInformationFile_WasRequested = true; 505 g_NtQueryInformationFile_WasRequested = true;
475 f_NtQueryInformationFile = (Func_NtQueryInformationFile) 506 f_NtQueryInformationFile = Z7_GET_PROC_ADDRESS(
476 My_GetProcAddress(::GetModuleHandleW(L"ntdll.dll"), 507 Func_NtQueryInformationFile, ::GetModuleHandleW(L"ntdll.dll"),
477 "NtQueryInformationFile"); 508 "NtQueryInformationFile");
478 } 509 }
479 if (!f_NtQueryInformationFile) 510 if (!f_NtQueryInformationFile)
@@ -482,23 +513,23 @@ void CFSFolder::ReadChangeTime(CDirItem &di)
482 NIO::CInFile file; 513 NIO::CInFile file;
483 if (!file.Open_for_ReadAttributes(_path + GetRelPath(di))) 514 if (!file.Open_for_ReadAttributes(_path + GetRelPath(di)))
484 return; 515 return;
485 MY__FILE_BASIC_INFORMATION fbi; 516 Z7_WIN_FILE_BASIC_INFORMATION fbi;
486 IO_STATUS_BLOCK IoStatusBlock; 517 Z7_WIN_IO_STATUS_BLOCK IoStatusBlock;
487 const NTSTATUS status = f_NtQueryInformationFile(file.GetHandle(), &IoStatusBlock, 518 const Z7_WIN_NTSTATUS status = f_NtQueryInformationFile(file.GetHandle(), &IoStatusBlock,
488 &fbi, sizeof(fbi), MY__FileBasicInformation); 519 &fbi, sizeof(fbi), Z7_WIN_FileBasicInformation);
489 if (status != MY__STATUS_SUCCESS) 520 if (status != MY_STATUS_SUCCESS)
490 return; 521 return;
491 if (IoStatusBlock.Information != sizeof(fbi)) 522 if (IoStatusBlock.Information != sizeof(fbi))
492 return; 523 return;
493 di.ChangeTime.dwLowDateTime = fbi.ChangeTime.u.LowPart; 524 di.ChangeTime.dwLowDateTime = fbi.ChangeTime.u.LowPart;
494 di.ChangeTime.dwHighDateTime = fbi.ChangeTime.u.HighPart; 525 di.ChangeTime.dwHighDateTime = (DWORD)fbi.ChangeTime.u.HighPart;
495 di.ChangeTime_Defined = true; 526 di.ChangeTime_Defined = true;
496} 527}
497 528
498#endif // FS_SHOW_LINKS_INFO 529#endif // FS_SHOW_LINKS_INFO
499 530
500 531
501STDMETHODIMP CFSFolder::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value) 532Z7_COM7F_IMF(CFSFolder::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value))
502{ 533{
503 NCOM::CPropVariant prop; 534 NCOM::CPropVariant prop;
504 /* 535 /*
@@ -622,34 +653,32 @@ STDMETHODIMP CFSFolder::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
622// ---------- IArchiveGetRawProps ---------- 653// ---------- IArchiveGetRawProps ----------
623 654
624 655
625STDMETHODIMP CFSFolder::GetNumRawProps(UInt32 *numProps) 656Z7_COM7F_IMF(CFSFolder::GetNumRawProps(UInt32 *numProps))
626{ 657{
627 *numProps = 1; 658 *numProps = 1;
628 return S_OK; 659 return S_OK;
629} 660}
630 661
631STDMETHODIMP CFSFolder::GetRawPropInfo(UInt32 /* index */, BSTR *name, PROPID *propID) 662Z7_COM7F_IMF(CFSFolder::GetRawPropInfo(UInt32 /* index */, BSTR *name, PROPID *propID))
632{ 663{
633 *name = NULL; 664 *name = NULL;
634 *propID = kpidNtReparse; 665 *propID = kpidNtReparse;
635 return S_OK; 666 return S_OK;
636} 667}
637 668
638STDMETHODIMP CFSFolder::GetParent(UInt32 /* index */, UInt32 * /* parent */, UInt32 * /* parentType */) 669Z7_COM7F_IMF(CFSFolder::GetParent(UInt32 /* index */, UInt32 * /* parent */, UInt32 * /* parentType */))
639{ 670{
640 return E_FAIL; 671 return E_FAIL;
641} 672}
642 673
643STDMETHODIMP CFSFolder::GetRawProp(UInt32 674Z7_COM7F_IMF(CFSFolder::GetRawProp(UInt32 index, PROPID propID,
644 #ifndef UNDER_CE 675 const void **data, UInt32 *dataSize, UInt32 *propType))
645 index
646 #endif
647 , PROPID
648 #ifndef UNDER_CE
649 propID
650 #endif
651 , const void **data, UInt32 *dataSize, UInt32 *propType)
652{ 676{
677 #ifdef UNDER_CE
678 UNUSED(index)
679 UNUSED(propID)
680 #endif
681
653 *data = NULL; 682 *data = NULL;
654 *dataSize = 0; 683 *dataSize = 0;
655 *propType = 0; 684 *propType = 0;
@@ -676,11 +705,11 @@ STDMETHODIMP CFSFolder::GetRawProp(UInt32
676 705
677static inline CFSTR GetExtensionPtr(const FString &name) 706static inline CFSTR GetExtensionPtr(const FString &name)
678{ 707{
679 int dotPos = name.ReverseFind_Dot(); 708 const int dotPos = name.ReverseFind_Dot();
680 return name.Ptr((dotPos < 0) ? name.Len() : dotPos); 709 return name.Ptr((dotPos < 0) ? name.Len() : (unsigned)dotPos);
681} 710}
682 711
683STDMETHODIMP_(Int32) CFSFolder::CompareItems(UInt32 index1, UInt32 index2, PROPID propID, Int32 /* propIsRaw */) 712Z7_COM7F_IMF2(Int32, CFSFolder::CompareItems(UInt32 index1, UInt32 index2, PROPID propID, Int32 /* propIsRaw */))
684{ 713{
685 /* 714 /*
686 const CAltStream *ss1 = NULL; 715 const CAltStream *ss1 = NULL;
@@ -695,7 +724,7 @@ STDMETHODIMP_(Int32) CFSFolder::CompareItems(UInt32 index1, UInt32 index2, PROPI
695 { 724 {
696 case kpidName: 725 case kpidName:
697 { 726 {
698 int comp = CompareFileNames_ForFolderList(fi1.Name, fi2.Name); 727 const int comp = CompareFileNames_ForFolderList(fi1.Name, fi2.Name);
699 /* 728 /*
700 if (comp != 0) 729 if (comp != 0)
701 return comp; 730 return comp;
@@ -783,10 +812,10 @@ STDMETHODIMP_(Int32) CFSFolder::CompareItems(UInt32 index1, UInt32 index2, PROPI
783 812
784HRESULT CFSFolder::BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder) 813HRESULT CFSFolder::BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder)
785{ 814{
786 *resultFolder = 0; 815 *resultFolder = NULL;
787 CFSFolder *folderSpec = new CFSFolder; 816 CFSFolder *folderSpec = new CFSFolder;
788 CMyComPtr<IFolderFolder> subFolder = folderSpec; 817 CMyComPtr<IFolderFolder> subFolder = folderSpec;
789 RINOK(folderSpec->Init(_path + name + FCHAR_PATH_SEPARATOR)); 818 RINOK(folderSpec->Init(_path + name + FCHAR_PATH_SEPARATOR))
790 *resultFolder = subFolder.Detach(); 819 *resultFolder = subFolder.Detach();
791 return S_OK; 820 return S_OK;
792} 821}
@@ -836,23 +865,23 @@ FString CFSFolder::GetRelPath(const CDirItem &item) const
836 return Folders[item.Parent] + item.Name; 865 return Folders[item.Parent] + item.Name;
837} 866}
838 867
839STDMETHODIMP CFSFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder) 868Z7_COM7F_IMF(CFSFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder))
840{ 869{
841 *resultFolder = 0; 870 *resultFolder = NULL;
842 const CDirItem &fi = Files[index]; 871 const CDirItem &fi = Files[index];
843 if (!fi.IsDir()) 872 if (!fi.IsDir())
844 return E_INVALIDARG; 873 return E_INVALIDARG;
845 return BindToFolderSpec(GetRelPath(fi), resultFolder); 874 return BindToFolderSpec(GetRelPath(fi), resultFolder);
846} 875}
847 876
848STDMETHODIMP CFSFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder) 877Z7_COM7F_IMF(CFSFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder))
849{ 878{
850 return BindToFolderSpec(us2fs(name), resultFolder); 879 return BindToFolderSpec(us2fs(name), resultFolder);
851} 880}
852 881
853STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder) 882Z7_COM7F_IMF(CFSFolder::BindToParentFolder(IFolderFolder **resultFolder))
854{ 883{
855 *resultFolder = 0; 884 *resultFolder = NULL;
856 /* 885 /*
857 if (_parentFolder) 886 if (_parentFolder)
858 { 887 {
@@ -914,17 +943,17 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
914 return S_OK; 943 return S_OK;
915} 944}
916 945
917STDMETHODIMP CFSFolder::GetNumberOfProperties(UInt32 *numProperties) 946Z7_COM7F_IMF(CFSFolder::GetNumberOfProperties(UInt32 *numProperties))
918{ 947{
919 *numProperties = ARRAY_SIZE(kProps); 948 *numProperties = Z7_ARRAY_SIZE(kProps);
920 if (!_flatMode) 949 if (!_flatMode)
921 (*numProperties)--; 950 (*numProperties)--;
922 return S_OK; 951 return S_OK;
923} 952}
924 953
925STDMETHODIMP CFSFolder::GetPropertyInfo IMP_IFolderFolder_GetProp(kProps) 954IMP_IFolderFolder_GetProp(CFSFolder::GetPropertyInfo, kProps)
926 955
927STDMETHODIMP CFSFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value) 956Z7_COM7F_IMF(CFSFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value))
928{ 957{
929 COM_TRY_BEGIN 958 COM_TRY_BEGIN
930 NWindows::NCOM::CPropVariant prop; 959 NWindows::NCOM::CPropVariant prop;
@@ -938,7 +967,7 @@ STDMETHODIMP CFSFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
938 COM_TRY_END 967 COM_TRY_END
939} 968}
940 969
941STDMETHODIMP CFSFolder::WasChanged(Int32 *wasChanged) 970Z7_COM7F_IMF(CFSFolder::WasChanged(Int32 *wasChanged))
942{ 971{
943 bool wasChangedMain = false; 972 bool wasChangedMain = false;
944 973
@@ -961,7 +990,7 @@ STDMETHODIMP CFSFolder::WasChanged(Int32 *wasChanged)
961 return S_OK; 990 return S_OK;
962} 991}
963 992
964STDMETHODIMP CFSFolder::Clone(IFolderFolder **resultFolder) 993Z7_COM7F_IMF(CFSFolder::Clone(IFolderFolder **resultFolder))
965{ 994{
966 CFSFolder *fsFolderSpec = new CFSFolder; 995 CFSFolder *fsFolderSpec = new CFSFolder;
967 CMyComPtr<IFolderFolder> folderNew = fsFolderSpec; 996 CMyComPtr<IFolderFolder> folderNew = fsFolderSpec;
@@ -970,35 +999,6 @@ STDMETHODIMP CFSFolder::Clone(IFolderFolder **resultFolder)
970 return S_OK; 999 return S_OK;
971} 1000}
972 1001
973HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems, CFsFolderStat &stat)
974{
975 for (UInt32 i = 0; i < numItems; i++)
976 {
977 UInt32 index = indices[i];
978 /*
979 if (index >= Files.Size())
980 {
981 size += Streams[index - Files.Size()].Size;
982 // numFiles++;
983 continue;
984 }
985 */
986 const CDirItem &fi = Files[index];
987 if (fi.IsDir())
988 {
989 stat.Path = _path;
990 stat.Path += GetRelPath(fi);
991 RINOK(stat.Enumerate());
992 stat.NumFolders++;
993 }
994 else
995 {
996 stat.NumFiles++;
997 stat.Size += fi.Size;
998 }
999 }
1000 return S_OK;
1001}
1002 1002
1003/* 1003/*
1004HRESULT CFSFolder::GetItemFullSize(unsigned index, UInt64 &size, IProgress *progress) 1004HRESULT CFSFolder::GetItemFullSize(unsigned index, UInt64 &size, IProgress *progress)
@@ -1019,7 +1019,7 @@ HRESULT CFSFolder::GetItemFullSize(unsigned index, UInt64 &size, IProgress *prog
1019 return S_OK; 1019 return S_OK;
1020} 1020}
1021 1021
1022STDMETHODIMP CFSFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgress *progress) 1022Z7_COM7F_IMF(CFSFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgress *progress)
1023{ 1023{
1024 NCOM::CPropVariant prop; 1024 NCOM::CPropVariant prop;
1025 UInt64 size = 0; 1025 UInt64 size = 0;
@@ -1030,7 +1030,7 @@ STDMETHODIMP CFSFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgr
1030} 1030}
1031*/ 1031*/
1032 1032
1033STDMETHODIMP CFSFolder::CalcItemFullSize(UInt32 index, IProgress *progress) 1033Z7_COM7F_IMF(CFSFolder::CalcItemFullSize(UInt32 index, IProgress *progress))
1034{ 1034{
1035 if (index >= (UInt32)Files.Size()) 1035 if (index >= (UInt32)Files.Size())
1036 return S_OK; 1036 return S_OK;
@@ -1038,7 +1038,7 @@ STDMETHODIMP CFSFolder::CalcItemFullSize(UInt32 index, IProgress *progress)
1038 if (!fi.IsDir()) 1038 if (!fi.IsDir())
1039 return S_OK; 1039 return S_OK;
1040 CFsFolderStat stat(_path + GetRelPath(fi), progress); 1040 CFsFolderStat stat(_path + GetRelPath(fi), progress);
1041 RINOK(stat.Enumerate()); 1041 RINOK(stat.Enumerate())
1042 fi.Size = stat.Size; 1042 fi.Size = stat.Size;
1043 fi.NumFolders = stat.NumFolders; 1043 fi.NumFolders = stat.NumFolders;
1044 fi.NumFiles = stat.NumFiles; 1044 fi.NumFiles = stat.NumFiles;
@@ -1054,30 +1054,29 @@ void CFSFolder::GetAbsPath(const wchar_t *name, FString &absPath)
1054 absPath += us2fs(name); 1054 absPath += us2fs(name);
1055} 1055}
1056 1056
1057STDMETHODIMP CFSFolder::CreateFolder(const wchar_t *name, IProgress * /* progress */) 1057Z7_COM7F_IMF(CFSFolder::CreateFolder(const wchar_t *name, IProgress * /* progress */))
1058{ 1058{
1059 FString absPath; 1059 FString absPath;
1060 GetAbsPath(name, absPath); 1060 GetAbsPath(name, absPath);
1061 if (CreateDir(absPath)) 1061 if (CreateDir(absPath))
1062 return S_OK; 1062 return S_OK;
1063 if (::GetLastError() == ERROR_ALREADY_EXISTS) 1063 if (::GetLastError() != ERROR_ALREADY_EXISTS)
1064 return ::GetLastError(); 1064 if (CreateComplexDir(absPath))
1065 if (!CreateComplexDir(absPath)) 1065 return S_OK;
1066 return ::GetLastError(); 1066 return GetLastError_noZero_HRESULT();
1067 return S_OK;
1068} 1067}
1069 1068
1070STDMETHODIMP CFSFolder::CreateFile(const wchar_t *name, IProgress * /* progress */) 1069Z7_COM7F_IMF(CFSFolder::CreateFile(const wchar_t *name, IProgress * /* progress */))
1071{ 1070{
1072 FString absPath; 1071 FString absPath;
1073 GetAbsPath(name, absPath); 1072 GetAbsPath(name, absPath);
1074 NIO::COutFile outFile; 1073 NIO::COutFile outFile;
1075 if (!outFile.Create(absPath, false)) 1074 if (!outFile.Create(absPath, false))
1076 return ::GetLastError(); 1075 return GetLastError_noZero_HRESULT();
1077 return S_OK; 1076 return S_OK;
1078} 1077}
1079 1078
1080STDMETHODIMP CFSFolder::Rename(UInt32 index, const wchar_t *newName, IProgress * /* progress */) 1079Z7_COM7F_IMF(CFSFolder::Rename(UInt32 index, const wchar_t *newName, IProgress * /* progress */))
1081{ 1080{
1082 if (index >= (UInt32)Files.Size()) 1081 if (index >= (UInt32)Files.Size())
1083 return E_NOTIMPL; 1082 return E_NOTIMPL;
@@ -1088,13 +1087,13 @@ STDMETHODIMP CFSFolder::Rename(UInt32 index, const wchar_t *newName, IProgress *
1088 if (fi.Parent >= 0) 1087 if (fi.Parent >= 0)
1089 fullPrefix += Folders[fi.Parent]; 1088 fullPrefix += Folders[fi.Parent];
1090 if (!MyMoveFile(fullPrefix + fi.Name, fullPrefix + us2fs(newName))) 1089 if (!MyMoveFile(fullPrefix + fi.Name, fullPrefix + us2fs(newName)))
1091 return GetLastError(); 1090 return GetLastError_noZero_HRESULT();
1092 return S_OK; 1091 return S_OK;
1093} 1092}
1094 1093
1095STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress *progress) 1094Z7_COM7F_IMF(CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress *progress))
1096{ 1095{
1097 RINOK(progress->SetTotal(numItems)); 1096 RINOK(progress->SetTotal(numItems))
1098 // int prevDeletedFileIndex = -1; 1097 // int prevDeletedFileIndex = -1;
1099 for (UInt32 i = 0; i < numItems; i++) 1098 for (UInt32 i = 0; i < numItems; i++)
1100 { 1099 {
@@ -1123,15 +1122,15 @@ STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress
1123 result = DeleteFileAlways(fullPath); 1122 result = DeleteFileAlways(fullPath);
1124 } 1123 }
1125 if (!result) 1124 if (!result)
1126 return GetLastError(); 1125 return GetLastError_noZero_HRESULT();
1127 UInt64 completed = i; 1126 const UInt64 completed = i;
1128 RINOK(progress->SetCompleted(&completed)); 1127 RINOK(progress->SetCompleted(&completed))
1129 } 1128 }
1130 return S_OK; 1129 return S_OK;
1131} 1130}
1132 1131
1133STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID, 1132Z7_COM7F_IMF(CFSFolder::SetProperty(UInt32 index, PROPID propID,
1134 const PROPVARIANT *value, IProgress * /* progress */) 1133 const PROPVARIANT *value, IProgress * /* progress */))
1135{ 1134{
1136 if (index >= (UInt32)Files.Size()) 1135 if (index >= (UInt32)Files.Size())
1137 return E_INVALIDARG; 1136 return E_INVALIDARG;
@@ -1169,7 +1168,7 @@ STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID,
1169 return S_OK; 1168 return S_OK;
1170} 1169}
1171 1170
1172STDMETHODIMP CFSFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex) 1171Z7_COM7F_IMF(CFSFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex))
1173{ 1172{
1174 if (index >= (UInt32)Files.Size()) 1173 if (index >= (UInt32)Files.Size())
1175 return E_INVALIDARG; 1174 return E_INVALIDARG;
@@ -1181,17 +1180,17 @@ STDMETHODIMP CFSFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex)
1181 *iconIndex = iconIndexTemp; 1180 *iconIndex = iconIndexTemp;
1182 return S_OK; 1181 return S_OK;
1183 } 1182 }
1184 return GetLastError(); 1183 return GetLastError_noZero_HRESULT();
1185} 1184}
1186 1185
1187STDMETHODIMP CFSFolder::SetFlatMode(Int32 flatMode) 1186Z7_COM7F_IMF(CFSFolder::SetFlatMode(Int32 flatMode))
1188{ 1187{
1189 _flatMode = IntToBool(flatMode); 1188 _flatMode = IntToBool(flatMode);
1190 return S_OK; 1189 return S_OK;
1191} 1190}
1192 1191
1193/* 1192/*
1194STDMETHODIMP CFSFolder::SetShowNtfsStreamsMode(Int32 showStreamsMode) 1193Z7_COM7F_IMF(CFSFolder::SetShowNtfsStreamsMode(Int32 showStreamsMode)
1195{ 1194{
1196 _scanAltStreams = IntToBool(showStreamsMode); 1195 _scanAltStreams = IntToBool(showStreamsMode);
1197 return S_OK; 1196 return S_OK;
diff --git a/CPP/7zip/UI/FileManager/FSFolder.h b/CPP/7zip/UI/FileManager/FSFolder.h
index 4f8c344..fe8538a 100644
--- a/CPP/7zip/UI/FileManager/FSFolder.h
+++ b/CPP/7zip/UI/FileManager/FSFolder.h
@@ -1,7 +1,7 @@
1// FSFolder.h 1// FSFolder.h
2 2
3#ifndef __FS_FOLDER_H 3#ifndef ZIP7_INC_FS_FOLDER_H
4#define __FS_FOLDER_H 4#define ZIP7_INC_FS_FOLDER_H
5 5
6#include "../../../Common/MyCom.h" 6#include "../../../Common/MyCom.h"
7#include "../../../Common/MyBuffer.h" 7#include "../../../Common/MyBuffer.h"
@@ -78,7 +78,7 @@ struct CFsFolderStat
78 HRESULT Enumerate(); 78 HRESULT Enumerate();
79}; 79};
80 80
81class CFSFolder: 81class CFSFolder Z7_final:
82 public IFolderFolder, 82 public IFolderFolder,
83 public IArchiveGetRawProps, 83 public IArchiveGetRawProps,
84 public IFolderCompare, 84 public IFolderCompare,
@@ -95,42 +95,36 @@ class CFSFolder:
95 // public IFolderSetShowNtfsStreamsMode, 95 // public IFolderSetShowNtfsStreamsMode,
96 public CMyUnknownImp 96 public CMyUnknownImp
97{ 97{
98public: 98 Z7_COM_QI_BEGIN2(IFolderFolder)
99 MY_QUERYINTERFACE_BEGIN2(IFolderFolder) 99 Z7_COM_QI_ENTRY(IArchiveGetRawProps)
100 MY_QUERYINTERFACE_ENTRY(IArchiveGetRawProps) 100 Z7_COM_QI_ENTRY(IFolderCompare)
101 MY_QUERYINTERFACE_ENTRY(IFolderCompare)
102 #ifdef USE_UNICODE_FSTRING 101 #ifdef USE_UNICODE_FSTRING
103 MY_QUERYINTERFACE_ENTRY(IFolderGetItemName) 102 Z7_COM_QI_ENTRY(IFolderGetItemName)
104 #endif 103 #endif
105 MY_QUERYINTERFACE_ENTRY(IFolderWasChanged) 104 Z7_COM_QI_ENTRY(IFolderWasChanged)
106 // MY_QUERYINTERFACE_ENTRY(IFolderOperationsDeleteToRecycleBin) 105 // Z7_COM_QI_ENTRY(IFolderOperationsDeleteToRecycleBin)
107 MY_QUERYINTERFACE_ENTRY(IFolderOperations) 106 Z7_COM_QI_ENTRY(IFolderOperations)
108 MY_QUERYINTERFACE_ENTRY(IFolderCalcItemFullSize) 107 Z7_COM_QI_ENTRY(IFolderCalcItemFullSize)
109 MY_QUERYINTERFACE_ENTRY(IFolderClone) 108 Z7_COM_QI_ENTRY(IFolderClone)
110 MY_QUERYINTERFACE_ENTRY(IFolderGetSystemIconIndex) 109 Z7_COM_QI_ENTRY(IFolderGetSystemIconIndex)
111 MY_QUERYINTERFACE_ENTRY(IFolderSetFlatMode) 110 Z7_COM_QI_ENTRY(IFolderSetFlatMode)
112 // MY_QUERYINTERFACE_ENTRY(IFolderSetShowNtfsStreamsMode) 111 // Z7_COM_QI_ENTRY(IFolderSetShowNtfsStreamsMode)
113 MY_QUERYINTERFACE_END 112 Z7_COM_QI_END
114 MY_ADDREF_RELEASE 113 Z7_COM_ADDREF_RELEASE
115 114
116 115 Z7_IFACE_COM7_IMP(IFolderFolder)
117 INTERFACE_FolderFolder(;) 116 Z7_IFACE_COM7_IMP(IArchiveGetRawProps)
118 INTERFACE_IArchiveGetRawProps(;) 117 Z7_IFACE_COM7_IMP(IFolderCompare)
119 INTERFACE_FolderOperations(;)
120
121 STDMETHOD_(Int32, CompareItems)(UInt32 index1, UInt32 index2, PROPID propID, Int32 propIsRaw);
122
123 #ifdef USE_UNICODE_FSTRING 118 #ifdef USE_UNICODE_FSTRING
124 INTERFACE_IFolderGetItemName(;) 119 Z7_IFACE_COM7_IMP(IFolderGetItemName)
125 #endif 120 #endif
126 STDMETHOD(WasChanged)(Int32 *wasChanged); 121 Z7_IFACE_COM7_IMP(IFolderWasChanged)
127 STDMETHOD(Clone)(IFolderFolder **resultFolder); 122 Z7_IFACE_COM7_IMP(IFolderOperations)
128 STDMETHOD(CalcItemFullSize)(UInt32 index, IProgress *progress); 123 Z7_IFACE_COM7_IMP(IFolderCalcItemFullSize)
129 124 Z7_IFACE_COM7_IMP(IFolderClone)
130 STDMETHOD(SetFlatMode)(Int32 flatMode); 125 Z7_IFACE_COM7_IMP(IFolderGetSystemIconIndex)
131 // STDMETHOD(SetShowNtfsStreamsMode)(Int32 showStreamsMode); 126 Z7_IFACE_COM7_IMP(IFolderSetFlatMode)
132 127 // Z7_IFACE_COM7_IMP(IFolderSetShowNtfsStreamsMode)
133 STDMETHOD(GetSystemIconIndex)(UInt32 index, Int32 *iconIndex);
134 128
135private: 129private:
136 FString _path; 130 FString _path;
@@ -150,9 +144,7 @@ private:
150 NWindows::NFile::NFind::CFindChangeNotification _findChangeNotification; 144 NWindows::NFile::NFind::CFindChangeNotification _findChangeNotification;
151 #endif 145 #endif
152 146
153 HRESULT GetItemsFullSize(const UInt32 *indices, UInt32 numItems, CFsFolderStat &stat); 147 // HRESULT GetItemFullSize(unsigned index, UInt64 &size, IProgress *progress);
154
155 HRESULT GetItemFullSize(unsigned index, UInt64 &size, IProgress *progress);
156 void GetAbsPath(const wchar_t *name, FString &absPath); 148 void GetAbsPath(const wchar_t *name, FString &absPath);
157 HRESULT BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder); 149 HRESULT BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder);
158 150
@@ -215,6 +207,15 @@ struct CCopyStateIO
215 207
216HRESULT SendLastErrorMessage(IFolderOperationsExtractCallback *callback, const FString &fileName); 208HRESULT SendLastErrorMessage(IFolderOperationsExtractCallback *callback, const FString &fileName);
217 209
210/* destDirPrefix is allowed to be:
211 "full_path\" or "full_path:" for alt streams */
212
213HRESULT CopyFileSystemItems(
214 const UStringVector &itemsPaths,
215 const FString &destDirPrefix,
216 bool moveMode,
217 IFolderOperationsExtractCallback *callback);
218
218} 219}
219 220
220#endif 221#endif
diff --git a/CPP/7zip/UI/FileManager/FSFolderCopy.cpp b/CPP/7zip/UI/FileManager/FSFolderCopy.cpp
index 4ca931b..db4ae0a 100644
--- a/CPP/7zip/UI/FileManager/FSFolderCopy.cpp
+++ b/CPP/7zip/UI/FileManager/FSFolderCopy.cpp
@@ -4,8 +4,6 @@
4 4
5#include "../../../Common/MyWindows.h" 5#include "../../../Common/MyWindows.h"
6 6
7#include <WinBase.h>
8
9#include "../../../Common/Defs.h" 7#include "../../../Common/Defs.h"
10#include "../../../Common/StringConvert.h" 8#include "../../../Common/StringConvert.h"
11#include "../../../Common/Wildcard.h" 9#include "../../../Common/Wildcard.h"
@@ -29,11 +27,11 @@ using namespace NFind;
29extern bool g_IsNT; 27extern bool g_IsNT;
30#endif 28#endif
31 29
32#define MY_CAST_FUNC (void(*)())
33// #define MY_CAST_FUNC
34
35namespace NFsFolder { 30namespace NFsFolder {
36 31
32static const char * const k_CannotCopyDirToAltStream = "Cannot copy folder as alternate stream";
33
34
37HRESULT CCopyStateIO::MyCopyFile(CFSTR inPath, CFSTR outPath, DWORD attrib) 35HRESULT CCopyStateIO::MyCopyFile(CFSTR inPath, CFSTR outPath, DWORD attrib)
38{ 36{
39 ErrorFileIndex = -1; 37 ErrorFileIndex = -1;
@@ -85,11 +83,15 @@ HRESULT CCopyStateIO::MyCopyFile(CFSTR inPath, CFSTR outPath, DWORD attrib)
85 if (Progress) 83 if (Progress)
86 { 84 {
87 UInt64 completed = StartPos + CurrentSize; 85 UInt64 completed = StartPos + CurrentSize;
88 RINOK(Progress->SetCompleted(&completed)); 86 RINOK(Progress->SetCompleted(&completed))
89 } 87 }
90 } 88 }
91 } 89 }
92 90
91 /* SetFileAttrib("path:alt_stream_name") sets attributes for main file "path".
92 But we don't want to change attributes of main file, when we write alt stream.
93 So we need INVALID_FILE_ATTRIBUTES for alt stream here */
94
93 if (attrib != INVALID_FILE_ATTRIBUTES) 95 if (attrib != INVALID_FILE_ATTRIBUTES)
94 SetFileAttrib(outPath, attrib); 96 SetFileAttrib(outPath, attrib);
95 97
@@ -177,7 +179,7 @@ static DWORD CALLBACK CopyProgressRoutine(
177 pi.FileSize = (UInt64)TotalFileSize.QuadPart; 179 pi.FileSize = (UInt64)TotalFileSize.QuadPart;
178 pi.ProgressResult = pi.Progress->SetTotal(pi.TotalSize); 180 pi.ProgressResult = pi.Progress->SetTotal(pi.TotalSize);
179 } 181 }
180 UInt64 completed = pi.StartPos + TotalBytesTransferred.QuadPart; 182 const UInt64 completed = pi.StartPos + (UInt64)TotalBytesTransferred.QuadPart;
181 pi.ProgressResult = pi.Progress->SetCompleted(&completed); 183 pi.ProgressResult = pi.Progress->SetCompleted(&completed);
182 return (pi.ProgressResult == S_OK ? PROGRESS_CONTINUE : PROGRESS_CANCEL); 184 return (pi.ProgressResult == S_OK ? PROGRESS_CONTINUE : PROGRESS_CANCEL);
183} 185}
@@ -214,6 +216,7 @@ struct CCopyState
214 IFolderOperationsExtractCallback *Callback; 216 IFolderOperationsExtractCallback *Callback;
215 bool MoveMode; 217 bool MoveMode;
216 bool UseReadWriteMode; 218 bool UseReadWriteMode;
219 bool IsAltStreamsDest;
217 220
218 Func_CopyFileExW my_CopyFileExW; 221 Func_CopyFileExW my_CopyFileExW;
219 #ifndef UNDER_CE 222 #ifndef UNDER_CE
@@ -248,23 +251,27 @@ void CCopyState::Prepare()
248 my_CopyFileExA = NULL; 251 my_CopyFileExA = NULL;
249 if (!g_IsNT) 252 if (!g_IsNT)
250 { 253 {
251 my_CopyFileExA = (Func_CopyFileExA) 254 my_CopyFileExA = Z7_GET_PROC_ADDRESS(
252 MY_CAST_FUNC 255 Func_CopyFileExA, ::GetModuleHandleA("kernel32.dll"),
253 ::GetProcAddress(::GetModuleHandleA("kernel32.dll"), "CopyFileExA"); 256 "CopyFileExA");
254 } 257 }
255 else 258 else
256 #endif 259 #endif
257 { 260 {
258 HMODULE module = ::GetModuleHandleW( 261 const HMODULE module = ::GetModuleHandleW(
259 #ifdef UNDER_CE 262 #ifdef UNDER_CE
260 L"coredll.dll" 263 L"coredll.dll"
261 #else 264 #else
262 L"kernel32.dll" 265 L"kernel32.dll"
263 #endif 266 #endif
264 ); 267 );
265 my_CopyFileExW = (Func_CopyFileExW)My_GetProcAddress(module, "CopyFileExW"); 268 my_CopyFileExW = Z7_GET_PROC_ADDRESS(
269 Func_CopyFileExW, module,
270 "CopyFileExW");
266 #ifndef UNDER_CE 271 #ifndef UNDER_CE
267 my_MoveFileWithProgressW = (Func_MoveFileWithProgressW)My_GetProcAddress(module, "MoveFileWithProgressW"); 272 my_MoveFileWithProgressW = Z7_GET_PROC_ADDRESS(
273 Func_MoveFileWithProgressW, module,
274 "MoveFileWithProgressW");
268 #endif 275 #endif
269 } 276 }
270} 277}
@@ -308,7 +315,7 @@ bool CCopyState::CopyFile_Sys(CFSTR oldFile, CFSTR newFile)
308 if (CopyFile_NT(fs2us(oldFile), fs2us(newFile))) 315 if (CopyFile_NT(fs2us(oldFile), fs2us(newFile)))
309 return true; 316 return true;
310 } 317 }
311 #ifdef WIN_LONG_PATH 318 #ifdef Z7_LONG_PATH
312 if (USE_SUPER_PATH_2) 319 if (USE_SUPER_PATH_2)
313 { 320 {
314 if (IsCallbackProgressError()) 321 if (IsCallbackProgressError())
@@ -337,7 +344,7 @@ bool CCopyState::MoveFile_Sys(CFSTR oldFile, CFSTR newFile)
337 &ProgressInfo, MOVEFILE_COPY_ALLOWED)) 344 &ProgressInfo, MOVEFILE_COPY_ALLOWED))
338 return true; 345 return true;
339 } 346 }
340 #ifdef WIN_LONG_PATH 347 #ifdef Z7_LONG_PATH
341 if ((!(USE_MAIN_PATH_2) || ::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) && USE_SUPER_PATH_2) 348 if ((!(USE_MAIN_PATH_2) || ::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) && USE_SUPER_PATH_2)
342 { 349 {
343 if (IsCallbackProgressError()) 350 if (IsCallbackProgressError())
@@ -404,7 +411,7 @@ static HRESULT CopyFile_Ask(
404 state.MoveMode ? 411 state.MoveMode ?
405 "Cannot move file onto itself" : 412 "Cannot move file onto itself" :
406 "Cannot copy file onto itself" 413 "Cannot copy file onto itself"
407 , destPath)); 414 , destPath))
408 return E_ABORT; 415 return E_ABORT;
409 } 416 }
410 417
@@ -416,12 +423,12 @@ static HRESULT CopyFile_Ask(
416 &srcFileInfo.MTime, &srcFileInfo.Size, 423 &srcFileInfo.MTime, &srcFileInfo.Size,
417 fs2us(destPath), 424 fs2us(destPath),
418 &destPathResult, 425 &destPathResult,
419 &writeAskResult)); 426 &writeAskResult))
420 427
421 if (IntToBool(writeAskResult)) 428 if (IntToBool(writeAskResult))
422 { 429 {
423 FString destPathNew = us2fs((LPCOLESTR)destPathResult); 430 FString destPathNew = us2fs((LPCOLESTR)destPathResult);
424 RINOK(state.Callback->SetCurrentFilePath(fs2us(srcPath))); 431 RINOK(state.Callback->SetCurrentFilePath(fs2us(srcPath)))
425 432
426 if (state.UseReadWriteMode) 433 if (state.UseReadWriteMode)
427 { 434 {
@@ -431,7 +438,8 @@ static HRESULT CopyFile_Ask(
431 state2.TotalSize = state.ProgressInfo.TotalSize; 438 state2.TotalSize = state.ProgressInfo.TotalSize;
432 state2.StartPos = state.ProgressInfo.StartPos; 439 state2.StartPos = state.ProgressInfo.StartPos;
433 440
434 RINOK(state2.MyCopyFile(srcPath, destPathNew, srcFileInfo.Attrib)); 441 RINOK(state2.MyCopyFile(srcPath, destPathNew,
442 state.IsAltStreamsDest ? INVALID_FILE_ATTRIBUTES: srcFileInfo.Attrib))
435 443
436 if (state2.ErrorFileIndex >= 0) 444 if (state2.ErrorFileIndex >= 0)
437 { 445 {
@@ -442,7 +450,7 @@ static HRESULT CopyFile_Ask(
442 errorName = srcPath; 450 errorName = srcPath;
443 else 451 else
444 errorName = destPathNew; 452 errorName = destPathNew;
445 RINOK(SendMessageError(state.Callback, state2.ErrorMessage, errorName)); 453 RINOK(SendMessageError(state.Callback, state2.ErrorMessage, errorName))
446 return E_ABORT; 454 return E_ABORT;
447 } 455 }
448 state.ProgressInfo.StartPos += state2.CurrentSize; 456 state.ProgressInfo.StartPos += state2.CurrentSize;
@@ -455,11 +463,11 @@ static HRESULT CopyFile_Ask(
455 res = state.MoveFile_Sys(srcPath, destPathNew); 463 res = state.MoveFile_Sys(srcPath, destPathNew);
456 else 464 else
457 res = state.CopyFile_Sys(srcPath, destPathNew); 465 res = state.CopyFile_Sys(srcPath, destPathNew);
458 RINOK(state.ProgressInfo.ProgressResult); 466 RINOK(state.ProgressInfo.ProgressResult)
459 if (!res) 467 if (!res)
460 { 468 {
461 // GetLastError() is ERROR_REQUEST_ABORTED in case of PROGRESS_CANCEL. 469 // GetLastError() is ERROR_REQUEST_ABORTED in case of PROGRESS_CANCEL.
462 RINOK(SendMessageError(state.Callback, GetLastErrorMessage(), destPathNew)); 470 RINOK(SendMessageError(state.Callback, GetLastErrorMessage(), destPathNew))
463 return E_ABORT; 471 return E_ABORT;
464 } 472 }
465 state.ProgressInfo.StartPos += state.ProgressInfo.FileSize; 473 state.ProgressInfo.StartPos += state.ProgressInfo.FileSize;
@@ -470,7 +478,7 @@ static HRESULT CopyFile_Ask(
470 if (state.ProgressInfo.TotalSize >= srcFileInfo.Size) 478 if (state.ProgressInfo.TotalSize >= srcFileInfo.Size)
471 { 479 {
472 state.ProgressInfo.TotalSize -= srcFileInfo.Size; 480 state.ProgressInfo.TotalSize -= srcFileInfo.Size;
473 RINOK(state.ProgressInfo.Progress->SetTotal(state.ProgressInfo.TotalSize)); 481 RINOK(state.ProgressInfo.Progress->SetTotal(state.ProgressInfo.TotalSize))
474 } 482 }
475 } 483 }
476 return state.CallProgress(); 484 return state.CallProgress();
@@ -499,7 +507,7 @@ static HRESULT CopyFolder(
499 const FString &srcPath, // without TAIL separator 507 const FString &srcPath, // without TAIL separator
500 const FString &destPath) // without TAIL separator 508 const FString &destPath) // without TAIL separator
501{ 509{
502 RINOK(state.CallProgress()); 510 RINOK(state.CallProgress())
503 511
504 if (IsDestChild(srcPath, destPath)) 512 if (IsDestChild(srcPath, destPath))
505 { 513 {
@@ -507,7 +515,7 @@ static HRESULT CopyFolder(
507 state.MoveMode ? 515 state.MoveMode ?
508 "Cannot copy folder onto itself" : 516 "Cannot copy folder onto itself" :
509 "Cannot move folder onto itself" 517 "Cannot move folder onto itself"
510 , destPath)); 518 , destPath))
511 return E_ABORT; 519 return E_ABORT;
512 } 520 }
513 521
@@ -521,7 +529,7 @@ static HRESULT CopyFolder(
521 529
522 if (!CreateComplexDir(destPath)) 530 if (!CreateComplexDir(destPath))
523 { 531 {
524 RINOK(SendMessageError(state.Callback, "Cannot create folder", destPath)); 532 RINOK(SendMessageError(state.Callback, "Cannot create folder", destPath))
525 return E_ABORT; 533 return E_ABORT;
526 } 534 }
527 535
@@ -547,7 +555,7 @@ static HRESULT CopyFolder(
547 } 555 }
548 else 556 else
549 { 557 {
550 RINOK(CopyFile_Ask(state, srcPath2, fi, destPath2)); 558 RINOK(CopyFile_Ask(state, srcPath2, fi, destPath2))
551 } 559 }
552 } 560 }
553 561
@@ -555,7 +563,7 @@ static HRESULT CopyFolder(
555 { 563 {
556 if (!RemoveDir(srcPath)) 564 if (!RemoveDir(srcPath))
557 { 565 {
558 RINOK(SendMessageError(state.Callback, "Cannot remove folder", srcPath)); 566 RINOK(SendMessageError(state.Callback, "Cannot remove folder", srcPath))
559 return E_ABORT; 567 return E_ABORT;
560 } 568 }
561 } 569 }
@@ -563,38 +571,67 @@ static HRESULT CopyFolder(
563 return S_OK; 571 return S_OK;
564} 572}
565 573
566STDMETHODIMP CFSFolder::CopyTo(Int32 moveMode, const UInt32 *indices, UInt32 numItems, 574Z7_COM7F_IMF(CFSFolder::CopyTo(Int32 moveMode, const UInt32 *indices, UInt32 numItems,
567 Int32 /* includeAltStreams */, Int32 /* replaceAltStreamColon */, 575 Int32 /* includeAltStreams */, Int32 /* replaceAltStreamColon */,
568 const wchar_t *path, IFolderOperationsExtractCallback *callback) 576 const wchar_t *path, IFolderOperationsExtractCallback *callback))
569{ 577{
570 if (numItems == 0) 578 if (numItems == 0)
571 return S_OK; 579 return S_OK;
572 580
573 FString destPath = us2fs(path); 581 const FString destPath = us2fs(path);
574 if (destPath.IsEmpty()) 582 if (destPath.IsEmpty())
575 return E_INVALIDARG; 583 return E_INVALIDARG;
576 584
577 bool isAltDest = NName::IsAltPathPrefix(destPath); 585 const bool isAltDest = NName::IsAltPathPrefix(destPath);
578 bool isDirectPath = (!isAltDest && !IsPathSepar(destPath.Back())); 586 const bool isDirectPath = (!isAltDest && !IsPathSepar(destPath.Back()));
579 587
580 if (isDirectPath) 588 if (isDirectPath)
581 {
582 if (numItems > 1) 589 if (numItems > 1)
583 return E_INVALIDARG; 590 return E_INVALIDARG;
584 }
585 591
586 CFsFolderStat stat; 592 CFsFolderStat stat;
587 stat.Progress = callback; 593 stat.Progress = callback;
588 RINOK(GetItemsFullSize(indices, numItems, stat));
589 594
595 UInt32 i;
596 for (i = 0; i < numItems; i++)
597 {
598 const UInt32 index = indices[i];
599 /*
600 if (index >= Files.Size())
601 {
602 size += Streams[index - Files.Size()].Size;
603 // numFiles++;
604 continue;
605 }
606 */
607 const CDirItem &fi = Files[index];
608 if (fi.IsDir())
609 {
610 if (!isAltDest)
611 {
612 stat.Path = _path;
613 stat.Path += GetRelPath(fi);
614 RINOK(stat.Enumerate())
615 }
616 stat.NumFolders++;
617 }
618 else
619 {
620 stat.NumFiles++;
621 stat.Size += fi.Size;
622 }
623 }
624
625 /*
590 if (stat.NumFolders != 0 && isAltDest) 626 if (stat.NumFolders != 0 && isAltDest)
591 return E_NOTIMPL; 627 return E_NOTIMPL;
628 */
592 629
593 RINOK(callback->SetTotal(stat.Size)); 630 RINOK(callback->SetTotal(stat.Size))
594 RINOK(callback->SetNumFiles(stat.NumFiles)); 631 RINOK(callback->SetNumFiles(stat.NumFiles))
595 632
596 UInt64 completedSize = 0; 633 UInt64 completedSize = 0;
597 RINOK(callback->SetCompleted(&completedSize)); 634 RINOK(callback->SetCompleted(&completedSize))
598 635
599 CCopyState state; 636 CCopyState state;
600 state.ProgressInfo.TotalSize = stat.Size; 637 state.ProgressInfo.TotalSize = stat.Size;
@@ -603,12 +640,16 @@ STDMETHODIMP CFSFolder::CopyTo(Int32 moveMode, const UInt32 *indices, UInt32 num
603 state.ProgressInfo.Init(); 640 state.ProgressInfo.Init();
604 state.Callback = callback; 641 state.Callback = callback;
605 state.MoveMode = IntToBool(moveMode); 642 state.MoveMode = IntToBool(moveMode);
643 state.IsAltStreamsDest = isAltDest;
644 /* CopyFileW(fromFile, toFile:altStream) returns ERROR_INVALID_PARAMETER,
645 if there are alt streams in fromFile.
646 So we don't use CopyFileW() for alt Streams. */
606 state.UseReadWriteMode = isAltDest; 647 state.UseReadWriteMode = isAltDest;
607 state.Prepare(); 648 state.Prepare();
608 649
609 for (UInt32 i = 0; i < numItems; i++) 650 for (i = 0; i < numItems; i++)
610 { 651 {
611 UInt32 index = indices[i]; 652 const UInt32 index = indices[i];
612 if (index >= (UInt32)Files.Size()) 653 if (index >= (UInt32)Files.Size())
613 continue; 654 continue;
614 const CDirItem &fi = Files[index]; 655 const CDirItem &fi = Files[index];
@@ -620,57 +661,148 @@ STDMETHODIMP CFSFolder::CopyTo(Int32 moveMode, const UInt32 *indices, UInt32 num
620 661
621 if (fi.IsDir()) 662 if (fi.IsDir())
622 { 663 {
623 RINOK(CopyFolder(state, srcPath, destPath2)); 664 if (isAltDest)
665 {
666 RINOK(SendMessageError(callback, k_CannotCopyDirToAltStream, srcPath))
667 }
668 else
669 {
670 RINOK(CopyFolder(state, srcPath, destPath2))
671 }
624 } 672 }
625 else 673 else
626 { 674 {
627 RINOK(CopyFile_Ask(state, srcPath, fi, destPath2)); 675 RINOK(CopyFile_Ask(state, srcPath, fi, destPath2))
628 } 676 }
629 } 677 }
630 return S_OK; 678 return S_OK;
631} 679}
632 680
633STDMETHODIMP CFSFolder::CopyFrom(Int32 /* moveMode */, const wchar_t * /* fromFolderPath */, 681
634 const wchar_t * const * /* itemsPaths */, UInt32 /* numItems */, IProgress * /* progress */) 682
683/* we can call CopyFileSystemItems() from CDropTarget::Drop() */
684
685HRESULT CopyFileSystemItems(
686 const UStringVector &itemsPaths,
687 const FString &destDirPrefix,
688 bool moveMode,
689 IFolderOperationsExtractCallback *callback)
635{ 690{
636 /* 691 if (itemsPaths.IsEmpty())
637 UInt64 numFolders, numFiles, totalSize; 692 return S_OK;
638 numFiles = numFolders = totalSize = 0; 693
639 UInt32 i; 694 if (destDirPrefix.IsEmpty())
640 for (i = 0; i < numItems; i++) 695 return E_INVALIDARG;
641 {
642 UString path = (UString)fromFolderPath + itemsPaths[i];
643 696
697 const bool isAltDest = NName::IsAltPathPrefix(destDirPrefix);
698
699 CFsFolderStat stat;
700 stat.Progress = callback;
701
702 {
703 FOR_VECTOR (i, itemsPaths)
704 {
705 const UString &path = itemsPaths[i];
644 CFileInfo fi; 706 CFileInfo fi;
645 if (!FindFile(path, fi)) 707 if (!fi.Find(us2fs(path)))
646 return ::GetLastError(); 708 continue;
647 if (fi.IsDir()) 709 if (fi.IsDir())
648 { 710 {
649 UInt64 subFolders, subFiles, subSize; 711 if (!isAltDest)
650 RINOK(GetFolderSize(CombinePath(path, fi.Name), subFolders, subFiles, subSize, progress)); 712 {
651 numFolders += subFolders; 713 stat.Path = us2fs(path);
652 numFolders++; 714 RINOK(stat.Enumerate())
653 numFiles += subFiles; 715 }
654 totalSize += subSize; 716 stat.NumFolders++;
655 } 717 }
656 else 718 else
657 { 719 {
658 numFiles++; 720 stat.NumFiles++;
659 totalSize += fi.Size; 721 stat.Size += fi.Size;
660 } 722 }
661 } 723 }
662 RINOK(progress->SetTotal(totalSize)); 724 }
663 RINOK(callback->SetNumFiles(numFiles)); 725
664 for (i = 0; i < numItems; i++) 726 /*
727 if (stat.NumFolders != 0 && isAltDest)
728 return E_NOTIMPL;
729 */
730
731 RINOK(callback->SetTotal(stat.Size))
732 // RINOK(progress->SetNumFiles(stat.NumFiles));
733
734 UInt64 completedSize = 0;
735 RINOK(callback->SetCompleted(&completedSize))
736
737 CCopyState state;
738 state.ProgressInfo.TotalSize = stat.Size;
739 state.ProgressInfo.StartPos = 0;
740 state.ProgressInfo.Progress = callback;
741 state.ProgressInfo.Init();
742 state.Callback = callback;
743 state.MoveMode = moveMode;
744 state.IsAltStreamsDest = isAltDest;
745 /* CopyFileW(fromFile, toFile:altStream) returns ERROR_INVALID_PARAMETER,
746 if there are alt streams in fromFile.
747 So we don't use CopyFileW() for alt Streams. */
748 state.UseReadWriteMode = isAltDest;
749 state.Prepare();
750
751 FOR_VECTOR (i, itemsPaths)
665 { 752 {
666 UString path = (UString)fromFolderPath + itemsPaths[i]; 753 const UString path = itemsPaths[i];
754 CFileInfo fi;
755
756 if (!fi.Find(us2fs(path)))
757 {
758 RINOK(SendMessageError(callback, "Cannot find the file", us2fs(path)))
759 continue;
760 }
761
762 FString destPath = destDirPrefix;
763 destPath += fi.Name;
764
765 if (fi.IsDir())
766 {
767 if (isAltDest)
768 {
769 RINOK(SendMessageError(callback, k_CannotCopyDirToAltStream, us2fs(path)))
770 }
771 else
772 {
773 RINOK(CopyFolder(state, us2fs(path), destPath))
774 }
775 }
776 else
777 {
778 RINOK(CopyFile_Ask(state, us2fs(path), fi, destPath))
779 }
667 } 780 }
668 return S_OK; 781 return S_OK;
782}
783
784
785/* we don't use CFSFolder::CopyFrom() because the caller of CopyFrom()
786 is optimized for IFolderArchiveUpdateCallback interface,
787 but we want to use IFolderOperationsExtractCallback interface instead */
788
789Z7_COM7F_IMF(CFSFolder::CopyFrom(Int32 /* moveMode */, const wchar_t * /* fromFolderPath */,
790 const wchar_t * const * /* itemsPaths */, UInt32 /* numItems */, IProgress * /* progress */))
791{
792 /*
793 Z7_DECL_CMyComPtr_QI_FROM(
794 IFolderOperationsExtractCallback,
795 callback, progress)
796 if (!callback)
797 return E_NOTIMPL;
798 return CopyFileSystemItems(_path,
799 moveMode, fromDirPrefix,
800 itemsPaths, numItems, callback);
669 */ 801 */
670 return E_NOTIMPL; 802 return E_NOTIMPL;
671} 803}
672 804
673STDMETHODIMP CFSFolder::CopyFromFile(UInt32 /* index */, const wchar_t * /* fullFilePath */, IProgress * /* progress */) 805Z7_COM7F_IMF(CFSFolder::CopyFromFile(UInt32 /* index */, const wchar_t * /* fullFilePath */, IProgress * /* progress */))
674{ 806{
675 return E_NOTIMPL; 807 return E_NOTIMPL;
676} 808}
diff --git a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp
index a7873fe..e4e9997 100644
--- a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp
+++ b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp
@@ -26,8 +26,15 @@ struct CThreadArchiveOpen
26 UString ArcFormat; 26 UString ArcFormat;
27 CMyComPtr<IInStream> InStream; 27 CMyComPtr<IInStream> InStream;
28 CMyComPtr<IFolderManager> FolderManager; 28 CMyComPtr<IFolderManager> FolderManager;
29 CMyComPtr<IProgress> OpenCallback; 29 CMyComPtr<IProgress> OpenCallbackProgress;
30
30 COpenArchiveCallback *OpenCallbackSpec; 31 COpenArchiveCallback *OpenCallbackSpec;
32 /*
33 CMyComPtr<IUnknown>
34 // CMyComPtr<IProgress>
35 // CMyComPtr<IArchiveOpenCallback>
36 OpenCallbackSpec_Ref;
37 */
31 38
32 CMyComPtr<IFolderFolder> Folder; 39 CMyComPtr<IFolderFolder> Folder;
33 HRESULT Result; 40 HRESULT Result;
@@ -37,7 +44,7 @@ struct CThreadArchiveOpen
37 try 44 try
38 { 45 {
39 CProgressCloser closer(OpenCallbackSpec->ProgressDialog); 46 CProgressCloser closer(OpenCallbackSpec->ProgressDialog);
40 Result = FolderManager->OpenFolderFile(InStream, Path, ArcFormat, &Folder, OpenCallback); 47 Result = FolderManager->OpenFolderFile(InStream, Path, ArcFormat, &Folder, OpenCallbackProgress);
41 } 48 }
42 catch(...) { Result = E_FAIL; } 49 catch(...) { Result = E_FAIL; }
43 } 50 }
@@ -62,7 +69,7 @@ static int FindPlugin(const CObjectVector<CPluginInfo> &plugins, const UString &
62static void SplitNameToPureNameAndExtension(const FString &fullName, 69static void SplitNameToPureNameAndExtension(const FString &fullName,
63 FString &pureName, FString &extensionDelimiter, FString &extension) 70 FString &pureName, FString &extensionDelimiter, FString &extension)
64{ 71{
65 int index = fullName.ReverseFind_Dot(); 72 const int index = fullName.ReverseFind_Dot();
66 if (index < 0) 73 if (index < 0)
67 { 74 {
68 pureName = fullName; 75 pureName = fullName;
@@ -71,7 +78,7 @@ static void SplitNameToPureNameAndExtension(const FString &fullName,
71 } 78 }
72 else 79 else
73 { 80 {
74 pureName.SetFrom(fullName, index); 81 pureName.SetFrom(fullName, (unsigned)index);
75 extensionDelimiter = '.'; 82 extensionDelimiter = '.';
76 extension = fullName.Ptr((unsigned)index + 1); 83 extension = fullName.Ptr((unsigned)index + 1);
77 } 84 }
@@ -229,16 +236,21 @@ static void GetFolderError(CMyComPtr<IFolderFolder> &folder, UString &open_Error
229 } 236 }
230} 237}
231 238
239#ifdef _MSC_VER
240#pragma warning(error : 4702) // unreachable code
241#endif
232 242
233HRESULT CFfpOpen::OpenFileFolderPlugin(IInStream *inStream, 243HRESULT CFfpOpen::OpenFileFolderPlugin(IInStream *inStream,
234 const FString &path, const UString &arcFormat, HWND parentWindow) 244 const FString &path, const UString &arcFormat, HWND parentWindow)
235{ 245{
246 /*
236 CObjectVector<CPluginInfo> plugins; 247 CObjectVector<CPluginInfo> plugins;
237 ReadFileFolderPluginInfoList(plugins); 248 ReadFileFolderPluginInfoList(plugins);
249 */
238 250
239 FString extension, name, pureName, dot; 251 FString extension, name, pureName, dot;
240 252
241 int slashPos = path.ReverseFind_PathSepar(); 253 const int slashPos = path.ReverseFind_PathSepar();
242 FString dirPrefix; 254 FString dirPrefix;
243 FString fileName; 255 FString fileName;
244 if (slashPos >= 0) 256 if (slashPos >= 0)
@@ -273,31 +285,48 @@ HRESULT CFfpOpen::OpenFileFolderPlugin(IInStream *inStream,
273 285
274 ErrorMessage.Empty(); 286 ErrorMessage.Empty();
275 287
276 FOR_VECTOR (i, plugins) 288 // FOR_VECTOR (i, plugins)
277 { 289 // {
290 /*
278 const CPluginInfo &plugin = plugins[i]; 291 const CPluginInfo &plugin = plugins[i];
279 if (!plugin.ClassIDDefined) 292 if (!plugin.ClassID_Defined && !plugin.FilePath.IsEmpty())
280 continue; 293 continue;
294 */
281 CPluginLibrary library; 295 CPluginLibrary library;
282 296
283 CThreadArchiveOpen t; 297 CThreadArchiveOpen t;
284 298
285 if (plugin.FilePath.IsEmpty()) 299 // if (plugin.FilePath.IsEmpty())
286 t.FolderManager = new CArchiveFolderManager; 300 t.FolderManager = new CArchiveFolderManager;
301 /*
287 else if (library.LoadAndCreateManager(plugin.FilePath, plugin.ClassID, &t.FolderManager) != S_OK) 302 else if (library.LoadAndCreateManager(plugin.FilePath, plugin.ClassID, &t.FolderManager) != S_OK)
288 continue; 303 continue;
304 */
289 305
306 COpenArchiveCallback OpenCallbackSpec_loc;
307 t.OpenCallbackSpec = &OpenCallbackSpec_loc;
308 /*
290 t.OpenCallbackSpec = new COpenArchiveCallback; 309 t.OpenCallbackSpec = new COpenArchiveCallback;
291 t.OpenCallback = t.OpenCallbackSpec; 310 t.OpenCallbackSpec_Ref = t.OpenCallbackSpec;
311 */
292 t.OpenCallbackSpec->PasswordIsDefined = Encrypted; 312 t.OpenCallbackSpec->PasswordIsDefined = Encrypted;
293 t.OpenCallbackSpec->Password = Password; 313 t.OpenCallbackSpec->Password = Password;
294 t.OpenCallbackSpec->ParentWindow = parentWindow; 314 t.OpenCallbackSpec->ParentWindow = parentWindow;
295 315
316 /* COpenCallbackImp object will exist after Open stage for multivolume archives */
317 COpenCallbackImp *openCallbackSpec = new COpenCallbackImp;
318 t.OpenCallbackProgress = openCallbackSpec;
319 // openCallbackSpec->Callback_Ref = t.OpenCallbackSpec;
320 // we set pointer without reference counter:
321 openCallbackSpec->Callback =
322 // openCallbackSpec->ReOpenCallback =
323 t.OpenCallbackSpec;
324
296 if (inStream) 325 if (inStream)
297 t.OpenCallbackSpec->SetSubArchiveName(fs2us(fileName)); 326 openCallbackSpec->SetSubArchiveName(fs2us(fileName));
298 else 327 else
299 { 328 {
300 RINOK(t.OpenCallbackSpec->LoadFileInfo2(dirPrefix, fileName)); 329 RINOK(openCallbackSpec->Init2(dirPrefix, fileName))
301 } 330 }
302 331
303 t.InStream = inStream; 332 t.InStream = inStream;
@@ -315,10 +344,20 @@ HRESULT CFfpOpen::OpenFileFolderPlugin(IInStream *inStream,
315 344
316 { 345 {
317 NWindows::CThread thread; 346 NWindows::CThread thread;
318 RINOK(thread.Create(CThreadArchiveOpen::MyThreadFunction, &t)); 347 const WRes wres = thread.Create(CThreadArchiveOpen::MyThreadFunction, &t);
348 if (wres != 0)
349 return HRESULT_FROM_WIN32(wres);
319 t.OpenCallbackSpec->StartProgressDialog(progressTitle, thread); 350 t.OpenCallbackSpec->StartProgressDialog(progressTitle, thread);
320 } 351 }
321 352
353 /*
354 if archive is multivolume:
355 COpenCallbackImp object will exist after Open stage.
356 COpenCallbackImp object will be deleted when last reference
357 from each volume object (CInFileStreamVol) will be closed (when archive will be closed).
358 */
359 t.OpenCallbackProgress.Release();
360
322 if (t.Result != S_FALSE && t.Result != S_OK) 361 if (t.Result != S_FALSE && t.Result != S_OK)
323 return t.Result; 362 return t.Result;
324 363
@@ -351,7 +390,5 @@ HRESULT CFfpOpen::OpenFileFolderPlugin(IInStream *inStream,
351 } 390 }
352 391
353 return t.Result; 392 return t.Result;
354 } 393 // }
355
356 return S_FALSE;
357} 394}
diff --git a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h
index a1f2f10..8802765 100644
--- a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h
+++ b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h
@@ -1,13 +1,13 @@
1// FileFolderPluginOpen.h 1// FileFolderPluginOpen.h
2 2
3#ifndef __FILE_FOLDER_PLUGIN_OPEN_H 3#ifndef ZIP7_INC_FILE_FOLDER_PLUGIN_OPEN_H
4#define __FILE_FOLDER_PLUGIN_OPEN_H 4#define ZIP7_INC_FILE_FOLDER_PLUGIN_OPEN_H
5 5
6#include "../../../Windows/DLL.h" 6#include "../../../Windows/DLL.h"
7 7
8struct CFfpOpen 8struct CFfpOpen
9{ 9{
10 CLASS_NO_COPY(CFfpOpen) 10 Z7_CLASS_NO_COPY(CFfpOpen)
11public: 11public:
12 // out: 12 // out:
13 bool Encrypted; 13 bool Encrypted;
diff --git a/CPP/7zip/UI/FileManager/FilePlugins.cpp b/CPP/7zip/UI/FileManager/FilePlugins.cpp
index 4600030..cf20970 100644
--- a/CPP/7zip/UI/FileManager/FilePlugins.cpp
+++ b/CPP/7zip/UI/FileManager/FilePlugins.cpp
@@ -8,28 +8,37 @@
8#include "PluginLoader.h" 8#include "PluginLoader.h"
9#include "StringUtils.h" 9#include "StringUtils.h"
10 10
11int CExtDatabase::FindExt(const UString &ext) 11int CExtDatabase::FindExt(const UString &ext) const
12{ 12{
13 FOR_VECTOR (i, Exts) 13 FOR_VECTOR (i, Exts)
14 if (Exts[i].Ext.IsEqualTo_NoCase(ext)) 14 if (Exts[i].Ext.IsEqualTo_NoCase(ext))
15 return i; 15 return (int)i;
16 return -1; 16 return -1;
17} 17}
18 18
19void CExtDatabase::Read() 19void CExtDatabase::Read()
20{ 20{
21 /*
21 ReadFileFolderPluginInfoList(Plugins); 22 ReadFileFolderPluginInfoList(Plugins);
22 FOR_VECTOR (pluginIndex, Plugins) 23 FOR_VECTOR (pluginIndex, Plugins)
24 */
23 { 25 {
24 const CPluginInfo &plugin = Plugins[pluginIndex]; 26 // const CPluginInfo &plugin = Plugins[pluginIndex];
25 27
26 CPluginLibrary pluginLib; 28 CPluginLibrary pluginLib;
27 CMyComPtr<IFolderManager> folderManager; 29 CMyComPtr<IFolderManager> folderManager;
28 30
29 if (plugin.FilePath.IsEmpty()) 31 // if (plugin.FilePath.IsEmpty())
30 folderManager = new CArchiveFolderManager; 32 folderManager = new CArchiveFolderManager;
31 else if (pluginLib.LoadAndCreateManager(plugin.FilePath, plugin.ClassID, &folderManager) != S_OK) 33 /*
32 continue; 34 else
35 {
36 if (!plugin.ClassID_Defined)
37 continue;
38 if (pluginLib.LoadAndCreateManager(plugin.FilePath, plugin.ClassID, &folderManager) != S_OK)
39 continue;
40 }
41 */
33 CMyComBSTR extBSTR; 42 CMyComBSTR extBSTR;
34 if (folderManager->GetExtensions(&extBSTR) != S_OK) 43 if (folderManager->GetExtensions(&extBSTR) != S_OK)
35 return; 44 return;
@@ -46,15 +55,15 @@ void CExtDatabase::Read()
46 Int32 iconIndex; 55 Int32 iconIndex;
47 CMyComBSTR iconPath; 56 CMyComBSTR iconPath;
48 CPluginToIcon plugPair; 57 CPluginToIcon plugPair;
49 plugPair.PluginIndex = pluginIndex; 58 // plugPair.PluginIndex = pluginIndex;
50 if (folderManager->GetIconPath(ext, &iconPath, &iconIndex) == S_OK) 59 if (folderManager->GetIconPath(ext, &iconPath, &iconIndex) == S_OK)
51 if (iconPath != 0) 60 if (iconPath)
52 { 61 {
53 plugPair.IconPath = (const wchar_t *)iconPath; 62 plugPair.IconPath = (const wchar_t *)iconPath;
54 plugPair.IconIndex = iconIndex; 63 plugPair.IconIndex = iconIndex;
55 } 64 }
56 65
57 int index = FindExt(ext); 66 const int index = FindExt(ext);
58 if (index >= 0) 67 if (index >= 0)
59 Exts[index].Plugins.Add(plugPair); 68 Exts[index].Plugins.Add(plugPair);
60 else 69 else
diff --git a/CPP/7zip/UI/FileManager/FilePlugins.h b/CPP/7zip/UI/FileManager/FilePlugins.h
index 43b05f9..db8ec39 100644
--- a/CPP/7zip/UI/FileManager/FilePlugins.h
+++ b/CPP/7zip/UI/FileManager/FilePlugins.h
@@ -1,15 +1,15 @@
1// FilePlugins.h 1// FilePlugins.h
2 2
3#ifndef __FILE_PLUGINS_H 3#ifndef ZIP7_INC_FILE_PLUGINS_H
4#define __FILE_PLUGINS_H 4#define ZIP7_INC_FILE_PLUGINS_H
5 5
6#include "RegistryPlugins.h" 6#include "RegistryPlugins.h"
7 7
8struct CPluginToIcon 8struct CPluginToIcon
9{ 9{
10 int PluginIndex; 10 // unsigned PluginIndex;
11 UString IconPath;
12 int IconIndex; 11 int IconIndex;
12 UString IconPath;
13 13
14 CPluginToIcon(): IconIndex(-1) {} 14 CPluginToIcon(): IconIndex(-1) {}
15}; 15};
@@ -22,10 +22,10 @@ struct CExtPlugins
22 22
23class CExtDatabase 23class CExtDatabase
24{ 24{
25 int FindExt(const UString &ext); 25 int FindExt(const UString &ext) const;
26public: 26public:
27 CObjectVector<CExtPlugins> Exts; 27 CObjectVector<CExtPlugins> Exts;
28 CObjectVector<CPluginInfo> Plugins; 28 // CObjectVector<CPluginInfo> Plugins;
29 29
30 void Read(); 30 void Read();
31}; 31};
diff --git a/CPP/7zip/UI/FileManager/FoldersPage.cpp b/CPP/7zip/UI/FileManager/FoldersPage.cpp
index d019bab..7e74635 100644
--- a/CPP/7zip/UI/FileManager/FoldersPage.cpp
+++ b/CPP/7zip/UI/FileManager/FoldersPage.cpp
@@ -11,6 +11,7 @@
11 11
12using namespace NWindows; 12using namespace NWindows;
13 13
14#ifdef Z7_LANG
14static const UInt32 kLangIDs[] = 15static const UInt32 kLangIDs[] =
15{ 16{
16 IDT_FOLDERS_WORKING_FOLDER, 17 IDT_FOLDERS_WORKING_FOLDER,
@@ -19,8 +20,9 @@ static const UInt32 kLangIDs[] =
19 IDR_FOLDERS_WORK_SPECIFIED, 20 IDR_FOLDERS_WORK_SPECIFIED,
20 IDX_FOLDERS_WORK_FOR_REMOVABLE 21 IDX_FOLDERS_WORK_FOR_REMOVABLE
21}; 22};
23#endif
22 24
23static const int kWorkModeButtons[] = 25static const unsigned kWorkModeButtons[] =
24{ 26{
25 IDR_FOLDERS_WORK_SYSTEM, 27 IDR_FOLDERS_WORK_SYSTEM,
26 IDR_FOLDERS_WORK_CURRENT, 28 IDR_FOLDERS_WORK_CURRENT,
@@ -29,19 +31,23 @@ static const int kWorkModeButtons[] =
29 31
30#define kFoldersTopic "fm/options.htm#folders" 32#define kFoldersTopic "fm/options.htm#folders"
31 33
32static const unsigned kNumWorkModeButtons = ARRAY_SIZE(kWorkModeButtons); 34static const unsigned kNumWorkModeButtons = Z7_ARRAY_SIZE(kWorkModeButtons);
33 35
34bool CFoldersPage::OnInit() 36bool CFoldersPage::OnInit()
35{ 37{
36 _initMode = true; 38 _initMode = true;
37 _needSave = false; 39 _needSave = false;
38 40
39 LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); 41 #ifdef Z7_LANG
42 LangSetDlgItems(*this, kLangIDs, Z7_ARRAY_SIZE(kLangIDs));
43 #endif
40 m_WorkDirInfo.Load(); 44 m_WorkDirInfo.Load();
41 45
42 CheckButton(IDX_FOLDERS_WORK_FOR_REMOVABLE, m_WorkDirInfo.ForRemovableOnly); 46 CheckButton(IDX_FOLDERS_WORK_FOR_REMOVABLE, m_WorkDirInfo.ForRemovableOnly);
43 47
44 CheckRadioButton(kWorkModeButtons[0], kWorkModeButtons[kNumWorkModeButtons - 1], 48 CheckRadioButton(
49 kWorkModeButtons[0],
50 kWorkModeButtons[kNumWorkModeButtons - 1],
45 kWorkModeButtons[m_WorkDirInfo.Mode]); 51 kWorkModeButtons[m_WorkDirInfo.Mode]);
46 52
47 m_WorkPath.Init(*this, IDE_FOLDERS_WORK_PATH); 53 m_WorkPath.Init(*this, IDE_FOLDERS_WORK_PATH);
@@ -58,7 +64,7 @@ int CFoldersPage::GetWorkMode() const
58{ 64{
59 for (unsigned i = 0; i < kNumWorkModeButtons; i++) 65 for (unsigned i = 0; i < kNumWorkModeButtons; i++)
60 if (IsButtonCheckedBool(kWorkModeButtons[i])) 66 if (IsButtonCheckedBool(kWorkModeButtons[i]))
61 return i; 67 return (int)i;
62 throw 0; 68 throw 0;
63} 69}
64 70
@@ -104,7 +110,7 @@ void CFoldersPage::ModifiedEvent()
104 */ 110 */
105} 111}
106 112
107bool CFoldersPage::OnButtonClicked(int buttonID, HWND buttonHWND) 113bool CFoldersPage::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
108{ 114{
109 for (unsigned i = 0; i < kNumWorkModeButtons; i++) 115 for (unsigned i = 0; i < kNumWorkModeButtons; i++)
110 if (buttonID == kWorkModeButtons[i]) 116 if (buttonID == kWorkModeButtons[i])
@@ -129,7 +135,7 @@ bool CFoldersPage::OnButtonClicked(int buttonID, HWND buttonHWND)
129 return true; 135 return true;
130} 136}
131 137
132bool CFoldersPage::OnCommand(int code, int itemID, LPARAM lParam) 138bool CFoldersPage::OnCommand(unsigned code, unsigned itemID, LPARAM lParam)
133{ 139{
134 if (code == EN_CHANGE && itemID == IDE_FOLDERS_WORK_PATH) 140 if (code == EN_CHANGE && itemID == IDE_FOLDERS_WORK_PATH)
135 { 141 {
diff --git a/CPP/7zip/UI/FileManager/FoldersPage.h b/CPP/7zip/UI/FileManager/FoldersPage.h
index 71c7bfc..09b6cdd 100644
--- a/CPP/7zip/UI/FileManager/FoldersPage.h
+++ b/CPP/7zip/UI/FileManager/FoldersPage.h
@@ -1,7 +1,7 @@
1// FoldersPage.h 1// FoldersPage.h
2 2
3#ifndef __FOLDERS_PAGE_H 3#ifndef ZIP7_INC_FOLDERS_PAGE_H
4#define __FOLDERS_PAGE_H 4#define ZIP7_INC_FOLDERS_PAGE_H
5 5
6#include "../../../Windows/Control/PropertyPage.h" 6#include "../../../Windows/Control/PropertyPage.h"
7 7
@@ -22,11 +22,11 @@ class CFoldersPage : public NWindows::NControl::CPropertyPage
22 int GetWorkMode() const; 22 int GetWorkMode() const;
23 void GetWorkDir(NWorkDir::CInfo &workDirInfo); 23 void GetWorkDir(NWorkDir::CInfo &workDirInfo);
24 // bool WasChanged(); 24 // bool WasChanged();
25 virtual bool OnInit(); 25 virtual bool OnInit() Z7_override;
26 virtual bool OnCommand(int code, int itemID, LPARAM lParam); 26 virtual bool OnCommand(unsigned code, unsigned itemID, LPARAM lParam) Z7_override;
27 virtual void OnNotifyHelp(); 27 virtual void OnNotifyHelp() Z7_override;
28 virtual LONG OnApply(); 28 virtual LONG OnApply() Z7_override;
29 virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); 29 virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
30}; 30};
31 31
32#endif 32#endif
diff --git a/CPP/7zip/UI/FileManager/FormatUtils.h b/CPP/7zip/UI/FileManager/FormatUtils.h
index 993e803..1db08ef 100644
--- a/CPP/7zip/UI/FileManager/FormatUtils.h
+++ b/CPP/7zip/UI/FileManager/FormatUtils.h
@@ -1,7 +1,7 @@
1// FormatUtils.h 1// FormatUtils.h
2 2
3#ifndef __FORMAT_UTILS_H 3#ifndef ZIP7_INC_FORMAT_UTILS_H
4#define __FORMAT_UTILS_H 4#define ZIP7_INC_FORMAT_UTILS_H
5 5
6#include "../../../Common/MyTypes.h" 6#include "../../../Common/MyTypes.h"
7#include "../../../Common/MyString.h" 7#include "../../../Common/MyString.h"
diff --git a/CPP/7zip/UI/FileManager/HelpUtils.cpp b/CPP/7zip/UI/FileManager/HelpUtils.cpp
index 5cb78fc..d5b6a58 100644
--- a/CPP/7zip/UI/FileManager/HelpUtils.cpp
+++ b/CPP/7zip/UI/FileManager/HelpUtils.cpp
@@ -4,7 +4,7 @@
4 4
5#include "HelpUtils.h" 5#include "HelpUtils.h"
6 6
7#if defined(UNDER_CE) || !defined(_WIN32) /* || !defined(_MSC_VER) */ 7#if defined(UNDER_CE) || defined(__MINGW32_VERSION)
8 8
9void ShowHelpWindow(LPCSTR) 9void ShowHelpWindow(LPCSTR)
10{ 10{
@@ -12,11 +12,15 @@ void ShowHelpWindow(LPCSTR)
12 12
13#else 13#else
14 14
15// #define USE_EXTERNAL_HELP 15/* USE_EXTERNAL_HELP creates new help process window for each HtmlHelp() call.
16 HtmlHelp() call uses one window. */
16 17
17#if defined(_MSC_VER) 18#if defined(__MINGW32_VERSION) /* || defined(Z7_OLD_WIN_SDK) */
19#define USE_EXTERNAL_HELP
18#endif 20#endif
19 21
22// #define USE_EXTERNAL_HELP
23
20#ifdef USE_EXTERNAL_HELP 24#ifdef USE_EXTERNAL_HELP
21 25
22#include "../../../Windows/ProcessUtils.h" 26#include "../../../Windows/ProcessUtils.h"
diff --git a/CPP/7zip/UI/FileManager/HelpUtils.h b/CPP/7zip/UI/FileManager/HelpUtils.h
index 90c5f7d..d7bdf45 100644
--- a/CPP/7zip/UI/FileManager/HelpUtils.h
+++ b/CPP/7zip/UI/FileManager/HelpUtils.h
@@ -1,7 +1,7 @@
1// HelpUtils.h 1// HelpUtils.h
2 2
3#ifndef __HELP_UTILS_H 3#ifndef ZIP7_INC_HELP_UTILS_H
4#define __HELP_UTILS_H 4#define ZIP7_INC_HELP_UTILS_H
5 5
6#include "../../../Common/MyString.h" 6#include "../../../Common/MyString.h"
7 7
diff --git a/CPP/7zip/UI/FileManager/IFolder.h b/CPP/7zip/UI/FileManager/IFolder.h
index c5cff06..1ebdf7e 100644
--- a/CPP/7zip/UI/FileManager/IFolder.h
+++ b/CPP/7zip/UI/FileManager/IFolder.h
@@ -1,13 +1,19 @@
1// IFolder.h 1// IFolder.h
2 2
3#ifndef __IFOLDER_H 3#ifndef ZIP7_INC_IFOLDER_H
4#define __IFOLDER_H 4#define ZIP7_INC_IFOLDER_H
5 5
6#include "../../IProgress.h" 6#include "../../IProgress.h"
7#include "../../IStream.h" 7#include "../../IStream.h"
8 8
9#define FOLDER_INTERFACE_SUB(i, b, x) DECL_INTERFACE_SUB(i, b, 8, x) 9Z7_PURE_INTERFACES_BEGIN
10#define FOLDER_INTERFACE(i, x) FOLDER_INTERFACE_SUB(i, IUnknown, x) 10
11#define Z7_IFACE_CONSTR_FOLDER_SUB(i, base, n) \
12 Z7_DECL_IFACE_7ZIP_SUB(i, base, 8, n) \
13 { Z7_IFACE_COM7_PURE(i) };
14
15#define Z7_IFACE_CONSTR_FOLDER(i, n) \
16 Z7_IFACE_CONSTR_FOLDER_SUB(i, IUnknown, n)
11 17
12namespace NPlugin 18namespace NPlugin
13{ 19{
@@ -20,199 +26,162 @@ namespace NPlugin
20 }; 26 };
21} 27}
22 28
23#define INTERFACE_FolderFolder(x) \ 29#define Z7_IFACEM_IFolderFolder(x) \
24 STDMETHOD(LoadItems)() x; \ 30 x(LoadItems()) \
25 STDMETHOD(GetNumberOfItems)(UInt32 *numItems) x; \ 31 x(GetNumberOfItems(UInt32 *numItems)) \
26 STDMETHOD(GetProperty)(UInt32 itemIndex, PROPID propID, PROPVARIANT *value) x; \ 32 x(GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)) \
27 STDMETHOD(BindToFolder)(UInt32 index, IFolderFolder **resultFolder) x; \ 33 x(BindToFolder(UInt32 index, IFolderFolder **resultFolder)) \
28 STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder) x; \ 34 x(BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)) \
29 STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder) x; \ 35 x(BindToParentFolder(IFolderFolder **resultFolder)) \
30 STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties) x; \ 36 x(GetNumberOfProperties(UInt32 *numProperties)) \
31 STDMETHOD(GetPropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x; \ 37 x(GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)) \
32 STDMETHOD(GetFolderProperty)(PROPID propID, PROPVARIANT *value) x; \ 38 x(GetFolderProperty(PROPID propID, PROPVARIANT *value)) \
33 39
34FOLDER_INTERFACE(IFolderFolder, 0x00) 40Z7_IFACE_CONSTR_FOLDER(IFolderFolder, 0x00)
35{
36 INTERFACE_FolderFolder(PURE)
37};
38 41
39/* 42/*
40 IFolderAltStreams:: 43 IFolderAltStreams::
41 BindToAltStreams((UInt32)(Int32)-1, ... ) means alt streams of that folder 44 BindToAltStreams((UInt32)(Int32)-1, ... ) means alt streams of that folder
42*/ 45*/
43 46
44#define INTERFACE_FolderAltStreams(x) \ 47#define Z7_IFACEM_IFolderAltStreams(x) \
45 STDMETHOD(BindToAltStreams)(UInt32 index, IFolderFolder **resultFolder) x; \ 48 x(BindToAltStreams(UInt32 index, IFolderFolder **resultFolder)) \
46 STDMETHOD(BindToAltStreams)(const wchar_t *name, IFolderFolder **resultFolder) x; \ 49 x(BindToAltStreams(const wchar_t *name, IFolderFolder **resultFolder)) \
47 STDMETHOD(AreAltStreamsSupported)(UInt32 index, Int32 *isSupported) x; \ 50 x(AreAltStreamsSupported(UInt32 index, Int32 *isSupported)) \
48 51
49FOLDER_INTERFACE(IFolderAltStreams, 0x17) 52Z7_IFACE_CONSTR_FOLDER(IFolderAltStreams, 0x17)
50{ 53
51 INTERFACE_FolderAltStreams(PURE) 54#define Z7_IFACEM_IFolderWasChanged(x) \
52}; 55 x(WasChanged(Int32 *wasChanged))
53 56Z7_IFACE_CONSTR_FOLDER(IFolderWasChanged, 0x04)
54FOLDER_INTERFACE(IFolderWasChanged, 0x04) 57
55{ 58 /* x(SetTotalFiles(UInt64 total)) */ \
56 STDMETHOD(WasChanged)(Int32 *wasChanged) PURE; 59 /* x(SetCompletedFiles(const UInt64 *completedValue)) */ \
57}; 60#define Z7_IFACEM_IFolderOperationsExtractCallback(x) \
58 61 x(AskWrite( \
59FOLDER_INTERFACE_SUB(IFolderOperationsExtractCallback, IProgress, 0x0B) 62 const wchar_t *srcPath, \
60{ 63 Int32 srcIsFolder, \
61 // STDMETHOD(SetTotalFiles)(UInt64 total) PURE; 64 const FILETIME *srcTime, \
62 // STDMETHOD(SetCompletedFiles)(const UInt64 *completedValue) PURE; 65 const UInt64 *srcSize, \
63 STDMETHOD(AskWrite)( 66 const wchar_t *destPathRequest, \
64 const wchar_t *srcPath, 67 BSTR *destPathResult, \
65 Int32 srcIsFolder, 68 Int32 *writeAnswer)) \
66 const FILETIME *srcTime, 69 x(ShowMessage(const wchar_t *message)) \
67 const UInt64 *srcSize, 70 x(SetCurrentFilePath(const wchar_t *filePath)) \
68 const wchar_t *destPathRequest, 71 x(SetNumFiles(UInt64 numFiles)) \
69 BSTR *destPathResult, 72
70 Int32 *writeAnswer) PURE; 73Z7_IFACE_CONSTR_FOLDER_SUB(IFolderOperationsExtractCallback, IProgress, 0x0B)
71 STDMETHOD(ShowMessage)(const wchar_t *message) PURE; 74
72 STDMETHOD(SetCurrentFilePath)(const wchar_t *filePath) PURE; 75
73 STDMETHOD(SetNumFiles)(UInt64 numFiles) PURE; 76#define Z7_IFACEM_IFolderOperations(x) \
74}; 77 x(CreateFolder(const wchar_t *name, IProgress *progress)) \
75 78 x(CreateFile(const wchar_t *name, IProgress *progress)) \
76#define INTERFACE_FolderOperations(x) \ 79 x(Rename(UInt32 index, const wchar_t *newName, IProgress *progress)) \
77 STDMETHOD(CreateFolder)(const wchar_t *name, IProgress *progress) x; \ 80 x(Delete(const UInt32 *indices, UInt32 numItems, IProgress *progress)) \
78 STDMETHOD(CreateFile)(const wchar_t *name, IProgress *progress) x; \ 81 x(CopyTo(Int32 moveMode, const UInt32 *indices, UInt32 numItems, \
79 STDMETHOD(Rename)(UInt32 index, const wchar_t *newName, IProgress *progress) x; \
80 STDMETHOD(Delete)(const UInt32 *indices, UInt32 numItems, IProgress *progress) x; \
81 STDMETHOD(CopyTo)(Int32 moveMode, const UInt32 *indices, UInt32 numItems, \
82 Int32 includeAltStreams, Int32 replaceAltStreamCharsMode, \ 82 Int32 includeAltStreams, Int32 replaceAltStreamCharsMode, \
83 const wchar_t *path, IFolderOperationsExtractCallback *callback) x; \ 83 const wchar_t *path, IFolderOperationsExtractCallback *callback)) \
84 STDMETHOD(CopyFrom)(Int32 moveMode, const wchar_t *fromFolderPath, \ 84 x(CopyFrom(Int32 moveMode, const wchar_t *fromFolderPath, \
85 const wchar_t * const *itemsPaths, UInt32 numItems, IProgress *progress) x; \ 85 const wchar_t * const *itemsPaths, UInt32 numItems, IProgress *progress)) \
86 STDMETHOD(SetProperty)(UInt32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress) x; \ 86 x(SetProperty(UInt32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress)) \
87 STDMETHOD(CopyFromFile)(UInt32 index, const wchar_t *fullFilePath, IProgress *progress) x; \ 87 x(CopyFromFile(UInt32 index, const wchar_t *fullFilePath, IProgress *progress)) \
88 88
89FOLDER_INTERFACE(IFolderOperations, 0x13) 89Z7_IFACE_CONSTR_FOLDER(IFolderOperations, 0x13)
90{
91 INTERFACE_FolderOperations(PURE)
92};
93 90
94/* 91/*
95FOLDER_INTERFACE2(IFolderOperationsDeleteToRecycleBin, 0x06, 0x03) 92FOLDER_INTERFACE2(IFolderOperationsDeleteToRecycleBin, 0x06, 0x03)
96{ 93{
97 STDMETHOD(DeleteToRecycleBin)(const UInt32 *indices, UInt32 numItems, IProgress *progress) PURE; 94 x(DeleteToRecycleBin(const UInt32 *indices, UInt32 numItems, IProgress *progress)) \
98}; 95};
99*/ 96*/
100 97
101FOLDER_INTERFACE(IFolderGetSystemIconIndex, 0x07) 98#define Z7_IFACEM_IFolderGetSystemIconIndex(x) \
102{ 99 x(GetSystemIconIndex(UInt32 index, Int32 *iconIndex))
103 STDMETHOD(GetSystemIconIndex)(UInt32 index, Int32 *iconIndex) PURE; 100Z7_IFACE_CONSTR_FOLDER(IFolderGetSystemIconIndex, 0x07)
104};
105 101
106FOLDER_INTERFACE(IFolderGetItemFullSize, 0x08) 102#define Z7_IFACEM_IFolderGetItemFullSize(x) \
107{ 103 x(GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgress *progress))
108 STDMETHOD(GetItemFullSize)(UInt32 index, PROPVARIANT *value, IProgress *progress) PURE; 104Z7_IFACE_CONSTR_FOLDER(IFolderGetItemFullSize, 0x08)
109};
110 105
111FOLDER_INTERFACE(IFolderCalcItemFullSize, 0x14) 106#define Z7_IFACEM_IFolderCalcItemFullSize(x) \
112{ 107 x(CalcItemFullSize(UInt32 index, IProgress *progress))
113 STDMETHOD(CalcItemFullSize)(UInt32 index, IProgress *progress) PURE; 108Z7_IFACE_CONSTR_FOLDER(IFolderCalcItemFullSize, 0x14)
114};
115 109
116FOLDER_INTERFACE(IFolderClone, 0x09) 110#define Z7_IFACEM_IFolderClone(x) \
117{ 111 x(Clone(IFolderFolder **resultFolder))
118 STDMETHOD(Clone)(IFolderFolder **resultFolder) PURE; 112Z7_IFACE_CONSTR_FOLDER(IFolderClone, 0x09)
119};
120 113
121FOLDER_INTERFACE(IFolderSetFlatMode, 0x0A) 114#define Z7_IFACEM_IFolderSetFlatMode(x) \
122{ 115 x(SetFlatMode(Int32 flatMode))
123 STDMETHOD(SetFlatMode)(Int32 flatMode) PURE; 116Z7_IFACE_CONSTR_FOLDER(IFolderSetFlatMode, 0x0A)
124};
125 117
126/* 118/*
127FOLDER_INTERFACE(IFolderSetShowNtfsStreamsMode, 0xFA) 119#define Z7_IFACEM_IFolderSetShowNtfsStreamsMode(x) \
128{ 120 x(SetShowNtfsStreamsMode(Int32 showStreamsMode))
129 STDMETHOD(SetShowNtfsStreamsMode)(Int32 showStreamsMode) PURE; 121Z7_IFACE_CONSTR_FOLDER(IFolderSetShowNtfsStreamsMode, 0xFA)
130};
131*/ 122*/
132 123
133#define INTERFACE_FolderProperties(x) \ 124#define Z7_IFACEM_IFolderProperties(x) \
134 STDMETHOD(GetNumberOfFolderProperties)(UInt32 *numProperties) x; \ 125 x(GetNumberOfFolderProperties(UInt32 *numProperties)) \
135 STDMETHOD(GetFolderPropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x; \ 126 x(GetFolderPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)) \
136 127
137FOLDER_INTERFACE(IFolderProperties, 0x0E) 128Z7_IFACE_CONSTR_FOLDER(IFolderProperties, 0x0E)
138{
139 INTERFACE_FolderProperties(PURE)
140};
141 129
142#define INTERFACE_IFolderArcProps(x) \ 130#define Z7_IFACEM_IFolderArcProps(x) \
143 STDMETHOD(GetArcNumLevels)(UInt32 *numLevels) x; \ 131 x(GetArcNumLevels(UInt32 *numLevels)) \
144 STDMETHOD(GetArcProp)(UInt32 level, PROPID propID, PROPVARIANT *value) x; \ 132 x(GetArcProp(UInt32 level, PROPID propID, PROPVARIANT *value)) \
145 STDMETHOD(GetArcNumProps)(UInt32 level, UInt32 *numProps) x; \ 133 x(GetArcNumProps(UInt32 level, UInt32 *numProps)) \
146 STDMETHOD(GetArcPropInfo)(UInt32 level, UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x; \ 134 x(GetArcPropInfo(UInt32 level, UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)) \
147 STDMETHOD(GetArcProp2)(UInt32 level, PROPID propID, PROPVARIANT *value) x; \ 135 x(GetArcProp2(UInt32 level, PROPID propID, PROPVARIANT *value)) \
148 STDMETHOD(GetArcNumProps2)(UInt32 level, UInt32 *numProps) x; \ 136 x(GetArcNumProps2(UInt32 level, UInt32 *numProps)) \
149 STDMETHOD(GetArcPropInfo2)(UInt32 level, UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x; \ 137 x(GetArcPropInfo2(UInt32 level, UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)) \
150 138
151FOLDER_INTERFACE(IFolderArcProps, 0x10) 139Z7_IFACE_CONSTR_FOLDER(IFolderArcProps, 0x10)
152{
153 INTERFACE_IFolderArcProps(PURE)
154};
155 140
156FOLDER_INTERFACE(IGetFolderArcProps, 0x11) 141#define Z7_IFACEM_IGetFolderArcProps(x) \
157{ 142 x(GetFolderArcProps(IFolderArcProps **object))
158 STDMETHOD(GetFolderArcProps)(IFolderArcProps **object) PURE; 143Z7_IFACE_CONSTR_FOLDER(IGetFolderArcProps, 0x11)
159};
160 144
161FOLDER_INTERFACE(IFolderCompare, 0x15) 145#define Z7_IFACEM_IFolderCompare(x) \
162{ 146 x##2(Int32, CompareItems(UInt32 index1, UInt32 index2, PROPID propID, Int32 propIsRaw))
163 STDMETHOD_(Int32, CompareItems)(UInt32 index1, UInt32 index2, PROPID propID, Int32 propIsRaw) PURE; 147Z7_IFACE_CONSTR_FOLDER(IFolderCompare, 0x15)
164};
165 148
166#define INTERFACE_IFolderGetItemName(x) \ 149#define Z7_IFACEM_IFolderGetItemName(x) \
167 STDMETHOD(GetItemName)(UInt32 index, const wchar_t **name, unsigned *len) x; \ 150 x(GetItemName(UInt32 index, const wchar_t **name, unsigned *len)) \
168 STDMETHOD(GetItemPrefix)(UInt32 index, const wchar_t **name, unsigned *len) x; \ 151 x(GetItemPrefix(UInt32 index, const wchar_t **name, unsigned *len)) \
169 STDMETHOD_(UInt64, GetItemSize)(UInt32 index) x; \ 152 x##2(UInt64, GetItemSize(UInt32 index)) \
170 153
171FOLDER_INTERFACE(IFolderGetItemName, 0x16) 154Z7_IFACE_CONSTR_FOLDER(IFolderGetItemName, 0x16)
172{
173 INTERFACE_IFolderGetItemName(PURE)
174};
175 155
176#define FOLDER_MANAGER_INTERFACE(i, x) DECL_INTERFACE(i, 9, x)
177 156
178#define INTERFACE_IFolderManager(x) \ 157#define Z7_IFACEM_IFolderManager(x) \
179 STDMETHOD(OpenFolderFile)(IInStream *inStream, const wchar_t *filePath, const wchar_t *arcFormat, IFolderFolder **resultFolder, IProgress *progress) x; \ 158 x(OpenFolderFile(IInStream *inStream, const wchar_t *filePath, const wchar_t *arcFormat, IFolderFolder **resultFolder, IProgress *progress)) \
180 STDMETHOD(GetExtensions)(BSTR *extensions) x; \ 159 x(GetExtensions(BSTR *extensions)) \
181 STDMETHOD(GetIconPath)(const wchar_t *ext, BSTR *iconPath, Int32 *iconIndex) x; \ 160 x(GetIconPath(const wchar_t *ext, BSTR *iconPath, Int32 *iconIndex)) \
182 161
183 // STDMETHOD(GetTypes)(BSTR *types) PURE; 162 // x(GetTypes(BSTR *types))
184 // STDMETHOD(CreateFolderFile)(const wchar_t *type, const wchar_t *filePath, IProgress *progress) PURE; 163 // x(CreateFolderFile(const wchar_t *type, const wchar_t *filePath, IProgress *progress))
185 164
186FOLDER_MANAGER_INTERFACE(IFolderManager, 0x05) 165Z7_DECL_IFACE_7ZIP(IFolderManager, 9, 5)
187{ 166 { Z7_IFACE_COM7_PURE(IFolderManager) };
188 INTERFACE_IFolderManager(PURE);
189};
190 167
191/* 168/*
192#define IMP_IFolderFolder_GetProp(k) \
193 (UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) \
194 { if (index >= ARRAY_SIZE(k)) return E_INVALIDARG; \
195 const CMy_STATPROPSTG_2 &srcItem = k[index]; \ 169 const CMy_STATPROPSTG_2 &srcItem = k[index]; \
196 *propID = srcItem.propid; *varType = srcItem.vt; *name = 0; return S_OK; } \ 170 *propID = srcItem.propid; *varType = srcItem.vt; *name = 0; return S_OK; } \
197
198#define IMP_IFolderFolder_Props(c) \
199 STDMETHODIMP c::GetNumberOfProperties(UInt32 *numProperties) \
200 { *numProperties = ARRAY_SIZE(kProps); return S_OK; } \
201 STDMETHODIMP c::GetPropertyInfo IMP_IFolderFolder_GetProp(kProps)
202*/ 171*/
203 172#define IMP_IFolderFolder_GetProp(fn, k) \
204#define IMP_IFolderFolder_GetProp(k) \ 173 Z7_COM7F_IMF(fn(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)) \
205 (UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) \ 174 { if (index >= Z7_ARRAY_SIZE(k)) return E_INVALIDARG; \
206 { if (index >= ARRAY_SIZE(k)) return E_INVALIDARG; \ 175 *propID = k[index]; *varType = k7z_PROPID_To_VARTYPE[(unsigned)*propID]; *name = NULL; return S_OK; } \
207 *propID = k[index]; *varType = k7z_PROPID_To_VARTYPE[(unsigned)*propID]; *name = 0; return S_OK; } \
208 176
209#define IMP_IFolderFolder_Props(c) \ 177#define IMP_IFolderFolder_Props(c) \
210 STDMETHODIMP c::GetNumberOfProperties(UInt32 *numProperties) \ 178 Z7_COM7F_IMF(c::GetNumberOfProperties(UInt32 *numProperties)) \
211 { *numProperties = ARRAY_SIZE(kProps); return S_OK; } \ 179 { *numProperties = Z7_ARRAY_SIZE(kProps); return S_OK; } \
212 STDMETHODIMP c::GetPropertyInfo IMP_IFolderFolder_GetProp(kProps) 180 IMP_IFolderFolder_GetProp(c::GetPropertyInfo, kProps)
213 181
214 182
215int CompareFileNames_ForFolderList(const wchar_t *s1, const wchar_t *s2); 183int CompareFileNames_ForFolderList(const wchar_t *s1, const wchar_t *s2);
216// int CompareFileNames_ForFolderList(const FChar *s1, const FChar *s2); 184// int CompareFileNames_ForFolderList(const FChar *s1, const FChar *s2);
217 185
186Z7_PURE_INTERFACES_END
218#endif 187#endif
diff --git a/CPP/7zip/UI/FileManager/LangPage.cpp b/CPP/7zip/UI/FileManager/LangPage.cpp
index 47e7894..ec1dd2e 100644
--- a/CPP/7zip/UI/FileManager/LangPage.cpp
+++ b/CPP/7zip/UI/FileManager/LangPage.cpp
@@ -15,13 +15,37 @@
15 15
16using namespace NWindows; 16using namespace NWindows;
17 17
18
19static const unsigned k_NumLangLines_EN = 429;
20
21#ifdef Z7_LANG
18static const UInt32 kLangIDs[] = 22static const UInt32 kLangIDs[] =
19{ 23{
20 IDT_LANG_LANG 24 IDT_LANG_LANG
21}; 25};
26#endif
22 27
23#define kLangTopic "fm/options.htm#language" 28#define kLangTopic "fm/options.htm#language"
24 29
30
31struct CLangListRecord
32{
33 int Order;
34 unsigned LangInfoIndex;
35 bool IsSelected;
36 UString Mark;
37 UString Name;
38
39 CLangListRecord(): Order (10), IsSelected(false) {}
40 int Compare(const CLangListRecord &a) const
41 {
42 if (Order < a.Order) return -1;
43 if (Order > a.Order) return 1;
44 return MyStringCompareNoCase(Name, a.Name);
45 }
46};
47
48
25static void NativeLangString(UString &dest, const wchar_t *s) 49static void NativeLangString(UString &dest, const wchar_t *s)
26{ 50{
27 dest += " ("; 51 dest += " (";
@@ -33,23 +57,51 @@ bool LangOpen(CLang &lang, CFSTR fileName);
33 57
34bool CLangPage::OnInit() 58bool CLangPage::OnInit()
35{ 59{
36 LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); 60#ifdef Z7_LANG
37 61 LangSetDlgItems(*this, kLangIDs, Z7_ARRAY_SIZE(kLangIDs));
62#endif
38 _langCombo.Attach(GetItem(IDC_LANG_LANG)); 63 _langCombo.Attach(GetItem(IDC_LANG_LANG));
39 64
40 UString temp = MyLoadString(IDS_LANG_ENGLISH); 65
41 NativeLangString(temp, MyLoadString(IDS_LANG_NATIVE)); 66 unsigned listRecords_SelectedIndex = 0;
42 int index = (int)_langCombo.AddString(temp); 67
43 _langCombo.SetItemData(index, _paths.Size()); 68 CObjectVector<CLangListRecord> listRecords;
44 _paths.Add(L"-"); 69 {
45 _langCombo.SetCurSel(0); 70 CLangListRecord listRecord;
71 listRecord.Order = 0;
72 listRecord.Mark = "---";
73 listRecord.Name = MyLoadString(IDS_LANG_ENGLISH);
74 NativeLangString(listRecord.Name, MyLoadString(IDS_LANG_NATIVE));
75 listRecord.LangInfoIndex = _langs.Size();
76 listRecords.Add(listRecord);
77 }
78
79 AStringVector names;
80 unsigned subLangIndex = 0;
81 Lang_GetShortNames_for_DefaultLang(names, subLangIndex);
46 82
47 const FString dirPrefix = GetLangDirPrefix(); 83 const FString dirPrefix = GetLangDirPrefix();
48 NFile::NFind::CEnumerator enumerator; 84 NFile::NFind::CEnumerator enumerator;
49 enumerator.SetDirPrefix(dirPrefix); 85 enumerator.SetDirPrefix(dirPrefix);
50 NFile::NFind::CFileInfo fi; 86 NFile::NFind::CFileInfo fi;
87
88 CLang lang_en;
89 {
90 CLangInfo &langInfo = _langs.AddNew();
91 langInfo.Name = "-";
92 if (LangOpen(lang_en, dirPrefix + FTEXT("en.ttt")))
93 {
94 langInfo.NumLines = lang_en._ids.Size();
95 // langInfo.Comments = lang_en.Comments;
96 }
97 else
98 langInfo.NumLines = k_NumLangLines_EN;
99 NumLangLines_EN = langInfo.NumLines;
100 }
101
51 CLang lang; 102 CLang lang;
52 UString error; 103 UString error;
104 UString n;
53 105
54 while (enumerator.Next(fi)) 106 while (enumerator.Next(fi))
55 { 107 {
@@ -73,6 +125,39 @@ bool CLangPage::OnInit()
73 } 125 }
74 126
75 const UString shortName = fs2us(fi.Name.Left(pos)); 127 const UString shortName = fs2us(fi.Name.Left(pos));
128
129 CLangListRecord listRecord;
130 if (!names.IsEmpty())
131 {
132 for (unsigned i = 0; i < names.Size(); i++)
133 if (shortName.IsEqualTo_Ascii_NoCase(names[i]))
134 {
135 if (subLangIndex == i || names.Size() == 1)
136 {
137 listRecord.Mark = "***";
138 // listRecord.Order = 1;
139 }
140 else
141 {
142 listRecord.Mark = "+++";
143 // listRecord.Order = 2;
144 }
145 break;
146 }
147 if (listRecord.Mark.IsEmpty())
148 {
149 const int minusPos = shortName.Find(L'-');
150 if (minusPos >= 0)
151 {
152 const UString shortName2 = shortName.Left(minusPos);
153 if (shortName2.IsEqualTo_Ascii_NoCase(names[0]))
154 {
155 listRecord.Mark = "+++";
156 // listRecord.Order = 3;
157 }
158 }
159 }
160 }
76 UString s = shortName; 161 UString s = shortName;
77 const wchar_t *eng = lang.Get(IDS_LANG_ENGLISH); 162 const wchar_t *eng = lang.Get(IDS_LANG_ENGLISH);
78 if (eng) 163 if (eng)
@@ -80,25 +165,119 @@ bool CLangPage::OnInit()
80 const wchar_t *native = lang.Get(IDS_LANG_NATIVE); 165 const wchar_t *native = lang.Get(IDS_LANG_NATIVE);
81 if (native) 166 if (native)
82 NativeLangString(s, native); 167 NativeLangString(s, native);
83 index = (int)_langCombo.AddString(s); 168
84 _langCombo.SetItemData(index, _paths.Size()); 169 listRecord.Name = s;
85 _paths.Add(shortName); 170 listRecord.LangInfoIndex = _langs.Size();
171 listRecords.Add(listRecord);
86 if (g_LangID.IsEqualTo_NoCase(shortName)) 172 if (g_LangID.IsEqualTo_NoCase(shortName))
173 listRecords_SelectedIndex = listRecords.Size() - 1;
174
175 CLangInfo &langInfo = _langs.AddNew();
176 langInfo.Comments = lang.Comments;
177 langInfo.Name = shortName;
178 unsigned numLines = lang._ids.Size();
179 if (!lang_en.IsEmpty())
180 {
181 numLines = 0;
182 unsigned i1 = 0;
183 unsigned i2 = 0;
184 for (;;)
185 {
186 UInt32 id1 = (UInt32)0 - 1;
187 UInt32 id2 = (UInt32)0 - 1;
188 bool id1_defined = false;
189 bool id2_defined = false;
190 if (i1 < lang_en._ids.Size())
191 {
192 id1 = lang_en._ids[i1];
193 id1_defined = true;
194 }
195 if (i2 < lang._ids.Size())
196 {
197 id2 = lang._ids[i2];
198 id2_defined = true;
199 }
200
201 bool id1_is_smaller = true;
202 if (id1_defined)
203 {
204 if (id2_defined)
205 {
206 if (id1 == id2)
207 {
208 i1++;
209 i2++;
210 numLines++;
211 continue;
212 }
213 if (id1 > id2)
214 id1_is_smaller = false;
215 }
216 }
217 else if (!id2_defined)
218 break;
219 else
220 id1_is_smaller = false;
221
222 n.Empty();
223 if (id1_is_smaller)
224 {
225 n.Add_UInt32(id1);
226 n += " : ";
227 n += lang_en.Get_by_index(i1);
228 langInfo.MissingLines.Add(n);
229 i1++;
230 }
231 else
232 {
233 n.Add_UInt32(id2);
234 n += " : ";
235 n += lang.Get_by_index(i2);
236 langInfo.ExtraLines.Add(n);
237 i2++;
238 }
239 }
240 }
241 langInfo.NumLines = numLines + langInfo.ExtraLines.Size();
242 }
243
244 listRecords[listRecords_SelectedIndex].IsSelected = true;
245
246 listRecords.Sort();
247 FOR_VECTOR (i, listRecords)
248 {
249 const CLangListRecord &rec= listRecords[i];
250 UString temp = rec.Name;
251 if (!rec.Mark.IsEmpty())
252 {
253 temp += " ";
254 temp += rec.Mark;
255 }
256 const int index = (int)_langCombo.AddString(temp);
257 _langCombo.SetItemData(index, (LPARAM)rec.LangInfoIndex);
258 if (rec.IsSelected)
87 _langCombo.SetCurSel(index); 259 _langCombo.SetCurSel(index);
88 } 260 }
261
262 ShowLangInfo();
89 263
90 if (!error.IsEmpty()) 264 if (!error.IsEmpty())
91 MessageBoxW(0, error, L"Error in Lang file", MB_ICONERROR); 265 MessageBoxW(NULL, error, L"Error in Lang file", MB_ICONERROR);
92 return CPropertyPage::OnInit(); 266 return CPropertyPage::OnInit();
93} 267}
94 268
95LONG CLangPage::OnApply() 269LONG CLangPage::OnApply()
96{ 270{
97 int pathIndex = (int)_langCombo.GetItemData_of_CurSel();
98 if (_needSave) 271 if (_needSave)
99 SaveRegLang(_paths[pathIndex]); 272 {
273 const int pathIndex = (int)_langCombo.GetItemData_of_CurSel();
274 if ((unsigned)pathIndex < _langs.Size())
275 SaveRegLang(_langs[pathIndex].Name);
276 }
100 _needSave = false; 277 _needSave = false;
278 #ifdef Z7_LANG
101 ReloadLang(); 279 ReloadLang();
280 #endif
102 LangWasChanged = true; 281 LangWasChanged = true;
103 return PSNRET_NOERROR; 282 return PSNRET_NOERROR;
104} 283}
@@ -108,13 +287,75 @@ void CLangPage::OnNotifyHelp()
108 ShowHelpWindow(kLangTopic); 287 ShowHelpWindow(kLangTopic);
109} 288}
110 289
111bool CLangPage::OnCommand(int code, int itemID, LPARAM param) 290bool CLangPage::OnCommand(unsigned code, unsigned itemID, LPARAM param)
112{ 291{
113 if (code == CBN_SELCHANGE && itemID == IDC_LANG_LANG) 292 if (code == CBN_SELCHANGE && itemID == IDC_LANG_LANG)
114 { 293 {
115 _needSave = true; 294 _needSave = true;
116 Changed(); 295 Changed();
296 ShowLangInfo();
117 return true; 297 return true;
118 } 298 }
119 return CPropertyPage::OnCommand(code, itemID, param); 299 return CPropertyPage::OnCommand(code, itemID, param);
120} 300}
301
302static void AddVectorToString(UString &s, const UStringVector &v)
303{
304 UString a;
305 FOR_VECTOR (i, v)
306 {
307 if (i >= 50)
308 break;
309 a = v[i];
310 if (a.Len() > 1500)
311 continue;
312 if (a[0] == ';')
313 {
314 a.DeleteFrontal(1);
315 a.Trim();
316 }
317 s += a;
318 s.Add_LF();
319 }
320}
321
322static void AddVectorToString2(UString &s, const char *name, const UStringVector &v)
323{
324 if (v.IsEmpty())
325 return;
326 s.Add_LF();
327 s += "------ ";
328 s += name;
329 s += ": ";
330 s.Add_UInt32(v.Size());
331 s += " :";
332 s.Add_LF();
333 AddVectorToString(s, v);
334}
335
336void CLangPage::ShowLangInfo()
337{
338 UString s;
339 const int pathIndex = (int)_langCombo.GetItemData_of_CurSel();
340 if ((unsigned)pathIndex < _langs.Size())
341 {
342 const CLangInfo &langInfo = _langs[pathIndex];
343 const unsigned numLines = langInfo.NumLines;
344 s += langInfo.Name;
345 s += " : ";
346 s.Add_UInt32(numLines);
347 if (NumLangLines_EN != 0)
348 {
349 s += " / ";
350 s.Add_UInt32(NumLangLines_EN);
351 s += " = ";
352 s.Add_UInt32(numLines * 100 / NumLangLines_EN);
353 s += "%";
354 }
355 s.Add_LF();
356 AddVectorToString(s, langInfo.Comments);
357 AddVectorToString2(s, "Missing lines", langInfo.MissingLines);
358 AddVectorToString2(s, "Extra lines", langInfo.ExtraLines);
359 }
360 SetItemText(IDT_LANG_INFO, s);
361}
diff --git a/CPP/7zip/UI/FileManager/LangPage.h b/CPP/7zip/UI/FileManager/LangPage.h
index b806257..e37ba05 100644
--- a/CPP/7zip/UI/FileManager/LangPage.h
+++ b/CPP/7zip/UI/FileManager/LangPage.h
@@ -1,25 +1,36 @@
1// LangPage.h 1// LangPage.h
2 2
3#ifndef __LANG_PAGE_H 3#ifndef ZIP7_INC_LANG_PAGE_H
4#define __LANG_PAGE_H 4#define ZIP7_INC_LANG_PAGE_H
5 5
6#include "../../../Windows/Control/PropertyPage.h" 6#include "../../../Windows/Control/PropertyPage.h"
7#include "../../../Windows/Control/ComboBox.h" 7#include "../../../Windows/Control/ComboBox.h"
8 8
9struct CLangInfo
10{
11 unsigned NumLines;
12 UString Name;
13 UStringVector Comments;
14 UStringVector MissingLines;
15 UStringVector ExtraLines;
16};
17
9class CLangPage: public NWindows::NControl::CPropertyPage 18class CLangPage: public NWindows::NControl::CPropertyPage
10{ 19{
11 NWindows::NControl::CComboBox _langCombo; 20 NWindows::NControl::CComboBox _langCombo;
12 UStringVector _paths; 21 CObjectVector<CLangInfo> _langs;
13 22 unsigned NumLangLines_EN;
14 bool _needSave; 23 bool _needSave;
24
25 void ShowLangInfo();
15public: 26public:
16 bool LangWasChanged; 27 bool LangWasChanged;
17 28
18 CLangPage(): _needSave(false), LangWasChanged(false) {} 29 CLangPage(): _needSave(false), LangWasChanged(false) {}
19 virtual bool OnInit(); 30 virtual bool OnInit() Z7_override;
20 virtual void OnNotifyHelp(); 31 virtual void OnNotifyHelp() Z7_override;
21 virtual bool OnCommand(int code, int itemID, LPARAM param); 32 virtual bool OnCommand(unsigned code, unsigned itemID, LPARAM param) Z7_override;
22 virtual LONG OnApply(); 33 virtual LONG OnApply() Z7_override;
23}; 34};
24 35
25#endif 36#endif
diff --git a/CPP/7zip/UI/FileManager/LangPage.rc b/CPP/7zip/UI/FileManager/LangPage.rc
index 164e2d3..506f102 100644
--- a/CPP/7zip/UI/FileManager/LangPage.rc
+++ b/CPP/7zip/UI/FileManager/LangPage.rc
@@ -1,14 +1,17 @@
1#include "LangPageRes.h" 1#include "LangPageRes.h"
2#include "../../GuiCommon.rc" 2#include "../../GuiCommon.rc"
3 3
4#define xc 160 4#define xc 240
5#define yc 100 5#define yc 252
6
7#define y 32
6 8
7IDD_LANG DIALOG 0, 0, xs, ys MY_PAGE_STYLE MY_FONT 9IDD_LANG DIALOG 0, 0, xs, ys MY_PAGE_STYLE MY_FONT
8CAPTION "Language" 10CAPTION "Language"
9{ 11{
10 LTEXT "Language:", IDT_LANG_LANG, m, m, xc, 8 12 LTEXT "Language:", IDT_LANG_LANG, m, m, xc, 8
11 COMBOBOX IDC_LANG_LANG, m, 20, xc, yc - 20, MY_COMBO_SORTED 13 COMBOBOX IDC_LANG_LANG, m, 20, 160, yc - 20, MY_COMBO // MY_COMBO_SORTED
14 LTEXT "", IDT_LANG_INFO, m, m + y, xc, yc - y, SS_NOPREFIX
12} 15}
13 16
14 17
@@ -24,7 +27,7 @@ IDD_LANG_2 MY_PAGE
24CAPTION "Language" 27CAPTION "Language"
25{ 28{
26 LTEXT "Language:", IDT_LANG_LANG, m, m, xc, 8 29 LTEXT "Language:", IDT_LANG_LANG, m, m, xc, 8
27 COMBOBOX IDC_LANG_LANG, m, 20, xc, yc - 20, MY_COMBO_SORTED 30 COMBOBOX IDC_LANG_LANG, m, 20, xc, yc - 20, MY_COMBO // MY_COMBO_SORTED
28} 31}
29 32
30#endif 33#endif
diff --git a/CPP/7zip/UI/FileManager/LangPageRes.h b/CPP/7zip/UI/FileManager/LangPageRes.h
index d7a39d7..a1ad30f 100644
--- a/CPP/7zip/UI/FileManager/LangPageRes.h
+++ b/CPP/7zip/UI/FileManager/LangPageRes.h
@@ -6,3 +6,4 @@
6 6
7#define IDT_LANG_LANG 2102 7#define IDT_LANG_LANG 2102
8#define IDC_LANG_LANG 100 8#define IDC_LANG_LANG 100
9#define IDT_LANG_INFO 101
diff --git a/CPP/7zip/UI/FileManager/LangUtils.cpp b/CPP/7zip/UI/FileManager/LangUtils.cpp
index 83d5aa7..4c9d16f 100644
--- a/CPP/7zip/UI/FileManager/LangUtils.cpp
+++ b/CPP/7zip/UI/FileManager/LangUtils.cpp
@@ -19,7 +19,8 @@ extern bool g_IsNT;
19 19
20UString g_LangID; 20UString g_LangID;
21 21
22static CLang g_Lang; 22// static
23CLang g_Lang;
23static bool g_Loaded = false; 24static bool g_Loaded = false;
24static NSynchronization::CCriticalSection g_CriticalSection; 25static NSynchronization::CCriticalSection g_CriticalSection;
25 26
@@ -34,6 +35,8 @@ FString GetLangDirPrefix()
34 return NDLL::GetModuleDirPrefix() + FTEXT("Lang") FSTRING_PATH_SEPARATOR; 35 return NDLL::GetModuleDirPrefix() + FTEXT("Lang") FSTRING_PATH_SEPARATOR;
35} 36}
36 37
38#ifdef Z7_LANG
39
37void LoadLangOneTime() 40void LoadLangOneTime()
38{ 41{
39 NSynchronization::CCriticalSectionLock lock(g_CriticalSection); 42 NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
@@ -48,7 +51,7 @@ void LangSetDlgItemText(HWND dialog, UInt32 controlID, UInt32 langID)
48 const wchar_t *s = g_Lang.Get(langID); 51 const wchar_t *s = g_Lang.Get(langID);
49 if (s) 52 if (s)
50 { 53 {
51 CWindow window(GetDlgItem(dialog, controlID)); 54 CWindow window(GetDlgItem(dialog, (int)controlID));
52 window.SetText(s); 55 window.SetText(s);
53 } 56 }
54} 57}
@@ -67,10 +70,10 @@ static const CIDLangPair kLangPairs[] =
67void LangSetDlgItems(HWND dialog, const UInt32 *ids, unsigned numItems) 70void LangSetDlgItems(HWND dialog, const UInt32 *ids, unsigned numItems)
68{ 71{
69 unsigned i; 72 unsigned i;
70 for (i = 0; i < ARRAY_SIZE(kLangPairs); i++) 73 for (i = 0; i < Z7_ARRAY_SIZE(kLangPairs); i++)
71 { 74 {
72 const CIDLangPair &pair = kLangPairs[i]; 75 const CIDLangPair &pair = kLangPairs[i];
73 CWindow window(GetDlgItem(dialog, pair.ControlID)); 76 CWindow window(GetDlgItem(dialog, (int)pair.ControlID));
74 if (window) 77 if (window)
75 { 78 {
76 const wchar_t *s = g_Lang.Get(pair.LangID); 79 const wchar_t *s = g_Lang.Get(pair.LangID);
@@ -81,7 +84,7 @@ void LangSetDlgItems(HWND dialog, const UInt32 *ids, unsigned numItems)
81 84
82 for (i = 0; i < numItems; i++) 85 for (i = 0; i < numItems; i++)
83 { 86 {
84 UInt32 id = ids[i]; 87 const UInt32 id = ids[i];
85 LangSetDlgItemText(dialog, id, id); 88 LangSetDlgItemText(dialog, id, id);
86 } 89 }
87} 90}
@@ -90,11 +93,11 @@ void LangSetDlgItems_Colon(HWND dialog, const UInt32 *ids, unsigned numItems)
90{ 93{
91 for (unsigned i = 0; i < numItems; i++) 94 for (unsigned i = 0; i < numItems; i++)
92 { 95 {
93 UInt32 id = ids[i]; 96 const UInt32 id = ids[i];
94 const wchar_t *s = g_Lang.Get(id); 97 const wchar_t *s = g_Lang.Get(id);
95 if (s) 98 if (s)
96 { 99 {
97 CWindow window(GetDlgItem(dialog, id)); 100 CWindow window(GetDlgItem(dialog, (int)id));
98 UString s2 = s; 101 UString s2 = s;
99 s2 += ':'; 102 s2 += ':';
100 window.SetText(s2); 103 window.SetText(s2);
@@ -102,6 +105,23 @@ void LangSetDlgItems_Colon(HWND dialog, const UInt32 *ids, unsigned numItems)
102 } 105 }
103} 106}
104 107
108void LangSetDlgItems_RemoveColon(HWND dialog, const UInt32 *ids, unsigned numItems)
109{
110 for (unsigned i = 0; i < numItems; i++)
111 {
112 const UInt32 id = ids[i];
113 const wchar_t *s = g_Lang.Get(id);
114 if (s)
115 {
116 CWindow window(GetDlgItem(dialog, (int)id));
117 UString s2 = s;
118 if (!s2.IsEmpty() && s2.Back() == ':')
119 s2.DeleteBack();
120 window.SetText(s2);
121 }
122 }
123}
124
105void LangSetWindowText(HWND window, UInt32 langID) 125void LangSetWindowText(HWND window, UInt32 langID)
106{ 126{
107 const wchar_t *s = g_Lang.Get(langID); 127 const wchar_t *s = g_Lang.Get(langID);
@@ -214,14 +234,18 @@ static struct CC1Lang
214 234
215// typedef LANGID (WINAPI *GetUserDefaultUILanguageP)(); 235// typedef LANGID (WINAPI *GetUserDefaultUILanguageP)();
216 236
217static void OpenDefaultLang() 237void Lang_GetShortNames_for_DefaultLang(AStringVector &names, unsigned &subLang)
218{ 238{
219 LANGID sysLang = GetSystemDefaultLangID(); // "Language for non-Unicode programs" in XP64 239 names.Clear();
220 LANGID userLang = GetUserDefaultLangID(); // "Standards and formats" language in XP64 240 subLang = 0;
241 const LANGID sysLang = GetSystemDefaultLangID(); // "Language for non-Unicode programs" in XP64
242 const LANGID userLang = GetUserDefaultLangID(); // "Standards and formats" language in XP64
221 243
222 if (sysLang != userLang) 244 if (sysLang != userLang)
223 return; 245 return;
224 LANGID langID = userLang; 246 const LANGID langID = userLang;
247
248 // const LANGID langID = MAKELANGID(0x1a, 1); // for debug
225 249
226 /* 250 /*
227 LANGID sysUILang; // english in XP64 251 LANGID sysUILang; // english in XP64
@@ -237,15 +261,22 @@ static void OpenDefaultLang()
237 sysUILang = fn(); 261 sysUILang = fn();
238 */ 262 */
239 263
240 WORD primLang = (WORD)(PRIMARYLANGID(langID)); 264 const WORD primLang = (WORD)(PRIMARYLANGID(langID));
241 WORD subLang = (WORD)(SUBLANGID(langID)); 265 subLang = SUBLANGID(langID);
266 FindShortNames(primLang, names);
267}
268
269
270static void OpenDefaultLang()
271{
272 AStringVector names;
273 unsigned subLang;
274 Lang_GetShortNames_for_DefaultLang(names, subLang);
242 { 275 {
243 AStringVector names;
244 FindShortNames(primLang, names);
245 const FString dirPrefix (GetLangDirPrefix()); 276 const FString dirPrefix (GetLangDirPrefix());
246 for (unsigned i = 0; i < 2; i++) 277 for (unsigned i = 0; i < 2; i++)
247 { 278 {
248 unsigned index = (i == 0 ? subLang : 0); 279 const unsigned index = (i == 0 ? subLang : 0);
249 if (index < names.Size()) 280 if (index < names.Size())
250 { 281 {
251 const AString &name = names[index]; 282 const AString &name = names[index];
@@ -282,12 +313,14 @@ void ReloadLang()
282 if (g_LangID.Len() > 1 || g_LangID[0] != L'-') 313 if (g_LangID.Len() > 1 || g_LangID[0] != L'-')
283 { 314 {
284 FString s = us2fs(g_LangID); 315 FString s = us2fs(g_LangID);
285 if (s.Find(FCHAR_PATH_SEPARATOR) < 0) 316 if (s.ReverseFind_PathSepar() < 0)
286 { 317 {
287 if (s.Find(FTEXT('.')) < 0) 318 if (s.ReverseFind_Dot() < 0)
288 s += ".txt"; 319 s += ".txt";
289 s.Insert(0, GetLangDirPrefix()); 320 s.Insert(0, GetLangDirPrefix());
321 LangOpen(g_Lang, s);
290 } 322 }
291 LangOpen(g_Lang, s);
292 } 323 }
293} 324}
325
326#endif
diff --git a/CPP/7zip/UI/FileManager/LangUtils.h b/CPP/7zip/UI/FileManager/LangUtils.h
index d63a443..d53d270 100644
--- a/CPP/7zip/UI/FileManager/LangUtils.h
+++ b/CPP/7zip/UI/FileManager/LangUtils.h
@@ -1,13 +1,16 @@
1// LangUtils.h 1// LangUtils.h
2 2
3#ifndef __LANG_UTILS_H 3#ifndef ZIP7_INC_LANG_UTILS_H
4#define __LANG_UTILS_H 4#define ZIP7_INC_LANG_UTILS_H
5 5
6#include "../../../Windows/ResourceString.h" 6#include "../../../Common/Lang.h"
7 7
8#ifdef LANG 8#include "../../../Windows/ResourceString.h"
9 9
10extern UString g_LangID; 10extern UString g_LangID;
11extern CLang g_Lang;
12
13#ifdef Z7_LANG
11 14
12struct CIDLangPair 15struct CIDLangPair
13{ 16{
@@ -17,11 +20,11 @@ struct CIDLangPair
17 20
18void ReloadLang(); 21void ReloadLang();
19void LoadLangOneTime(); 22void LoadLangOneTime();
20FString GetLangDirPrefix();
21 23
22void LangSetDlgItemText(HWND dialog, UInt32 controlID, UInt32 langID); 24void LangSetDlgItemText(HWND dialog, UInt32 controlID, UInt32 langID);
23void LangSetDlgItems(HWND dialog, const UInt32 *ids, unsigned numItems); 25void LangSetDlgItems(HWND dialog, const UInt32 *ids, unsigned numItems);
24void LangSetDlgItems_Colon(HWND dialog, const UInt32 *ids, unsigned numItems); 26void LangSetDlgItems_Colon(HWND dialog, const UInt32 *ids, unsigned numItems);
27void LangSetDlgItems_RemoveColon(HWND dialog, const UInt32 *ids, unsigned numItems);
25void LangSetWindowText(HWND window, UInt32 langID); 28void LangSetWindowText(HWND window, UInt32 langID);
26 29
27UString LangString(UInt32 langID); 30UString LangString(UInt32 langID);
@@ -37,4 +40,9 @@ inline void AddLangString(UString &s, UInt32 langID) { s += NWindows::MyLoadStri
37 40
38#endif 41#endif
39 42
43FString GetLangDirPrefix();
44// bool LangOpen(CLang &lang, CFSTR fileName);
45
46void Lang_GetShortNames_for_DefaultLang(AStringVector &names, unsigned &subLang);
47
40#endif 48#endif
diff --git a/CPP/7zip/UI/FileManager/LinkDialog.cpp b/CPP/7zip/UI/FileManager/LinkDialog.cpp
index 07f1f06..0f24761 100644
--- a/CPP/7zip/UI/FileManager/LinkDialog.cpp
+++ b/CPP/7zip/UI/FileManager/LinkDialog.cpp
@@ -8,9 +8,7 @@
8#include "../../../Windows/FileIO.h" 8#include "../../../Windows/FileIO.h"
9#include "../../../Windows/FileName.h" 9#include "../../../Windows/FileName.h"
10 10
11#ifdef LANG
12#include "LangUtils.h" 11#include "LangUtils.h"
13#endif
14 12
15#include "BrowseDialog.h" 13#include "BrowseDialog.h"
16#include "CopyDialogRes.h" 14#include "CopyDialogRes.h"
@@ -26,7 +24,7 @@ extern bool g_SymLink_Supported;
26using namespace NWindows; 24using namespace NWindows;
27using namespace NFile; 25using namespace NFile;
28 26
29#ifdef LANG 27#ifdef Z7_LANG
30static const UInt32 kLangIDs[] = 28static const UInt32 kLangIDs[] =
31{ 29{
32 IDB_LINK_LINK, 30 IDB_LINK_LINK,
@@ -73,7 +71,7 @@ static bool GetSymLink(CFSTR path, CReparseAttr &attr, UString &errorMessage)
73} 71}
74 72
75 73
76static const int k_LinkType_Buttons[] = 74static const unsigned k_LinkType_Buttons[] =
77{ 75{
78 IDR_LINK_TYPE_HARD, 76 IDR_LINK_TYPE_HARD,
79 IDR_LINK_TYPE_SYM_FILE, 77 IDR_LINK_TYPE_SYM_FILE,
@@ -82,16 +80,19 @@ static const int k_LinkType_Buttons[] =
82 IDR_LINK_TYPE_WSL 80 IDR_LINK_TYPE_WSL
83}; 81};
84 82
85void CLinkDialog::Set_LinkType_Radio(int idb) 83void CLinkDialog::Set_LinkType_Radio(unsigned idb)
86{ 84{
87 CheckRadioButton(k_LinkType_Buttons[0], k_LinkType_Buttons[ARRAY_SIZE(k_LinkType_Buttons) - 1], idb); 85 CheckRadioButton(
86 k_LinkType_Buttons[0],
87 k_LinkType_Buttons[Z7_ARRAY_SIZE(k_LinkType_Buttons) - 1],
88 idb);
88} 89}
89 90
90bool CLinkDialog::OnInit() 91bool CLinkDialog::OnInit()
91{ 92{
92 #ifdef LANG 93 #ifdef Z7_LANG
93 LangSetWindowText(*this, IDD_LINK); 94 LangSetWindowText(*this, IDD_LINK);
94 LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); 95 LangSetDlgItems(*this, kLangIDs, Z7_ARRAY_SIZE(kLangIDs));
95 #endif 96 #endif
96 97
97 _pathFromCombo.Attach(GetItem(IDC_LINK_PATH_FROM)); 98 _pathFromCombo.Attach(GetItem(IDC_LINK_PATH_FROM));
@@ -100,7 +101,7 @@ bool CLinkDialog::OnInit()
100 if (!FilePath.IsEmpty()) 101 if (!FilePath.IsEmpty())
101 { 102 {
102 NFind::CFileInfo fi; 103 NFind::CFileInfo fi;
103 int linkType = 0; 104 unsigned linkType = 0;
104 if (!fi.Find(us2fs(FilePath))) 105 if (!fi.Find(us2fs(FilePath)))
105 linkType = IDR_LINK_TYPE_SYM_FILE; 106 linkType = IDR_LINK_TYPE_SYM_FILE;
106 else 107 else
@@ -109,7 +110,7 @@ bool CLinkDialog::OnInit()
109 { 110 {
110 CReparseAttr attr; 111 CReparseAttr attr;
111 UString error; 112 UString error;
112 bool res = GetSymLink(us2fs(FilePath), attr, error); 113 const bool res = GetSymLink(us2fs(FilePath), attr, error);
113 if (!res && error.IsEmpty()) 114 if (!res && error.IsEmpty())
114 { 115 {
115 DWORD lastError = GetLastError(); 116 DWORD lastError = GetLastError();
@@ -138,7 +139,7 @@ bool CLinkDialog::OnInit()
138 139
139 SetItemText(IDT_LINK_PATH_TO_CUR, s); 140 SetItemText(IDT_LINK_PATH_TO_CUR, s);
140 141
141 UString destPath = attr.GetPath(); 142 const UString destPath = attr.GetPath();
142 _pathFromCombo.SetText(FilePath); 143 _pathFromCombo.SetText(FilePath);
143 _pathToCombo.SetText(destPath); 144 _pathToCombo.SetText(destPath);
144 145
@@ -215,7 +216,7 @@ bool CLinkDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
215 return false; 216 return false;
216} 217}
217 218
218bool CLinkDialog::OnButtonClicked(int buttonID, HWND buttonHWND) 219bool CLinkDialog::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
219{ 220{
220 switch (buttonID) 221 switch (buttonID)
221 { 222 {
@@ -240,7 +241,7 @@ void CLinkDialog::OnButton_SetPath(bool to)
240 _pathFromCombo; 241 _pathFromCombo;
241 combo.GetText(currentPath); 242 combo.GetText(currentPath);
242 // UString title = "Specify a location for output folder"; 243 // UString title = "Specify a location for output folder";
243 UString title = LangString(IDS_SET_FOLDER); 244 const UString title = LangString(IDS_SET_FOLDER);
244 245
245 UString resultPath; 246 UString resultPath;
246 if (!MyBrowseForFolder(*this, title, currentPath, resultPath)) 247 if (!MyBrowseForFolder(*this, title, currentPath, resultPath))
@@ -271,10 +272,10 @@ void CLinkDialog::OnButton_Link()
271 if (!NName::IsAbsolutePath(from)) 272 if (!NName::IsAbsolutePath(from))
272 from.Insert(0, CurDirPrefix); 273 from.Insert(0, CurDirPrefix);
273 274
274 int idb = -1; 275 unsigned idb = 0;
275 for (unsigned i = 0;; i++) 276 for (unsigned i = 0;; i++)
276 { 277 {
277 if (i >= ARRAY_SIZE(k_LinkType_Buttons)) 278 if (i >= Z7_ARRAY_SIZE(k_LinkType_Buttons))
278 return; 279 return;
279 idb = k_LinkType_Buttons[i]; 280 idb = k_LinkType_Buttons[i];
280 if (IsButtonCheckedBool(idb)) 281 if (IsButtonCheckedBool(idb))
@@ -355,7 +356,7 @@ void CLinkDialog::OnButton_Link()
355 356
356void CApp::Link() 357void CApp::Link()
357{ 358{
358 unsigned srcPanelIndex = GetFocusedPanelIndex(); 359 const unsigned srcPanelIndex = GetFocusedPanelIndex();
359 CPanel &srcPanel = Panels[srcPanelIndex]; 360 CPanel &srcPanel = Panels[srcPanelIndex];
360 if (!srcPanel.IsFSFolder()) 361 if (!srcPanel.IsFSFolder())
361 { 362 {
@@ -363,7 +364,7 @@ void CApp::Link()
363 return; 364 return;
364 } 365 }
365 CRecordVector<UInt32> indices; 366 CRecordVector<UInt32> indices;
366 srcPanel.GetOperatedItemIndices(indices); 367 srcPanel.Get_ItemIndices_Operated(indices);
367 if (indices.IsEmpty()) 368 if (indices.IsEmpty())
368 return; 369 return;
369 if (indices.Size() != 1) 370 if (indices.Size() != 1)
@@ -371,14 +372,14 @@ void CApp::Link()
371 srcPanel.MessageBox_Error_LangID(IDS_SELECT_ONE_FILE); 372 srcPanel.MessageBox_Error_LangID(IDS_SELECT_ONE_FILE);
372 return; 373 return;
373 } 374 }
374 int index = indices[0]; 375 const UInt32 index = indices[0];
375 const UString itemName = srcPanel.GetItemName(index); 376 const UString itemName = srcPanel.GetItemName(index);
376 377
377 const UString fsPrefix = srcPanel.GetFsPath(); 378 const UString fsPrefix = srcPanel.GetFsPath();
378 const UString srcPath = fsPrefix + srcPanel.GetItemPrefix(index); 379 const UString srcPath = fsPrefix + srcPanel.GetItemPrefix(index);
379 UString path = srcPath; 380 UString path = srcPath;
380 { 381 {
381 unsigned destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex); 382 const unsigned destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
382 CPanel &destPanel = Panels[destPanelIndex]; 383 CPanel &destPanel = Panels[destPanelIndex];
383 if (NumPanels > 1) 384 if (NumPanels > 1)
384 if (destPanel.IsFSFolder()) 385 if (destPanel.IsFSFolder())
diff --git a/CPP/7zip/UI/FileManager/LinkDialog.h b/CPP/7zip/UI/FileManager/LinkDialog.h
index 56deec9..dd768f7 100644
--- a/CPP/7zip/UI/FileManager/LinkDialog.h
+++ b/CPP/7zip/UI/FileManager/LinkDialog.h
@@ -1,7 +1,7 @@
1// LinkDialog.h 1// LinkDialog.h
2 2
3#ifndef __LINK_DIALOG_H 3#ifndef ZIP7_INC_LINK_DIALOG_H
4#define __LINK_DIALOG_H 4#define ZIP7_INC_LINK_DIALOG_H
5 5
6#include "../../../Windows/Control/Dialog.h" 6#include "../../../Windows/Control/Dialog.h"
7#include "../../../Windows/Control/ComboBox.h" 7#include "../../../Windows/Control/ComboBox.h"
@@ -13,21 +13,21 @@ class CLinkDialog: public NWindows::NControl::CModalDialog
13 NWindows::NControl::CComboBox _pathFromCombo; 13 NWindows::NControl::CComboBox _pathFromCombo;
14 NWindows::NControl::CComboBox _pathToCombo; 14 NWindows::NControl::CComboBox _pathToCombo;
15 15
16 virtual bool OnInit(); 16 virtual bool OnInit() Z7_override;
17 virtual bool OnSize(WPARAM wParam, int xSize, int ySize); 17 virtual bool OnSize(WPARAM wParam, int xSize, int ySize) Z7_override;
18 virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); 18 virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
19 void OnButton_SetPath(bool to); 19 void OnButton_SetPath(bool to);
20 void OnButton_Link(); 20 void OnButton_Link();
21 21
22 void ShowLastErrorMessage(); 22 void ShowLastErrorMessage();
23 void ShowError(const wchar_t *s); 23 void ShowError(const wchar_t *s);
24 void Set_LinkType_Radio(int idb); 24 void Set_LinkType_Radio(unsigned idb);
25public: 25public:
26 UString CurDirPrefix; 26 UString CurDirPrefix;
27 UString FilePath; 27 UString FilePath;
28 UString AnotherPath; 28 UString AnotherPath;
29 29
30 INT_PTR Create(HWND parentWindow = 0) 30 INT_PTR Create(HWND parentWindow = NULL)
31 { return CModalDialog::Create(IDD_LINK, parentWindow); } 31 { return CModalDialog::Create(IDD_LINK, parentWindow); }
32}; 32};
33 33
diff --git a/CPP/7zip/UI/FileManager/ListViewDialog.cpp b/CPP/7zip/UI/FileManager/ListViewDialog.cpp
index a42e790..6767e4c 100644
--- a/CPP/7zip/UI/FileManager/ListViewDialog.cpp
+++ b/CPP/7zip/UI/FileManager/ListViewDialog.cpp
@@ -8,7 +8,7 @@
8#include "ListViewDialog.h" 8#include "ListViewDialog.h"
9#include "RegistryUtils.h" 9#include "RegistryUtils.h"
10 10
11#ifdef LANG 11#ifdef Z7_LANG
12#include "LangUtils.h" 12#include "LangUtils.h"
13#endif 13#endif
14 14
@@ -26,14 +26,14 @@ static void ListView_GetSelected(NControl::CListView &listView, CUIntVector &vec
26 index = listView.GetNextSelectedItem(index); 26 index = listView.GetNextSelectedItem(index);
27 if (index < 0) 27 if (index < 0)
28 break; 28 break;
29 vector.Add(index); 29 vector.Add((unsigned)index);
30 } 30 }
31} 31}
32 32
33 33
34bool CListViewDialog::OnInit() 34bool CListViewDialog::OnInit()
35{ 35{
36 #ifdef LANG 36 #ifdef Z7_LANG
37 LangSetDlgItems(*this, NULL, 0); 37 LangSetDlgItems(*this, NULL, 0);
38 #endif 38 #endif
39 _listView.Attach(GetItem(IDL_LISTVIEW)); 39 _listView.Attach(GetItem(IDL_LISTVIEW));
@@ -227,17 +227,17 @@ void CListViewDialog::DeleteItems()
227{ 227{
228 for (;;) 228 for (;;)
229 { 229 {
230 int index = _listView.GetNextSelectedItem(-1); 230 const int index = _listView.GetNextSelectedItem(-1);
231 if (index < 0) 231 if (index < 0)
232 break; 232 break;
233 StringsWereChanged = true; 233 StringsWereChanged = true;
234 _listView.DeleteItem(index); 234 _listView.DeleteItem((unsigned)index);
235 if ((unsigned)index < Strings.Size()) 235 if ((unsigned)index < Strings.Size())
236 Strings.Delete(index); 236 Strings.Delete((unsigned)index);
237 if ((unsigned)index < Values.Size()) 237 if ((unsigned)index < Values.Size())
238 Values.Delete(index); 238 Values.Delete((unsigned)index);
239 } 239 }
240 int focusedIndex = _listView.GetFocusedItem(); 240 const int focusedIndex = _listView.GetFocusedItem();
241 if (focusedIndex >= 0) 241 if (focusedIndex >= 0)
242 _listView.SetItemState_FocusedSelected(focusedIndex); 242 _listView.SetItemState_FocusedSelected(focusedIndex);
243 _listView.SetColumnWidthAuto(0); 243 _listView.SetColumnWidthAuto(0);
diff --git a/CPP/7zip/UI/FileManager/ListViewDialog.h b/CPP/7zip/UI/FileManager/ListViewDialog.h
index 00206af..5f0b66d 100644
--- a/CPP/7zip/UI/FileManager/ListViewDialog.h
+++ b/CPP/7zip/UI/FileManager/ListViewDialog.h
@@ -1,7 +1,7 @@
1// ListViewDialog.h 1// ListViewDialog.h
2 2
3#ifndef __LISTVIEW_DIALOG_H 3#ifndef ZIP7_INC_LISTVIEW_DIALOG_H
4#define __LISTVIEW_DIALOG_H 4#define ZIP7_INC_LISTVIEW_DIALOG_H
5 5
6#include "../../../Windows/Control/Dialog.h" 6#include "../../../Windows/Control/Dialog.h"
7#include "../../../Windows/Control/ListView.h" 7#include "../../../Windows/Control/ListView.h"
@@ -11,10 +11,10 @@
11class CListViewDialog: public NWindows::NControl::CModalDialog 11class CListViewDialog: public NWindows::NControl::CModalDialog
12{ 12{
13 NWindows::NControl::CListView _listView; 13 NWindows::NControl::CListView _listView;
14 virtual void OnOK(); 14 virtual void OnOK() Z7_override;
15 virtual bool OnInit(); 15 virtual bool OnInit() Z7_override;
16 virtual bool OnSize(WPARAM wParam, int xSize, int ySize); 16 virtual bool OnSize(WPARAM wParam, int xSize, int ySize) Z7_override;
17 virtual bool OnNotify(UINT controlID, LPNMHDR header); 17 virtual bool OnNotify(UINT controlID, LPNMHDR header) Z7_override;
18 void CopyToClipboard(); 18 void CopyToClipboard();
19 void DeleteItems(); 19 void DeleteItems();
20 void ShowItemInfo(); 20 void ShowItemInfo();
@@ -32,7 +32,7 @@ public:
32 int FocusedItemIndex; 32 int FocusedItemIndex;
33 unsigned NumColumns; 33 unsigned NumColumns;
34 34
35 INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_LISTVIEW, wndParent); } 35 INT_PTR Create(HWND wndParent = NULL) { return CModalDialog::Create(IDD_LISTVIEW, wndParent); }
36 36
37 CListViewDialog(): 37 CListViewDialog():
38 SelectFirst(false), 38 SelectFirst(false),
diff --git a/CPP/7zip/UI/FileManager/MenuPage.cpp b/CPP/7zip/UI/FileManager/MenuPage.cpp
index 32dabae..2da7f3a 100644
--- a/CPP/7zip/UI/FileManager/MenuPage.cpp
+++ b/CPP/7zip/UI/FileManager/MenuPage.cpp
@@ -26,6 +26,7 @@
26using namespace NWindows; 26using namespace NWindows;
27using namespace NContextMenuFlags; 27using namespace NContextMenuFlags;
28 28
29#ifdef Z7_LANG
29static const UInt32 kLangIDs[] = 30static const UInt32 kLangIDs[] =
30{ 31{
31 IDX_SYSTEM_INTEGRATE_TO_MENU, 32 IDX_SYSTEM_INTEGRATE_TO_MENU,
@@ -35,12 +36,13 @@ static const UInt32 kLangIDs[] =
35 IDT_SYSTEM_ZONE, 36 IDT_SYSTEM_ZONE,
36 IDT_SYSTEM_CONTEXT_MENU_ITEMS 37 IDT_SYSTEM_CONTEXT_MENU_ITEMS
37}; 38};
39#endif
38 40
39#define kMenuTopic "fm/options.htm#sevenZip" 41#define kMenuTopic "fm/options.htm#sevenZip"
40 42
41struct CContextMenuItem 43struct CContextMenuItem
42{ 44{
43 int ControlID; 45 unsigned ControlID;
44 UInt32 Flag; 46 UInt32 Flag;
45}; 47};
46 48
@@ -97,7 +99,9 @@ bool CMenuPage::OnInit()
97 99
98 Clear_MenuChanged(); 100 Clear_MenuChanged();
99 101
100 LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); 102#ifdef Z7_LANG
103 LangSetDlgItems(*this, kLangIDs, Z7_ARRAY_SIZE(kLangIDs));
104#endif
101 105
102 #ifdef UNDER_CE 106 #ifdef UNDER_CE
103 107
@@ -219,7 +223,7 @@ bool CMenuPage::OnInit()
219 if (i == 0) 223 if (i == 0)
220 s.Insert(0, L"* "); 224 s.Insert(0, L"* ");
221 const int index = (int)_zoneCombo.AddString(s); 225 const int index = (int)_zoneCombo.AddString(s);
222 _zoneCombo.SetItemData(index, val); 226 _zoneCombo.SetItemData(index, (LPARAM)val);
223 if (val == wz) 227 if (val == wz)
224 _zoneCombo.SetCurSel(index); 228 _zoneCombo.SetCurSel(index);
225 } 229 }
@@ -231,7 +235,7 @@ bool CMenuPage::OnInit()
231 235
232 _listView.InsertColumn(0, L"", 200); 236 _listView.InsertColumn(0, L"", 200);
233 237
234 for (unsigned i = 0; i < ARRAY_SIZE(kMenuItems); i++) 238 for (unsigned i = 0; i < Z7_ARRAY_SIZE(kMenuItems); i++)
235 { 239 {
236 const CContextMenuItem &menuItem = kMenuItems[i]; 240 const CContextMenuItem &menuItem = kMenuItems[i];
237 241
@@ -272,8 +276,8 @@ bool CMenuPage::OnInit()
272 } 276 }
273 } 277 }
274 278
275 int itemIndex = _listView.InsertItem(i, s); 279 const int itemIndex = _listView.InsertItem(i, s);
276 _listView.SetCheckState(itemIndex, ((ci.Flags & menuItem.Flag) != 0)); 280 _listView.SetCheckState((unsigned)itemIndex, ((ci.Flags & menuItem.Flag) != 0));
277 } 281 }
278 282
279 _listView.SetColumnWidthAuto(0); 283 _listView.SetColumnWidthAuto(0);
@@ -303,8 +307,8 @@ LONG CMenuPage::OnApply()
303 CShellDll &dll = _dlls[d]; 307 CShellDll &dll = _dlls[d];
304 if (dll.wasChanged && !dll.Path.IsEmpty()) 308 if (dll.wasChanged && !dll.Path.IsEmpty())
305 { 309 {
306 bool newVal = IsButtonCheckedBool(dll.ctrl); 310 const bool newVal = IsButtonCheckedBool(dll.ctrl);
307 LONG res = SetContextMenuHandler(newVal, fs2us(dll.Path), dll.wow); 311 const LONG res = SetContextMenuHandler(newVal, fs2us(dll.Path), dll.wow);
308 if (res != ERROR_SUCCESS && (dll.prevValue != newVal || newVal)) 312 if (res != ERROR_SUCCESS && (dll.prevValue != newVal || newVal))
309 ShowMenuErrorMessage(NError::MyFormatMessage(res), *this); 313 ShowMenuErrorMessage(NError::MyFormatMessage(res), *this);
310 dll.prevValue = CheckContextMenuHandler(fs2us(dll.Path), dll.wow); 314 dll.prevValue = CheckContextMenuHandler(fs2us(dll.Path), dll.wow);
@@ -340,7 +344,7 @@ LONG CMenuPage::OnApply()
340 344
341 ci.Flags = 0; 345 ci.Flags = 0;
342 346
343 for (unsigned i = 0; i < ARRAY_SIZE(kMenuItems); i++) 347 for (unsigned i = 0; i < Z7_ARRAY_SIZE(kMenuItems); i++)
344 if (_listView.GetCheckState(i)) 348 if (_listView.GetCheckState(i))
345 ci.Flags |= kMenuItems[i].Flag; 349 ci.Flags |= kMenuItems[i].Flag;
346 350
@@ -360,7 +364,7 @@ void CMenuPage::OnNotifyHelp()
360 ShowHelpWindow(kMenuTopic); 364 ShowHelpWindow(kMenuTopic);
361} 365}
362 366
363bool CMenuPage::OnButtonClicked(int buttonID, HWND buttonHWND) 367bool CMenuPage::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
364{ 368{
365 switch (buttonID) 369 switch (buttonID)
366 { 370 {
@@ -392,7 +396,7 @@ bool CMenuPage::OnButtonClicked(int buttonID, HWND buttonHWND)
392} 396}
393 397
394 398
395bool CMenuPage::OnCommand(int code, int itemID, LPARAM param) 399bool CMenuPage::OnCommand(unsigned code, unsigned itemID, LPARAM param)
396{ 400{
397 if (code == CBN_SELCHANGE && itemID == IDC_SYSTEM_ZONE) 401 if (code == CBN_SELCHANGE && itemID == IDC_SYSTEM_ZONE)
398 { 402 {
diff --git a/CPP/7zip/UI/FileManager/MenuPage.h b/CPP/7zip/UI/FileManager/MenuPage.h
index 02aee6d..3b62a8b 100644
--- a/CPP/7zip/UI/FileManager/MenuPage.h
+++ b/CPP/7zip/UI/FileManager/MenuPage.h
@@ -1,7 +1,7 @@
1// MenuPage.h 1// MenuPage.h
2 2
3#ifndef __MENU_PAGE_H 3#ifndef ZIP7_INC_MENU_PAGE_H
4#define __MENU_PAGE_H 4#define ZIP7_INC_MENU_PAGE_H
5 5
6#include "../../../Windows/Control/PropertyPage.h" 6#include "../../../Windows/Control/PropertyPage.h"
7#include "../../../Windows/Control/ComboBox.h" 7#include "../../../Windows/Control/ComboBox.h"
@@ -12,7 +12,7 @@ struct CShellDll
12 FString Path; 12 FString Path;
13 bool wasChanged; 13 bool wasChanged;
14 bool prevValue; 14 bool prevValue;
15 int ctrl; 15 unsigned ctrl;
16 UInt32 wow; 16 UInt32 wow;
17 17
18 CShellDll(): wasChanged (false), prevValue(false), ctrl(0), wow(0) {} 18 CShellDll(): wasChanged (false), prevValue(false), ctrl(0), wow(0) {}
@@ -44,14 +44,14 @@ class CMenuPage: public NWindows::NControl::CPropertyPage
44 NWindows::NControl::CListView _listView; 44 NWindows::NControl::CListView _listView;
45 NWindows::NControl::CComboBox _zoneCombo; 45 NWindows::NControl::CComboBox _zoneCombo;
46 46
47 virtual bool OnInit(); 47 virtual bool OnInit() Z7_override;
48 virtual void OnNotifyHelp(); 48 virtual void OnNotifyHelp() Z7_override;
49 virtual bool OnNotify(UINT controlID, LPNMHDR lParam); 49 virtual bool OnNotify(UINT controlID, LPNMHDR lParam) Z7_override;
50 virtual bool OnItemChanged(const NMLISTVIEW *info); 50 virtual LONG OnApply() Z7_override;
51 virtual LONG OnApply(); 51 virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
52 virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); 52 virtual bool OnCommand(unsigned code, unsigned itemID, LPARAM param) Z7_override;
53 virtual bool OnCommand(int code, int itemID, LPARAM param); 53
54public: 54 bool OnItemChanged(const NMLISTVIEW* info);
55}; 55};
56 56
57#endif 57#endif
diff --git a/CPP/7zip/UI/FileManager/MessagesDialog.cpp b/CPP/7zip/UI/FileManager/MessagesDialog.cpp
index 4124827..57e56bc 100644
--- a/CPP/7zip/UI/FileManager/MessagesDialog.cpp
+++ b/CPP/7zip/UI/FileManager/MessagesDialog.cpp
@@ -16,9 +16,9 @@ using namespace NWindows;
16 16
17void CMessagesDialog::AddMessageDirect(LPCWSTR message) 17void CMessagesDialog::AddMessageDirect(LPCWSTR message)
18{ 18{
19 int i = _messageList.GetItemCount(); 19 const unsigned i = (unsigned)_messageList.GetItemCount();
20 wchar_t sz[16]; 20 wchar_t sz[16];
21 ConvertUInt32ToString((UInt32)i, sz); 21 ConvertUInt32ToString(i, sz);
22 _messageList.InsertItem(i, sz); 22 _messageList.InsertItem(i, sz);
23 _messageList.SetSubItem(i, 1, message); 23 _messageList.SetSubItem(i, 1, message);
24} 24}
@@ -28,18 +28,18 @@ void CMessagesDialog::AddMessage(LPCWSTR message)
28 UString s = message; 28 UString s = message;
29 while (!s.IsEmpty()) 29 while (!s.IsEmpty())
30 { 30 {
31 int pos = s.Find(L'\n'); 31 const int pos = s.Find(L'\n');
32 if (pos < 0) 32 if (pos < 0)
33 break; 33 break;
34 AddMessageDirect(s.Left(pos)); 34 AddMessageDirect(s.Left(pos));
35 s.DeleteFrontal(pos + 1); 35 s.DeleteFrontal((unsigned)pos + 1);
36 } 36 }
37 AddMessageDirect(s); 37 AddMessageDirect(s);
38} 38}
39 39
40bool CMessagesDialog::OnInit() 40bool CMessagesDialog::OnInit()
41{ 41{
42 #ifdef LANG 42 #ifdef Z7_LANG
43 LangSetWindowText(*this, IDD_MESSAGES); 43 LangSetWindowText(*this, IDD_MESSAGES);
44 LangSetDlgItems(*this, NULL, 0); 44 LangSetDlgItems(*this, NULL, 0);
45 SetItemText(IDOK, LangString(IDS_CLOSE)); 45 SetItemText(IDOK, LangString(IDS_CLOSE));
diff --git a/CPP/7zip/UI/FileManager/MessagesDialog.h b/CPP/7zip/UI/FileManager/MessagesDialog.h
index 5c017eb..40b0379 100644
--- a/CPP/7zip/UI/FileManager/MessagesDialog.h
+++ b/CPP/7zip/UI/FileManager/MessagesDialog.h
@@ -1,7 +1,7 @@
1// MessagesDialog.h 1// MessagesDialog.h
2 2
3#ifndef __MESSAGES_DIALOG_H 3#ifndef ZIP7_INC_MESSAGES_DIALOG_H
4#define __MESSAGES_DIALOG_H 4#define ZIP7_INC_MESSAGES_DIALOG_H
5 5
6#include "../../../Windows/Control/Dialog.h" 6#include "../../../Windows/Control/Dialog.h"
7#include "../../../Windows/Control/ListView.h" 7#include "../../../Windows/Control/ListView.h"
@@ -14,12 +14,12 @@ class CMessagesDialog: public NWindows::NControl::CModalDialog
14 14
15 void AddMessageDirect(LPCWSTR message); 15 void AddMessageDirect(LPCWSTR message);
16 void AddMessage(LPCWSTR message); 16 void AddMessage(LPCWSTR message);
17 virtual bool OnInit(); 17 virtual bool OnInit() Z7_override;
18 virtual bool OnSize(WPARAM wParam, int xSize, int ySize); 18 virtual bool OnSize(WPARAM wParam, int xSize, int ySize) Z7_override;
19public: 19public:
20 const UStringVector *Messages; 20 const UStringVector *Messages;
21 21
22 INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_MESSAGES, parent); } 22 INT_PTR Create(HWND parent = NULL) { return CModalDialog::Create(IDD_MESSAGES, parent); }
23}; 23};
24 24
25#endif 25#endif
diff --git a/CPP/7zip/UI/FileManager/MyCom2.h b/CPP/7zip/UI/FileManager/MyCom2.h
index 5fe1ef7..d3b49fe 100644
--- a/CPP/7zip/UI/FileManager/MyCom2.h
+++ b/CPP/7zip/UI/FileManager/MyCom2.h
@@ -1,48 +1,55 @@
1// MyCom2.h 1// MyCom2.h
2 2
3#ifndef __MYCOM2_H 3#ifndef ZIP7_INC_MYCOM2_H
4#define __MYCOM2_H 4#define ZIP7_INC_MYCOM2_H
5 5
6#include "../../../Common/MyCom.h" 6#include "../../../Common/MyCom.h"
7 7
8#define MY_ADDREF_RELEASE_MT \ 8#define Z7_COM_ADDREF_RELEASE_MT \
9STDMETHOD_(ULONG, AddRef)() { InterlockedIncrement((LONG *)&__m_RefCount); return __m_RefCount; } \ 9 private: \
10STDMETHOD_(ULONG, Release)() { InterlockedDecrement((LONG *)&__m_RefCount); \ 10 STDMETHOD_(ULONG, AddRef)() Z7_override Z7_final \
11 if (__m_RefCount != 0) return __m_RefCount; \ 11 { return (ULONG)InterlockedIncrement((LONG *)&_m_RefCount); } \
12 delete this; return 0; } 12 STDMETHOD_(ULONG, Release)() Z7_override Z7_final \
13 13 { const LONG v = InterlockedDecrement((LONG *)&_m_RefCount); \
14#define MY_UNKNOWN_IMP_SPEC_MT2(i1, i) \ 14 if (v != 0) return (ULONG)v; \
15 MY_QUERYINTERFACE_BEGIN \ 15 delete this; return 0; }
16 MY_QUERYINTERFACE_ENTRY_UNKNOWN(i1) \ 16
17#define Z7_COM_UNKNOWN_IMP_SPEC_MT2(i1, i) \
18 Z7_COM_QI_BEGIN \
19 Z7_COM_QI_ENTRY_UNKNOWN(i1) \
17 i \ 20 i \
18 MY_QUERYINTERFACE_END \ 21 Z7_COM_QI_END \
19 MY_ADDREF_RELEASE_MT 22 Z7_COM_ADDREF_RELEASE_MT
20 23
21 24
22#define MY_UNKNOWN_IMP1_MT(i) MY_UNKNOWN_IMP_SPEC_MT2( \ 25#define Z7_COM_UNKNOWN_IMP_1_MT(i) \
26 Z7_COM_UNKNOWN_IMP_SPEC_MT2( \
23 i, \ 27 i, \
24 MY_QUERYINTERFACE_ENTRY(i) \ 28 Z7_COM_QI_ENTRY(i) \
25 ) 29 )
26 30
27#define MY_UNKNOWN_IMP2_MT(i1, i2) MY_UNKNOWN_IMP_SPEC_MT2( \ 31#define Z7_COM_UNKNOWN_IMP_2_MT(i1, i2) \
32 Z7_COM_UNKNOWN_IMP_SPEC_MT2( \
28 i1, \ 33 i1, \
29 MY_QUERYINTERFACE_ENTRY(i1) \ 34 Z7_COM_QI_ENTRY(i1) \
30 MY_QUERYINTERFACE_ENTRY(i2) \ 35 Z7_COM_QI_ENTRY(i2) \
31 ) 36 )
32 37
33#define MY_UNKNOWN_IMP3_MT(i1, i2, i3) MY_UNKNOWN_IMP_SPEC_MT2( \ 38#define Z7_COM_UNKNOWN_IMP_3_MT(i1, i2, i3) \
39 Z7_COM_UNKNOWN_IMP_SPEC_MT2( \
34 i1, \ 40 i1, \
35 MY_QUERYINTERFACE_ENTRY(i1) \ 41 Z7_COM_QI_ENTRY(i1) \
36 MY_QUERYINTERFACE_ENTRY(i2) \ 42 Z7_COM_QI_ENTRY(i2) \
37 MY_QUERYINTERFACE_ENTRY(i3) \ 43 Z7_COM_QI_ENTRY(i3) \
38 ) 44 )
39 45
40#define MY_UNKNOWN_IMP4_MT(i1, i2, i3, i4) MY_UNKNOWN_IMP_SPEC_MT2( \ 46#define Z7_COM_UNKNOWN_IMP_4_MT(i1, i2, i3, i4) \
47 Z7_COM_UNKNOWN_IMP_SPEC_MT2( \
41 i1, \ 48 i1, \
42 MY_QUERYINTERFACE_ENTRY(i1) \ 49 Z7_COM_QI_ENTRY(i1) \
43 MY_QUERYINTERFACE_ENTRY(i2) \ 50 Z7_COM_QI_ENTRY(i2) \
44 MY_QUERYINTERFACE_ENTRY(i3) \ 51 Z7_COM_QI_ENTRY(i3) \
45 MY_QUERYINTERFACE_ENTRY(i4) \ 52 Z7_COM_QI_ENTRY(i4) \
46 ) 53 )
47 54
48#endif 55#endif
diff --git a/CPP/7zip/UI/FileManager/MyLoadMenu.cpp b/CPP/7zip/UI/FileManager/MyLoadMenu.cpp
index 3973bb2..9453536 100644
--- a/CPP/7zip/UI/FileManager/MyLoadMenu.cpp
+++ b/CPP/7zip/UI/FileManager/MyLoadMenu.cpp
@@ -17,14 +17,15 @@
17#include "MyLoadMenu.h" 17#include "MyLoadMenu.h"
18#include "RegistryUtils.h" 18#include "RegistryUtils.h"
19 19
20#include "PropertyNameRes.h"
20#include "resource.h" 21#include "resource.h"
21 22
22using namespace NWindows; 23using namespace NWindows;
23 24
24static const UINT kOpenBookmarkMenuID = 830; 25static const UINT k_MenuID_OpenBookmark = 830;
25static const UINT kSetBookmarkMenuID = 810; 26static const UINT k_MenuID_SetBookmark = 810;
26static const UINT kMenuID_Time_Parent = 760; 27static const UINT k_MenuID_TimePopup = IDM_VIEW_TIME_POPUP;
27static const UINT kMenuID_Time = 761; 28static const UINT k_MenuID_Time = IDM_VIEW_TIME;
28 29
29extern HINSTANCE g_hInstance; 30extern HINSTANCE g_hInstance;
30 31
@@ -34,35 +35,45 @@ extern void OptionsDialog(HWND hwndOwner, HINSTANCE hInstance);
34 35
35enum 36enum
36{ 37{
37 kMenuIndex_File = 0, 38 k_MenuIndex_File = 0,
38 kMenuIndex_Edit, 39 k_MenuIndex_Edit,
39 kMenuIndex_View, 40 k_MenuIndex_View,
40 kMenuIndex_Bookmarks 41 k_MenuIndex_Bookmarks
41}; 42};
42 43
43static const UInt32 kTopMenuLangIDs[] = { 500, 501, 502, 503, 504, 505 }; 44#ifdef Z7_LANG
45static const UInt32 k_LangID_TopMenuItems[] =
46{
47 IDM_FILE,
48 IDM_EDIT,
49 IDM_VIEW,
50 IDM_FAVORITES,
51 IDM_TOOLS,
52 IDM_HELP
53};
44 54
45static const UInt32 kAddToFavoritesLangID = 800; 55static const UInt32 k_LangID_Toolbars = IDM_VIEW_TOOLBARS;
46static const UInt32 kToolbarsLangID = 733; 56static const UInt32 k_LangID_AddToFavorites = IDM_ADD_TO_FAVORITES;
47 57
48static const CIDLangPair kIDLangPairs[] = 58static const CIDLangPair kIDLangPairs[] =
49{ 59{
50 { IDCLOSE, 557 }, 60 { IDCLOSE, 557 }, // IDM_EXIT
51 { IDM_VIEW_ARANGE_BY_NAME, 1004 }, 61 { IDM_VIEW_ARANGE_BY_NAME, IDS_PROP_NAME },
52 { IDM_VIEW_ARANGE_BY_TYPE, 1020 }, 62 { IDM_VIEW_ARANGE_BY_TYPE, IDS_PROP_FILE_TYPE },
53 { IDM_VIEW_ARANGE_BY_DATE, 1012 }, 63 { IDM_VIEW_ARANGE_BY_DATE, IDS_PROP_MTIME },
54 { IDM_VIEW_ARANGE_BY_SIZE, 1007 } 64 { IDM_VIEW_ARANGE_BY_SIZE, IDS_PROP_SIZE }
55}; 65};
56 66
57static int FindLangItem(unsigned controlID) 67static int FindLangItem(unsigned controlID)
58{ 68{
59 for (unsigned i = 0; i < ARRAY_SIZE(kIDLangPairs); i++) 69 for (unsigned i = 0; i < Z7_ARRAY_SIZE(kIDLangPairs); i++)
60 if (kIDLangPairs[i].ControlID == controlID) 70 if (kIDLangPairs[i].ControlID == controlID)
61 return i; 71 return (int)i;
62 return -1; 72 return -1;
63} 73}
74#endif
64 75
65static int GetSortControlID(PROPID propID) 76static unsigned GetSortControlID(PROPID propID)
66{ 77{
67 switch (propID) 78 switch (propID)
68 { 79 {
@@ -72,54 +83,55 @@ static int GetSortControlID(PROPID propID)
72 case kpidSize: return IDM_VIEW_ARANGE_BY_SIZE; 83 case kpidSize: return IDM_VIEW_ARANGE_BY_SIZE;
73 case kpidNoProperty: return IDM_VIEW_ARANGE_NO_SORT; 84 case kpidNoProperty: return IDM_VIEW_ARANGE_NO_SORT;
74 } 85 }
75 return -1; 86 return IDM_VIEW_ARANGE_BY_NAME;
87 // IDM_VIEW_ARANGE_NO_SORT;
88 // return -1;
76} 89}
77 90
78/* 91/*
79static bool g_IsNew_fMask = true; 92#if _MSC_VER > 1400
93// GetVersion was declared deprecated
94#pragma warning(disable : 4996)
95#endif
80 96
81class CInit_fMask 97static bool g_IsNew_fMask = false;
98static class CInit_fMask
82{ 99{
83public: 100public:
84 CInit_fMask() 101 CInit_fMask()
85 { 102 {
86 g_IsNew_fMask = false; 103 DWORD v = GetVersion();
87 OSVERSIONINFO vi; 104 v = ((v & 0xff) << 8) | ((v >> 8) & 0xFF);
88 vi.dwOSVersionInfoSize = sizeof(vi); 105 g_IsNew_fMask = (v > 0x400); // (win98/win2000) or newer
89 if (::GetVersionEx(&vi))
90 {
91 g_IsNew_fMask = (vi.dwMajorVersion > 4 ||
92 (vi.dwMajorVersion == 4 && vi.dwMinorVersion > 0));
93 }
94 g_IsNew_fMask = false;
95 } 106 }
96} g_Init_fMask; 107} g_Init_fMask;
97
98// it's hack for supporting Windows NT
99// constants are from WinUser.h
100
101#if (WINVER < 0x0500)
102#define MIIM_STRING 0x00000040
103#define MIIM_BITMAP 0x00000080
104#define MIIM_FTYPE 0x00000100
105#endif
106
107static UINT Get_fMask_for_String() 108static UINT Get_fMask_for_String()
108{ 109 { return g_IsNew_fMask ? MIIM_STRING : MIIM_TYPE; }
109 return g_IsNew_fMask ? MIIM_STRING : MIIM_TYPE;
110}
111
112static UINT Get_fMask_for_FType_and_String() 110static UINT Get_fMask_for_FType_and_String()
113{ 111 { return g_IsNew_fMask ? (MIIM_STRING | MIIM_FTYPE) : MIIM_TYPE; }
114 return g_IsNew_fMask ? (MIIM_STRING | MIIM_FTYPE) : MIIM_TYPE;
115}
116*/ 112*/
117 113
114/*
115We can use new MIIM_STRING / MIIM_FTYPE flags in the following conditions:
116 1) we run at new Windows (win98/win2000) or newer
117 2) also we probably must set MENUITEMINFO::cbSize as sizeof of full
118 (MENUITEMINFO) that was compiled with (WINVER >= 0x0500)
119But it's simpler to use old MIIM_TYPE without these complex checks.
120*/
121
122// /*
118static inline UINT Get_fMask_for_String() { return MIIM_TYPE; } 123static inline UINT Get_fMask_for_String() { return MIIM_TYPE; }
119static inline UINT Get_fMask_for_FType_and_String() { return MIIM_TYPE; } 124static inline UINT Get_fMask_for_FType_and_String() { return MIIM_TYPE; }
125// */
120 126
127static bool Is_MenuItem_TimePopup(const CMenuItem &item)
128{
129 return item.wID == k_MenuID_TimePopup ||
130 item.StringValue.IsPrefixedBy_Ascii_NoCase("20");
131}
121 132
122static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex) 133#ifdef Z7_LANG
134static void MyChangeMenu(HMENU menuLoc, unsigned menuID, unsigned level, unsigned menuIndex)
123{ 135{
124 CMenu menu; 136 CMenu menu;
125 menu.Attach(menuLoc); 137 menu.Attach(menuLoc);
@@ -127,55 +139,90 @@ static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex)
127 for (unsigned i = 0;; i++) 139 for (unsigned i = 0;; i++)
128 { 140 {
129 CMenuItem item; 141 CMenuItem item;
130 item.fMask = Get_fMask_for_String() | MIIM_SUBMENU | MIIM_ID; 142 /* here we can use
131 item.fType = MFT_STRING; 143 Get_fMask_for_String() or
144 Get_fMask_for_FType_and_String()
145 We want to change only String of menu item.
146 It's not required to change (fType) of menu item.
147 We can look (fType) to check for SEPARATOR item.
148 But String of separator is empty and (wID == 0).
149 So we can check for SEPARATOR without (fType) requesting.
150 So it's enough to use Get_fMask_for_String() here */
151 item.fMask =
152 Get_fMask_for_String()
153 // Get_fMask_for_FType_and_String()
154 | MIIM_SUBMENU | MIIM_ID;
132 if (!menu.GetItem(i, true, item)) 155 if (!menu.GetItem(i, true, item))
133 break; 156 break;
134 { 157 {
135 UString newString; 158 UString newString;
136 if (item.hSubMenu) 159 if (item.hSubMenu)
137 { 160 {
138 UInt32 langID = 0; 161 /* in win10:
139 if (level == 1 && menuIndex == kMenuIndex_Bookmarks) 162 MENU+POPUP:
140 langID = kAddToFavoritesLangID; 163 (wID == item.hSubMenu)
141 else 164 MENUEX+POPUP where ID is not set:
165 (wID == 0)
166 MENU+SEPARATOR
167 (wID == 0)
168 */
169 UInt32 langID = item.wID;
170 if (langID >= (1 << 16))
171 {
172 // here we try to exclude the case (wID == item.hSubMenu) if (MENU+POPUP)
173 continue;
174 }
175 if (langID == 0)
142 { 176 {
143 MyChangeMenu(item.hSubMenu, level + 1, i); 177 if (level == 0)
144 if (level == 1 && menuIndex == kMenuIndex_View)
145 { 178 {
146 if (item.wID == kMenuID_Time_Parent || item.StringValue.IsPrefixedBy_Ascii_NoCase("20")) 179 if (i < Z7_ARRAY_SIZE(k_LangID_TopMenuItems))
147 continue; 180 langID = k_LangID_TopMenuItems[i];
148 else 181 }
149 langID = kToolbarsLangID; 182 else if (level == 1)
183 {
184 if (menuID == IDM_FAVORITES || (menuID == 0 && menuIndex == k_MenuIndex_Bookmarks))
185 langID = k_LangID_AddToFavorites;
186 else if (menuID == IDM_VIEW || (menuID == 0 && menuIndex == k_MenuIndex_View))
187 {
188 if (Is_MenuItem_TimePopup(item))
189 langID = k_MenuID_TimePopup;
190 else
191 langID = k_LangID_Toolbars;
192 }
150 } 193 }
151 else if (level == 0 && i < ARRAY_SIZE(kTopMenuLangIDs))
152 langID = kTopMenuLangIDs[i];
153 else
154 continue;
155 } 194 }
156 195 if (langID == k_MenuID_TimePopup)
196 continue;
197 if (langID != k_LangID_AddToFavorites)
198 MyChangeMenu(item.hSubMenu, langID, level + 1, i);
199 if (langID == 0)
200 continue;
157 LangString_OnlyFromLangFile(langID, newString); 201 LangString_OnlyFromLangFile(langID, newString);
158
159 if (newString.IsEmpty()) 202 if (newString.IsEmpty())
160 continue; 203 continue;
161 } 204 }
162 else 205 else
163 { 206 {
207 if (item.fMask & (MIIM_TYPE | MIIM_FTYPE))
164 if (item.IsSeparator()) 208 if (item.IsSeparator())
165 continue; 209 continue;
166 int langPos = FindLangItem(item.wID); 210 if (item.StringValue.IsEmpty())
167 211 continue;
212 const int langPos = FindLangItem(item.wID);
168 // we don't need lang change for CRC items!!! 213 // we don't need lang change for CRC items!!!
214 const UInt32 langID = langPos >= 0 ? kIDLangPairs[langPos].LangID : item.wID;
215 if (langID == 0)
216 continue;
169 217
170 UInt32 langID = langPos >= 0 ? kIDLangPairs[langPos].LangID : item.wID; 218 if (langID == IDM_OPEN_INSIDE_ONE ||
171 219 langID == IDM_OPEN_INSIDE_PARSER)
172 if (langID == IDM_OPEN_INSIDE_ONE || langID == IDM_OPEN_INSIDE_PARSER)
173 { 220 {
174 LangString_OnlyFromLangFile(IDM_OPEN_INSIDE, newString); 221 LangString_OnlyFromLangFile(IDM_OPEN_INSIDE, newString);
175 if (newString.IsEmpty()) 222 if (newString.IsEmpty())
176 continue; 223 continue;
177 newString.Replace(L"&", L""); 224 newString.Replace(L"&", L"");
178 int tabPos = newString.Find(L"\t"); 225 const int tabPos = newString.Find(L"\t");
179 if (tabPos >= 0) 226 if (tabPos >= 0)
180 newString.DeleteFrom(tabPos); 227 newString.DeleteFrom(tabPos);
181 newString += (langID == IDM_OPEN_INSIDE_ONE ? " *" : " #"); 228 newString += (langID == IDM_OPEN_INSIDE_ONE ? " *" : " #");
@@ -186,37 +233,40 @@ static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex)
186 if (newString.IsEmpty()) 233 if (newString.IsEmpty())
187 continue; 234 continue;
188 newString.Replace(L"&", L""); 235 newString.Replace(L"&", L"");
189 int tabPos = newString.Find(L"\t"); 236 const int tabPos = newString.Find(L"\t");
190 if (tabPos >= 0) 237 if (tabPos >= 0)
191 newString.DeleteFrom(tabPos); 238 newString.DeleteFrom(tabPos);
192 newString += " 2"; 239 newString += " 2";
193 } 240 }
194 else 241 else
242 {
195 LangString_OnlyFromLangFile(langID, newString); 243 LangString_OnlyFromLangFile(langID, newString);
244 }
196 245
197 if (newString.IsEmpty()) 246 if (newString.IsEmpty())
198 continue; 247 continue;
199 248
200 int tabPos = item.StringValue.ReverseFind(L'\t'); 249 const int tabPos = item.StringValue.ReverseFind(L'\t');
201 if (tabPos >= 0) 250 if (tabPos >= 0)
202 newString += item.StringValue.Ptr(tabPos); 251 newString += item.StringValue.Ptr(tabPos);
203 } 252 }
204 253
205 { 254 {
206 item.StringValue = newString; 255 item.StringValue = newString;
256 // we want to change only String
207 item.fMask = Get_fMask_for_String(); 257 item.fMask = Get_fMask_for_String();
208 item.fType = MFT_STRING;
209 menu.SetItem(i, true, item); 258 menu.SetItem(i, true, item);
210 } 259 }
211 } 260 }
212 } 261 }
213} 262}
263#endif
214 264
215static CMenu g_FileMenu; 265static CMenu g_FileMenu;
216 266
217static struct CFileMenuDestroyer 267static struct CFileMenuDestroyer
218{ 268{
219 ~CFileMenuDestroyer() { if ((HMENU)g_FileMenu != 0) g_FileMenu.Destroy(); } 269 ~CFileMenuDestroyer() { if ((HMENU)g_FileMenu) g_FileMenu.Destroy(); }
220} g_FileMenuDestroyer; 270} g_FileMenuDestroyer;
221 271
222 272
@@ -224,6 +274,12 @@ static void CopyMenu(HMENU srcMenuSpec, HMENU destMenuSpec);
224 274
225static void CopyPopMenu_IfRequired(CMenuItem &item) 275static void CopyPopMenu_IfRequired(CMenuItem &item)
226{ 276{
277 /* if (item.hSubMenu) is defined
278 {
279 - it creates new (popup) menu
280 - it copies menu items from old item.hSubMenu menu to new (popup) menu
281 - it sets item.hSubMenu to handle of created (popup) menu
282 } */
227 if (item.hSubMenu) 283 if (item.hSubMenu)
228 { 284 {
229 CMenu popup; 285 CMenu popup;
@@ -233,64 +289,91 @@ static void CopyPopMenu_IfRequired(CMenuItem &item)
233 } 289 }
234} 290}
235 291
292/* destMenuSpec must be non-NULL handle to created empty popup menu */
236static void CopyMenu(HMENU srcMenuSpec, HMENU destMenuSpec) 293static void CopyMenu(HMENU srcMenuSpec, HMENU destMenuSpec)
237{ 294{
238 CMenu srcMenu; 295 CMenu srcMenu;
239 srcMenu.Attach(srcMenuSpec); 296 srcMenu.Attach(srcMenuSpec);
240 CMenu destMenu; 297 CMenu destMenu;
241 destMenu.Attach(destMenuSpec); 298 destMenu.Attach(destMenuSpec);
242 int startPos = 0; 299 unsigned startPos = 0;
243 for (int i = 0;; i++) 300 for (unsigned i = 0;; i++)
244 { 301 {
245 CMenuItem item; 302 CMenuItem item;
246 item.fMask = MIIM_SUBMENU | MIIM_STATE | MIIM_ID | Get_fMask_for_FType_and_String(); 303 item.fMask = MIIM_SUBMENU | MIIM_STATE | MIIM_ID | Get_fMask_for_FType_and_String();
247 item.fType = MFT_STRING;
248
249 if (!srcMenu.GetItem(i, true, item)) 304 if (!srcMenu.GetItem(i, true, item))
250 break; 305 break;
251
252 CopyPopMenu_IfRequired(item); 306 CopyPopMenu_IfRequired(item);
253 if (destMenu.InsertItem(startPos, true, item)) 307 if (destMenu.InsertItem(startPos, true, item))
254 startPos++; 308 startPos++;
255 } 309 }
256} 310}
257 311
258void MyLoadMenu()
259{
260 HMENU baseMenu;
261 312
313/* use for (needResetMenu):
314 false : for call from program window creation code
315 true : for another calls : (from Options language change)
316*/
317void MyLoadMenu(bool needResetMenu)
318{
262 #ifdef UNDER_CE 319 #ifdef UNDER_CE
263 320
264 HMENU oldMenu = g_App._commandBar.GetMenu(0); 321 const HMENU oldMenu = g_App._commandBar.GetMenu(0);
265 if (oldMenu) 322 if (oldMenu)
266 ::DestroyMenu(oldMenu); 323 ::DestroyMenu(oldMenu);
267 /* BOOL b = */ g_App._commandBar.InsertMenubar(g_hInstance, IDM_MENU, 0); 324 /* BOOL b = */ g_App._commandBar.InsertMenubar(g_hInstance, IDM_MENU, 0);
268 baseMenu = g_App._commandBar.GetMenu(0); 325 const HMENU baseMenu = g_App._commandBar.GetMenu(0);
269 // if (startInit) 326 // if (startInit)
270 // SetIdsForSubMenes(baseMenu, 0, 0); 327 // SetIdsForSubMenus(baseMenu, 0, 0);
271 if (!g_LangID.IsEmpty()) 328 if (!g_LangID.IsEmpty())
272 MyChangeMenu(baseMenu, 0, 0); 329 MyChangeMenu(baseMenu, 0, 0);
273 g_App._commandBar.DrawMenuBar(0); 330 g_App._commandBar.DrawMenuBar(0);
274 331
275 #else 332 #else // UNDER_CE
276 333
277 HWND hWnd = g_HWND; 334 const HWND hWnd = g_HWND;
278 HMENU oldMenu = ::GetMenu(hWnd); 335 bool menuWasChanged = false;
279 ::SetMenu(hWnd, ::LoadMenu(g_hInstance, MAKEINTRESOURCE(IDM_MENU))); 336 /*
280 ::DestroyMenu(oldMenu); 337 We must reload to english default menu for at least two cases:
281 baseMenu = ::GetMenu(hWnd); 338 - if some submenu was changed (File or another submenu can be changed after menu activating).
339 - for change from non-english lang to another partial non-english lang,
340 where we still need some english strings.
341 But we reload menu to default menu everytime except of program starting stage.
342 That scheme is simpler than complex checks for exact conditions for menu reload.
343 */
344 if (needResetMenu)
345 {
346 const HMENU oldMenu = ::GetMenu(hWnd);
347 const HMENU newMenu = ::LoadMenu(g_hInstance, MAKEINTRESOURCE(IDM_MENU));
348 // docs for SetMenu(): the window is redrawn to reflect the menu change.
349 if (newMenu && ::SetMenu(hWnd, newMenu))
350 ::DestroyMenu(oldMenu);
351 menuWasChanged = true;
352 }
353 const HMENU baseMenu = ::GetMenu(hWnd);
282 // if (startInit) 354 // if (startInit)
283 // SetIdsForSubMenes(baseMenu, 0, 0); 355 // SetIdsForSubMenus(baseMenu, 0, 0);
284 if (!g_LangID.IsEmpty()) 356 #ifdef Z7_LANG
285 MyChangeMenu(baseMenu, 0, 0); 357 if (!g_Lang.IsEmpty()) // !g_LangID.IsEmpty() &&
286 ::DrawMenuBar(hWnd); 358 {
287 359 MyChangeMenu(baseMenu, 0, 0, 0);
360 menuWasChanged = true;
361 }
288 #endif 362 #endif
289 363
290 if ((HMENU)g_FileMenu != 0) 364 if (menuWasChanged)
291 g_FileMenu.Destroy(); 365 ::DrawMenuBar(hWnd);
292 g_FileMenu.CreatePopup(); 366
293 CopyMenu(::GetSubMenu(baseMenu, 0), g_FileMenu); 367 #endif // UNDER_CE
368
369 // menuWasChanged = false; // for debug
370 if (menuWasChanged || !(HMENU)g_FileMenu)
371 {
372 if ((HMENU)g_FileMenu)
373 g_FileMenu.Destroy();
374 g_FileMenu.CreatePopup();
375 CopyMenu(::GetSubMenu(baseMenu, k_MenuIndex_File), g_FileMenu);
376 }
294} 377}
295 378
296void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position) 379void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position)
@@ -306,14 +389,14 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position)
306 if (::GetSubMenu(mainMenu, position) != hMenu) 389 if (::GetSubMenu(mainMenu, position) != hMenu)
307 return; 390 return;
308 391
309 if (position == kMenuIndex_File) 392 if (position == k_MenuIndex_File)
310 { 393 {
311 CMenu menu; 394 CMenu menu;
312 menu.Attach(hMenu); 395 menu.Attach(hMenu);
313 menu.RemoveAllItems(); 396 menu.RemoveAllItems();
314 g_App.GetFocusedPanel().CreateFileMenu(hMenu); 397 g_App.GetFocusedPanel().CreateFileMenu(hMenu);
315 } 398 }
316 else if (position == kMenuIndex_Edit) 399 else if (position == k_MenuIndex_Edit)
317 { 400 {
318 /* 401 /*
319 CMenu menu; 402 CMenu menu;
@@ -323,16 +406,20 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position)
323 menu.EnableItem(IDM_EDIT_PASTE, IsClipboardFormatAvailableHDROP() ? MF_ENABLED : MF_GRAYED); 406 menu.EnableItem(IDM_EDIT_PASTE, IsClipboardFormatAvailableHDROP() ? MF_ENABLED : MF_GRAYED);
324 */ 407 */
325 } 408 }
326 else if (position == kMenuIndex_View) 409 else if (position == k_MenuIndex_View)
327 { 410 {
328 // View; 411 // View;
329 CMenu menu; 412 CMenu menu;
330 menu.Attach(hMenu); 413 menu.Attach(hMenu);
331 menu.CheckRadioItem(IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS, 414 menu.CheckRadioItem(
332 IDM_VIEW_LARGE_ICONS + g_App.GetListViewMode(), MF_BYCOMMAND); 415 IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS,
333 416 IDM_VIEW_LARGE_ICONS + g_App.GetListViewMode(), MF_BYCOMMAND);
334 menu.CheckRadioItem(IDM_VIEW_ARANGE_BY_NAME, IDM_VIEW_ARANGE_NO_SORT, 417
335 GetSortControlID(g_App.GetSortID()), MF_BYCOMMAND); 418 menu.CheckRadioItem(
419 IDM_VIEW_ARANGE_BY_NAME,
420 IDM_VIEW_ARANGE_NO_SORT,
421 GetSortControlID(g_App.GetSortID()),
422 MF_BYCOMMAND);
336 423
337 menu.CheckItemByID(IDM_VIEW_TWO_PANELS, g_App.NumPanels == 2); 424 menu.CheckItemByID(IDM_VIEW_TWO_PANELS, g_App.NumPanels == 2);
338 menu.CheckItemByID(IDM_VIEW_FLAT_VIEW, g_App.GetFlatMode()); 425 menu.CheckItemByID(IDM_VIEW_FLAT_VIEW, g_App.GetFlatMode());
@@ -344,16 +431,14 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position)
344 // menu.CheckItemByID(IDM_VIEW_SHOW_STREAMS, g_App.Get_ShowNtfsStrems_Mode()); 431 // menu.CheckItemByID(IDM_VIEW_SHOW_STREAMS, g_App.Get_ShowNtfsStrems_Mode());
345 // menu.CheckItemByID(IDM_VIEW_SHOW_DELETED, g_App.ShowDeletedFiles); 432 // menu.CheckItemByID(IDM_VIEW_SHOW_DELETED, g_App.ShowDeletedFiles);
346 433
347 for (int i = 0;; i++) 434 for (unsigned i = 0;; i++)
348 { 435 {
349 CMenuItem item; 436 CMenuItem item;
350 item.fMask = Get_fMask_for_String() | MIIM_SUBMENU | MIIM_ID; 437 item.fMask = Get_fMask_for_String() | MIIM_SUBMENU | MIIM_ID;
351 item.fType = MFT_STRING; 438 item.fType = MFT_STRING;
352 if (!menu.GetItem(i, true, item)) 439 if (!menu.GetItem(i, true, item))
353 break; 440 break;
354 if (item.hSubMenu && (item.wID == kMenuID_Time_Parent 441 if (item.hSubMenu && Is_MenuItem_TimePopup(item))
355 || item.StringValue.IsPrefixedBy_Ascii_NoCase("20")
356 ))
357 { 442 {
358 FILETIME ft; 443 FILETIME ft;
359 NTime::GetCurUtcFileTime(ft); 444 NTime::GetCurUtcFileTime(ft);
@@ -367,11 +452,11 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position)
367 452
368 item.fMask = Get_fMask_for_String() | MIIM_ID; 453 item.fMask = Get_fMask_for_String() | MIIM_ID;
369 item.fType = MFT_STRING; 454 item.fType = MFT_STRING;
370 item.wID = kMenuID_Time_Parent; 455 item.wID = k_MenuID_TimePopup;
371 menu.SetItem(i, true, item); 456 menu.SetItem(i, true, item);
372 457
373 CMenu subMenu; 458 CMenu subMenu;
374 subMenu.Attach(menu.GetSubMenu(i)); 459 subMenu.Attach(menu.GetSubMenu((int)i));
375 subMenu.RemoveAllItems(); 460 subMenu.RemoveAllItems();
376 461
377 const int k_TimeLevels[] = 462 const int k_TimeLevels[] =
@@ -384,16 +469,16 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position)
384 kTimestampPrintLevel_NS 469 kTimestampPrintLevel_NS
385 }; 470 };
386 471
387 unsigned last = kMenuID_Time; 472 unsigned last = k_MenuID_Time;
388 unsigned selectedCommand = 0; 473 unsigned selectedCommand = 0;
389 g_App._timestampLevels.Clear(); 474 g_App._timestampLevels.Clear();
390 unsigned id = kMenuID_Time; 475 unsigned id = k_MenuID_Time;
391 476
392 for (unsigned k = 0; k < ARRAY_SIZE(k_TimeLevels); k++) 477 for (unsigned k = 0; k < Z7_ARRAY_SIZE(k_TimeLevels); k++)
393 { 478 {
394 wchar_t s[64]; 479 wchar_t s[64];
395 s[0] = 0; 480 s[0] = 0;
396 int timestampLevel = k_TimeLevels[k]; 481 const int timestampLevel = k_TimeLevels[k];
397 if (ConvertUtcFileTimeToString(ft, s, timestampLevel)) 482 if (ConvertUtcFileTimeToString(ft, s, timestampLevel))
398 { 483 {
399 if (subMenu.AppendItem(MF_STRING, id, s)) 484 if (subMenu.AppendItem(MF_STRING, id, s))
@@ -407,11 +492,11 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position)
407 } 492 }
408 } 493 }
409 if (selectedCommand != 0) 494 if (selectedCommand != 0)
410 menu.CheckRadioItem(kMenuID_Time, last, selectedCommand, MF_BYCOMMAND); 495 menu.CheckRadioItem(k_MenuID_Time, last, selectedCommand, MF_BYCOMMAND);
411 } 496 }
412 } 497 }
413 } 498 }
414 else if (position == kMenuIndex_Bookmarks) 499 else if (position == k_MenuIndex_Bookmarks)
415 { 500 {
416 CMenu menu; 501 CMenu menu;
417 menu.Attach(hMenu); 502 menu.Attach(hMenu);
@@ -419,17 +504,17 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position)
419 CMenu subMenu; 504 CMenu subMenu;
420 subMenu.Attach(menu.GetSubMenu(0)); 505 subMenu.Attach(menu.GetSubMenu(0));
421 subMenu.RemoveAllItems(); 506 subMenu.RemoveAllItems();
422 int i; 507 unsigned i;
423 508
424 for (i = 0; i < 10; i++) 509 for (i = 0; i < 10; i++)
425 { 510 {
426 UString s = LangString(IDS_BOOKMARK); 511 UString s = LangString(IDS_BOOKMARK);
427 s.Add_Space(); 512 s.Add_Space();
428 char c = (char)(L'0' + i); 513 const char c = (char)(L'0' + i);
429 s += c; 514 s += c;
430 s += "\tAlt+Shift+"; 515 s += "\tAlt+Shift+";
431 s += c; 516 s += c;
432 subMenu.AppendItem(MF_STRING, kSetBookmarkMenuID + i, s); 517 subMenu.AppendItem(MF_STRING, k_MenuID_SetBookmark + i, s);
433 } 518 }
434 519
435 menu.RemoveAllItemsFrom(2); 520 menu.RemoveAllItemsFrom(2);
@@ -448,7 +533,7 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position)
448 s = '-'; 533 s = '-';
449 s += "\tAlt+"; 534 s += "\tAlt+";
450 s += (char)('0' + i); 535 s += (char)('0' + i);
451 menu.AppendItem(MF_STRING, kOpenBookmarkMenuID + i, s); 536 menu.AppendItem(MF_STRING, k_MenuID_OpenBookmark + i, s);
452 } 537 }
453 } 538 }
454} 539}
@@ -596,7 +681,7 @@ void CFileMenu::Load(HMENU hMenu, unsigned startPos)
596 NFile::NFind::CFileInfo fi; 681 NFile::NFind::CFileInfo fi;
597 if (fi.Find(FilePath) && fi.Size < ((UInt32)1 << 31) && !fi.IsDir()) 682 if (fi.Find(FilePath) && fi.Size < ((UInt32)1 << 31) && !fi.IsDir())
598 { 683 {
599 for (unsigned k = 0; k < ARRAY_SIZE(g_Zvc_IDs); k++) 684 for (unsigned k = 0; k < Z7_ARRAY_SIZE(g_Zvc_IDs); k++)
600 { 685 {
601 const unsigned id = g_Zvc_IDs[k]; 686 const unsigned id = g_Zvc_IDs[k];
602 if (fi.IsReadOnly()) 687 if (fi.IsReadOnly())
@@ -756,7 +841,7 @@ bool OnMenuCommand(HWND hWnd, unsigned id)
756 g_App.SetListViewMode(index); 841 g_App.SetListViewMode(index);
757 /* 842 /*
758 CMenu menu; 843 CMenu menu;
759 menu.Attach(::GetSubMenu(::GetMenu(hWnd), kMenuIndex_View)); 844 menu.Attach(::GetSubMenu(::GetMenu(hWnd), k_MenuIndex_View));
760 menu.CheckRadioItem(IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS, 845 menu.CheckRadioItem(IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS,
761 id, MF_BYCOMMAND); 846 id, MF_BYCOMMAND);
762 */ 847 */
@@ -811,20 +896,19 @@ bool OnMenuCommand(HWND hWnd, unsigned id)
811 } 896 }
812 default: 897 default:
813 { 898 {
814 if (id >= kOpenBookmarkMenuID && id <= kOpenBookmarkMenuID + 9) 899 if (id >= k_MenuID_OpenBookmark && id <= k_MenuID_OpenBookmark + 9)
815 { 900 {
816 g_App.OpenBookmark(id - kOpenBookmarkMenuID); 901 g_App.OpenBookmark(id - k_MenuID_OpenBookmark);
817 return true; 902 return true;
818 } 903 }
819 else if (id >= kSetBookmarkMenuID && id <= kSetBookmarkMenuID + 9) 904 else if (id >= k_MenuID_SetBookmark && id <= k_MenuID_SetBookmark + 9)
820 { 905 {
821 g_App.SetBookmark(id - kSetBookmarkMenuID); 906 g_App.SetBookmark(id - k_MenuID_SetBookmark);
822 return true; 907 return true;
823 } 908 }
824 else if (id >= kMenuID_Time && (unsigned)id <= kMenuID_Time + g_App._timestampLevels.Size()) 909 else if (id >= k_MenuID_Time && (unsigned)id < k_MenuID_Time + g_App._timestampLevels.Size())
825 { 910 {
826 unsigned index = id - kMenuID_Time; 911 g_App.SetTimestampLevel(g_App._timestampLevels[id - k_MenuID_Time]);
827 g_App.SetTimestampLevel(g_App._timestampLevels[index]);
828 return true; 912 return true;
829 } 913 }
830 return false; 914 return false;
diff --git a/CPP/7zip/UI/FileManager/MyLoadMenu.h b/CPP/7zip/UI/FileManager/MyLoadMenu.h
index 764bf7c..e71dbbf 100644
--- a/CPP/7zip/UI/FileManager/MyLoadMenu.h
+++ b/CPP/7zip/UI/FileManager/MyLoadMenu.h
@@ -1,14 +1,14 @@
1// MyLoadMenu.h 1// MyLoadMenu.h
2 2
3#ifndef __MY_LOAD_MENU_H 3#ifndef ZIP7_INC_MY_LOAD_MENU_H
4#define __MY_LOAD_MENU_H 4#define ZIP7_INC_MY_LOAD_MENU_H
5 5
6void OnMenuActivating(HWND hWnd, HMENU hMenu, int position); 6void OnMenuActivating(HWND hWnd, HMENU hMenu, int position);
7// void OnMenuUnActivating(HWND hWnd, HMENU hMenu, int id); 7// void OnMenuUnActivating(HWND hWnd, HMENU hMenu, int id);
8// void OnMenuUnActivating(HWND hWnd); 8// void OnMenuUnActivating(HWND hWnd);
9 9
10bool OnMenuCommand(HWND hWnd, unsigned id); 10bool OnMenuCommand(HWND hWnd, unsigned id);
11void MyLoadMenu(); 11void MyLoadMenu(bool needResetMenu);
12 12
13struct CFileMenu 13struct CFileMenu
14{ 14{
@@ -18,7 +18,7 @@ struct CFileMenu
18 bool isFsFolder; 18 bool isFsFolder;
19 bool allAreFiles; 19 bool allAreFiles;
20 bool isAltStreamsSupported; 20 bool isAltStreamsSupported;
21 int numItems; 21 unsigned numItems;
22 22
23 FString FilePath; 23 FString FilePath;
24 24
diff --git a/CPP/7zip/UI/FileManager/MyWindowsNew.h b/CPP/7zip/UI/FileManager/MyWindowsNew.h
index 48a9535..325babc 100644
--- a/CPP/7zip/UI/FileManager/MyWindowsNew.h
+++ b/CPP/7zip/UI/FileManager/MyWindowsNew.h
@@ -1,11 +1,54 @@
1// MyWindowsNew.h 1// MyWindowsNew.h
2 2
3#ifndef __MY_WINDOWS_NEW_H 3#ifndef ZIP7_INC_MY_WINDOWS_NEW_H
4#define __MY_WINDOWS_NEW_H 4#define ZIP7_INC_MY_WINDOWS_NEW_H
5 5
6#ifdef _MSC_VER 6#if defined(__MINGW32__) || defined(__MINGW64__) || defined(__MINGW32_VERSION)
7#include <shobjidl.h>
7 8
9#if defined(__MINGW32_VERSION) && !defined(__ITaskbarList3_INTERFACE_DEFINED__)
10// for old mingw
11extern "C" {
12DEFINE_GUID(IID_ITaskbarList3, 0xEA1AFB91, 0x9E28, 0x4B86, 0x90, 0xE9, 0x9E, 0x9F, 0x8A, 0x5E, 0xEF, 0xAF);
13DEFINE_GUID(CLSID_TaskbarList, 0x56fdf344, 0xfd6d, 0x11d0, 0x95,0x8a, 0x00,0x60,0x97,0xc9,0xa0,0x90);
14}
15#endif
16
17#else // is not __MINGW*
18
19#ifndef Z7_OLD_WIN_SDK
8#include <ShObjIdl.h> 20#include <ShObjIdl.h>
21#else
22
23#ifndef HIMAGELIST
24struct _IMAGELIST;
25typedef struct _IMAGELIST* HIMAGELIST;
26#endif
27
28#ifndef __ITaskbarList_INTERFACE_DEFINED__
29#define __ITaskbarList_INTERFACE_DEFINED__
30DEFINE_GUID(IID_ITaskbarList, 0x56FDF342, 0xFD6D, 0x11d0, 0x95, 0x8A, 0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90);
31struct ITaskbarList: public IUnknown
32{
33 STDMETHOD(HrInit)(void) = 0;
34 STDMETHOD(AddTab)(HWND hwnd) = 0;
35 STDMETHOD(DeleteTab)(HWND hwnd) = 0;
36 STDMETHOD(ActivateTab)(HWND hwnd) = 0;
37 STDMETHOD(SetActiveAlt)(HWND hwnd) = 0;
38};
39#endif // __ITaskbarList_INTERFACE_DEFINED__
40
41#ifndef __ITaskbarList2_INTERFACE_DEFINED__
42#define __ITaskbarList2_INTERFACE_DEFINED__
43DEFINE_GUID(IID_ITaskbarList2, 0x602D4995, 0xB13A, 0x429b, 0xA6, 0x6E, 0x19, 0x35, 0xE4, 0x4F, 0x43, 0x17);
44struct ITaskbarList2: public ITaskbarList
45{
46 STDMETHOD(MarkFullscreenWindow)(HWND hwnd, BOOL fFullscreen) = 0;
47};
48#endif // __ITaskbarList2_INTERFACE_DEFINED__
49
50#endif // Z7_OLD_WIN_SDK
51
9 52
10#ifndef __ITaskbarList3_INTERFACE_DEFINED__ 53#ifndef __ITaskbarList3_INTERFACE_DEFINED__
11#define __ITaskbarList3_INTERFACE_DEFINED__ 54#define __ITaskbarList3_INTERFACE_DEFINED__
@@ -69,8 +112,8 @@ struct ITaskbarList3: public ITaskbarList2
69 STDMETHOD(SetThumbnailClip)(HWND hwnd, RECT *prcClip) = 0; 112 STDMETHOD(SetThumbnailClip)(HWND hwnd, RECT *prcClip) = 0;
70}; 113};
71 114
72#endif 115#endif // __ITaskbarList3_INTERFACE_DEFINED__
73 116
74#endif 117#endif // __MINGW*
75 118
76#endif 119#endif
diff --git a/CPP/7zip/UI/FileManager/NetFolder.cpp b/CPP/7zip/UI/FileManager/NetFolder.cpp
index a941e73..879f1db 100644
--- a/CPP/7zip/UI/FileManager/NetFolder.cpp
+++ b/CPP/7zip/UI/FileManager/NetFolder.cpp
@@ -55,9 +55,9 @@ void CNetFolder::Init(const UString &path)
55 UString systemPathPart; 55 UString systemPathPart;
56 DWORD result = GetResourceInformation(resource, destResource, systemPathPart); 56 DWORD result = GetResourceInformation(resource, destResource, systemPathPart);
57 if (result == NO_ERROR) 57 if (result == NO_ERROR)
58 Init(&destResource, 0, path); 58 Init(&destResource, NULL, path);
59 else 59 else
60 Init(0, 0 , L""); 60 Init(NULL, NULL , L"");
61 return; 61 return;
62} 62}
63 63
@@ -65,8 +65,8 @@ void CNetFolder::Init(const NWindows::NNet::CResourceW *netResource,
65 IFolderFolder *parentFolder, const UString &path) 65 IFolderFolder *parentFolder, const UString &path)
66{ 66{
67 _path = path; 67 _path = path;
68 if (netResource == 0) 68 if (!netResource)
69 _netResourcePointer = 0; 69 _netResourcePointer = NULL;
70 else 70 else
71 { 71 {
72 _netResource = *netResource; 72 _netResource = *netResource;
@@ -86,7 +86,7 @@ void CNetFolder::Init(const NWindows::NNet::CResourceW *netResource,
86 _parentFolder = parentFolder; 86 _parentFolder = parentFolder;
87} 87}
88 88
89STDMETHODIMP CNetFolder::LoadItems() 89Z7_COM7F_IMF(CNetFolder::LoadItems())
90{ 90{
91 _items.Clear(); 91 _items.Clear();
92 CEnum enumerator; 92 CEnum enumerator;
@@ -102,35 +102,35 @@ STDMETHODIMP CNetFolder::LoadItems()
102 if (result == NO_ERROR) 102 if (result == NO_ERROR)
103 break; 103 break;
104 if (result != ERROR_ACCESS_DENIED) 104 if (result != ERROR_ACCESS_DENIED)
105 return result; 105 return HRESULT_FROM_WIN32(result);
106 if (_netResourcePointer != 0) 106 if (_netResourcePointer)
107 result = AddConnection2(_netResource, 107 result = AddConnection2(_netResource,
108 0, 0, CONNECT_INTERACTIVE); 108 NULL, NULL, CONNECT_INTERACTIVE);
109 if (result != NO_ERROR) 109 if (result != NO_ERROR)
110 return result; 110 return HRESULT_FROM_WIN32(result);
111 } 111 }
112 112
113 for (;;) 113 for (;;)
114 { 114 {
115 CResourceEx resource; 115 CResourceEx resource;
116 DWORD result = enumerator.Next(resource); 116 const DWORD result = enumerator.Next(resource);
117 if (result == NO_ERROR) 117 if (result == NO_ERROR)
118 { 118 {
119 if (!resource.RemoteNameIsDefined) // For Win 98, I don't know what's wrong 119 if (!resource.RemoteNameIsDefined) // For Win 98, I don't know what's wrong
120 resource.RemoteName = resource.Comment; 120 resource.RemoteName = resource.Comment;
121 resource.Name = resource.RemoteName; 121 resource.Name = resource.RemoteName;
122 int pos = resource.Name.ReverseFind_PathSepar(); 122 const int pos = resource.Name.ReverseFind_PathSepar();
123 if (pos >= 0) 123 if (pos >= 0)
124 { 124 {
125 // _path = resource.Name.Left(pos + 1); 125 // _path = resource.Name.Left(pos + 1);
126 resource.Name.DeleteFrontal(pos + 1); 126 resource.Name.DeleteFrontal((unsigned)pos + 1);
127 } 127 }
128 _items.Add(resource); 128 _items.Add(resource);
129 } 129 }
130 else if (result == ERROR_NO_MORE_ITEMS) 130 else if (result == ERROR_NO_MORE_ITEMS)
131 break; 131 break;
132 else 132 else
133 return result; 133 return HRESULT_FROM_WIN32(result);
134 } 134 }
135 135
136 /* 136 /*
@@ -160,13 +160,13 @@ STDMETHODIMP CNetFolder::LoadItems()
160} 160}
161 161
162 162
163STDMETHODIMP CNetFolder::GetNumberOfItems(UInt32 *numItems) 163Z7_COM7F_IMF(CNetFolder::GetNumberOfItems(UInt32 *numItems))
164{ 164{
165 *numItems = _items.Size(); 165 *numItems = _items.Size();
166 return S_OK; 166 return S_OK;
167} 167}
168 168
169STDMETHODIMP CNetFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value) 169Z7_COM7F_IMF(CNetFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value))
170{ 170{
171 NCOM::CPropVariant prop; 171 NCOM::CPropVariant prop;
172 const CResourceEx &item = _items[itemIndex]; 172 const CResourceEx &item = _items[itemIndex];
@@ -185,16 +185,16 @@ STDMETHODIMP CNetFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIAN
185 return S_OK; 185 return S_OK;
186} 186}
187 187
188STDMETHODIMP CNetFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder) 188Z7_COM7F_IMF(CNetFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder))
189{ 189{
190 *resultFolder = 0; 190 *resultFolder = NULL;
191 const CResourceEx &resource = _items[index]; 191 const CResourceEx &resource = _items[index];
192 if (resource.Usage == RESOURCEUSAGE_CONNECTABLE || 192 if (resource.Usage == RESOURCEUSAGE_CONNECTABLE ||
193 resource.DisplayType == RESOURCEDISPLAYTYPE_SHARE) 193 resource.DisplayType == RESOURCEDISPLAYTYPE_SHARE)
194 { 194 {
195 NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder; 195 NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder;
196 CMyComPtr<IFolderFolder> subFolder = fsFolderSpec; 196 CMyComPtr<IFolderFolder> subFolder = fsFolderSpec;
197 RINOK(fsFolderSpec->Init(us2fs(resource.RemoteName + WCHAR_PATH_SEPARATOR))); // , this 197 RINOK(fsFolderSpec->Init(us2fs(resource.RemoteName + WCHAR_PATH_SEPARATOR))) // , this
198 *resultFolder = subFolder.Detach(); 198 *resultFolder = subFolder.Detach();
199 } 199 }
200 else 200 else
@@ -207,32 +207,32 @@ STDMETHODIMP CNetFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder
207 return S_OK; 207 return S_OK;
208} 208}
209 209
210STDMETHODIMP CNetFolder::BindToFolder(const wchar_t * /* name */, IFolderFolder ** /* resultFolder */) 210Z7_COM7F_IMF(CNetFolder::BindToFolder(const wchar_t * /* name */, IFolderFolder ** /* resultFolder */))
211{ 211{
212 return E_NOTIMPL; 212 return E_NOTIMPL;
213} 213}
214 214
215STDMETHODIMP CNetFolder::BindToParentFolder(IFolderFolder **resultFolder) 215Z7_COM7F_IMF(CNetFolder::BindToParentFolder(IFolderFolder **resultFolder))
216{ 216{
217 *resultFolder = 0; 217 *resultFolder = NULL;
218 if (_parentFolder) 218 if (_parentFolder)
219 { 219 {
220 CMyComPtr<IFolderFolder> parentFolder = _parentFolder; 220 CMyComPtr<IFolderFolder> parentFolder = _parentFolder;
221 *resultFolder = parentFolder.Detach(); 221 *resultFolder = parentFolder.Detach();
222 return S_OK; 222 return S_OK;
223 } 223 }
224 if (_netResourcePointer != 0) 224 if (_netResourcePointer)
225 { 225 {
226 CResourceW resourceParent; 226 CResourceW resourceParent;
227 DWORD result = GetResourceParent(_netResource, resourceParent); 227 const DWORD result = GetResourceParent(_netResource, resourceParent);
228 if (result != NO_ERROR) 228 if (result != NO_ERROR)
229 return result; 229 return HRESULT_FROM_WIN32(result);
230 if (!_netResource.RemoteNameIsDefined) 230 if (!_netResource.RemoteNameIsDefined)
231 return S_OK; 231 return S_OK;
232 232
233 CNetFolder *netFolder = new CNetFolder; 233 CNetFolder *netFolder = new CNetFolder;
234 CMyComPtr<IFolderFolder> subFolder = netFolder; 234 CMyComPtr<IFolderFolder> subFolder = netFolder;
235 netFolder->Init(&resourceParent, 0, WSTRING_PATH_SEPARATOR); 235 netFolder->Init(&resourceParent, NULL, WSTRING_PATH_SEPARATOR);
236 *resultFolder = subFolder.Detach(); 236 *resultFolder = subFolder.Detach();
237 } 237 }
238 return S_OK; 238 return S_OK;
@@ -240,7 +240,7 @@ STDMETHODIMP CNetFolder::BindToParentFolder(IFolderFolder **resultFolder)
240 240
241IMP_IFolderFolder_Props(CNetFolder) 241IMP_IFolderFolder_Props(CNetFolder)
242 242
243STDMETHODIMP CNetFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value) 243Z7_COM7F_IMF(CNetFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value))
244{ 244{
245 NWindows::NCOM::CPropVariant prop; 245 NWindows::NCOM::CPropVariant prop;
246 switch (propID) 246 switch (propID)
@@ -252,7 +252,7 @@ STDMETHODIMP CNetFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
252 return S_OK; 252 return S_OK;
253} 253}
254 254
255STDMETHODIMP CNetFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex) 255Z7_COM7F_IMF(CNetFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex))
256{ 256{
257 if (index >= (UInt32)_items.Size()) 257 if (index >= (UInt32)_items.Size())
258 return E_INVALIDARG; 258 return E_INVALIDARG;
@@ -277,5 +277,5 @@ STDMETHODIMP CNetFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex)
277 } 277 }
278 // *anIconIndex = GetRealIconIndex(0, L"\\\\HOME"); 278 // *anIconIndex = GetRealIconIndex(0, L"\\\\HOME");
279 } 279 }
280 return GetLastError(); 280 return GetLastError_noZero_HRESULT();
281} 281}
diff --git a/CPP/7zip/UI/FileManager/NetFolder.h b/CPP/7zip/UI/FileManager/NetFolder.h
index 151dd09..352f5bd 100644
--- a/CPP/7zip/UI/FileManager/NetFolder.h
+++ b/CPP/7zip/UI/FileManager/NetFolder.h
@@ -1,7 +1,7 @@
1// NetFolder.h 1// NetFolder.h
2 2
3#ifndef __NET_FOLDER_H 3#ifndef ZIP7_INC_NET_FOLDER_H
4#define __NET_FOLDER_H 4#define ZIP7_INC_NET_FOLDER_H
5 5
6#include "../../../Common/MyCom.h" 6#include "../../../Common/MyCom.h"
7 7
@@ -14,11 +14,11 @@ struct CResourceEx: public NWindows::NNet::CResourceW
14 UString Name; 14 UString Name;
15}; 15};
16 16
17class CNetFolder: 17Z7_CLASS_IMP_NOQIB_2(
18 public IFolderFolder, 18 CNetFolder
19 public IFolderGetSystemIconIndex, 19 , IFolderFolder
20 public CMyUnknownImp 20 , IFolderGetSystemIconIndex
21{ 21)
22 NWindows::NNet::CResourceW _netResource; 22 NWindows::NNet::CResourceW _netResource;
23 NWindows::NNet::CResourceW *_netResourcePointer; 23 NWindows::NNet::CResourceW *_netResourcePointer;
24 24
@@ -27,11 +27,7 @@ class CNetFolder:
27 CMyComPtr<IFolderFolder> _parentFolder; 27 CMyComPtr<IFolderFolder> _parentFolder;
28 UString _path; 28 UString _path;
29public: 29public:
30 MY_UNKNOWN_IMP1(IFolderGetSystemIconIndex) 30 CNetFolder(): _netResourcePointer(NULL) {}
31 INTERFACE_FolderFolder(;)
32 STDMETHOD(GetSystemIconIndex)(UInt32 index, Int32 *iconIndex);
33
34 CNetFolder(): _netResourcePointer(0) {}
35 void Init(const UString &path); 31 void Init(const UString &path);
36 void Init(const NWindows::NNet::CResourceW *netResource, 32 void Init(const NWindows::NNet::CResourceW *netResource,
37 IFolderFolder *parentFolder, const UString &path); 33 IFolderFolder *parentFolder, const UString &path);
diff --git a/CPP/7zip/UI/FileManager/OpenCallback.cpp b/CPP/7zip/UI/FileManager/OpenCallback.cpp
index e2e03f5..5b6df50 100644
--- a/CPP/7zip/UI/FileManager/OpenCallback.cpp
+++ b/CPP/7zip/UI/FileManager/OpenCallback.cpp
@@ -17,9 +17,11 @@
17 17
18using namespace NWindows; 18using namespace NWindows;
19 19
20STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 *numFiles, const UInt64 *numBytes) 20HRESULT COpenArchiveCallback::Open_SetTotal(const UInt64 *numFiles, const UInt64 *numBytes)
21// Z7_COM7F_IMF(COpenArchiveCallback::SetTotal(const UInt64 *numFiles, const UInt64 *numBytes))
21{ 22{
22 RINOK(ProgressDialog.Sync.CheckStop()); 23 // COM_TRY_BEGIN
24 RINOK(ProgressDialog.Sync.CheckStop())
23 { 25 {
24 // NSynchronization::CCriticalSectionLock lock(_criticalSection); 26 // NSynchronization::CCriticalSectionLock lock(_criticalSection);
25 ProgressDialog.Sync.Set_NumFilesTotal(numFiles ? *numFiles : (UInt64)(Int64)-1); 27 ProgressDialog.Sync.Set_NumFilesTotal(numFiles ? *numFiles : (UInt64)(Int64)-1);
@@ -31,83 +33,37 @@ STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 *numFiles, const UInt64
31 ProgressDialog.Sync.Set_NumBytesTotal(*numBytes); 33 ProgressDialog.Sync.Set_NumBytesTotal(*numBytes);
32 } 34 }
33 return S_OK; 35 return S_OK;
36 // COM_TRY_END
34} 37}
35 38
36STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *numFiles, const UInt64 *numBytes) 39HRESULT COpenArchiveCallback::Open_SetCompleted(const UInt64 *numFiles, const UInt64 *numBytes)
40// Z7_COM7F_IMF(COpenArchiveCallback::SetCompleted(const UInt64 *numFiles, const UInt64 *numBytes))
37{ 41{
42 // COM_TRY_BEGIN
38 // NSynchronization::CCriticalSectionLock lock(_criticalSection); 43 // NSynchronization::CCriticalSectionLock lock(_criticalSection);
39 if (numFiles) 44 if (numFiles)
40 ProgressDialog.Sync.Set_NumFilesCur(*numFiles); 45 ProgressDialog.Sync.Set_NumFilesCur(*numFiles);
41 if (numBytes) 46 if (numBytes)
42 ProgressDialog.Sync.Set_NumBytesCur(*numBytes); 47 ProgressDialog.Sync.Set_NumBytesCur(*numBytes);
43 return ProgressDialog.Sync.CheckStop(); 48 return ProgressDialog.Sync.CheckStop();
49 // COM_TRY_END
44} 50}
45 51
46STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 total) 52HRESULT COpenArchiveCallback::Open_CheckBreak()
47{ 53{
48 RINOK(ProgressDialog.Sync.CheckStop()); 54 return ProgressDialog.Sync.CheckStop();
49 ProgressDialog.Sync.Set_NumBytesTotal(total);
50 return S_OK;
51}
52
53STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *completed)
54{
55 return ProgressDialog.Sync.Set_NumBytesCur(completed);
56}
57
58STDMETHODIMP COpenArchiveCallback::GetProperty(PROPID propID, PROPVARIANT *value)
59{
60 NCOM::CPropVariant prop;
61 if (_subArchiveMode)
62 {
63 switch (propID)
64 {
65 case kpidName: prop = _subArchiveName; break;
66 }
67 }
68 else
69 {
70 switch (propID)
71 {
72 case kpidName: prop = fs2us(_fileInfo.Name); break;
73 case kpidIsDir: prop = _fileInfo.IsDir(); break;
74 case kpidSize: prop = _fileInfo.Size; break;
75 case kpidAttrib: prop = (UInt32)_fileInfo.Attrib; break;
76 case kpidCTime: prop = _fileInfo.CTime; break;
77 case kpidATime: prop = _fileInfo.ATime; break;
78 case kpidMTime: prop = _fileInfo.MTime; break;
79 }
80 }
81 prop.Detach(value);
82 return S_OK;
83} 55}
84 56
85STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name, IInStream **inStream) 57HRESULT COpenArchiveCallback::Open_Finished()
86{ 58{
87 COM_TRY_BEGIN 59 return ProgressDialog.Sync.CheckStop();
88 *inStream = NULL;
89 if (_subArchiveMode)
90 return S_FALSE;
91
92 FString fullPath;
93 if (!NFile::NName::GetFullPath(_folderPrefix, us2fs(name), fullPath))
94 return S_FALSE;
95 if (!_fileInfo.Find_FollowLink(fullPath))
96 return S_FALSE;
97 if (_fileInfo.IsDir())
98 return S_FALSE;
99 CInFileStream *inFile = new CInFileStream;
100 CMyComPtr<IInStream> inStreamTemp = inFile;
101 if (!inFile->Open(fullPath))
102 return ::GetLastError();
103 *inStream = inStreamTemp.Detach();
104 return S_OK;
105 COM_TRY_END
106} 60}
107 61
108STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password) 62#ifndef Z7_NO_CRYPTO
63HRESULT COpenArchiveCallback::Open_CryptoGetTextPassword(BSTR *password)
64// Z7_COM7F_IMF(COpenArchiveCallback::CryptoGetTextPassword(BSTR *password))
109{ 65{
110 COM_TRY_BEGIN 66 // COM_TRY_BEGIN
111 PasswordWasAsked = true; 67 PasswordWasAsked = true;
112 if (!PasswordIsDefined) 68 if (!PasswordIsDefined)
113 { 69 {
@@ -125,5 +81,6 @@ STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password)
125 NExtract::Save_ShowPassword(dialog.ShowPassword); 81 NExtract::Save_ShowPassword(dialog.ShowPassword);
126 } 82 }
127 return StringToBstr(Password, password); 83 return StringToBstr(Password, password);
128 COM_TRY_END 84 // COM_TRY_END
129} 85}
86#endif
diff --git a/CPP/7zip/UI/FileManager/OpenCallback.h b/CPP/7zip/UI/FileManager/OpenCallback.h
index 9aa5d43..8f4638c 100644
--- a/CPP/7zip/UI/FileManager/OpenCallback.h
+++ b/CPP/7zip/UI/FileManager/OpenCallback.h
@@ -1,37 +1,28 @@
1// OpenCallback.h 1// OpenCallback.h
2 2
3#ifndef __OPEN_CALLBACK_H 3#ifndef ZIP7_INC_OPEN_CALLBACK_H
4#define __OPEN_CALLBACK_H 4#define ZIP7_INC_OPEN_CALLBACK_H
5 5
6#include "../../../Common/MyCom.h" 6#include "../Common/ArchiveOpenCallback.h"
7 7
8#include "../../../Windows/FileFind.h" 8#ifdef Z7_SFX
9
10#include "../../IPassword.h"
11
12#include "../../Archive/IArchive.h"
13
14#ifdef _SFX
15#include "ProgressDialog.h" 9#include "ProgressDialog.h"
16#else 10#else
17#include "ProgressDialog2.h" 11#include "ProgressDialog2.h"
18#endif 12#endif
19 13
14/* we can use IArchiveOpenCallback or IOpenCallbackUI here */
20 15
21class COpenArchiveCallback: 16class COpenArchiveCallback Z7_final:
17 /*
22 public IArchiveOpenCallback, 18 public IArchiveOpenCallback,
23 public IArchiveOpenVolumeCallback,
24 public IArchiveOpenSetSubArchiveName,
25 public IProgress, 19 public IProgress,
26 public ICryptoGetTextPassword, 20 public ICryptoGetTextPassword,
27 public CMyUnknownImp 21 public CMyUnknownImp
22 */
23 public IOpenCallbackUI
28{ 24{
29 FString _folderPrefix;
30 NWindows::NFile::NFind::CFileInfo _fileInfo;
31 // NWindows::NSynchronization::CCriticalSection _criticalSection; 25 // NWindows::NSynchronization::CCriticalSection _criticalSection;
32 bool _subArchiveMode;
33 UString _subArchiveName;
34
35public: 26public:
36 bool PasswordIsDefined; 27 bool PasswordIsDefined;
37 bool PasswordWasAsked; 28 bool PasswordWasAsked;
@@ -39,31 +30,25 @@ public:
39 HWND ParentWindow; 30 HWND ParentWindow;
40 CProgressDialog ProgressDialog; 31 CProgressDialog ProgressDialog;
41 32
42 MY_UNKNOWN_IMP5( 33 /*
43 IArchiveOpenCallback, 34 Z7_COM_UNKNOWN_IMP_3(
44 IArchiveOpenVolumeCallback, 35 IArchiveOpenVolumeCallback,
45 IArchiveOpenSetSubArchiveName, 36 IProgress
46 IProgress, 37 ICryptoGetTextPassword
47 ICryptoGetTextPassword) 38 )
48
49 INTERFACE_IProgress(;)
50 INTERFACE_IArchiveOpenCallback(;)
51 INTERFACE_IArchiveOpenVolumeCallback(;)
52 39
40 Z7_IFACE_COM7_IMP(IProgress)
41 Z7_IFACE_COM7_IMP(IArchiveOpenCallback)
53 // ICryptoGetTextPassword 42 // ICryptoGetTextPassword
54 STDMETHOD(CryptoGetTextPassword)(BSTR *password); 43 Z7_COM7F_IMP(CryptoGetTextPassword(BSTR *password))
44 */
55 45
56 STDMETHOD(SetSubArchiveName(const wchar_t *name)) 46 Z7_IFACE_IMP(IOpenCallbackUI)
57 {
58 _subArchiveMode = true;
59 _subArchiveName = name;
60 return S_OK;
61 }
62 47
63 COpenArchiveCallback(): 48 COpenArchiveCallback():
64 ParentWindow(0) 49 ParentWindow(NULL)
65 { 50 {
66 _subArchiveMode = false; 51 // _subArchiveMode = false;
67 PasswordIsDefined = false; 52 PasswordIsDefined = false;
68 PasswordWasAsked = false; 53 PasswordWasAsked = false;
69 } 54 }
@@ -75,18 +60,6 @@ public:
75 } 60 }
76 */ 61 */
77 62
78 HRESULT LoadFileInfo2(const FString &folderPrefix, const FString &fileName)
79 {
80 _folderPrefix = folderPrefix;
81 if (!_fileInfo.Find_FollowLink(_folderPrefix + fileName))
82 {
83 return GetLastError_noZero_HRESULT();
84 }
85 return S_OK;
86 }
87
88 void ShowMessage(const UInt64 *completed);
89
90 INT_PTR StartProgressDialog(const UString &title, NWindows::CThread &thread) 63 INT_PTR StartProgressDialog(const UString &title, NWindows::CThread &thread)
91 { 64 {
92 return ProgressDialog.Create(title, thread, ParentWindow); 65 return ProgressDialog.Create(title, thread, ParentWindow);
diff --git a/CPP/7zip/UI/FileManager/OptionsDialog.cpp b/CPP/7zip/UI/FileManager/OptionsDialog.cpp
index c42e0f8..b71c323 100644
--- a/CPP/7zip/UI/FileManager/OptionsDialog.cpp
+++ b/CPP/7zip/UI/FileManager/OptionsDialog.cpp
@@ -51,25 +51,27 @@ void OptionsDialog(HWND hwndOwner, HINSTANCE /* hInstance */)
51 51
52 NControl::CPropertyPage *pagePointers[] = { &systemPage, &menuPage, &foldersPage, &editPage, &settingsPage, &langPage }; 52 NControl::CPropertyPage *pagePointers[] = { &systemPage, &menuPage, &foldersPage, &editPage, &settingsPage, &langPage };
53 53
54 for (unsigned i = 0; i < ARRAY_SIZE(pageIDs); i++) 54 for (unsigned i = 0; i < Z7_ARRAY_SIZE(pageIDs); i++)
55 { 55 {
56 NControl::CPageInfo &page = pages.AddNew(); 56 NControl::CPageInfo &page = pages.AddNew();
57 page.ID = pageIDs[i]; 57 page.ID = pageIDs[i];
58 #ifdef Z7_LANG
58 LangString_OnlyFromLangFile(page.ID, page.Title); 59 LangString_OnlyFromLangFile(page.ID, page.Title);
60 #endif
59 page.Page = pagePointers[i]; 61 page.Page = pagePointers[i];
60 } 62 }
61 63
62 INT_PTR res = NControl::MyPropertySheet(pages, hwndOwner, LangString(IDS_OPTIONS)); 64 const INT_PTR res = NControl::MyPropertySheet(pages, hwndOwner, LangString(IDS_OPTIONS));
63 65
64 if (res != -1 && res != 0) 66 if (res != -1 && res != 0)
65 { 67 {
66 if (langPage.LangWasChanged) 68 if (langPage.LangWasChanged)
67 { 69 {
68 // g_App._window.SetText(LangString(IDS_APP_TITLE, 0x03000000)); 70 // g_App._window.SetText(LangString(IDS_APP_TITLE, 0x03000000));
69 MyLoadMenu(); 71 MyLoadMenu(true); // needResetMenu
70 g_App.ReloadToolbars(); 72 g_App.ReloadToolbars();
71 g_App.MoveSubWindows(); // we need it to change list window aafter _toolBar.AutoSize(); 73 g_App.MoveSubWindows(); // we need it to change list window aafter _toolBar.AutoSize();
72 g_App.ReloadLang(); 74 g_App.ReloadLangItems();
73 } 75 }
74 76
75 /* 77 /*
diff --git a/CPP/7zip/UI/FileManager/OverwriteDialog.cpp b/CPP/7zip/UI/FileManager/OverwriteDialog.cpp
index b455b14..096527c 100644
--- a/CPP/7zip/UI/FileManager/OverwriteDialog.cpp
+++ b/CPP/7zip/UI/FileManager/OverwriteDialog.cpp
@@ -17,7 +17,7 @@
17 17
18using namespace NWindows; 18using namespace NWindows;
19 19
20#ifdef LANG 20#ifdef Z7_LANG
21static const UInt32 kLangIDs[] = 21static const UInt32 kLangIDs[] =
22{ 22{
23 IDT_OVERWRITE_HEADER, 23 IDT_OVERWRITE_HEADER,
@@ -48,7 +48,7 @@ void COverwriteDialog::ReduceString(UString &s)
48 } 48 }
49} 49}
50 50
51void COverwriteDialog::SetFileInfoControl(int textID, int iconID, 51void COverwriteDialog::SetFileInfoControl(unsigned textID, unsigned iconID,
52 const NOverwriteDialog::CFileInfo &fileInfo) 52 const NOverwriteDialog::CFileInfo &fileInfo)
53{ 53{
54 UString sizeString; 54 UString sizeString;
@@ -96,9 +96,9 @@ void COverwriteDialog::SetFileInfoControl(int textID, int iconID,
96 96
97bool COverwriteDialog::OnInit() 97bool COverwriteDialog::OnInit()
98{ 98{
99 #ifdef LANG 99 #ifdef Z7_LANG
100 LangSetWindowText(*this, IDD_OVERWRITE); 100 LangSetWindowText(*this, IDD_OVERWRITE);
101 LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); 101 LangSetDlgItems(*this, kLangIDs, Z7_ARRAY_SIZE(kLangIDs));
102 #endif 102 #endif
103 SetFileInfoControl(IDT_OVERWRITE_OLD_FILE_SIZE_TIME, IDI_OVERWRITE_OLD_FILE, OldFileInfo); 103 SetFileInfoControl(IDT_OVERWRITE_OLD_FILE_SIZE_TIME, IDI_OVERWRITE_OLD_FILE, OldFileInfo);
104 SetFileInfoControl(IDT_OVERWRITE_NEW_FILE_SIZE_TIME, IDI_OVERWRITE_NEW_FILE, NewFileInfo); 104 SetFileInfoControl(IDT_OVERWRITE_NEW_FILE_SIZE_TIME, IDI_OVERWRITE_NEW_FILE, NewFileInfo);
@@ -122,7 +122,7 @@ bool COverwriteDialog::OnInit()
122 return CModalDialog::OnInit(); 122 return CModalDialog::OnInit();
123} 123}
124 124
125bool COverwriteDialog::OnButtonClicked(int buttonID, HWND buttonHWND) 125bool COverwriteDialog::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
126{ 126{
127 switch (buttonID) 127 switch (buttonID)
128 { 128 {
@@ -131,7 +131,7 @@ bool COverwriteDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
131 case IDB_YES_TO_ALL: 131 case IDB_YES_TO_ALL:
132 case IDB_NO_TO_ALL: 132 case IDB_NO_TO_ALL:
133 case IDB_AUTO_RENAME: 133 case IDB_AUTO_RENAME:
134 End(buttonID); 134 End((INT_PTR)buttonID);
135 return true; 135 return true;
136 } 136 }
137 return CModalDialog::OnButtonClicked(buttonID, buttonHWND); 137 return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
diff --git a/CPP/7zip/UI/FileManager/OverwriteDialog.h b/CPP/7zip/UI/FileManager/OverwriteDialog.h
index 24e56ca..a9ca991 100644
--- a/CPP/7zip/UI/FileManager/OverwriteDialog.h
+++ b/CPP/7zip/UI/FileManager/OverwriteDialog.h
@@ -1,7 +1,7 @@
1// OverwriteDialog.h 1// OverwriteDialog.h
2 2
3#ifndef __OVERWRITE_DIALOG_H 3#ifndef ZIP7_INC_OVERWRITE_DIALOG_H
4#define __OVERWRITE_DIALOG_H 4#define ZIP7_INC_OVERWRITE_DIALOG_H
5 5
6#include "../../../Windows/Control/Dialog.h" 6#include "../../../Windows/Control/Dialog.h"
7 7
@@ -49,9 +49,9 @@ class COverwriteDialog: public NWindows::NControl::CModalDialog
49{ 49{
50 bool _isBig; 50 bool _isBig;
51 51
52 void SetFileInfoControl(int textID, int iconID, const NOverwriteDialog::CFileInfo &fileInfo); 52 void SetFileInfoControl(unsigned textID, unsigned iconID, const NOverwriteDialog::CFileInfo &fileInfo);
53 virtual bool OnInit(); 53 virtual bool OnInit() Z7_override;
54 bool OnButtonClicked(int buttonID, HWND buttonHWND); 54 virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
55 void ReduceString(UString &s); 55 void ReduceString(UString &s);
56 56
57public: 57public:
@@ -61,7 +61,7 @@ public:
61 61
62 COverwriteDialog(): ShowExtraButtons(true), DefaultButton_is_NO(false) {} 62 COverwriteDialog(): ShowExtraButtons(true), DefaultButton_is_NO(false) {}
63 63
64 INT_PTR Create(HWND parent = 0) 64 INT_PTR Create(HWND parent = NULL)
65 { 65 {
66 BIG_DIALOG_SIZE(280, 200); 66 BIG_DIALOG_SIZE(280, 200);
67 #ifdef UNDER_CE 67 #ifdef UNDER_CE
diff --git a/CPP/7zip/UI/FileManager/Panel.cpp b/CPP/7zip/UI/FileManager/Panel.cpp
index f7cdb5b..72b72c6 100644
--- a/CPP/7zip/UI/FileManager/Panel.cpp
+++ b/CPP/7zip/UI/FileManager/Panel.cpp
@@ -2,8 +2,7 @@
2 2
3#include "StdAfx.h" 3#include "StdAfx.h"
4 4
5#include <WindowsX.h> 5#include <windowsx.h>
6// #include <stdio.h>
7 6
8#include "../../../Common/IntToString.h" 7#include "../../../Common/IntToString.h"
9#include "../../../Common/StringConvert.h" 8#include "../../../Common/StringConvert.h"
@@ -28,6 +27,7 @@
28#include "ExtractCallback.h" 27#include "ExtractCallback.h"
29#include "FSFolder.h" 28#include "FSFolder.h"
30#include "FormatUtils.h" 29#include "FormatUtils.h"
30#include "LangUtils.h"
31#include "Panel.h" 31#include "Panel.h"
32#include "RootFolder.h" 32#include "RootFolder.h"
33 33
@@ -65,8 +65,8 @@ CPanel::~CPanel()
65 65
66HWND CPanel::GetParent() const 66HWND CPanel::GetParent() const
67{ 67{
68 HWND h = CWindow2::GetParent(); 68 const HWND h = CWindow2::GetParent();
69 return (h == 0) ? _mainWindow : h; 69 return h ? h : _mainWindow;
70} 70}
71 71
72#define kClassName L"7-Zip::Panel" 72#define kClassName L"7-Zip::Panel"
@@ -101,12 +101,12 @@ HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
101 cfp = fs2us(cfpF); 101 cfp = fs2us(cfpF);
102 } 102 }
103 103
104 RINOK(BindToPath(cfp, arcFormat, openRes)); 104 RINOK(BindToPath(cfp, arcFormat, openRes))
105 105
106 if (needOpenArc && !openRes.ArchiveIsOpened) 106 if (needOpenArc && !openRes.ArchiveIsOpened)
107 return S_OK; 107 return S_OK;
108 108
109 if (!CreateEx(0, kClassName, 0, WS_CHILD | WS_VISIBLE, 109 if (!CreateEx(0, kClassName, NULL, WS_CHILD | WS_VISIBLE,
110 0, 0, _xSize, 260, 110 0, 0, _xSize, 260,
111 parentWindow, (HMENU)(UINT_PTR)id, g_hInstance)) 111 parentWindow, (HMENU)(UINT_PTR)id, g_hInstance))
112 return E_FAIL; 112 return E_FAIL;
@@ -318,6 +318,16 @@ LRESULT CMyComboBoxEdit::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
318 } 318 }
319 break; 319 break;
320 } 320 }
321 case 'W':
322 {
323 bool ctrl = IsKeyDown(VK_CONTROL);
324 if (ctrl)
325 {
326 PostMessage(g_HWND, WM_COMMAND, IDCLOSE, 0);
327 return 0;
328 }
329 break;
330 }
321 } 331 }
322 break; 332 break;
323 case WM_CHAR: 333 case WM_CHAR:
@@ -336,6 +346,40 @@ LRESULT CMyComboBoxEdit::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
336 return CallWindowProc(_origWindowProc, *this, message, wParam, lParam); 346 return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
337} 347}
338 348
349
350/*
351 REBARBANDINFO in vista (_WIN32_WINNT >= 0x0600) has additional fields
352 we want 2000/xp compatibility.
353 so we must use reduced structure, if we compile with (_WIN32_WINNT >= 0x0600)
354 Also there are additional fields, if (_WIN32_IE >= 0x0400).
355 but (_WIN32_IE >= 0x0400) is expected.
356 note:
357 in x64 (64-bit):
358 {
359 (108 == REBARBANDINFO_V6_SIZE)
360 (112 == sizeof(REBARBANDINFO) // for (_WIN32_WINNT < 0x0600)
361 (128 == sizeof(REBARBANDINFO) // for (_WIN32_WINNT >= 0x0600)
362 there is difference in sizes, because REBARBANDINFO size was
363 not aligned for 8-bytes in (_WIN32_WINNT < 0x0600).
364 We hope that WinVista+ support support both (108 and 112) sizes.
365 But does WinXP-x64 support (108 == REBARBANDINFO_V6_SIZE)?
366 {
367 96 LPARAM lParam;
368 104 UINT cxHeader;
369 #if (_WIN32_WINNT >= 0x0600)
370 108 RECT rcChevronLocation;
371 124 UINT uChevronState;
372 #endif
373 }
374*/
375
376#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600) && defined(REBARBANDINFOA_V6_SIZE)
377 #define my_compatib_REBARBANDINFO_size REBARBANDINFO_V6_SIZE
378#else
379 #define my_compatib_REBARBANDINFO_size sizeof(REBARBANDINFO)
380#endif
381
382
339bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) 383bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
340{ 384{
341 // _virtualMode = false; 385 // _virtualMode = false;
@@ -351,11 +395,11 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
351 style |= WS_CLIPCHILDREN; 395 style |= WS_CLIPCHILDREN;
352 style |= WS_CLIPSIBLINGS; 396 style |= WS_CLIPSIBLINGS;
353 397
354 const UInt32 kNumListModes = ARRAY_SIZE(kStyles); 398 const UInt32 kNumListModes = Z7_ARRAY_SIZE(kStyles);
355 if (_ListViewMode >= kNumListModes) 399 if (_listViewMode >= kNumListModes)
356 _ListViewMode = kNumListModes - 1; 400 _listViewMode = kNumListModes - 1;
357 401
358 style |= kStyles[_ListViewMode] 402 style |= kStyles[_listViewMode]
359 | WS_TABSTOP 403 | WS_TABSTOP
360 | LVS_EDITLABELS; 404 | LVS_EDITLABELS;
361 if (_mySelectMode) 405 if (_mySelectMode)
@@ -397,7 +441,7 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
397 icex.dwICC = ICC_BAR_CLASSES; 441 icex.dwICC = ICC_BAR_CLASSES;
398 InitCommonControlsEx(&icex); 442 InitCommonControlsEx(&icex);
399 443
400 TBBUTTON tbb [ ] = 444 const TBBUTTON tbb[] =
401 { 445 {
402 // {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0}, 446 // {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
403 {VIEW_PARENTFOLDER, kParentFolderID, TBSTATE_ENABLED, BTNS_BUTTON, { 0, 0 }, 0, 0 }, 447 {VIEW_PARENTFOLDER, kParentFolderID, TBSTATE_ENABLED, BTNS_BUTTON, { 0, 0 }, 0, 0 },
@@ -445,7 +489,7 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
445 _baseID + 2, 11, 489 _baseID + 2, 11,
446 (HINSTANCE)HINST_COMMCTRL, 490 (HINSTANCE)HINST_COMMCTRL,
447 IDB_VIEW_SMALL_COLOR, 491 IDB_VIEW_SMALL_COLOR,
448 (LPCTBBUTTON)&tbb, ARRAY_SIZE(tbb), 492 (LPCTBBUTTON)&tbb, Z7_ARRAY_SIZE(tbb),
449 0, 0, 0, 0, sizeof (TBBUTTON))); 493 0, 0, 0, 0, sizeof (TBBUTTON)));
450 494
451 #ifndef UNDER_CE 495 #ifndef UNDER_CE
@@ -464,7 +508,7 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
464 , NULL, 508 , NULL,
465 WS_BORDER | WS_VISIBLE |WS_CHILD | CBS_DROPDOWN | CBS_AUTOHSCROLL, 509 WS_BORDER | WS_VISIBLE |WS_CHILD | CBS_DROPDOWN | CBS_AUTOHSCROLL,
466 0, 0, 100, 520, 510 0, 0, 100, 520,
467 ((_headerReBar == 0) ? (HWND)*this : _headerToolBar), 511 (_headerReBar ? _headerToolBar : (HWND)*this),
468 (HMENU)(UINT_PTR)(_comboBoxID), 512 (HMENU)(UINT_PTR)(_comboBoxID),
469 g_hInstance, NULL); 513 g_hInstance, NULL);
470 #ifndef UNDER_CE 514 #ifndef UNDER_CE
@@ -513,20 +557,23 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
513 _headerToolBar.GetMaxSize(&size); 557 _headerToolBar.GetMaxSize(&size);
514 558
515 REBARBANDINFO rbBand; 559 REBARBANDINFO rbBand;
516 rbBand.cbSize = sizeof(REBARBANDINFO); // Required 560 memset(&rbBand, 0, sizeof(rbBand));
561 // rbBand.cbSize = sizeof(rbBand); // for debug
562 // rbBand.cbSize = REBARBANDINFO_V3_SIZE; // for debug
563 rbBand.cbSize = my_compatib_REBARBANDINFO_size;
517 rbBand.fMask = RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE; 564 rbBand.fMask = RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE;
518 rbBand.fStyle = RBBS_NOGRIPPER; 565 rbBand.fStyle = RBBS_NOGRIPPER;
519 rbBand.cxMinChild = size.cx; 566 rbBand.cxMinChild = (UINT)size.cx;
520 rbBand.cyMinChild = size.cy; 567 rbBand.cyMinChild = (UINT)size.cy;
521 rbBand.cyChild = size.cy; 568 rbBand.cyChild = (UINT)size.cy;
522 rbBand.cx = size.cx; 569 rbBand.cx = (UINT)size.cx;
523 rbBand.hwndChild = _headerToolBar; 570 rbBand.hwndChild = _headerToolBar;
524 _headerReBar.InsertBand(-1, &rbBand); 571 _headerReBar.InsertBand(-1, &rbBand);
525 572
526 RECT rc; 573 RECT rc;
527 ::GetWindowRect(_headerComboBox, &rc); 574 ::GetWindowRect(_headerComboBox, &rc);
528 rbBand.cxMinChild = 30; 575 rbBand.cxMinChild = 30;
529 rbBand.cyMinChild = rc.bottom - rc.top; 576 rbBand.cyMinChild = (UINT)(rc.bottom - rc.top);
530 rbBand.cx = 1000; 577 rbBand.cx = 1000;
531 rbBand.hwndChild = _headerComboBox; 578 rbBand.hwndChild = _headerComboBox;
532 _headerReBar.InsertBand(-1, &rbBand); 579 _headerReBar.InsertBand(-1, &rbBand);
@@ -562,7 +609,7 @@ void CPanel::OnDestroy()
562 609
563void CPanel::ChangeWindowSize(int xSize, int ySize) 610void CPanel::ChangeWindowSize(int xSize, int ySize)
564{ 611{
565 if ((HWND)*this == 0) 612 if (!(HWND)*this)
566 return; 613 return;
567 int kHeaderSize; 614 int kHeaderSize;
568 int kStatusBarSize; 615 int kStatusBarSize;
@@ -601,7 +648,7 @@ void CPanel::ChangeWindowSize(int xSize, int ySize)
601 648
602bool CPanel::OnSize(WPARAM /* wParam */, int xSize, int ySize) 649bool CPanel::OnSize(WPARAM /* wParam */, int xSize, int ySize)
603{ 650{
604 if ((HWND)*this == 0) 651 if (!(HWND)*this)
605 return true; 652 return true;
606 if (_headerReBar) 653 if (_headerReBar)
607 _headerReBar.Move(0, 0, xSize, 0); 654 _headerReBar.Move(0, 0, xSize, 0);
@@ -682,7 +729,7 @@ bool CPanel::OnNotify(UINT /* controlID */, LPNMHDR header, LRESULT &result)
682 return false; 729 return false;
683} 730}
684 731
685bool CPanel::OnCommand(int code, int itemID, LPARAM lParam, LRESULT &result) 732bool CPanel::OnCommand(unsigned code, unsigned itemID, LPARAM lParam, LRESULT &result)
686{ 733{
687 if (itemID == kParentFolderID) 734 if (itemID == kParentFolderID)
688 { 735 {
@@ -745,7 +792,7 @@ void CPanel::MessageBox_Error_2Lines_Message_HRESULT(LPCWSTR message, HRESULT er
745} 792}
746 793
747void CPanel::MessageBox_LastError(LPCWSTR caption) const 794void CPanel::MessageBox_LastError(LPCWSTR caption) const
748 { MessageBox_Error_HRESULT_Caption(::GetLastError(), caption); } 795 { MessageBox_Error_HRESULT_Caption(GetLastError_noZero_HRESULT(), caption); }
749 796
750void CPanel::MessageBox_LastError() const 797void CPanel::MessageBox_LastError() const
751 { MessageBox_LastError(L"7-Zip"); } 798 { MessageBox_LastError(L"7-Zip"); }
@@ -830,13 +877,13 @@ void CPanel::SetListViewMode(UInt32 index)
830{ 877{
831 if (index >= 4) 878 if (index >= 4)
832 return; 879 return;
833 _ListViewMode = index; 880 _listViewMode = index;
834 DWORD oldStyle = (DWORD)_listView.GetStyle(); 881 const LONG_PTR oldStyle = _listView.GetStyle();
835 DWORD newStyle = kStyles[index]; 882 const DWORD newStyle = kStyles[index];
836 883
837 // DWORD tickCount1 = GetTickCount(); 884 // DWORD tickCount1 = GetTickCount();
838 if ((oldStyle & LVS_TYPEMASK) != newStyle) 885 if ((oldStyle & LVS_TYPEMASK) != (LONG_PTR)newStyle)
839 _listView.SetStyle((oldStyle & ~LVS_TYPEMASK) | newStyle); 886 _listView.SetStyle((oldStyle & ~(LONG_PTR)(DWORD)LVS_TYPEMASK) | (LONG_PTR)newStyle);
840 // RefreshListCtrlSaveFocused(); 887 // RefreshListCtrlSaveFocused();
841 /* 888 /*
842 DWORD tickCount2 = GetTickCount(); 889 DWORD tickCount2 = GetTickCount();
@@ -879,33 +926,34 @@ void CPanel::Post_Refresh_StatusBar()
879 926
880void CPanel::AddToArchive() 927void CPanel::AddToArchive()
881{ 928{
882 CRecordVector<UInt32> indices;
883 GetOperatedItemIndices(indices);
884 if (!Is_IO_FS_Folder()) 929 if (!Is_IO_FS_Folder())
885 { 930 {
886 MessageBox_Error_UnsupportOperation(); 931 MessageBox_Error_UnsupportOperation();
887 return; 932 return;
888 } 933 }
934 CRecordVector<UInt32> indices;
935 Get_ItemIndices_Operated(indices);
889 if (indices.Size() == 0) 936 if (indices.Size() == 0)
890 { 937 {
891 MessageBox_Error_LangID(IDS_SELECT_FILES); 938 MessageBox_Error_LangID(IDS_SELECT_FILES);
892 return; 939 return;
893 } 940 }
894 UStringVector names; 941 UString destCurDirPrefix = GetFsPath();
895
896 const UString curPrefix = GetFsPath();
897 UString destCurDirPrefix = curPrefix;
898 if (IsFSDrivesFolder()) 942 if (IsFSDrivesFolder())
899 destCurDirPrefix = ROOT_FS_FOLDER; 943 destCurDirPrefix = ROOT_FS_FOLDER;
900 944 UStringVector names;
901 FOR_VECTOR (i, indices) 945 GetFilePaths(indices, names);
902 names.Add(curPrefix + GetItemRelPath2(indices[i])); 946 UString baseName;
903 947 const UString arcName = CreateArchiveName(names,
904 const UString arcName = CreateArchiveName(names); 948 false, // isHash
905 949 NULL, // CFileInfo *fi
906 HRESULT res = CompressFiles(destCurDirPrefix, arcName, L"", 950 baseName);
907 true, // addExtension 951 const HRESULT res = CompressFiles(destCurDirPrefix, arcName, L"",
908 names, false, true, false); 952 true, // addExtension
953 names,
954 false, // email
955 true, // showDialog
956 false); // waitFinish
909 if (res != S_OK) 957 if (res != S_OK)
910 { 958 {
911 if (destCurDirPrefix.Len() >= MAX_PATH) 959 if (destCurDirPrefix.Len() >= MAX_PATH)
@@ -931,26 +979,37 @@ static UString GetSubFolderNameForExtract2(const UString &arcPath)
931 return s; 979 return s;
932} 980}
933 981
934void CPanel::GetFilePaths(const CRecordVector<UInt32> &indices, UStringVector &paths, bool allowFolders) 982
983int CPanel::FindDir_InOperatedList(const CRecordVector<UInt32> &operatedIndices) const
935{ 984{
936 const UString prefix = GetFsPath(); 985 const bool *isDirVector = &_isDirVector.Front();
937 FOR_VECTOR (i, indices) 986 const UInt32 *indices = &operatedIndices.Front();
938 { 987 const unsigned numItems = operatedIndices.Size();
939 int index = indices[i]; 988 for (unsigned i = 0; i < numItems; i++)
940 if (!allowFolders && IsItem_Folder(index)) 989 if (isDirVector[indices[i]])
941 { 990 return (int)i;
942 paths.Clear(); 991 return -1;
943 break; 992}
944 } 993
945 paths.Add(prefix + GetItemRelPath2(index)); 994
946 } 995void CPanel::GetFilePaths(const CRecordVector<UInt32> &operatedIndices, UStringVector &paths) const
947 if (paths.Size() == 0) 996{
997 paths.ClearAndReserve(operatedIndices.Size());
998 UString path = GetFsPath();
999 const unsigned prefixLen = path.Len();
1000 const UInt32 *indices = &operatedIndices.Front();
1001 const unsigned numItems = operatedIndices.Size();
1002 // for (unsigned y = 0; y < 10000; y++, paths.Clear())
1003 for (unsigned i = 0; i < numItems; i++)
948 { 1004 {
949 MessageBox_Error_LangID(IDS_SELECT_FILES); 1005 path.DeleteFrom(prefixLen);
950 return; 1006 Add_ItemRelPath2_To_String(indices[i], path);
1007 // ODS_U(path)
1008 paths.AddInReserved(path);
951 } 1009 }
952} 1010}
953 1011
1012
954void CPanel::ExtractArchives() 1013void CPanel::ExtractArchives()
955{ 1014{
956 if (_parentFolders.Size() > 0) 1015 if (_parentFolders.Size() > 0)
@@ -959,12 +1018,14 @@ void CPanel::ExtractArchives()
959 return; 1018 return;
960 } 1019 }
961 CRecordVector<UInt32> indices; 1020 CRecordVector<UInt32> indices;
962 GetOperatedItemIndices(indices); 1021 Get_ItemIndices_Operated(indices);
1022 if (indices.IsEmpty() || FindDir_InOperatedList(indices) != -1)
1023 {
1024 MessageBox_Error_LangID(IDS_SELECT_FILES);
1025 return;
1026 }
963 UStringVector paths; 1027 UStringVector paths;
964 GetFilePaths(indices, paths); 1028 GetFilePaths(indices, paths);
965 if (paths.IsEmpty())
966 return;
967
968 UString outFolder = GetFsPath(); 1029 UString outFolder = GetFsPath();
969 if (indices.Size() == 1) 1030 if (indices.Size() == 1)
970 outFolder += GetSubFolderNameForExtract2(GetItemRelPath(indices[0])); 1031 outFolder += GetSubFolderNameForExtract2(GetItemRelPath(indices[0]));
@@ -976,8 +1037,8 @@ void CPanel::ExtractArchives()
976 ci.Load(); 1037 ci.Load();
977 1038
978 ::ExtractArchives(paths, outFolder 1039 ::ExtractArchives(paths, outFolder
979 , true // showDialog 1040 , true // showDialog
980 , false // elimDup 1041 , false // elimDup
981 , ci.WriteZone 1042 , ci.WriteZone
982 ); 1043 );
983} 1044}
@@ -1047,7 +1108,7 @@ static void AddSizePair(UInt32 langID, UInt64 value, UString &s)
1047void CPanel::TestArchives() 1108void CPanel::TestArchives()
1048{ 1109{
1049 CRecordVector<UInt32> indices; 1110 CRecordVector<UInt32> indices;
1050 GetOperatedIndicesSmart(indices); 1111 Get_ItemIndices_OperSmart(indices);
1051 CMyComPtr<IArchiveFolder> archiveFolder; 1112 CMyComPtr<IArchiveFolder> archiveFolder;
1052 _folder.QueryInterface(IID_IArchiveFolder, &archiveFolder); 1113 _folder.QueryInterface(IID_IArchiveFolder, &archiveFolder);
1053 if (archiveFolder) 1114 if (archiveFolder)
@@ -1086,7 +1147,7 @@ void CPanel::TestArchives()
1086 1147
1087 extracter.Indices = indices; 1148 extracter.Indices = indices;
1088 1149
1089 UString title = LangString(IDS_PROGRESS_TESTING); 1150 const UString title = LangString(IDS_PROGRESS_TESTING);
1090 1151
1091 extracter.ProgressDialog.CompressingMode = false; 1152 extracter.ProgressDialog.CompressingMode = false;
1092 extracter.ProgressDialog.MainWindow = GetParent(); 1153 extracter.ProgressDialog.MainWindow = GetParent();
@@ -1111,8 +1172,11 @@ void CPanel::TestArchives()
1111 return; 1172 return;
1112 } 1173 }
1113 UStringVector paths; 1174 UStringVector paths;
1114 GetFilePaths(indices, paths, true); 1175 GetFilePaths(indices, paths);
1115 if (paths.IsEmpty()) 1176 if (paths.IsEmpty())
1177 {
1178 MessageBox_Error_LangID(IDS_SELECT_FILES);
1116 return; 1179 return;
1180 }
1117 ::TestArchives(paths); 1181 ::TestArchives(paths);
1118} 1182}
diff --git a/CPP/7zip/UI/FileManager/Panel.h b/CPP/7zip/UI/FileManager/Panel.h
index 4755678..e512cad 100644
--- a/CPP/7zip/UI/FileManager/Panel.h
+++ b/CPP/7zip/UI/FileManager/Panel.h
@@ -1,11 +1,15 @@
1// Panel.h 1// Panel.h
2 2
3#ifndef __PANEL_H 3#ifndef ZIP7_INC_PANEL_H
4#define __PANEL_H 4#define ZIP7_INC_PANEL_H
5 5
6#include "../../../Common/MyWindows.h" 6#include "../../../Common/MyWindows.h"
7 7
8#if defined(__MINGW32__) || defined(__MINGW64__)
9#include <shlobj.h>
10#else
8#include <ShlObj.h> 11#include <ShlObj.h>
12#endif
9 13
10#include "../../../../C/Alloc.h" 14#include "../../../../C/Alloc.h"
11 15
@@ -47,7 +51,7 @@
47 51
48const int kParentFolderID = 100; 52const int kParentFolderID = 100;
49 53
50const int kParentIndex = -1; 54const unsigned kParentIndex = (unsigned)(int)-1;
51const UInt32 kParentIndex_UInt32 = (UInt32)(Int32)kParentIndex; 55const UInt32 kParentIndex_UInt32 = (UInt32)(Int32)kParentIndex;
52 56
53#if !defined(_WIN32) || defined(UNDER_CE) 57#if !defined(_WIN32) || defined(UNDER_CE)
@@ -56,7 +60,9 @@ const UInt32 kParentIndex_UInt32 = (UInt32)(Int32)kParentIndex;
56#define ROOT_FS_FOLDER L"C:\\" 60#define ROOT_FS_FOLDER L"C:\\"
57#endif 61#endif
58 62
59struct CPanelCallback 63Z7_PURE_INTERFACES_BEGIN
64
65DECLARE_INTERFACE(CPanelCallback)
60{ 66{
61 virtual void OnTab() = 0; 67 virtual void OnTab() = 0;
62 virtual void SetFocusToPath(unsigned index) = 0; 68 virtual void SetFocusToPath(unsigned index) = 0;
@@ -68,6 +74,7 @@ struct CPanelCallback
68 virtual void DragEnd() = 0; 74 virtual void DragEnd() = 0;
69 virtual void RefreshTitle(bool always) = 0; 75 virtual void RefreshTitle(bool always) = 0;
70}; 76};
77Z7_PURE_INTERFACES_END
71 78
72void PanelCopyItems(); 79void PanelCopyItems();
73 80
@@ -116,7 +123,7 @@ public:
116 { 123 {
117 FOR_VECTOR (i, (*this)) 124 FOR_VECTOR (i, (*this))
118 if ((*this)[i].ID == id) 125 if ((*this)[i].ID == id)
119 return i; 126 return (int)i;
120 return -1; 127 return -1;
121 } 128 }
122 129
@@ -194,11 +201,15 @@ UString GetFolderPath(IFolderFolder *folder);
194 201
195class CPanel; 202class CPanel;
196 203
197class CMyListView: public NWindows::NControl::CListView2 204class CMyListView Z7_final: public NWindows::NControl::CListView2
198{ 205{
206 // ~CMyListView() ZIP7_eq_delete;
207 // CMyListView() ZIP7_eq_delete;
199public: 208public:
209 // CMyListView() {}
210 // ~CMyListView() Z7_DESTRUCTOR_override {} // change it
200 CPanel *_panel; 211 CPanel *_panel;
201 LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam); 212 LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam) Z7_override;
202}; 213};
203 214
204/* 215/*
@@ -223,10 +234,16 @@ struct CSelectedState
223 int FocusedItem; 234 int FocusedItem;
224 bool SelectFocused; 235 bool SelectFocused;
225 bool FocusedName_Defined; 236 bool FocusedName_Defined;
237 bool CalledFromTimer;
226 UString FocusedName; 238 UString FocusedName;
227 UStringVector SelectedNames; 239 UStringVector SelectedNames;
228 240
229 CSelectedState(): FocusedItem(-1), SelectFocused(true), FocusedName_Defined(false) {} 241 CSelectedState():
242 FocusedItem(-1),
243 SelectFocused(true),
244 FocusedName_Defined(false),
245 CalledFromTimer(false)
246 {}
230}; 247};
231 248
232#ifdef UNDER_CE 249#ifdef UNDER_CE
@@ -286,21 +303,21 @@ struct COpenResult
286 303
287 304
288 305
289class CPanel: public NWindows::NControl::CWindow2 306class CPanel Z7_final: public NWindows::NControl::CWindow2
290{ 307{
291 CExtToIconMap _extToIconMap; 308 CExtToIconMap _extToIconMap;
292 UINT _baseID; 309 UINT _baseID;
293 int _comboBoxID; 310 unsigned _comboBoxID;
294 UINT _statusBarID; 311 UINT _statusBarID;
295 312
296 CAppState *_appState; 313 CAppState *_appState;
297 314
298 bool OnCommand(int code, int itemID, LPARAM lParam, LRESULT &result); 315 virtual bool OnCommand(unsigned code, unsigned itemID, LPARAM lParam, LRESULT &result) Z7_override;
299 LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam); 316 virtual LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam) Z7_override;
300 virtual bool OnCreate(CREATESTRUCT *createStruct); 317 virtual bool OnCreate(CREATESTRUCT *createStruct) Z7_override;
301 virtual bool OnSize(WPARAM wParam, int xSize, int ySize); 318 virtual bool OnSize(WPARAM wParam, int xSize, int ySize) Z7_override;
302 virtual void OnDestroy(); 319 virtual void OnDestroy() Z7_override;
303 virtual bool OnNotify(UINT controlID, LPNMHDR lParam, LRESULT &result); 320 virtual bool OnNotify(UINT controlID, LPNMHDR lParam, LRESULT &result) Z7_override;
304 321
305 void AddComboBoxItem(const UString &name, int iconIndex, int indent, bool addToList); 322 void AddComboBoxItem(const UString &name, int iconIndex, int indent, bool addToList);
306 323
@@ -321,7 +338,7 @@ class CPanel: public NWindows::NControl::CWindow2
321 void OnItemChanged(NMLISTVIEW *item); 338 void OnItemChanged(NMLISTVIEW *item);
322 void OnNotifyActivateItems(); 339 void OnNotifyActivateItems();
323 bool OnNotifyList(LPNMHDR lParam, LRESULT &result); 340 bool OnNotifyList(LPNMHDR lParam, LRESULT &result);
324 void OnDrag(LPNMLISTVIEW nmListView); 341 void OnDrag(LPNMLISTVIEW nmListView, bool isRightButton = false);
325 bool OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result); 342 bool OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result);
326 BOOL OnBeginLabelEdit(LV_DISPINFOW * lpnmh); 343 BOOL OnBeginLabelEdit(LV_DISPINFOW * lpnmh);
327 BOOL OnEndLabelEdit(LV_DISPINFOW * lpnmh); 344 BOOL OnEndLabelEdit(LV_DISPINFOW * lpnmh);
@@ -437,19 +454,19 @@ public:
437 return (UInt32)item.lParam; 454 return (UInt32)item.lParam;
438 } 455 }
439 456
440 int GetRealItemIndex(int indexInListView) const 457 unsigned GetRealItemIndex(int indexInListView) const
441 { 458 {
442 /* 459 /*
443 if (_virtualMode) 460 if (_virtualMode)
444 return indexInListView; 461 return indexInListView;
445 */ 462 */
446 LPARAM param; 463 LPARAM param;
447 if (!_listView.GetItemParam(indexInListView, param)) 464 if (!_listView.GetItemParam((unsigned)indexInListView, param))
448 throw 1; 465 throw 1;
449 return (int)param; 466 return (unsigned)param;
450 } 467 }
451 468
452 UInt32 _ListViewMode; 469 UInt32 _listViewMode;
453 int _xSize; 470 int _xSize;
454 471
455 bool _flatMode; 472 bool _flatMode;
@@ -469,12 +486,19 @@ public:
469 NWindows::NDLL::CLibrary _library; 486 NWindows::NDLL::CLibrary _library;
470 487
471 CMyComPtr<IFolderFolder> _folder; 488 CMyComPtr<IFolderFolder> _folder;
489 CBoolVector _isDirVector;
472 CMyComPtr<IFolderCompare> _folderCompare; 490 CMyComPtr<IFolderCompare> _folderCompare;
473 CMyComPtr<IFolderGetItemName> _folderGetItemName; 491 CMyComPtr<IFolderGetItemName> _folderGetItemName;
474 CMyComPtr<IArchiveGetRawProps> _folderRawProps; 492 CMyComPtr<IArchiveGetRawProps> _folderRawProps;
475 CMyComPtr<IFolderAltStreams> _folderAltStreams; 493 CMyComPtr<IFolderAltStreams> _folderAltStreams;
476 CMyComPtr<IFolderOperations> _folderOperations; 494 CMyComPtr<IFolderOperations> _folderOperations;
477 495
496
497 // for drag and drop highliting
498 int m_DropHighlighted_SelectionIndex;
499 // int m_SubFolderIndex; // realIndex of item in m_Panel list (if drop cursor to that item)
500 UString m_DropHighlighted_SubFolderName; // name of folder in m_Panel list (if drop cursor to that folder)
501
478 void ReleaseFolder(); 502 void ReleaseFolder();
479 void SetNewFolder(IFolderFolder *newFolder); 503 void SetNewFolder(IFolderFolder *newFolder);
480 504
@@ -485,22 +509,28 @@ public:
485 void GetSelectedNames(UStringVector &selectedNames); 509 void GetSelectedNames(UStringVector &selectedNames);
486 void SaveSelectedState(CSelectedState &s); 510 void SaveSelectedState(CSelectedState &s);
487 HRESULT RefreshListCtrl(const CSelectedState &s); 511 HRESULT RefreshListCtrl(const CSelectedState &s);
488 HRESULT RefreshListCtrl_SaveFocused(); 512 HRESULT RefreshListCtrl_SaveFocused(bool onTimer = false);
513
514 // UInt32 GetItem_Attrib(UInt32 itemIndex) const;
489 515
490 bool GetItem_BoolProp(UInt32 itemIndex, PROPID propID) const; 516 bool GetItem_BoolProp(UInt32 itemIndex, PROPID propID) const;
491 bool IsItem_Deleted(int itemIndex) const; 517
492 bool IsItem_Folder(int itemIndex) const; 518 bool IsItem_Deleted(unsigned itemIndex) const;
493 bool IsItem_AltStream(int itemIndex) const; 519 bool IsItem_Folder(unsigned itemIndex) const;
494 520 bool IsItem_AltStream(unsigned itemIndex) const;
495 UString GetItemName(int itemIndex) const; 521
496 UString GetItemName_for_Copy(int itemIndex) const; 522 UString GetItemName(unsigned itemIndex) const;
497 void GetItemName(int itemIndex, UString &s) const; 523 UString GetItemName_for_Copy(unsigned itemIndex) const;
498 UString GetItemPrefix(int itemIndex) const; 524 void GetItemName(unsigned itemIndex, UString &s) const;
499 UString GetItemRelPath(int itemIndex) const; 525 UString GetItemPrefix(unsigned itemIndex) const;
500 UString GetItemRelPath2(int itemIndex) const; 526 UString GetItemRelPath(unsigned itemIndex) const;
501 UString GetItemFullPath(int itemIndex) const; 527 UString GetItemRelPath2(unsigned itemIndex) const;
502 UInt64 GetItem_UInt64Prop(int itemIndex, PROPID propID) const; 528
503 UInt64 GetItemSize(int itemIndex) const; 529 void Add_ItemRelPath2_To_String(unsigned itemIndex, UString &s) const;
530
531 UString GetItemFullPath(unsigned itemIndex) const;
532 UInt64 GetItem_UInt64Prop(unsigned itemIndex, PROPID propID) const;
533 UInt64 GetItemSize(unsigned itemIndex) const;
504 534
505 //////////////////////// 535 ////////////////////////
506 // PanelFolderChange.cpp 536 // PanelFolderChange.cpp
@@ -552,7 +582,7 @@ public:
552 _markDeletedItems(true), 582 _markDeletedItems(true),
553 PanelCreated(false), 583 PanelCreated(false),
554 584
555 _ListViewMode(3), 585 _listViewMode(3),
556 _xSize(300), 586 _xSize(300),
557 587
558 _flatMode(false), 588 _flatMode(false),
@@ -565,6 +595,8 @@ public:
565 595
566 _dontShowMode(false), 596 _dontShowMode(false),
567 597
598 m_DropHighlighted_SelectionIndex(-1),
599
568 _needSaveInfo(false), 600 _needSaveInfo(false),
569 _startGroupSelect(0), 601 _startGroupSelect(0),
570 _selectionIsDefined(false) 602 _selectionIsDefined(false)
@@ -572,7 +604,7 @@ public:
572 604
573 void SetExtendedStyle() 605 void SetExtendedStyle()
574 { 606 {
575 if (_listView != 0) 607 if (_listView)
576 _listView.SetExtendedListViewStyle(_exStyle); 608 _listView.SetExtendedListViewStyle(_exStyle);
577 } 609 }
578 610
@@ -592,30 +624,38 @@ public:
592 void SetSortRawStatus(); 624 void SetSortRawStatus();
593 625
594 void Release(); 626 void Release();
595 ~CPanel(); 627 ~CPanel() Z7_DESTRUCTOR_override;
596 void OnLeftClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActivate); 628 void OnLeftClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActivate);
597 bool OnRightClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActivate, LRESULT &result); 629 bool OnRightClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActivate, LRESULT &result);
598 void ShowColumnsContextMenu(int x, int y); 630 void ShowColumnsContextMenu(int x, int y);
599 631
600 void OnTimer(); 632 void OnTimer();
601 void OnReload(); 633 void OnReload(bool onTimer = false);
602 bool OnContextMenu(HANDLE windowHandle, int xPos, int yPos); 634 bool OnContextMenu(HANDLE windowHandle, int xPos, int yPos);
603 635
604 CMyComPtr<IContextMenu> _sevenZipContextMenu; 636 CMyComPtr<IContextMenu> _sevenZipContextMenu;
605 CMyComPtr<IContextMenu> _systemContextMenu; 637 CMyComPtr<IContextMenu> _systemContextMenu;
638
606 HRESULT CreateShellContextMenu( 639 HRESULT CreateShellContextMenu(
607 const CRecordVector<UInt32> &operatedIndices, 640 const CRecordVector<UInt32> &operatedIndices,
608 CMyComPtr<IContextMenu> &systemContextMenu); 641 CMyComPtr<IContextMenu> &systemContextMenu);
642
609 void CreateSystemMenu(HMENU menu, 643 void CreateSystemMenu(HMENU menu,
644 bool showExtendedVerbs,
610 const CRecordVector<UInt32> &operatedIndices, 645 const CRecordVector<UInt32> &operatedIndices,
611 CMyComPtr<IContextMenu> &systemContextMenu); 646 CMyComPtr<IContextMenu> &systemContextMenu);
647
612 void CreateSevenZipMenu(HMENU menu, 648 void CreateSevenZipMenu(HMENU menu,
649 bool showExtendedVerbs,
613 const CRecordVector<UInt32> &operatedIndices, 650 const CRecordVector<UInt32> &operatedIndices,
651 int firstDirIndex,
614 CMyComPtr<IContextMenu> &sevenZipContextMenu); 652 CMyComPtr<IContextMenu> &sevenZipContextMenu);
653
615 void CreateFileMenu(HMENU menu, 654 void CreateFileMenu(HMENU menu,
616 CMyComPtr<IContextMenu> &sevenZipContextMenu, 655 CMyComPtr<IContextMenu> &sevenZipContextMenu,
617 CMyComPtr<IContextMenu> &systemContextMenu, 656 CMyComPtr<IContextMenu> &systemContextMenu,
618 bool programMenu); 657 bool programMenu);
658
619 void CreateFileMenu(HMENU menu); 659 void CreateFileMenu(HMENU menu);
620 bool InvokePluginCommand(unsigned id); 660 bool InvokePluginCommand(unsigned id);
621 bool InvokePluginCommand(unsigned id, IContextMenu *sevenZipContextMenu, 661 bool InvokePluginCommand(unsigned id, IContextMenu *sevenZipContextMenu,
@@ -637,10 +677,10 @@ public:
637 // void SortItems(int index); 677 // void SortItems(int index);
638 void SortItemsWithPropID(PROPID propID); 678 void SortItemsWithPropID(PROPID propID);
639 679
640 void GetSelectedItemsIndices(CRecordVector<UInt32> &indices) const; 680 void Get_ItemIndices_Selected(CRecordVector<UInt32> &indices) const;
641 void GetOperatedItemIndices(CRecordVector<UInt32> &indices) const; 681 void Get_ItemIndices_Operated(CRecordVector<UInt32> &indices) const;
642 void GetAllItemIndices(CRecordVector<UInt32> &indices) const; 682 void Get_ItemIndices_All(CRecordVector<UInt32> &indices) const;
643 void GetOperatedIndicesSmart(CRecordVector<UInt32> &indices) const; 683 void Get_ItemIndices_OperSmart(CRecordVector<UInt32> &indices) const;
644 // void GetOperatedListViewIndices(CRecordVector<UInt32> &indices) const; 684 // void GetOperatedListViewIndices(CRecordVector<UInt32> &indices) const;
645 void KillSelection(); 685 void KillSelection();
646 686
@@ -712,12 +752,11 @@ public:
712 752
713 class CDisableTimerProcessing 753 class CDisableTimerProcessing
714 { 754 {
715 CLASS_NO_COPY(CDisableTimerProcessing); 755 Z7_CLASS_NO_COPY(CDisableTimerProcessing)
716 756
717 bool _processTimer; 757 bool _processTimer;
718
719 CPanel &_panel; 758 CPanel &_panel;
720 759
721 public: 760 public:
722 761
723 CDisableTimerProcessing(CPanel &panel): _panel(panel) { Disable(); } 762 CDisableTimerProcessing(CPanel &panel): _panel(panel) { Disable(); }
@@ -733,9 +772,38 @@ public:
733 } 772 }
734 }; 773 };
735 774
775 class CDisableTimerProcessing2
776 {
777 Z7_CLASS_NO_COPY(CDisableTimerProcessing2)
778
779 bool _processTimer;
780 CPanel *_panel;
781
782 public:
783
784 CDisableTimerProcessing2(CPanel *panel): _processTimer(true), _panel(panel) { Disable(); }
785 ~CDisableTimerProcessing2() { Restore(); }
786 void Disable()
787 {
788 if (_panel)
789 {
790 _processTimer = _panel->_processTimer;
791 _panel->_processTimer = false;
792 }
793 }
794 void Restore()
795 {
796 if (_panel)
797 {
798 _panel->_processTimer = _processTimer;
799 _panel = NULL;
800 }
801 }
802 };
803
736 class CDisableNotify 804 class CDisableNotify
737 { 805 {
738 CLASS_NO_COPY(CDisableNotify); 806 Z7_CLASS_NO_COPY(CDisableNotify)
739 807
740 bool _processNotify; 808 bool _processNotify;
741 bool _processStatusBar; 809 bool _processStatusBar;
@@ -789,9 +857,9 @@ public:
789 void OpenFocusedItemAsInternal(const wchar_t *type = NULL); 857 void OpenFocusedItemAsInternal(const wchar_t *type = NULL);
790 void OpenSelectedItems(bool internal); 858 void OpenSelectedItems(bool internal);
791 859
792 void OpenFolderExternal(int index); 860 void OpenFolderExternal(unsigned index);
793 861
794 void OpenFolder(int index); 862 void OpenFolder(unsigned index);
795 HRESULT OpenParentArchiveFolder(); 863 HRESULT OpenParentArchiveFolder();
796 864
797 HRESULT OpenAsArc(IInStream *inStream, 865 HRESULT OpenAsArc(IInStream *inStream,
@@ -810,26 +878,26 @@ public:
810 HRESULT OpenAsArc_Name(const UString &relPath, const UString &arcFormat 878 HRESULT OpenAsArc_Name(const UString &relPath, const UString &arcFormat
811 // , bool showErrorMessage 879 // , bool showErrorMessage
812 ); 880 );
813 HRESULT OpenAsArc_Index(int index, const wchar_t *type /* = NULL */ 881 HRESULT OpenAsArc_Index(unsigned index, const wchar_t *type /* = NULL */
814 // , bool showErrorMessage 882 // , bool showErrorMessage
815 ); 883 );
816 884
817 void OpenItemInArchive(int index, bool tryInternal, bool tryExternal, 885 void OpenItemInArchive(unsigned index, bool tryInternal, bool tryExternal,
818 bool editMode, bool useEditor, const wchar_t *type = NULL); 886 bool editMode, bool useEditor, const wchar_t *type = NULL);
819 887
820 HRESULT OnOpenItemChanged(UInt32 index, const wchar_t *fullFilePath, bool usePassword, const UString &password); 888 HRESULT OnOpenItemChanged(UInt32 index, const wchar_t *fullFilePath, bool usePassword, const UString &password);
821 LRESULT OnOpenItemChanged(LPARAM lParam); 889 LRESULT OnOpenItemChanged(LPARAM lParam);
822 890
823 bool IsVirus_Message(const UString &name); 891 bool IsVirus_Message(const UString &name);
824 void OpenItem(int index, bool tryInternal, bool tryExternal, const wchar_t *type = NULL); 892 void OpenItem(unsigned index, bool tryInternal, bool tryExternal, const wchar_t *type = NULL);
825 void EditItem(bool useEditor); 893 void EditItem(bool useEditor);
826 void EditItem(int index, bool useEditor); 894 void EditItem(unsigned index, bool useEditor);
827 895
828 void RenameFile(); 896 void RenameFile();
829 void ChangeComment(); 897 void ChangeComment();
830 898
831 void SetListViewMode(UInt32 index); 899 void SetListViewMode(UInt32 index);
832 UInt32 GetListViewMode() const { return _ListViewMode; } 900 UInt32 GetListViewMode() const { return _listViewMode; }
833 PROPID GetSortID() const { return _sortID; } 901 PROPID GetSortID() const { return _sortID; }
834 902
835 void ChangeFlatMode(); 903 void ChangeFlatMode();
@@ -848,16 +916,21 @@ public:
848 916
849 void AddToArchive(); 917 void AddToArchive();
850 918
851 void GetFilePaths(const CRecordVector<UInt32> &indices, UStringVector &paths, bool allowFolders = false); 919 int FindDir_InOperatedList(const CRecordVector<UInt32> &indices) const;
920 void GetFilePaths(const CRecordVector<UInt32> &indices, UStringVector &paths) const;
852 void ExtractArchives(); 921 void ExtractArchives();
853 void TestArchives(); 922 void TestArchives();
854 923
924
855 HRESULT CopyTo(CCopyToOptions &options, 925 HRESULT CopyTo(CCopyToOptions &options,
856 const CRecordVector<UInt32> &indices, 926 const CRecordVector<UInt32> &indices,
857 UStringVector *messages, 927 UStringVector *messages,
858 bool &usePassword, UString &password); 928 bool &usePassword, UString &password,
929 const UStringVector *filePaths = NULL);
859 930
860 HRESULT CopyTo(CCopyToOptions &options, const CRecordVector<UInt32> &indices, UStringVector *messages) 931 HRESULT CopyTo(CCopyToOptions &options,
932 const CRecordVector<UInt32> &indices,
933 UStringVector *messages)
861 { 934 {
862 bool usePassword = false; 935 bool usePassword = false;
863 UString password; 936 UString password;
@@ -870,17 +943,29 @@ public:
870 return CopyTo(options, indices, messages, usePassword, password); 943 return CopyTo(options, indices, messages, usePassword, password);
871 } 944 }
872 945
946 HRESULT CopyFsItems(CCopyToOptions &options,
947 const UStringVector &filePaths,
948 UStringVector *messages)
949 {
950 bool usePassword = false;
951 UString password;
952 CRecordVector<UInt32> indices;
953 return CopyTo(options, indices, messages, usePassword, password, &filePaths);
954 }
955
956
873 HRESULT CopyFrom(bool moveMode, const UString &folderPrefix, const UStringVector &filePaths, 957 HRESULT CopyFrom(bool moveMode, const UString &folderPrefix, const UStringVector &filePaths,
874 bool showErrorMessages, UStringVector *messages); 958 bool showErrorMessages, UStringVector *messages);
875 959
876 void CopyFromNoAsk(const UStringVector &filePaths); 960 void CopyFromNoAsk(bool moveMode, const UStringVector &filePaths);
877 void CopyFromAsk(const UStringVector &filePaths);
878
879 // empty folderPath means create new Archive to path of first fileName.
880 void DropObject(IDataObject * dataObject, const UString &folderPath);
881 961
882 // empty folderPath means create new Archive to path of first fileName. 962 void CompressDropFiles(
883 void CompressDropFiles(const UStringVector &fileNames, const UString &folderPath); 963 const UStringVector &filePaths,
964 const UString &folderPath,
965 bool createNewArchive,
966 bool moveMode,
967 UInt32 sourceFlags,
968 UInt32 &targetFlags);
884 969
885 void RefreshTitle(bool always = false) { _panelCallback->RefreshTitle(always); } 970 void RefreshTitle(bool always = false) { _panelCallback->RefreshTitle(always); }
886 void RefreshTitleAlways() { RefreshTitle(true); } 971 void RefreshTitleAlways() { RefreshTitle(true); }
@@ -892,14 +977,14 @@ class CMyBuffer
892{ 977{
893 void *_data; 978 void *_data;
894public: 979public:
895 CMyBuffer(): _data(0) {} 980 CMyBuffer(): _data(NULL) {}
896 operator void *() { return _data; } 981 operator void *() { return _data; }
897 bool Allocate(size_t size) 982 bool Allocate(size_t size)
898 { 983 {
899 if (_data != 0) 984 if (_data)
900 return false; 985 return false;
901 _data = ::MidAlloc(size); 986 _data = ::MidAlloc(size);
902 return _data != 0; 987 return _data != NULL;
903 } 988 }
904 ~CMyBuffer() { ::MidFree(_data); } 989 ~CMyBuffer() { ::MidFree(_data); }
905}; 990};
@@ -919,7 +1004,7 @@ public:
919 throw 9387173; 1004 throw 9387173;
920 _needExit = true; 1005 _needExit = true;
921 _numActiveThreads = 0; 1006 _numActiveThreads = 0;
922 }; 1007 }
923 1008
924 ~CExitEventLauncher() { Exit(true); } 1009 ~CExitEventLauncher() { Exit(true); }
925 1010
diff --git a/CPP/7zip/UI/FileManager/PanelCopy.cpp b/CPP/7zip/UI/FileManager/PanelCopy.cpp
index 2ea3e3b..de3d764 100644
--- a/CPP/7zip/UI/FileManager/PanelCopy.cpp
+++ b/CPP/7zip/UI/FileManager/PanelCopy.cpp
@@ -2,29 +2,29 @@
2 2
3#include "StdAfx.h" 3#include "StdAfx.h"
4 4
5#include "../../../Common/MyException.h"
6
7#include "../Common/ZipRegistry.h" 5#include "../Common/ZipRegistry.h"
8 6
9#include "../GUI/HashGUI.h" 7#include "../GUI/HashGUI.h"
10 8
9#include "FSFolder.h"
11#include "ExtractCallback.h" 10#include "ExtractCallback.h"
12#include "LangUtils.h" 11#include "LangUtils.h"
13#include "Panel.h" 12#include "Panel.h"
14#include "resource.h"
15#include "UpdateCallback100.h" 13#include "UpdateCallback100.h"
16 14
17using namespace NWindows; 15#include "resource.h"
16
18 17
19class CPanelCopyThread: public CProgressThreadVirt 18class CPanelCopyThread: public CProgressThreadVirt
20{ 19{
21 bool ResultsWereShown; 20 bool ResultsWereShown;
22 bool NeedShowRes; 21 bool NeedShowRes;
23 22
24 HRESULT ProcessVirt(); 23 HRESULT ProcessVirt() Z7_override;
25 virtual void ProcessWasFinished_GuiVirt(); 24 virtual void ProcessWasFinished_GuiVirt() Z7_override;
26public: 25public:
27 const CCopyToOptions *options; 26 const CCopyToOptions *options;
27 const UStringVector *CopyFrom_Paths;
28 CMyComPtr<IFolderOperations> FolderOperations; 28 CMyComPtr<IFolderOperations> FolderOperations;
29 CRecordVector<UInt32> Indices; 29 CRecordVector<UInt32> Indices;
30 CExtractCallbackImp *ExtractCallbackSpec; 30 CExtractCallbackImp *ExtractCallbackSpec;
@@ -39,7 +39,8 @@ public:
39 39
40 CPanelCopyThread(): 40 CPanelCopyThread():
41 ResultsWereShown(false), 41 ResultsWereShown(false),
42 NeedShowRes(false) 42 NeedShowRes(false),
43 CopyFrom_Paths(NULL)
43 // , Result2(E_FAIL) 44 // , Result2(E_FAIL)
44 {} 45 {}
45}; 46};
@@ -72,23 +73,32 @@ HRESULT CPanelCopyThread::ProcessVirt()
72 73
73 HRESULT result2; 74 HRESULT result2;
74 75
76 if (FolderOperations)
75 { 77 {
76 CMyComPtr<IFolderSetZoneIdMode> setZoneMode; 78 CMyComPtr<IFolderSetZoneIdMode> setZoneMode;
77 FolderOperations.QueryInterface(IID_IFolderSetZoneIdMode, &setZoneMode); 79 FolderOperations.QueryInterface(IID_IFolderSetZoneIdMode, &setZoneMode);
78 if (setZoneMode) 80 if (setZoneMode)
79 { 81 {
80 RINOK(setZoneMode->SetZoneIdMode(options->ZoneIdMode)); 82 RINOK(setZoneMode->SetZoneIdMode(options->ZoneIdMode))
81 } 83 }
82 } 84 }
83 85
84 if (options->testMode) 86 if (CopyFrom_Paths)
87 {
88 result2 = NFsFolder::CopyFileSystemItems(
89 *CopyFrom_Paths,
90 us2fs(options->folder),
91 options->moveMode,
92 (IFolderOperationsExtractCallback *)ExtractCallbackSpec);
93 }
94 else if (options->testMode)
85 { 95 {
86 CMyComPtr<IArchiveFolder> archiveFolder; 96 CMyComPtr<IArchiveFolder> archiveFolder;
87 FolderOperations.QueryInterface(IID_IArchiveFolder, &archiveFolder); 97 FolderOperations.QueryInterface(IID_IArchiveFolder, &archiveFolder);
88 if (!archiveFolder) 98 if (!archiveFolder)
89 return E_NOTIMPL; 99 return E_NOTIMPL;
90 CMyComPtr<IFolderArchiveExtractCallback> extractCallback2; 100 CMyComPtr<IFolderArchiveExtractCallback> extractCallback2;
91 RINOK(ExtractCallback.QueryInterface(IID_IFolderArchiveExtractCallback, &extractCallback2)); 101 RINOK(ExtractCallback.QueryInterface(IID_IFolderArchiveExtractCallback, &extractCallback2))
92 NExtract::NPathMode::EEnum pathMode = 102 NExtract::NPathMode::EEnum pathMode =
93 NExtract::NPathMode::kCurPaths; 103 NExtract::NPathMode::kCurPaths;
94 // NExtract::NPathMode::kFullPathnames; 104 // NExtract::NPathMode::kFullPathnames;
@@ -122,7 +132,7 @@ HRESULT CPanelCopyThread::ProcessVirt()
122 132
123 133
124/* 134/*
125#ifdef EXTERNAL_CODECS 135#ifdef Z7_EXTERNAL_CODECS
126 136
127static void ThrowException_if_Error(HRESULT res) 137static void ThrowException_if_Error(HRESULT res)
128{ 138{
@@ -133,9 +143,11 @@ static void ThrowException_if_Error(HRESULT res)
133#endif 143#endif
134*/ 144*/
135 145
136HRESULT CPanel::CopyTo(CCopyToOptions &options, const CRecordVector<UInt32> &indices, 146HRESULT CPanel::CopyTo(CCopyToOptions &options,
147 const CRecordVector<UInt32> &indices,
137 UStringVector *messages, 148 UStringVector *messages,
138 bool &usePassword, UString &password) 149 bool &usePassword, UString &password,
150 const UStringVector *filePaths)
139{ 151{
140 if (options.NeedRegistryZone && !options.testMode) 152 if (options.NeedRegistryZone && !options.testMode)
141 { 153 {
@@ -151,9 +163,10 @@ HRESULT CPanel::CopyTo(CCopyToOptions &options, const CRecordVector<UInt32> &ind
151 return E_NOTIMPL; 163 return E_NOTIMPL;
152 } 164 }
153 165
166 if (!filePaths)
154 if (!_folderOperations) 167 if (!_folderOperations)
155 { 168 {
156 UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED); 169 const UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED);
157 if (options.showErrorMessages) 170 if (options.showErrorMessages)
158 MessageBox_Error(errorMessage); 171 MessageBox_Error(errorMessage);
159 else if (messages) 172 else if (messages)
@@ -165,7 +178,7 @@ HRESULT CPanel::CopyTo(CCopyToOptions &options, const CRecordVector<UInt32> &ind
165 178
166 { 179 {
167 /* 180 /*
168 #ifdef EXTERNAL_CODECS 181 #ifdef Z7_EXTERNAL_CODECS
169 CExternalCodecs g_ExternalCodecs; 182 CExternalCodecs g_ExternalCodecs;
170 #endif 183 #endif
171 */ 184 */
@@ -203,7 +216,7 @@ HRESULT CPanel::CopyTo(CCopyToOptions &options, const CRecordVector<UInt32> &ind
203 But new code uses global codecs so we don't need to call LoadGlobalCodecs again */ 216 But new code uses global codecs so we don't need to call LoadGlobalCodecs again */
204 217
205 /* 218 /*
206 #ifdef EXTERNAL_CODECS 219 #ifdef Z7_EXTERNAL_CODECS
207 ThrowException_if_Error(LoadGlobalCodecs()); 220 ThrowException_if_Error(LoadGlobalCodecs());
208 #endif 221 #endif
209 */ 222 */
@@ -248,13 +261,18 @@ HRESULT CPanel::CopyTo(CCopyToOptions &options, const CRecordVector<UInt32> &ind
248 261
249 extracter.ExtractCallbackSpec->OverwriteMode = NExtract::NOverwriteMode::kAsk; 262 extracter.ExtractCallbackSpec->OverwriteMode = NExtract::NOverwriteMode::kAsk;
250 extracter.ExtractCallbackSpec->Init(); 263 extracter.ExtractCallbackSpec->Init();
251 extracter.Indices = indices; 264
252 extracter.FolderOperations = _folderOperations; 265 extracter.CopyFrom_Paths = filePaths;
266 if (!filePaths)
267 {
268 extracter.Indices = indices;
269 extracter.FolderOperations = _folderOperations;
270 }
253 271
254 extracter.ExtractCallbackSpec->PasswordIsDefined = usePassword; 272 extracter.ExtractCallbackSpec->PasswordIsDefined = usePassword;
255 extracter.ExtractCallbackSpec->Password = password; 273 extracter.ExtractCallbackSpec->Password = password;
256 274
257 RINOK(extracter.Create(title, GetParent())); 275 RINOK(extracter.Create(title, GetParent()))
258 276
259 277
260 if (messages) 278 if (messages)
@@ -335,8 +353,8 @@ HRESULT CPanel::CopyFrom(bool moveMode, const UString &folderPrefix, const UStri
335 353
336 updater.UpdateCallbackSpec->ProgressDialog = &updater.ProgressDialog; 354 updater.UpdateCallbackSpec->ProgressDialog = &updater.ProgressDialog;
337 355
338 UString title = LangString(IDS_COPYING); 356 const UString title = LangString(IDS_COPYING);
339 UString progressWindowTitle ("7-Zip"); // LangString(IDS_APP_TITLE); 357 const UString progressWindowTitle ("7-Zip"); // LangString(IDS_APP_TITLE);
340 358
341 updater.ProgressDialog.MainWindow = GetParent(); 359 updater.ProgressDialog.MainWindow = GetParent();
342 updater.ProgressDialog.MainTitle = progressWindowTitle; 360 updater.ProgressDialog.MainTitle = progressWindowTitle;
@@ -363,7 +381,9 @@ HRESULT CPanel::CopyFrom(bool moveMode, const UString &folderPrefix, const UStri
363 381
364 { 382 {
365 NWindows::CThread thread; 383 NWindows::CThread thread;
366 RINOK(thread.Create(CThreadUpdate::MyThreadFunction, &updater)); 384 const WRes wres = thread.Create(CThreadUpdate::MyThreadFunction, &updater);
385 if (wres != 0)
386 return HRESULT_FROM_WIN32(wres);
367 updater.ProgressDialog.Create(title, thread, GetParent()); 387 updater.ProgressDialog.Create(title, thread, GetParent());
368 } 388 }
369 389
@@ -375,7 +395,7 @@ HRESULT CPanel::CopyFrom(bool moveMode, const UString &folderPrefix, const UStri
375 395
376 if (res == E_NOINTERFACE) 396 if (res == E_NOINTERFACE)
377 { 397 {
378 UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED); 398 const UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED);
379 if (showErrorMessages) 399 if (showErrorMessages)
380 MessageBox_Error(errorMessage); 400 MessageBox_Error(errorMessage);
381 else if (messages) 401 else if (messages)
@@ -387,7 +407,7 @@ HRESULT CPanel::CopyFrom(bool moveMode, const UString &folderPrefix, const UStri
387 return res; 407 return res;
388} 408}
389 409
390void CPanel::CopyFromNoAsk(const UStringVector &filePaths) 410void CPanel::CopyFromNoAsk(bool moveMode, const UStringVector &filePaths)
391{ 411{
392 CDisableTimerProcessing disableTimerProcessing(*this); 412 CDisableTimerProcessing disableTimerProcessing(*this);
393 413
@@ -396,7 +416,7 @@ void CPanel::CopyFromNoAsk(const UStringVector &filePaths)
396 416
397 CDisableNotify disableNotify(*this); 417 CDisableNotify disableNotify(*this);
398 418
399 HRESULT result = CopyFrom(false, L"", filePaths, true, 0); 419 const HRESULT result = CopyFrom(moveMode, L"", filePaths, true, NULL);
400 420
401 if (result != S_OK) 421 if (result != S_OK)
402 { 422 {
@@ -413,17 +433,3 @@ void CPanel::CopyFromNoAsk(const UStringVector &filePaths)
413 disableNotify.Restore(); 433 disableNotify.Restore();
414 SetFocusToList(); 434 SetFocusToList();
415} 435}
416
417void CPanel::CopyFromAsk(const UStringVector &filePaths)
418{
419 UString title = LangString(IDS_CONFIRM_FILE_COPY);
420 UString message = LangString(IDS_WANT_TO_COPY_FILES);
421 message += "\n\'";
422 message += _currentFolderPrefix;
423 message += "\' ?";
424 int res = ::MessageBoxW(*(this), message, title, MB_YESNOCANCEL | MB_ICONQUESTION);
425 if (res != IDYES)
426 return;
427
428 CopyFromNoAsk(filePaths);
429}
diff --git a/CPP/7zip/UI/FileManager/PanelCrc.cpp b/CPP/7zip/UI/FileManager/PanelCrc.cpp
index 32948d8..df0b733 100644
--- a/CPP/7zip/UI/FileManager/PanelCrc.cpp
+++ b/CPP/7zip/UI/FileManager/PanelCrc.cpp
@@ -20,7 +20,7 @@
20using namespace NWindows; 20using namespace NWindows;
21using namespace NFile; 21using namespace NFile;
22 22
23#ifdef EXTERNAL_CODECS 23#ifdef Z7_EXTERNAL_CODECS
24extern CExternalCodecs g_ExternalCodecs; 24extern CExternalCodecs g_ExternalCodecs;
25HRESULT LoadGlobalCodecs(); 25HRESULT LoadGlobalCodecs();
26#endif 26#endif
@@ -38,7 +38,7 @@ struct CDirEnumerator
38 FStringVector Prefixes; 38 FStringVector Prefixes;
39 unsigned Index; 39 unsigned Index;
40 40
41 CDirEnumerator(): EnterToDirs(false), Index(0) {}; 41 CDirEnumerator(): EnterToDirs(false), Index(0) {}
42 42
43 void Init(); 43 void Init();
44 DWORD GetNextFile(NFind::CFileInfo &fi, bool &filled, FString &resPath); 44 DWORD GetNextFile(NFind::CFileInfo &fi, bool &filled, FString &resPath);
@@ -53,8 +53,8 @@ void CDirEnumerator::Init()
53 53
54static DWORD GetNormalizedError() 54static DWORD GetNormalizedError()
55{ 55{
56 DWORD error = GetLastError(); 56 const DWORD error = GetLastError();
57 return (error == 0) ? E_FAIL : error; 57 return (error == 0) ? (DWORD)E_FAIL : error;
58} 58}
59 59
60DWORD CDirEnumerator::GetNextFile(NFind::CFileInfo &fi, bool &filled, FString &resPath) 60DWORD CDirEnumerator::GetNextFile(NFind::CFileInfo &fi, bool &filled, FString &resPath)
@@ -73,9 +73,9 @@ DWORD CDirEnumerator::GetNextFile(NFind::CFileInfo &fi, bool &filled, FString &r
73 if (Index >= FilePaths.Size()) 73 if (Index >= FilePaths.Size())
74 return S_OK; 74 return S_OK;
75 const FString &path = FilePaths[Index++]; 75 const FString &path = FilePaths[Index++];
76 int pos = path.ReverseFind_PathSepar(); 76 const int pos = path.ReverseFind_PathSepar();
77 if (pos >= 0) 77 if (pos >= 0)
78 resPath.SetFrom(path, pos + 1); 78 resPath.SetFrom(path, (unsigned)pos + 1);
79 79
80 #if defined(_WIN32) && !defined(UNDER_CE) 80 #if defined(_WIN32) && !defined(UNDER_CE)
81 if (isRootPrefix && path.Len() == 2 && NName::IsDrivePath2(path)) 81 if (isRootPrefix && path.Len() == 2 && NName::IsDrivePath2(path))
@@ -90,7 +90,7 @@ DWORD CDirEnumerator::GetNextFile(NFind::CFileInfo &fi, bool &filled, FString &r
90 #endif 90 #endif
91 if (!fi.Find(BasePrefix + path)) 91 if (!fi.Find(BasePrefix + path))
92 { 92 {
93 DWORD error = GetNormalizedError(); 93 const DWORD error = GetNormalizedError();
94 resPath = path; 94 resPath = path;
95 return error; 95 return error;
96 } 96 }
@@ -110,7 +110,7 @@ DWORD CDirEnumerator::GetNextFile(NFind::CFileInfo &fi, bool &filled, FString &r
110 } 110 }
111 else 111 else
112 { 112 {
113 DWORD error = GetNormalizedError(); 113 const DWORD error = GetNormalizedError();
114 resPath = Prefixes.Back(); 114 resPath = Prefixes.Back();
115 Enumerators.DeleteBack(); 115 Enumerators.DeleteBack();
116 Prefixes.DeleteBack(); 116 Prefixes.DeleteBack();
@@ -142,8 +142,8 @@ class CThreadCrc: public CProgressThreadVirt
142 bool ResultsWereShown; 142 bool ResultsWereShown;
143 bool WasFinished; 143 bool WasFinished;
144 144
145 HRESULT ProcessVirt(); 145 HRESULT ProcessVirt() Z7_override;
146 virtual void ProcessWasFinished_GuiVirt(); 146 virtual void ProcessWasFinished_GuiVirt() Z7_override;
147public: 147public:
148 CDirEnumerator Enumerator; 148 CDirEnumerator Enumerator;
149 CHashBundle Hash; 149 CHashBundle Hash;
@@ -176,7 +176,7 @@ void CThreadCrc::ProcessWasFinished_GuiVirt()
176 176
177void CThreadCrc::AddErrorMessage(DWORD systemError, const FChar *name) 177void CThreadCrc::AddErrorMessage(DWORD systemError, const FChar *name)
178{ 178{
179 Sync.AddError_Code_Name(systemError, fs2us(Enumerator.BasePrefix + name)); 179 Sync.AddError_Code_Name(HRESULT_FROM_WIN32(systemError), fs2us(Enumerator.BasePrefix + name));
180 Hash.NumErrors++; 180 Hash.NumErrors++;
181} 181}
182 182
@@ -214,7 +214,7 @@ HRESULT CThreadCrc::ProcessVirt()
214 for (;;) 214 for (;;)
215 { 215 {
216 bool filled; 216 bool filled;
217 DWORD error = Enumerator.GetNextFile(fi, filled, path); 217 const DWORD error = Enumerator.GetNextFile(fi, filled, path);
218 if (error != 0) 218 if (error != 0)
219 { 219 {
220 AddErrorMessage(error, path); 220 AddErrorMessage(error, path);
@@ -246,10 +246,10 @@ HRESULT CThreadCrc::ProcessVirt()
246 */ 246 */
247 if (needPrint) 247 if (needPrint)
248 { 248 {
249 RINOK(sync.ScanProgress(numFiles, totalSize, path, fi.IsDir())); 249 RINOK(sync.ScanProgress(numFiles, totalSize, path, fi.IsDir()))
250 } 250 }
251 } 251 }
252 RINOK(sync.ScanProgress(numFiles, totalSize, FString(), false)); 252 RINOK(sync.ScanProgress(numFiles, totalSize, FString(), false))
253 // sync.SetNumFilesTotal(numFiles); 253 // sync.SetNumFilesTotal(numFiles);
254 // sync.SetProgress(totalSize, 0); 254 // sync.SetProgress(totalSize, 0);
255 // SetStatus(LangString(IDS_CHECKSUM_CALCULATING)); 255 // SetStatus(LangString(IDS_CHECKSUM_CALCULATING));
@@ -312,16 +312,16 @@ HRESULT CThreadCrc::ProcessVirt()
312 Hash.Update(buf, size); 312 Hash.Update(buf, size);
313 if (Hash.CurSize - progress_Prev >= ((UInt32)1 << 21)) 313 if (Hash.CurSize - progress_Prev >= ((UInt32)1 << 21))
314 { 314 {
315 RINOK(sync.Set_NumBytesCur(errorsFilesSize + Hash.FilesSize + Hash.CurSize)); 315 RINOK(sync.Set_NumBytesCur(errorsFilesSize + Hash.FilesSize + Hash.CurSize))
316 progress_Prev = Hash.CurSize; 316 progress_Prev = Hash.CurSize;
317 } 317 }
318 } 318 }
319 } 319 }
320 if (error == 0) 320 if (error == 0)
321 Hash.Final(fi.IsDir(), false, fs2us(path)); 321 Hash.Final(fi.IsDir(), false, fs2us(path));
322 RINOK(sync.Set_NumBytesCur(errorsFilesSize + Hash.FilesSize)); 322 RINOK(sync.Set_NumBytesCur(errorsFilesSize + Hash.FilesSize))
323 } 323 }
324 RINOK(sync.Set_NumBytesCur(errorsFilesSize + Hash.FilesSize)); 324 RINOK(sync.Set_NumBytesCur(errorsFilesSize + Hash.FilesSize))
325 sync.Set_NumFilesCur(Hash.NumFiles); 325 sync.Set_NumFilesCur(Hash.NumFiles);
326 if (Hash.NumFiles != 1) 326 if (Hash.NumFiles != 1)
327 sync.Set_FilePath(L""); 327 sync.Set_FilePath(L"");
@@ -341,7 +341,7 @@ HRESULT CApp::CalculateCrc2(const UString &methodName)
341 CPanel &srcPanel = Panels[srcPanelIndex]; 341 CPanel &srcPanel = Panels[srcPanelIndex];
342 342
343 CRecordVector<UInt32> indices; 343 CRecordVector<UInt32> indices;
344 srcPanel.GetOperatedIndicesSmart(indices); 344 srcPanel.Get_ItemIndices_OperSmart(indices);
345 if (indices.IsEmpty()) 345 if (indices.IsEmpty())
346 return S_OK; 346 return S_OK;
347 347
@@ -357,7 +357,7 @@ HRESULT CApp::CalculateCrc2(const UString &methodName)
357 return srcPanel.CopyTo(options, indices, &messages); 357 return srcPanel.CopyTo(options, indices, &messages);
358 } 358 }
359 359
360 #ifdef EXTERNAL_CODECS 360 #ifdef Z7_EXTERNAL_CODECS
361 361
362 LoadGlobalCodecs(); 362 LoadGlobalCodecs();
363 363
@@ -369,7 +369,7 @@ HRESULT CApp::CalculateCrc2(const UString &methodName)
369 { 369 {
370 UStringVector methods; 370 UStringVector methods;
371 methods.Add(methodName); 371 methods.Add(methodName);
372 RINOK(t.Hash.SetMethods(EXTERNAL_CODECS_VARS_G methods)); 372 RINOK(t.Hash.SetMethods(EXTERNAL_CODECS_VARS_G methods))
373 } 373 }
374 374
375 FOR_VECTOR (i, indices) 375 FOR_VECTOR (i, indices)
@@ -382,7 +382,7 @@ HRESULT CApp::CalculateCrc2(const UString &methodName)
382 UString basePrefix2 = basePrefix; 382 UString basePrefix2 = basePrefix;
383 if (basePrefix2.Back() == ':') 383 if (basePrefix2.Back() == ':')
384 { 384 {
385 int pos = basePrefix2.ReverseFind_PathSepar(); 385 const int pos = basePrefix2.ReverseFind_PathSepar();
386 if (pos >= 0) 386 if (pos >= 0)
387 basePrefix2.DeleteFrom((unsigned)(pos + 1)); 387 basePrefix2.DeleteFrom((unsigned)(pos + 1));
388 } 388 }
@@ -394,14 +394,14 @@ HRESULT CApp::CalculateCrc2(const UString &methodName)
394 394
395 t.ShowCompressionInfo = false; 395 t.ShowCompressionInfo = false;
396 396
397 UString title = LangString(IDS_CHECKSUM_CALCULATING); 397 const UString title = LangString(IDS_CHECKSUM_CALCULATING);
398 398
399 t.MainWindow = _window; 399 t.MainWindow = _window;
400 t.MainTitle = "7-Zip"; // LangString(IDS_APP_TITLE); 400 t.MainTitle = "7-Zip"; // LangString(IDS_APP_TITLE);
401 t.MainAddTitle = title; 401 t.MainAddTitle = title;
402 t.MainAddTitle.Add_Space(); 402 t.MainAddTitle.Add_Space();
403 403
404 RINOK(t.Create(title, _window)); 404 RINOK(t.Create(title, _window))
405 405
406 t.ShowFinalResults(_window); 406 t.ShowFinalResults(_window);
407 } 407 }
diff --git a/CPP/7zip/UI/FileManager/PanelDrag.cpp b/CPP/7zip/UI/FileManager/PanelDrag.cpp
index af8799c..040444c 100644
--- a/CPP/7zip/UI/FileManager/PanelDrag.cpp
+++ b/CPP/7zip/UI/FileManager/PanelDrag.cpp
@@ -6,10 +6,15 @@
6#include <winuserm.h> 6#include <winuserm.h>
7#endif 7#endif
8 8
9#include "../../../../C/7zVersion.h"
10#include "../../../../C/CpuArch.h"
11
9#include "../../../Common/StringConvert.h" 12#include "../../../Common/StringConvert.h"
10#include "../../../Common/Wildcard.h" 13#include "../../../Common/Wildcard.h"
11 14
15#include "../../../Windows/COM.h"
12#include "../../../Windows/MemoryGlobal.h" 16#include "../../../Windows/MemoryGlobal.h"
17#include "../../../Windows/Menu.h"
13#include "../../../Windows/FileDir.h" 18#include "../../../Windows/FileDir.h"
14#include "../../../Windows/FileName.h" 19#include "../../../Windows/FileName.h"
15#include "../../../Windows/Shell.h" 20#include "../../../Windows/Shell.h"
@@ -22,6 +27,11 @@
22 27
23#include "App.h" 28#include "App.h"
24#include "EnumFormatEtc.h" 29#include "EnumFormatEtc.h"
30#include "FormatUtils.h"
31#include "LangUtils.h"
32
33#include "resource.h"
34#include "../Explorer/resource.h"
25 35
26using namespace NWindows; 36using namespace NWindows;
27using namespace NFile; 37using namespace NFile;
@@ -31,88 +41,1003 @@ using namespace NDir;
31extern bool g_IsNT; 41extern bool g_IsNT;
32#endif 42#endif
33 43
34#define kTempDirPrefix FTEXT("7zE") 44#define PRF(x)
45#define PRF_W(x)
46// #define PRF2(x)
47#define PRF3(x)
48#define PRF3_W(x)
49#define PRF4(x)
50// #define PRF4(x) OutputDebugStringA(x)
51// #define PRF4_W(x) OutputDebugStringW(x)
35 52
36static LPCTSTR const kSvenZipSetFolderFormat = TEXT("7-Zip::SetTargetFolder"); 53// #define SHOW_DEBUG_DRAG
37 54
38//////////////////////////////////////////////////////// 55#ifdef SHOW_DEBUG_DRAG
56
57#define PRF_(x) { x; }
58
59static void Print_Point(const char *name, DWORD keyState, const POINTL &pt, DWORD effect)
60{
61 AString s (name);
62 s += " x="; s.Add_UInt32((unsigned)pt.x);
63 s += " y="; s.Add_UInt32((unsigned)pt.y);
64 s += " k="; s.Add_UInt32(keyState);
65 s += " e="; s.Add_UInt32(effect);
66 PRF4(s);
67}
68
69#else
70
71#define PRF_(x)
72
73#endif
74
75
76#define kTempDirPrefix FTEXT("7zE")
77
78// all versions: k_Format_7zip_SetTargetFolder format to transfer folder path from target to source
79static LPCTSTR const k_Format_7zip_SetTargetFolder = TEXT("7-Zip::SetTargetFolder");
80// new v23 formats:
81static LPCTSTR const k_Format_7zip_SetTransfer = TEXT("7-Zip::SetTransfer");
82static LPCTSTR const k_Format_7zip_GetTransfer = TEXT("7-Zip::GetTransfer");
83
84/*
85 Win10: clipboard formats.
86 There are about 16K free ids (formats) per system that can be
87 registered with RegisterClipboardFormat() with different names.
88 Probably that 16K ids space is common for ids registering for both
89 formats: RegisterClipboardFormat(), and registered window classes:
90 RegisterClass(). But ids for window classes will be deleted from
91 the list after process finishing. And registered clipboard
92 formats probably will be deleted from the list only after reboot.
93*/
94
95// static bool const g_CreateArchive_for_Drag_from_7zip = false;
96// static bool const g_CreateArchive_for_Drag_from_Explorer = true;
97 // = false; // for debug
98
99/*
100How DoDragDrop() works:
101{
102 IDropSource::QueryContinueDrag() (keyState & MK_LBUTTON) != 0
103 IDropTarget::Enter()
104 IDropSource::GiveFeedback()
105 IDropTarget::DragOver()
106 IDropSource::GiveFeedback()
107
108 for()
109 {
110 IDropSource::QueryContinueDrag() (keyState & MK_LBUTTON) != 0
111 IDropTarget::DragOver() (keyState & MK_LBUTTON) != 0
112 IDropSource::GiveFeedback()
113 }
114
115 {
116 // DoDragDrop() in Win10 before calling // QueryContinueDrag()
117 // with (*(keyState & MK_LBUTTON) == 0) probably calls:
118 // 1) IDropTarget::DragOver() with same point values (x,y), but (keyState & MK_LBUTTON) != 0)
119 // 2) IDropSource::GiveFeedback().
120 // so DropSource can know exact GiveFeedback(effect) mode just before LBUTTON releasing.
121
122 if (IDropSource::QueryContinueDrag() for (keyState & MK_LBUTTON) == 0
123 returns DRAGDROP_S_DROP), it will call
124 IDropTarget::Drop()
125 }
126 or
127 {
128 IDropSource::QueryContinueDrag()
129 IDropTarget::DragLeave()
130 IDropSource::GiveFeedback(0)
131 }
132 or
133 {
134 if (IDropSource::QueryContinueDrag()
135 returns DRAGDROP_S_CANCEL)
136 IDropTarget::DragLeave()
137 }
138}
139*/
140
141
142// ---------- CDropTarget ----------
143
144static const UInt32 k_Struct_Id_SetTranfer = 2; // it's our selected id
145static const UInt32 k_Struct_Id_GetTranfer = 3; // it's our selected id
146
147static const UInt64 k_Program_Id = 1; // "7-Zip"
148
149enum E_Program_ISA
150{
151 k_Program_ISA_x86 = 2,
152 k_Program_ISA_x64 = 3,
153 k_Program_ISA_armt = 4,
154 k_Program_ISA_arm64 = 5,
155 k_Program_ISA_arm32 = 6,
156 k_Program_ISA_ia64 = 9
157};
158
159#define k_Program_Ver ((MY_VER_MAJOR << 16) | MY_VER_MINOR)
160
161
162// k_SourceFlags_* are flags that are sent from Source to Target
163
164static const UInt32 k_SourceFlags_DoNotProcessInTarget = 1 << 1;
165/* Do not process in Target. Source will process operation instead of Target.
166 By default Target processes Drop opearation. */
167// static const UInt32 k_SourceFlags_ProcessInTarget = 1 << 2;
168
169static const UInt32 k_SourceFlags_DoNotWaitFinish = 1 << 3;
170static const UInt32 k_SourceFlags_WaitFinish = 1 << 4;
171/* usually Source needs WaitFinish, if temp files were created. */
172
173static const UInt32 k_SourceFlags_TempFiles = 1 << 6;
174static const UInt32 k_SourceFlags_NamesAreParent = 1 << 7;
175/* if returned path list for GetData(CF_HDROP) contains
176 path of parent temp folder instead of final paths of items
177 that will be extracted later from archive */
178
179static const UInt32 k_SourceFlags_SetTargetFolder = 1 << 8;
180/* SetData::("SetTargetFolder") was called (with empty or non-empty string) */
181
182static const UInt32 k_SourceFlags_SetTargetFolder_NonEmpty = 1 << 9;
183/* SetData::("SetTargetFolder") was called with non-empty string */
184
185static const UInt32 k_SourceFlags_NeedExtractOpToFs = 1 << 10;
186
187static const UInt32 k_SourceFlags_Copy_WasCalled = 1 << 11;
188
189static const UInt32 k_SourceFlags_LeftButton = 1 << 14;
190static const UInt32 k_SourceFlags_RightButton = 1 << 15;
191
192
193static const UInt32 k_TargetFlags_WasCanceled = 1 << 0;
194static const UInt32 k_TargetFlags_MustBeProcessedBySource = 1 << 1;
195static const UInt32 k_TargetFlags_WasProcessed = 1 << 2;
196static const UInt32 k_TargetFlags_DoNotWaitFinish = 1 << 3;
197static const UInt32 k_TargetFlags_WaitFinish = 1 << 4;
198static const UInt32 k_TargetFlags_MenuWasShown = 1 << 16;
199
200struct CDataObject_TransferBase
201{
202 UInt32 Struct_Id;
203 UInt32 Struct_Size;
204
205 UInt64 Program_Id;
206 UInt32 Program_Ver_Main;
207 UInt32 Program_Ver_Build;
208 UInt32 Program_ISA;
209 UInt32 Program_Flags;
210
211 UInt32 ProcessId;
212 UInt32 _reserved1[7];
213
214protected:
215 void Init_Program();
216};
217
218
219void CDataObject_TransferBase::Init_Program()
220{
221 Program_Id = k_Program_Id;
222 Program_ISA =
223 #if defined(MY_CPU_AMD64)
224 k_Program_ISA_x64
225 #elif defined(MY_CPU_X86)
226 k_Program_ISA_x86
227 #elif defined(MY_CPU_ARM64)
228 k_Program_ISA_arm64
229 #elif defined(MY_CPU_ARM32)
230 k_Program_ISA_arm32
231 #elif defined(MY_CPU_ARMT) || defined(MY_CPU_ARM)
232 k_Program_ISA_armt
233 #elif defined(MY_CPU_IA64)
234 k_Program_ISA_ia64
235 #else
236 0
237 #endif
238 ;
239 Program_Flags = sizeof(size_t);
240 Program_Ver_Main = k_Program_Ver;
241 // Program_Ver_Build = 0;
242 ProcessId = GetCurrentProcessId();
243}
244
245
246#if defined(__GNUC__) && !defined(__clang__)
247/* 'void* memset(void*, int, size_t)' clearing an object
248 of non-trivial type 'struct CDataObject_SetTransfer' */
249#pragma GCC diagnostic ignored "-Wclass-memaccess"
250#endif
251
252
253struct CDataObject_GetTransfer:
254public CDataObject_TransferBase
255{
256 UInt32 Flags;
257
258 UInt32 _reserved2[11];
259
260 CDataObject_GetTransfer()
261 {
262 memset(this, 0, sizeof(*this));
263 Init_Program();
264 Struct_Id = k_Struct_Id_GetTranfer;
265 Struct_Size = sizeof(*this);
266 }
267
268 bool Check() const
269 {
270 return Struct_Size >= sizeof(*this) && Struct_Id == k_Struct_Id_GetTranfer;
271 }
272};
273
274
275enum Enum_FolderType
276{
277 k_FolderType_None,
278 k_FolderType_Unknown = 1,
279 k_FolderType_Fs = 2,
280 k_FolderType_AltStreams = 3,
281 k_FolderType_Archive = 4
282};
283
284struct CTargetTransferInfo
285{
286 UInt32 Flags;
287 UInt32 FuncType;
288
289 UInt32 KeyState;
290 UInt32 OkEffects;
291 POINTL Point;
292
293 UInt32 Cmd_Effect;
294 UInt32 Cmd_Type;
295 UInt32 FolderType;
296 UInt32 _reserved3[3];
297
298 CTargetTransferInfo()
299 {
300 memset(this, 0, sizeof(*this));
301 }
302};
303
304struct CDataObject_SetTransfer:
305public CDataObject_TransferBase
306{
307 CTargetTransferInfo Target;
308
309 void Init()
310 {
311 memset(this, 0, sizeof(*this));
312 Init_Program();
313 Struct_Id = k_Struct_Id_SetTranfer;
314 Struct_Size = sizeof(*this);
315 }
316
317 bool Check() const
318 {
319 return Struct_Size >= sizeof(*this) && Struct_Id == k_Struct_Id_SetTranfer;
320 }
321};
322
323
324
325
326
327enum Enum_DragTargetMode
328{
329 k_DragTargetMode_None = 0,
330 k_DragTargetMode_Leave = 1,
331 k_DragTargetMode_Enter = 2,
332 k_DragTargetMode_Over = 3,
333 k_DragTargetMode_Drop_Begin = 4,
334 k_DragTargetMode_Drop_End = 5
335};
336
337
338// ---- menu ----
339
340namespace NDragMenu {
341
342enum Enum_CmdId
343{
344 k_None = 0,
345 k_Cancel = 1,
346 k_Copy_Base = 2, // to fs
347 k_Copy_ToArc = 3,
348 k_AddToArc = 4
349 /*
350 k_OpenArc = 8,
351 k_TestArc = 9,
352 k_ExtractFiles = 10,
353 k_ExtractHere = 11
354 */
355};
356
357struct CCmdLangPair
358{
359 unsigned CmdId_and_Flags;
360 unsigned LangId;
361};
362
363static const UInt32 k_MenuFlags_CmdMask = (1 << 7) - 1;
364static const UInt32 k_MenuFlag_Copy = 1 << 14;
365static const UInt32 k_MenuFlag_Move = 1 << 15;
366// #define IDS_CANCEL (IDCANCEL + 400)
367#define IDS_CANCEL 402
368
369static const CCmdLangPair g_Pairs[] =
370{
371 { k_Copy_Base | k_MenuFlag_Copy, IDS_COPY },
372 { k_Copy_Base | k_MenuFlag_Move, IDS_MOVE },
373 { k_Copy_ToArc | k_MenuFlag_Copy, IDS_COPY_TO },
374 // { k_Copy_ToArc | k_MenuFlag_Move, IDS_MOVE_TO }, // IDS_CONTEXT_COMPRESS_TO
375 // { k_OpenArc, IDS_CONTEXT_OPEN },
376 // { k_ExtractFiles, IDS_CONTEXT_EXTRACT },
377 // { k_ExtractHere, IDS_CONTEXT_EXTRACT_HERE },
378 // { k_TestArc, IDS_CONTEXT_TEST },
379 { k_AddToArc | k_MenuFlag_Copy, IDS_CONTEXT_COMPRESS },
380 { k_Cancel, IDS_CANCEL }
381};
382
383}
384
385
386class CDropTarget Z7_final:
387 public IDropTarget,
388 public CMyUnknownImp
389{
390 Z7_COM_UNKNOWN_IMP_1_MT(IDropTarget)
391 STDMETHOD(DragEnter)(IDataObject *dataObject, DWORD keyState, POINTL pt, DWORD *effect) Z7_override;
392 STDMETHOD(DragOver)(DWORD keyState, POINTL pt, DWORD *effect) Z7_override;
393 STDMETHOD(DragLeave)() Z7_override;
394 STDMETHOD(Drop)(IDataObject *dataObject, DWORD keyState, POINTL pt, DWORD *effect) Z7_override;
395
396 bool m_IsRightButton;
397 bool m_GetTransfer_WasSuccess;
398 bool m_DropIsAllowed; // = true, if data IDataObject can return CF_HDROP (so we can get list of paths)
399 bool m_PanelDropIsAllowed; // = false, if current target_panel is source_panel.
400 // check it only if m_DropIsAllowed == true
401 // we use it to show icon effect that drop is not allowed here.
402
403 CMyComPtr<IDataObject> m_DataObject; // we set it in DragEnter()
404 UStringVector m_SourcePaths;
405
406 // int m_DropHighlighted_SelectionIndex;
407 // int m_SubFolderIndex; // realIndex of item in m_Panel list (if drop cursor to that item)
408 // UString m_DropHighlighted_SubFolderName; // name of folder in m_Panel list (if drop cursor to that folder)
409
410 CPanel *m_Panel;
411 bool m_IsAppTarget; // true, if we want to drop to app window (not to panel)
412
413 bool m_TargetPath_WasSent_ToDataObject; // true, if TargetPath was sent
414 bool m_TargetPath_NonEmpty_WasSent_ToDataObject; // true, if non-empty TargetPath was sent
415 bool m_Transfer_WasSent_ToDataObject; // true, if Transfer was sent
416 UINT m_Format_7zip_SetTargetFolder;
417 UINT m_Format_7zip_SetTransfer;
418 UINT m_Format_7zip_GetTransfer;
419
420 UInt32 m_ProcessId; // for sending
421
422 bool IsItSameDrive() const;
423
424 // void Try_QueryGetData(IDataObject *dataObject);
425 void LoadNames_From_DataObject(IDataObject *dataObject);
426
427 UInt32 GetFolderType() const;
428 bool IsFsFolderPath() const;
429 DWORD GetEffect(DWORD keyState, POINTL pt, DWORD allowedEffect) const;
430 void RemoveSelection();
431 void PositionCursor(const POINTL &ptl);
432 UString GetTargetPath() const;
433 bool SendToSource_TargetPath_enable(IDataObject *dataObject, bool enablePath);
434 bool SendToSource_UInt32(IDataObject *dataObject, UINT format, UInt32 value);
435 bool SendToSource_TransferInfo(IDataObject *dataObject,
436 const CTargetTransferInfo &info);
437 void SendToSource_auto(IDataObject *dataObject,
438 const CTargetTransferInfo &info);
439 void SendToSource_Drag(CTargetTransferInfo &info)
440 {
441 SendToSource_auto(m_DataObject, info);
442 }
443
444 void ClearState();
445
446public:
447 CDropTarget();
448
449 CApp *App;
450 int SrcPanelIndex; // index of D&D source_panel
451 int TargetPanelIndex; // what panel to use as target_panel of Application
452};
453
454
455
456
457// ---------- CDataObject ----------
458
459/*
460 Some programs (like Sticky Notes in Win10) do not like
461 virtual non-existing items (files/dirs) in CF_HDROP format.
462 So we use two versions of CF_HDROP data:
463 m_hGlobal_HDROP_Pre : the list contains only destination path of temp directory.
464 That directory later will be filled with extracted items.
465 m_hGlobal_HDROP_Final : the list contains paths of all root items that
466 will be created in temp directory by archive extraction operation,
467 or the list of existing fs items, if source is filesystem directory.
468
469 The DRAWBACK: some programs (like Edge in Win10) can use names from IDataObject::GetData()
470 call that was called before IDropSource::QueryContinueDrag() where we set (UseFinalGlobal = true)
471 So such programs will use non-relevant m_hGlobal_HDROP_Pre item,
472 instead of m_hGlobal_HDROP_Final items.
473*/
39 474
40class CDataObject: 475class CDataObject Z7_final:
41 public IDataObject, 476 public IDataObject,
42 public CMyUnknownImp 477 public CMyUnknownImp
43{ 478{
479 Z7_COM_UNKNOWN_IMP_1_MT(IDataObject)
480
481 Z7_COMWF_B GetData(LPFORMATETC pformatetcIn, LPSTGMEDIUM medium) Z7_override;
482 Z7_COMWF_B GetDataHere(LPFORMATETC pformatetc, LPSTGMEDIUM medium) Z7_override;
483 Z7_COMWF_B QueryGetData(LPFORMATETC pformatetc) Z7_override;
484
485 Z7_COMWF_B GetCanonicalFormatEtc(LPFORMATETC /* pformatetc */, LPFORMATETC pformatetcOut) Z7_override
486 {
487 if (!pformatetcOut)
488 return E_INVALIDARG;
489 pformatetcOut->ptd = NULL;
490 return E_NOTIMPL;
491 }
492
493 Z7_COMWF_B SetData(LPFORMATETC etc, STGMEDIUM *medium, BOOL release) Z7_override;
494 Z7_COMWF_B EnumFormatEtc(DWORD drection, LPENUMFORMATETC *enumFormatEtc) Z7_override;
495
496 Z7_COMWF_B DAdvise(FORMATETC * /* etc */, DWORD /* advf */, LPADVISESINK /* pAdvSink */, DWORD * /* pdwConnection */) Z7_override
497 { return OLE_E_ADVISENOTSUPPORTED; }
498 Z7_COMWF_B DUnadvise(DWORD /* dwConnection */) Z7_override
499 { return OLE_E_ADVISENOTSUPPORTED; }
500 Z7_COMWF_B EnumDAdvise(LPENUMSTATDATA *ppenumAdvise) Z7_override
501 {
502 if (ppenumAdvise)
503 *ppenumAdvise = NULL;
504 return OLE_E_ADVISENOTSUPPORTED;
505 }
506
507 bool m_PerformedDropEffect_WasSet;
508 bool m_LogicalPerformedDropEffect_WasSet;
509 bool m_DestDirPrefix_FromTarget_WasSet;
510public:
511 bool m_Transfer_WasSet;
44private: 512private:
513 // GetData formats (source to target):
45 FORMATETC m_Etc; 514 FORMATETC m_Etc;
46 UINT m_SetFolderFormat; 515 // UINT m_Format_FileOpFlags;
516 // UINT m_Format_PreferredDropEffect;
517
518 // SetData() formats (target to source):
519 // 7-Zip's format:
520 UINT m_Format_7zip_SetTargetFolder;
521 UINT m_Format_7zip_SetTransfer;
522 UINT m_Format_7zip_GetTransfer; // for GetData()
523
524 UINT m_Format_PerformedDropEffect;
525 UINT m_Format_LogicalPerformedDropEffect;
526 UINT m_Format_DisableDragText;
527 UINT m_Format_IsShowingLayered;
528 UINT m_Format_IsShowingText;
529 UINT m_Format_DropDescription;
530 UINT m_Format_TargetCLSID;
531
532 DWORD m_PerformedDropEffect;
533 DWORD m_LogicalPerformedDropEffect;
534
535 void CopyFromPanelTo_Folder();
536 HRESULT SetData2(const FORMATETC *formatetc, const STGMEDIUM *medium);
47 537
48public: 538public:
49 MY_UNKNOWN_IMP1_MT(IDataObject) 539 bool IsRightButton;
540 bool IsTempFiles;
50 541
51 STDMETHODIMP GetData(LPFORMATETC pformatetcIn, LPSTGMEDIUM medium); 542 bool UsePreGlobal;
52 STDMETHODIMP GetDataHere(LPFORMATETC pformatetc, LPSTGMEDIUM medium); 543 bool DoNotProcessInTarget;
53 STDMETHODIMP QueryGetData(LPFORMATETC pformatetc );
54 544
55 STDMETHODIMP GetCanonicalFormatEtc ( LPFORMATETC /* pformatetc */, LPFORMATETC pformatetcOut) 545 bool NeedCall_Copy;
56 { pformatetcOut->ptd = NULL; return ResultFromScode(E_NOTIMPL); } 546 bool Copy_WasCalled;
57 547
58 STDMETHODIMP SetData(LPFORMATETC etc, STGMEDIUM *medium, BOOL release); 548 NMemory::CGlobal m_hGlobal_HDROP_Pre;
59 STDMETHODIMP EnumFormatEtc(DWORD drection, LPENUMFORMATETC *enumFormatEtc); 549 NMemory::CGlobal m_hGlobal_HDROP_Final;
550 // NMemory::CGlobal m_hGlobal_FileOpFlags;
551 // NMemory::CGlobal m_hGlobal_PreferredDropEffect;
60 552
61 STDMETHODIMP DAdvise(FORMATETC * /* etc */, DWORD /* advf */, LPADVISESINK /* pAdvSink */, DWORD * /* pdwConnection */) 553 CPanel *Panel;
62 { return OLE_E_ADVISENOTSUPPORTED; } 554 CRecordVector<UInt32> Indices;
63 STDMETHODIMP DUnadvise(DWORD /* dwConnection */) { return OLE_E_ADVISENOTSUPPORTED; }
64 STDMETHODIMP EnumDAdvise( LPENUMSTATDATA * /* ppenumAdvise */) { return OLE_E_ADVISENOTSUPPORTED; }
65 555
66 CDataObject(); 556 UString SrcDirPrefix_Temp; // FS directory with source files or Temp
557 UString DestDirPrefix_FromTarget;
558 /* destination Path that was sent by Target via SetData().
559 it can be altstreams prefix.
560 if (!DestDirPrefix_FromTarget.IsEmpty()) m_Panel->CompressDropFiles() was not called by Target.
561 So we must do drop actions in Source */
562 HRESULT Copy_HRESULT;
563 UStringVector Messages;
67 564
68 NMemory::CGlobal hGlobal; 565 CDataObject();
69 UString Path; 566public:
567 CDataObject_SetTransfer m_Transfer;
70}; 568};
71 569
570
571// for old mingw:
572#ifndef CFSTR_LOGICALPERFORMEDDROPEFFECT
573#define CFSTR_LOGICALPERFORMEDDROPEFFECT TEXT("Logical Performed DropEffect")
574#endif
575#ifndef CFSTR_TARGETCLSID
576#define CFSTR_TARGETCLSID TEXT("TargetCLSID") // HGLOBAL with a CLSID of the drop target
577#endif
578
579
580
72CDataObject::CDataObject() 581CDataObject::CDataObject()
73{ 582{
74 m_SetFolderFormat = RegisterClipboardFormat(kSvenZipSetFolderFormat); 583 // GetData formats (source to target):
584 // and we use CF_HDROP format to transfer file paths from source to target:
75 m_Etc.cfFormat = CF_HDROP; 585 m_Etc.cfFormat = CF_HDROP;
76 m_Etc.ptd = NULL; 586 m_Etc.ptd = NULL;
77 m_Etc.dwAspect = DVASPECT_CONTENT; 587 m_Etc.dwAspect = DVASPECT_CONTENT;
78 m_Etc.lindex = -1; 588 m_Etc.lindex = -1;
79 m_Etc.tymed = TYMED_HGLOBAL; 589 m_Etc.tymed = TYMED_HGLOBAL;
590
591 // m_Format_FileOpFlags = RegisterClipboardFormat(TEXT("FileOpFlags"));
592 // m_Format_PreferredDropEffect = RegisterClipboardFormat(CFSTR_PREFERREDDROPEFFECT); // "Preferred DropEffect"
593
594 // SetData() formats (target to source):
595 m_Format_7zip_SetTargetFolder = RegisterClipboardFormat(k_Format_7zip_SetTargetFolder);
596 m_Format_7zip_SetTransfer = RegisterClipboardFormat(k_Format_7zip_SetTransfer);
597 m_Format_7zip_GetTransfer = RegisterClipboardFormat(k_Format_7zip_GetTransfer);
598
599 m_Format_PerformedDropEffect = RegisterClipboardFormat(CFSTR_PERFORMEDDROPEFFECT); // "Performed DropEffect"
600 m_Format_LogicalPerformedDropEffect = RegisterClipboardFormat(CFSTR_LOGICALPERFORMEDDROPEFFECT); // "Logical Performed DropEffect"
601 m_Format_DisableDragText = RegisterClipboardFormat(TEXT("DisableDragText"));
602 m_Format_IsShowingLayered = RegisterClipboardFormat(TEXT("IsShowingLayered"));
603 m_Format_IsShowingText = RegisterClipboardFormat(TEXT("IsShowingText"));
604 m_Format_DropDescription = RegisterClipboardFormat(TEXT("DropDescription"));
605 m_Format_TargetCLSID = RegisterClipboardFormat(CFSTR_TARGETCLSID);
606
607 m_PerformedDropEffect = 0;
608 m_LogicalPerformedDropEffect = 0;
609
610 m_PerformedDropEffect_WasSet = false;
611 m_LogicalPerformedDropEffect_WasSet = false;
612
613 m_DestDirPrefix_FromTarget_WasSet = false;
614 m_Transfer_WasSet = false;
615
616 IsRightButton = false;
617 IsTempFiles = false;
618
619 UsePreGlobal = false;
620 DoNotProcessInTarget = false;
621
622 NeedCall_Copy = false;
623 Copy_WasCalled = false;
624
625 Copy_HRESULT = S_OK;
80} 626}
81 627
82STDMETHODIMP CDataObject::SetData(LPFORMATETC etc, STGMEDIUM *medium, BOOL /* release */) 628
629
630void CDataObject::CopyFromPanelTo_Folder()
83{ 631{
84 if (etc->cfFormat == m_SetFolderFormat 632 try
85 && etc->tymed == TYMED_HGLOBAL
86 && etc->dwAspect == DVASPECT_CONTENT
87 && medium->tymed == TYMED_HGLOBAL)
88 { 633 {
89 Path.Empty(); 634 CCopyToOptions options;
90 if (!medium->hGlobal) 635 options.folder = SrcDirPrefix_Temp;
91 return S_OK; 636 /* 15.13: fixed problem with mouse cursor for password window.
92 size_t size = GlobalSize(medium->hGlobal) / sizeof(wchar_t); 637 DoDragDrop() probably calls SetCapture() to some hidden window.
93 const wchar_t *src = (const wchar_t *)GlobalLock(medium->hGlobal); 638 But it's problem, if we show some modal window, like MessageBox.
94 if (src) 639 So we return capture to our window.
640 If you know better way to solve the problem, please notify 7-Zip developer.
641 */
642 // MessageBoxW(*Panel, L"test", L"test", 0);
643 /* HWND oldHwnd = */ SetCapture(*Panel);
644 Copy_WasCalled = true;
645 Copy_HRESULT = E_FAIL;
646 Copy_HRESULT = Panel->CopyTo(options, Indices, &Messages);
647 // do we need to restore capture?
648 // ReleaseCapture();
649 // oldHwnd = SetCapture(oldHwnd);
650 }
651 catch(...)
652 {
653 Copy_HRESULT = E_FAIL;
654 }
655}
656
657
658#ifdef SHOW_DEBUG_DRAG
659
660static void PrintFormat2(AString &s, unsigned format)
661{
662 s += " ";
663 s += "= format=";
664 s.Add_UInt32(format);
665 s += " ";
666 const int k_len = 512;
667 CHAR temp[k_len];
668 if (GetClipboardFormatNameA(format, temp, k_len) && strlen(temp) != 0)
669 s += temp;
670}
671
672static void PrintFormat(const char *title, unsigned format)
673{
674 AString s (title);
675 PrintFormat2(s, format);
676 PRF4(s);
677}
678
679static void PrintFormat_AndData(const char *title, unsigned format, const void *data, size_t size)
680{
681 AString s (title);
682 PrintFormat2(s, format);
683 s += " size=";
684 s.Add_UInt32((UInt32)size);
685 for (size_t i = 0; i < size && i < 16; i++)
686 {
687 s += " ";
688 s.Add_UInt32(((const Byte *)data)[i]);
689 }
690 PRF4(s);
691}
692
693static void PrintFormat_GUIDToStringW(const void *p)
694{
695 const GUID *guid = (const GUID *)p;
696 UString s;
697 const unsigned kSize = 48;
698 StringFromGUID2(*guid, s.GetBuf(kSize), kSize);
699 s.ReleaseBuf_CalcLen(kSize);
700 PRF3_W(s);
701}
702
703// Vista
704typedef enum
705{
706 MY_DROPIMAGE_INVALID = -1, // no image preference (use default)
707 MY_DROPIMAGE_NONE = 0, // red "no" circle
708 MY_DROPIMAGE_COPY = DROPEFFECT_COPY, // plus for copy
709 MY_DROPIMAGE_MOVE = DROPEFFECT_MOVE, // movement arrow for move
710 MY_DROPIMAGE_LINK = DROPEFFECT_LINK, // link arrow for link
711 MY_DROPIMAGE_LABEL = 6, // tag icon to indicate metadata will be changed
712 MY_DROPIMAGE_WARNING = 7, // yellow exclamation, something is amiss with the operation
713 MY_DROPIMAGE_NOIMAGE = 8 // no image at all
714} MY_DROPIMAGETYPE;
715
716typedef struct {
717 MY_DROPIMAGETYPE type;
718 WCHAR szMessage[MAX_PATH];
719 WCHAR szInsert[MAX_PATH];
720} MY_DROPDESCRIPTION;
721
722#endif
723
724
725/*
726IDataObject::SetData(LPFORMATETC etc, STGMEDIUM *medium, BOOL release)
727======================================================================
728
729 Main purpose of CDataObject is to transfer data from source to target
730 of drag and drop operation.
731 But also CDataObject can be used to transfer data in backward direction
732 from target to source (even if target and source are different processes).
733 There are some predefined Explorer's formats to transfer some data from target to source.
734 And 7-Zip uses 7-Zip's format k_Format_7zip_SetTargetFolder to transfer
735 destination directory path from target to source.
736
737 Our CDataObject::SetData() function here is used only to transfer data from target to source.
738 Usual source_to_target data is filled to m_hGlobal_* objects directly without SetData() calling.
739
740The main problem of SetData() is ownership of medium for (release == TRUE) case.
741
742SetData(,, release = TRUE) from different processes (DropSource and DropTarget)
743===============================================================================
744{
745 MS DOCs about (STGMEDIUM *medium) ownership:
746 The data object called does not take ownership of the data
747 until it has successfully received it and no error code is returned.
748
749 Each of processes (Source and Target) has own copy of medium allocated.
750 Windows code creates proxy IDataObject object in Target process to transferr
751 SetData() call between Target and Source processes via special proxies:
752 DropTarget ->
753 proxy_DataObject_in_Target ->
754 proxy_in_Source ->
755 DataObject_in_Source
756 when Target calls SetData() with proxy_DataObject_in_Target,
757 the system and proxy_in_Source
758 - allocates proxy-medium-in-Source process
759 - copies medium data from Target to that proxy-medium-in-Source
760 - sends proxy-medium-in-Source to DataObject_in_Source->SetData().
761
762 after returning from SetData() to Target process:
763 Win10 proxy_DataObject_in_Target releases original medium in Target process,
764 only if SetData() in Source returns S_OK. It's consistent with DOCs above.
765
766 for unsupported cfFormat:
767 [DropSource is 7-Zip 22.01 (old) : (etc->cfFormat != m_Format_7zip_SetTargetFolder && release == TRUE)]
768 (DropSource is WinRAR case):
769 Source doesn't release medium and returns error (for example, E_NOTIMPL)
770 {
771 Then Win10 proxy_in_Source also doesn't release proxy-medium-in-Source.
772 So there is memory leak in Source process.
773 Probably Win10 proxy_in_Source tries to avoid possible double releasing
774 that can be more fatal than memory leak.
775
776 Then Win10 proxy_DataObject_in_Target also doesn't release
777 original medium, that was allocated by DropTarget.
778 So if DropTarget also doesn't release medium, there is memory leak in
779 DropTarget process too.
780 DropTarget is Win10-Explorer probably doesn't release medium in that case.
781 }
782
783 [DropSource is 7-Zip 22.01 (old) : (etc->cfFormat == m_Format_7zip_SetTargetFolder && release == TRUE)]
784 DropSource returns S_OK and doesn't release medium:
785 {
786 then there is memory leak in DropSource process only.
787 }
788
789 (DropSource is 7-Zip v23 (new)):
790 (DropSource is Win10-Explorer case)
791 {
792 Win10-Explorer-DropSource probably always releases medium,
793 and then it always returns S_OK.
794 So Win10 proxy_DataObject_in_Target also releases
795 original medium, that was allocated by DropTarget.
796 So there is no memory leak in Source and Target processes.
797 }
798
799 if (DropTarget is Win10-Explorer)
800 {
801 Explorer Target uses SetData(,, (release = TRUE)) and
802 Explorer Target probably doesn't free memory after SetData(),
803 even if SetData(,, (release = TRUE)) returns E_NOTIMPL;
804 }
805
806 if (DropSource is Win10-Explorer)
807 {
808 (release == FALSE) doesn't work, and SetData() returns E_NOTIMPL;
809 (release == TRUE) works, and SetData() returns S_OK, and
810 it returns S_OK even for formats unsupported by Explorer.
811 }
812
813 To be more compatible with DOCs and Win10-Explorer and to avoid memory leaks,
814 we use the following scheme for our IDataObject::SetData(,, release == TRUE)
815 in DropSource code:
816 if (release == TRUE) { our SetData() always releases medium
817 with ReleaseStgMedium() and returns S_OK; }
818 The DRAWBACK of that scheme:
819 The caller always receives S_OK,
820 so the caller doesn't know about any error in SetData() in that case.
821
822for 7zip-Target to 7zip-Source calls:
823 we use (release == FALSE)
824 So we avoid (release == TRUE) memory leak problems,
825 and we can get real return code from SetData().
826
827for 7zip-Target to Explorer-Source calls:
828 we use (release == TRUE).
829 beacuse Explorer-Source doesn't accept (release == FALSE).
830}
831*/
832
833/*
834https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/shell/datascenarios.md
835CFSTR_PERFORMEDDROPEFFECT:
836 is used by the target to inform the data object through its
837 IDataObject::SetData method of the outcome of a data transfer.
838CFSTR_PREFERREDDROPEFFECT:
839 is used by the source to specify whether its preferred method of data transfer is move or copy.
840*/
841
842Z7_COMWF_B CDataObject::SetData(LPFORMATETC etc, STGMEDIUM *medium, BOOL release)
843{
844 try {
845 const HRESULT hres = SetData2(etc, medium);
846 // PrintFormat(release ? "SetData RELEASE=TRUE" : "SetData RELEASE=FALSE" , etc->cfFormat);
847 if (release)
848 {
849 /*
850 const DWORD tymed = medium->tymed;
851 IUnknown *pUnkForRelease = medium->pUnkForRelease;
852 */
853 // medium->tymed = NULL; // for debug
854 // return E_NOTIMPL; // for debug
855 ReleaseStgMedium(medium);
856 /* ReleaseStgMedium() will change STGMEDIUM::tymed to (TYMED_NULL = 0).
857 but we also can clear (medium.hGlobal = NULL),
858 to prevent some incorrect releasing, if the caller will try to release the data */
859 /*
860 if (medium->tymed == TYMED_NULL && tymed == TYMED_HGLOBAL && !pUnkForRelease)
861 medium->hGlobal = NULL;
862 */
863 // do we need return S_OK; for (tymed != TYMED_HGLOBAL) cases ?
864 /* we return S_OK here to shows that we take ownership of the data in (medium),
865 so the caller will not try to release (medium) */
866 return S_OK; // to be more compatible with Win10-Explorer and DOCs.
867 }
868 return hres;
869 } catch(...) { return E_FAIL; }
870}
871
872
873
874HRESULT CDataObject::SetData2(const FORMATETC *etc, const STGMEDIUM *medium)
875{
876 // PRF3("== CDataObject::SetData()");
877
878 HRESULT hres = S_OK;
879
880 if (etc->cfFormat == 0)
881 return DV_E_FORMATETC;
882 if (etc->tymed != TYMED_HGLOBAL)
883 return E_NOTIMPL; // DV_E_TYMED;
884 if (etc->dwAspect != DVASPECT_CONTENT)
885 return E_NOTIMPL; // DV_E_DVASPECT;
886 if (medium->tymed != TYMED_HGLOBAL)
887 return E_NOTIMPL; // DV_E_TYMED;
888
889 if (!medium->hGlobal)
890 return S_OK;
891
892 if (etc->cfFormat == m_Format_7zip_SetTargetFolder)
893 {
894 DestDirPrefix_FromTarget.Empty();
895 m_DestDirPrefix_FromTarget_WasSet = true;
896 }
897 else if (etc->cfFormat == m_Format_7zip_SetTransfer)
898 m_Transfer_WasSet = false;
899
900 const size_t size = GlobalSize(medium->hGlobal);
901 // GlobalLock() can return NULL, if memory block has a zero size
902 if (size == 0)
903 return S_OK;
904 const void *src = (const Byte *)GlobalLock(medium->hGlobal);
905 if (!src)
906 return E_FAIL;
907
908 PRF_(PrintFormat_AndData("SetData", etc->cfFormat, src, size))
909
910 if (etc->cfFormat == m_Format_7zip_SetTargetFolder)
911 {
912 /* this is our registered k_Format_7zip_SetTargetFolder format.
913 so it's call from 7-zip's CDropTarget */
914 /* 7-zip's CDropTarget calls SetData() for m_Format_7zip_SetTargetFolder
915 with (release == FALSE) */
916 const size_t num = size / sizeof(wchar_t);
917 if (size != num * sizeof(wchar_t))
918 return E_FAIL;
919 // if (num == 0) return S_OK;
920 // GlobalLock() can return NULL, if memory block has a zero-byte size
921 const wchar_t *s = (const wchar_t *)src;
922 UString &dest = DestDirPrefix_FromTarget;
923 for (size_t i = 0; i < num; i++)
924 {
925 const wchar_t c = s[i];
926 if (c == 0)
927 break;
928 dest += c;
929 }
930 // PRF_(PrintFormat_AndData("SetData", etc->cfFormat, src, size))
931 PRF3_W(DestDirPrefix_FromTarget);
932 }
933 else if (etc->cfFormat == m_Format_7zip_SetTransfer)
934 {
935 /* 7-zip's CDropTarget calls SetData() for m_Format_7zip_SetTransfer
936 with (release == FALSE) */
937 if (size < sizeof(CDataObject_SetTransfer))
938 return E_FAIL;
939 const CDataObject_SetTransfer *t = (const CDataObject_SetTransfer *)src;
940 if (!t->Check())
941 return E_FAIL;
942 m_Transfer = *t;
943 if (t->Target.FuncType != k_DragTargetMode_Leave)
944 m_Transfer_WasSet = true;
945 bool needProcessBySource = !DestDirPrefix_FromTarget.IsEmpty();
946 if (t->Target.FuncType == k_DragTargetMode_Drop_Begin)
947 {
948 if (t->Target.Cmd_Type != NDragMenu::k_Copy_Base
949 // || t->Target.Cmd_Effect != DROPEFFECT_COPY
950 )
951 needProcessBySource = false;
952 }
953 if (t->Target.FuncType == k_DragTargetMode_Drop_End)
95 { 954 {
96 for (size_t i = 0; i < size; i++) 955 if (t->Target.Flags & k_TargetFlags_MustBeProcessedBySource)
956 needProcessBySource = true;
957 else if (t->Target.Flags & k_TargetFlags_WasProcessed)
958 needProcessBySource = false;
959 }
960 DoNotProcessInTarget = needProcessBySource;
961 }
962 else
963 {
964 // SetData() from Explorer Target:
965 if (etc->cfFormat == m_Format_PerformedDropEffect)
966 {
967 m_PerformedDropEffect_WasSet = false;
968 if (size == sizeof(DWORD))
97 { 969 {
98 wchar_t c = src[i]; 970 m_PerformedDropEffect = *(const DWORD *)src;
99 if (c == 0) 971 m_PerformedDropEffect_WasSet = true;
100 break; 972 }
101 Path += c; 973 }
974 else if (etc->cfFormat == m_Format_LogicalPerformedDropEffect)
975 {
976 m_LogicalPerformedDropEffect_WasSet = false;
977 if (size == sizeof(DWORD))
978 {
979 m_LogicalPerformedDropEffect = *(const DWORD *)src;
980 m_LogicalPerformedDropEffect_WasSet = true;
102 } 981 }
103 GlobalUnlock(medium->hGlobal);
104 return S_OK;
105 } 982 }
983 else if (etc->cfFormat == m_Format_DropDescription)
984 {
985 // drop description contains only name of dest folder without full path
986 #ifdef SHOW_DEBUG_DRAG
987 if (size == sizeof(MY_DROPDESCRIPTION))
988 {
989 // const MY_DROPDESCRIPTION *s = (const MY_DROPDESCRIPTION *)src;
990 // PRF3_W(s->szMessage);
991 // PRF3_W(s->szInsert);
992 }
993 #endif
994 }
995 else if (etc->cfFormat == m_Format_TargetCLSID)
996 {
997 // it's called after call QueryContinueDrag() (keyState & MK_LBUTTON) == 0
998 // Shell File System Folder (explorer) guid: F3364BA0-65B9-11CE-A9BA-00AA004AE837
999 #ifdef SHOW_DEBUG_DRAG
1000 if (size == 16)
1001 {
1002 PrintFormat_GUIDToStringW((const Byte *)src);
1003 }
1004 #endif
1005 }
1006 else if (etc->cfFormat == m_Format_DisableDragText)
1007 {
1008 // (size == 4) (UInt32 value)
1009 // value==0 : if drag to folder item or folder
1010 // value==1 : if drag to file or non list_view */
1011 }
1012 else if (
1013 etc->cfFormat == m_Format_IsShowingLayered ||
1014 etc->cfFormat == m_Format_IsShowingText)
1015 {
1016 // (size == 4) (UInt32 value) value==0 :
1017 }
1018 else
1019 hres = DV_E_FORMATETC;
1020 // hres = E_NOTIMPL; // for debug
1021 // hres = DV_E_FORMATETC; // for debug
106 } 1022 }
107 return E_NOTIMPL; 1023
1024 GlobalUnlock(medium->hGlobal);
1025 return hres;
108} 1026}
109 1027
1028
1029
110static HGLOBAL DuplicateGlobalMem(HGLOBAL srcGlobal) 1030static HGLOBAL DuplicateGlobalMem(HGLOBAL srcGlobal)
111{ 1031{
112 SIZE_T size = GlobalSize(srcGlobal); 1032 /* GlobalSize() returns 0: If the specified handle
1033 is not valid or if the object has been discarded */
1034 const SIZE_T size = GlobalSize(srcGlobal);
1035 if (size == 0)
1036 return NULL;
1037 // GlobalLock() can return NULL, if memory block has a zero-byte size
113 const void *src = GlobalLock(srcGlobal); 1038 const void *src = GlobalLock(srcGlobal);
114 if (!src) 1039 if (!src)
115 return 0; 1040 return NULL;
116 HGLOBAL destGlobal = GlobalAlloc(GHND | GMEM_SHARE, size); 1041 HGLOBAL destGlobal = GlobalAlloc(GHND | GMEM_SHARE, size);
117 if (destGlobal) 1042 if (destGlobal)
118 { 1043 {
@@ -120,7 +1045,7 @@ static HGLOBAL DuplicateGlobalMem(HGLOBAL srcGlobal)
120 if (!dest) 1045 if (!dest)
121 { 1046 {
122 GlobalFree(destGlobal); 1047 GlobalFree(destGlobal);
123 destGlobal = 0; 1048 destGlobal = NULL;
124 } 1049 }
125 else 1050 else
126 { 1051 {
@@ -132,118 +1057,370 @@ static HGLOBAL DuplicateGlobalMem(HGLOBAL srcGlobal)
132 return destGlobal; 1057 return destGlobal;
133} 1058}
134 1059
135STDMETHODIMP CDataObject::GetData(LPFORMATETC etc, LPSTGMEDIUM medium) 1060
1061static bool Medium_CopyFrom(LPSTGMEDIUM medium, const void *data, size_t size)
136{ 1062{
137 RINOK(QueryGetData(etc)); 1063 medium->tymed = TYMED_NULL;
1064 medium->pUnkForRelease = NULL;
1065 medium->hGlobal = NULL;
1066 const HGLOBAL global = GlobalAlloc(GHND | GMEM_SHARE, size);
1067 if (!global)
1068 return false;
1069 void *dest = GlobalLock(global);
1070 if (!dest)
1071 {
1072 GlobalFree(global);
1073 return false;
1074 }
1075 memcpy(dest, data, size);
1076 GlobalUnlock(global);
1077 medium->hGlobal = global;
1078 medium->tymed = TYMED_HGLOBAL;
1079 return true;
1080}
1081
1082
1083Z7_COMWF_B CDataObject::GetData(LPFORMATETC etc, LPSTGMEDIUM medium)
1084{
1085 try {
1086 PRF_(PrintFormat("-- GetData", etc->cfFormat))
1087
1088 medium->tymed = TYMED_NULL;
1089 medium->pUnkForRelease = NULL;
1090 medium->hGlobal = NULL;
1091
1092 if (NeedCall_Copy && !Copy_WasCalled)
1093 CopyFromPanelTo_Folder();
1094
1095 // PRF3("+ CDataObject::GetData");
1096 // PrintFormat(etc->cfFormat);
1097 HGLOBAL global;
1098 RINOK(QueryGetData(etc))
1099
1100 /*
1101 if (etc->cfFormat == m_Format_FileOpFlags)
1102 global = m_hGlobal_FileOpFlags;
1103 else if (etc->cfFormat == m_Format_PreferredDropEffect)
1104 {
1105 // Explorer requests PreferredDropEffect only if Move/Copy selection is possible:
1106 // Shift is not pressed and Ctrl is not pressed
1107 PRF3("------ CDataObject::GetData() PreferredDropEffect");
1108 global = m_hGlobal_PreferredDropEffect;
1109 }
1110 else
1111 */
1112 if (etc->cfFormat == m_Etc.cfFormat) // CF_HDROP
1113 global = UsePreGlobal ? m_hGlobal_HDROP_Pre : m_hGlobal_HDROP_Final;
1114 else if (etc->cfFormat == m_Format_7zip_GetTransfer)
1115 {
1116 CDataObject_GetTransfer transfer;
1117 if (m_DestDirPrefix_FromTarget_WasSet)
1118 {
1119 transfer.Flags |= k_SourceFlags_SetTargetFolder;
1120 }
1121 if (!DestDirPrefix_FromTarget.IsEmpty())
1122 {
1123 transfer.Flags |= k_SourceFlags_SetTargetFolder_NonEmpty;
1124 }
1125 if (IsTempFiles)
1126 {
1127 transfer.Flags |= k_SourceFlags_TempFiles;
1128 transfer.Flags |= k_SourceFlags_WaitFinish;
1129 transfer.Flags |= k_SourceFlags_NeedExtractOpToFs;
1130 if (UsePreGlobal)
1131 transfer.Flags |= k_SourceFlags_NamesAreParent;
1132 }
1133 else
1134 transfer.Flags |= k_SourceFlags_DoNotWaitFinish;
1135
1136 if (IsRightButton)
1137 transfer.Flags |= k_SourceFlags_RightButton;
1138 else
1139 transfer.Flags |= k_SourceFlags_LeftButton;
1140
1141 if (DoNotProcessInTarget)
1142 transfer.Flags |= k_SourceFlags_DoNotProcessInTarget;
1143 if (Copy_WasCalled)
1144 transfer.Flags |= k_SourceFlags_Copy_WasCalled;
1145
1146 if (Medium_CopyFrom(medium, &transfer, sizeof(transfer)))
1147 return S_OK;
1148 return E_OUTOFMEMORY;
1149 }
1150 else
1151 return DV_E_FORMATETC;
1152
1153 if (!global)
1154 return DV_E_FORMATETC;
138 medium->tymed = m_Etc.tymed; 1155 medium->tymed = m_Etc.tymed;
139 medium->pUnkForRelease = 0; 1156 medium->hGlobal = DuplicateGlobalMem(global);
140 medium->hGlobal = DuplicateGlobalMem(hGlobal);
141 if (!medium->hGlobal) 1157 if (!medium->hGlobal)
142 return E_OUTOFMEMORY; 1158 return E_OUTOFMEMORY;
143 return S_OK; 1159 return S_OK;
1160 } catch(...) { return E_FAIL; }
144} 1161}
145 1162
146STDMETHODIMP CDataObject::GetDataHere(LPFORMATETC /* etc */, LPSTGMEDIUM /* medium */) 1163Z7_COMWF_B CDataObject::GetDataHere(LPFORMATETC /* etc */, LPSTGMEDIUM /* medium */)
147{ 1164{
1165 PRF3("CDataObject::GetDataHere()");
148 // Seems Windows doesn't call it, so we will not implement it. 1166 // Seems Windows doesn't call it, so we will not implement it.
149 return E_UNEXPECTED; 1167 return E_UNEXPECTED;
150} 1168}
151 1169
152 1170
153STDMETHODIMP CDataObject::QueryGetData(LPFORMATETC etc) 1171/*
1172 IDataObject::QueryGetData() Determines whether the data object is capable of
1173 rendering the data as specified. Objects attempting a paste or drop
1174 operation can call this method before calling IDataObject::GetData
1175 to get an indication of whether the operation may be successful.
1176
1177 The client of a data object calls QueryGetData to determine whether
1178 passing the specified FORMATETC structure to a subsequent call to
1179 IDataObject::GetData is likely to be successful.
1180
1181 we check Try_QueryGetData with CF_HDROP
1182*/
1183
1184Z7_COMWF_B CDataObject::QueryGetData(LPFORMATETC etc)
154{ 1185{
155 if ((m_Etc.tymed & etc->tymed) && 1186 PRF3("-- CDataObject::QueryGetData()");
156 m_Etc.cfFormat == etc->cfFormat && 1187 if ( etc->cfFormat == m_Etc.cfFormat // CF_HDROP
157 m_Etc.dwAspect == etc->dwAspect) 1188 || etc->cfFormat == m_Format_7zip_GetTransfer
158 return S_OK; 1189 // || (etc->cfFormat == m_Format_FileOpFlags && (HGLOBAL)m_hGlobal_FileOpFlags)
159 return DV_E_FORMATETC; 1190 // || (etc->cfFormat == m_Format_PreferredDropEffect && (HGLOBAL)m_hGlobal_PreferredDropEffect)
1191 )
1192 {
1193 }
1194 else
1195 return DV_E_FORMATETC;
1196 if (etc->dwAspect != m_Etc.dwAspect)
1197 return DV_E_DVASPECT;
1198 /* GetData(): It is possible to specify more than one medium by using the Boolean OR
1199 operator, allowing the method to choose the best medium among those specified. */
1200 if ((etc->tymed & m_Etc.tymed) == 0)
1201 return DV_E_TYMED;
1202 return S_OK;
160} 1203}
161 1204
162STDMETHODIMP CDataObject::EnumFormatEtc(DWORD direction, LPENUMFORMATETC FAR* enumFormatEtc) 1205Z7_COMWF_B CDataObject::EnumFormatEtc(DWORD direction, LPENUMFORMATETC FAR* enumFormatEtc)
163{ 1206{
1207 // we don't enumerate for DATADIR_SET. Seems it can work without it.
164 if (direction != DATADIR_GET) 1208 if (direction != DATADIR_GET)
165 return E_NOTIMPL; 1209 return E_NOTIMPL;
1210 // we don't enumerate for m_Format_FileOpFlags also. Seems it can work without it.
166 return CreateEnumFormatEtc(1, &m_Etc, enumFormatEtc); 1211 return CreateEnumFormatEtc(1, &m_Etc, enumFormatEtc);
167} 1212}
168 1213
1214
1215
169//////////////////////////////////////////////////////// 1216////////////////////////////////////////////////////////
170 1217
171class CDropSource: 1218class CDropSource Z7_final:
172 public IDropSource, 1219 public IDropSource,
173 public CMyUnknownImp 1220 public CMyUnknownImp
174{ 1221{
1222 Z7_COM_UNKNOWN_IMP_1_MT(IDropSource)
1223 STDMETHOD(QueryContinueDrag)(BOOL escapePressed, DWORD keyState) Z7_override;
1224 STDMETHOD(GiveFeedback)(DWORD effect) Z7_override;
1225
175 DWORD m_Effect; 1226 DWORD m_Effect;
176public: 1227public:
177 MY_UNKNOWN_IMP1_MT(IDropSource)
178 STDMETHOD(QueryContinueDrag)(BOOL escapePressed, DWORD keyState);
179 STDMETHOD(GiveFeedback)(DWORD effect);
180
181
182 bool NeedExtract;
183 CPanel *Panel;
184 CRecordVector<UInt32> Indices;
185 UString Folder;
186 CDataObject *DataObjectSpec; 1228 CDataObject *DataObjectSpec;
187 CMyComPtr<IDataObject> DataObject; 1229 CMyComPtr<IDataObject> DataObject;
188 1230
189 bool NeedPostCopy; 1231 HRESULT DragProcessing_HRESULT;
190 HRESULT Result; 1232 bool DragProcessing_WasFinished;
191 UStringVector Messages; 1233
192 1234 CDropSource():
193 CDropSource(): m_Effect(DROPEFFECT_NONE), Panel(NULL), NeedPostCopy(false), Result(S_OK) {} 1235 m_Effect(DROPEFFECT_NONE),
1236 // Panel(NULL),
1237 DragProcessing_HRESULT(S_OK),
1238 DragProcessing_WasFinished(false)
1239 {}
194}; 1240};
195 1241
196STDMETHODIMP CDropSource::QueryContinueDrag(BOOL escapePressed, DWORD keyState) 1242// static bool g_Debug = 0;
1243
1244
1245Z7_COMWF_B CDropSource::QueryContinueDrag(BOOL escapePressed, DWORD keyState)
197{ 1246{
198 if (escapePressed == TRUE) 1247 // try {
199 return DRAGDROP_S_CANCEL; 1248
1249 /* Determines whether a drag-and-drop operation should be continued, canceled, or completed.
1250 escapePressed : Indicates whether the Esc key has been pressed
1251 since the previous call to QueryContinueDrag
1252 or to DoDragDrop if this is the first call to QueryContinueDrag:
1253 TRUE : the end user has pressed the escape key;
1254 FALSE : it has not been pressed.
1255 keyState : The current state of the keyboard modifier keys on the keyboard.
1256 Possible values can be a combination of any of the flags:
1257 MK_CONTROL, MK_SHIFT, MK_ALT, MK_BUTTON, MK_LBUTTON, MK_MBUTTON, and MK_RBUTTON.
1258 */
1259 #ifdef SHOW_DEBUG_DRAG
1260 {
1261 AString s ("CDropSource::QueryContinueDrag()");
1262 s.Add_Space();
1263 s += "keystate=";
1264 s.Add_UInt32(keyState);
1265 PRF4(s);
1266 }
1267 #endif
1268
1269 /*
200 if ((keyState & MK_LBUTTON) == 0) 1270 if ((keyState & MK_LBUTTON) == 0)
201 { 1271 {
202 if (m_Effect == DROPEFFECT_NONE) 1272 // PRF4("CDropSource::QueryContinueDrag() (keyState & MK_LBUTTON) == 0");
203 return DRAGDROP_S_CANCEL; 1273 g_Debug = true;
204 Result = S_OK; 1274 }
205 bool needExtract = NeedExtract; 1275 else
206 // MoveMode = (((keyState & MK_SHIFT) != 0) && MoveIsAllowed); 1276 {
207 if (!DataObjectSpec->Path.IsEmpty()) 1277 // PRF4("CDropSource::QueryContinueDrag() (keyState & MK_LBUTTON) != 0");
208 { 1278 }
209 needExtract = false; 1279 */
210 NeedPostCopy = true;
211 }
212 if (needExtract)
213 {
214 CCopyToOptions options;
215 options.folder = Folder;
216 1280
217 // 15.13: fixed problem with mouse cursor for password window. 1281 if (escapePressed)
218 // DoDragDrop() probably calls SetCapture() to some hidden window. 1282 {
219 // But it's problem, if we show some modal window, like MessageBox. 1283 // The drag operation should be canceled with no drop operation occurring.
220 // So we return capture to our window. 1284 DragProcessing_WasFinished = true;
221 // If you know better way to solve the problem, please notify 7-Zip developer. 1285 DragProcessing_HRESULT = DRAGDROP_S_CANCEL;
222 1286 return DRAGDROP_S_CANCEL;
223 // MessageBoxW(*Panel, L"test", L"test", 0); 1287 }
224 1288
225 /* HWND oldHwnd = */ SetCapture(*Panel); 1289 if (DragProcessing_WasFinished)
1290 return DragProcessing_HRESULT;
226 1291
227 Result = Panel->CopyTo(options, Indices, &Messages); 1292 if ((keyState & MK_RBUTTON) != 0)
1293 {
1294 if (!DataObjectSpec->IsRightButton)
1295 {
1296 DragProcessing_WasFinished = true;
1297 DragProcessing_HRESULT = DRAGDROP_S_CANCEL;
1298 return DRAGDROP_S_CANCEL;
1299 }
1300 return S_OK;
1301 }
1302
1303 if ((keyState & MK_LBUTTON) != 0)
1304 {
1305 if (DataObjectSpec->IsRightButton)
1306 {
1307 DragProcessing_WasFinished = true;
1308 DragProcessing_HRESULT = DRAGDROP_S_CANCEL;
1309 return DRAGDROP_S_CANCEL;
1310 }
1311 /* The drag operation should continue. This result occurs if no errors are detected,
1312 the mouse button starting the drag-and-drop operation has not been released,
1313 and the Esc key has not been detected. */
1314 return S_OK;
1315 }
1316 {
1317 // the mouse button starting the drag-and-drop operation has been released.
1318
1319 /* Win10 probably calls DragOver()/GiveFeedback() just before LBUTTON releasing.
1320 so m_Effect is effect returned by DropTarget::DragOver()
1321 just before LBUTTON releasing.
1322 So here we can use Effect sent to last GiveFeedback() */
228 1323
229 // do we need to restore capture? 1324 if (m_Effect == DROPEFFECT_NONE)
230 // ReleaseCapture(); 1325 {
231 // oldHwnd = SetCapture(oldHwnd); 1326 DragProcessing_WasFinished = true;
1327 DragProcessing_HRESULT = DRAGDROP_S_CANCEL;
1328 // Drop target cannot accept the data. So we cancel drag and drop
1329 // maybe return DRAGDROP_S_DROP also OK here ?
1330 // return DRAGDROP_S_DROP; // for debug
1331 return DRAGDROP_S_CANCEL;
1332 }
232 1333
233 if (Result != S_OK || !Messages.IsEmpty()) 1334 // we switch to real names for items that will be created in temp folder
234 return DRAGDROP_S_CANCEL; 1335 DataObjectSpec->UsePreGlobal = false;
1336 DataObjectSpec->Copy_HRESULT = S_OK;
1337 // MoveMode = (((keyState & MK_SHIFT) != 0) && MoveIsAllowed);
1338 /*
1339 if (DataObjectSpec->IsRightButton)
1340 return DRAGDROP_S_DROP;
1341 */
1342
1343 if (DataObjectSpec->IsTempFiles)
1344 {
1345 if (!DataObjectSpec->DestDirPrefix_FromTarget.IsEmpty())
1346 {
1347 /* we know the destination Path.
1348 So we can copy or extract items later in Source with simpler code. */
1349 DataObjectSpec->DoNotProcessInTarget = true;
1350 // return DRAGDROP_S_CANCEL;
1351 }
1352 else
1353 {
1354 DataObjectSpec->NeedCall_Copy = true;
1355 /*
1356 if (Copy_HRESULT != S_OK || !Messages.IsEmpty())
1357 {
1358 DragProcessing_WasFinished = true;
1359 DragProcessing_HRESULT = DRAGDROP_S_CANCEL;
1360 return DRAGDROP_S_CANCEL;
1361 }
1362 */
1363 }
235 } 1364 }
1365 DragProcessing_HRESULT = DRAGDROP_S_DROP;
1366 DragProcessing_WasFinished = true;
236 return DRAGDROP_S_DROP; 1367 return DRAGDROP_S_DROP;
237 } 1368 }
238 return S_OK; 1369 // } catch(...) { return E_FAIL; }
239} 1370}
240 1371
241STDMETHODIMP CDropSource::GiveFeedback(DWORD effect) 1372
1373Z7_COMWF_B CDropSource::GiveFeedback(DWORD effect)
242{ 1374{
1375 // PRF3("CDropSource::GiveFeedback");
1376 /* Enables a source application to give visual feedback to the end user
1377 during a drag-and-drop operation by providing the DoDragDrop function
1378 with an enumeration value specifying the visual effect.
1379 in (effect):
1380 The DROPEFFECT value returned by the most recent call to
1381 IDropTarget::DragEnter,
1382 IDropTarget::DragOver,
1383 or DROPEFFECT_NONE after IDropTarget::DragLeave.
1384 0: DROPEFFECT_NONE
1385 1: DROPEFFECT_COPY
1386 2: DROPEFFECT_MOVE
1387 4: DROPEFFECT_LINK
1388 0x80000000: DROPEFFECT_SCROLL
1389 The dwEffect parameter can include DROPEFFECT_SCROLL, indicating that the
1390 source should put up the drag-scrolling variation of the appropriate pointer.
1391 */
243 m_Effect = effect; 1392 m_Effect = effect;
1393
1394 #ifdef SHOW_DEBUG_DRAG
1395 AString w ("GiveFeedback effect=");
1396 if (effect & DROPEFFECT_SCROLL)
1397 w += " SCROLL ";
1398 w.Add_UInt32(effect & ~DROPEFFECT_SCROLL);
1399 // if (g_Debug)
1400 PRF4(w);
1401 #endif
1402
1403 /* S_OK : no special drag and drop cursors.
1404 Maybe it's for case where we created custom custom cursors.
1405 DRAGDROP_S_USEDEFAULTCURSORS: Indicates successful completion of the method,
1406 and requests OLE to update the cursor using the OLE-provided default cursors. */
1407 // return S_OK; // for debug
244 return DRAGDROP_S_USEDEFAULTCURSORS; 1408 return DRAGDROP_S_USEDEFAULTCURSORS;
245} 1409}
246 1410
1411
1412
1413/*
1414static bool Global_SetUInt32(NMemory::CGlobal &hg, const UInt32 v)
1415{
1416 if (!hg.Alloc(GHND | GMEM_SHARE, sizeof(v)))
1417 return false;
1418 NMemory::CGlobalLock dropLock(hg);
1419 *(UInt32 *)dropLock.GetPointer() = v;
1420 return true;
1421}
1422*/
1423
247static bool CopyNamesToHGlobal(NMemory::CGlobal &hgDrop, const UStringVector &names) 1424static bool CopyNamesToHGlobal(NMemory::CGlobal &hgDrop, const UStringVector &names)
248{ 1425{
249 size_t totalLen = 1; 1426 size_t totalLen = 1;
@@ -255,14 +1432,14 @@ static bool CopyNamesToHGlobal(NMemory::CGlobal &hgDrop, const UStringVector &na
255 unsigned i; 1432 unsigned i;
256 for (i = 0; i < names.Size(); i++) 1433 for (i = 0; i < names.Size(); i++)
257 namesA.Add(GetSystemString(names[i])); 1434 namesA.Add(GetSystemString(names[i]));
258 for (i = 0; i < names.Size(); i++) 1435 for (i = 0; i < namesA.Size(); i++)
259 totalLen += namesA[i].Len() + 1; 1436 totalLen += namesA[i].Len() + 1;
260 1437
261 if (!hgDrop.Alloc(GHND | GMEM_SHARE, totalLen * sizeof(CHAR) + sizeof(DROPFILES))) 1438 if (!hgDrop.Alloc(GHND | GMEM_SHARE, totalLen * sizeof(CHAR) + sizeof(DROPFILES)))
262 return false; 1439 return false;
263 1440
264 NMemory::CGlobalLock dropLock(hgDrop); 1441 NMemory::CGlobalLock dropLock(hgDrop);
265 DROPFILES* dropFiles = (DROPFILES*)dropLock.GetPointer(); 1442 DROPFILES *dropFiles = (DROPFILES *)dropLock.GetPointer();
266 if (!dropFiles) 1443 if (!dropFiles)
267 return false; 1444 return false;
268 dropFiles->fNC = FALSE; 1445 dropFiles->fNC = FALSE;
@@ -270,11 +1447,11 @@ static bool CopyNamesToHGlobal(NMemory::CGlobal &hgDrop, const UStringVector &na
270 dropFiles->pt.y = 0; 1447 dropFiles->pt.y = 0;
271 dropFiles->pFiles = sizeof(DROPFILES); 1448 dropFiles->pFiles = sizeof(DROPFILES);
272 dropFiles->fWide = FALSE; 1449 dropFiles->fWide = FALSE;
273 CHAR *p = (CHAR *)((BYTE *)dropFiles + sizeof(DROPFILES)); 1450 CHAR *p = (CHAR *) (void *) ((BYTE *)dropFiles + sizeof(DROPFILES));
274 for (i = 0; i < names.Size(); i++) 1451 for (i = 0; i < namesA.Size(); i++)
275 { 1452 {
276 const AString &s = namesA[i]; 1453 const AString &s = namesA[i];
277 unsigned fullLen = s.Len() + 1; 1454 const unsigned fullLen = s.Len() + 1;
278 MyStringCopy(p, (const char *)s); 1455 MyStringCopy(p, (const char *)s);
279 p += fullLen; 1456 p += fullLen;
280 totalLen -= fullLen; 1457 totalLen -= fullLen;
@@ -292,9 +1469,13 @@ static bool CopyNamesToHGlobal(NMemory::CGlobal &hgDrop, const UStringVector &na
292 return false; 1469 return false;
293 1470
294 NMemory::CGlobalLock dropLock(hgDrop); 1471 NMemory::CGlobalLock dropLock(hgDrop);
295 DROPFILES* dropFiles = (DROPFILES*)dropLock.GetPointer(); 1472 DROPFILES *dropFiles = (DROPFILES *)dropLock.GetPointer();
296 if (!dropFiles) 1473 if (!dropFiles)
297 return false; 1474 return false;
1475 /* fNC:
1476 TRUE : pt specifies the screen coordinates of a point in a window's nonclient area.
1477 FALSE : pt specifies the client coordinates of a point in the client area.
1478 */
298 dropFiles->fNC = FALSE; 1479 dropFiles->fNC = FALSE;
299 dropFiles->pt.x = 0; 1480 dropFiles->pt.x = 0;
300 dropFiles->pt.y = 0; 1481 dropFiles->pt.y = 0;
@@ -304,38 +1485,74 @@ static bool CopyNamesToHGlobal(NMemory::CGlobal &hgDrop, const UStringVector &na
304 for (i = 0; i < names.Size(); i++) 1485 for (i = 0; i < names.Size(); i++)
305 { 1486 {
306 const UString &s = names[i]; 1487 const UString &s = names[i];
307 unsigned fullLen = s.Len() + 1; 1488 const unsigned fullLen = s.Len() + 1;
308 MyStringCopy(p, (const WCHAR *)s); 1489 MyStringCopy(p, (const WCHAR *)s);
309 p += fullLen; 1490 p += fullLen;
310 totalLen -= fullLen; 1491 totalLen -= fullLen;
311 } 1492 }
312 *p = 0; 1493 *p = 0;
313 } 1494 }
1495 // if (totalLen != 1) return false;
314 return true; 1496 return true;
315} 1497}
316 1498
317void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */) 1499
1500void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */, bool isRightButton)
318{ 1501{
1502 PRF("CPanel::OnDrag");
319 if (!DoesItSupportOperations()) 1503 if (!DoesItSupportOperations())
320 return; 1504 return;
321 1505
322 CDisableTimerProcessing disableTimerProcessing2(*this); 1506 CDisableTimerProcessing disableTimerProcessing2(*this);
323 1507
324 CRecordVector<UInt32> indices; 1508 CRecordVector<UInt32> indices;
325 GetOperatedItemIndices(indices); 1509 Get_ItemIndices_Operated(indices);
326 if (indices.Size() == 0) 1510 if (indices.Size() == 0)
327 return; 1511 return;
328 1512
329 // CSelectedState selState; 1513 // CSelectedState selState;
330 // SaveSelectedState(selState); 1514 // SaveSelectedState(selState);
331 1515
332 // FString dirPrefix2; 1516 const bool isFSFolder = IsFSFolder();
333 FString dirPrefix; 1517 // why we don't allow drag with rightButton from archive?
1518 if (!isFSFolder && isRightButton)
1519 return;
1520
1521 UString dirPrefix;
334 CTempDir tempDirectory; 1522 CTempDir tempDirectory;
335 1523
336 bool isFSFolder = IsFSFolder(); 1524 CDataObject *dataObjectSpec = new CDataObject;
1525 CMyComPtr<IDataObject> dataObject = dataObjectSpec;
1526 dataObjectSpec->IsRightButton = isRightButton;
1527
1528 {
1529 /* we can change confirmation mode and another options.
1530 Explorer target requests that FILEOP_FLAGS value. */
1531 /*
1532 const FILEOP_FLAGS fopFlags =
1533 FOF_NOCONFIRMATION
1534 | FOF_NOCONFIRMMKDIR
1535 | FOF_NOERRORUI
1536 | FOF_SILENT;
1537 // | FOF_SIMPLEPROGRESS; // it doesn't work as expected in Win10
1538 Global_SetUInt32(dataObjectSpec->m_hGlobal_FileOpFlags, fopFlags);
1539 // dataObjectSpec->m_hGlobal_FileOpFlags.Free(); // for debug : disable these options
1540 */
1541 }
1542 {
1543 /* we can change Preferred DropEffect.
1544 Explorer target requests that FILEOP_FLAGS value. */
1545 /*
1546 const DWORD effect = DROPEFFECT_MOVE; // DROPEFFECT_COPY;
1547 Global_SetUInt32(dataObjectSpec->m_hGlobal_PreferredDropEffect, effect);
1548 */
1549 }
337 if (isFSFolder) 1550 if (isFSFolder)
338 dirPrefix = us2fs(GetFsPath()); 1551 {
1552 dirPrefix = GetFsPath(); // why this in 22.01 ?
1553 dataObjectSpec->UsePreGlobal = false;
1554 // dataObjectSpec->IsTempFiles = false;
1555 }
339 else 1556 else
340 { 1557 {
341 if (!tempDirectory.Create(kTempDirPrefix)) 1558 if (!tempDirectory.Create(kTempDirPrefix))
@@ -343,23 +1560,32 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
343 MessageBox_Error(L"Can't create temp folder"); 1560 MessageBox_Error(L"Can't create temp folder");
344 return; 1561 return;
345 } 1562 }
346 dirPrefix = tempDirectory.GetPath(); 1563 dirPrefix = fs2us(tempDirectory.GetPath());
347 // dirPrefix2 = dirPrefix; 1564 {
1565 UStringVector names;
1566 names.Add(dirPrefix);
1567 dataObjectSpec->IsTempFiles = true;
1568 dataObjectSpec->UsePreGlobal = true;
1569 if (!CopyNamesToHGlobal(dataObjectSpec->m_hGlobal_HDROP_Pre, names))
1570 return;
1571 }
348 NFile::NName::NormalizeDirPathPrefix(dirPrefix); 1572 NFile::NName::NormalizeDirPathPrefix(dirPrefix);
1573 /*
1574 {
1575 FString path2 = dirPrefix;
1576 path2 += "1.txt";
1577 CopyFileW(L"C:\\1\\1.txt", path2, FALSE);
1578 }
1579 */
349 } 1580 }
350 1581
351 CDataObject *dataObjectSpec = new CDataObject;
352 CMyComPtr<IDataObject> dataObject = dataObjectSpec;
353
354 { 1582 {
355 UStringVector names; 1583 UStringVector names;
356
357 // names variable is USED for drag and drop from 7-zip to Explorer or to 7-zip archive folder. 1584 // names variable is USED for drag and drop from 7-zip to Explorer or to 7-zip archive folder.
358 // names variable is NOT USED for drag and drop from 7-zip to 7-zip File System folder. 1585 // names variable is NOT USED for drag and drop from 7-zip to 7-zip File System folder.
359
360 FOR_VECTOR (i, indices) 1586 FOR_VECTOR (i, indices)
361 { 1587 {
362 UInt32 index = indices[i]; 1588 const UInt32 index = indices[i];
363 UString s; 1589 UString s;
364 if (isFSFolder) 1590 if (isFSFolder)
365 s = GetItemRelPath(index); 1591 s = GetItemRelPath(index);
@@ -370,14 +1596,12 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
370 // We use (keepAndReplaceEmptyPrefixes = true) in CAgentFolder::Extract 1596 // We use (keepAndReplaceEmptyPrefixes = true) in CAgentFolder::Extract
371 // So the following code is not required. 1597 // So the following code is not required.
372 // Maybe we also can change IFolder interface and send some flag also. 1598 // Maybe we also can change IFolder interface and send some flag also.
373
374 if (s.IsEmpty()) 1599 if (s.IsEmpty())
375 { 1600 {
376 // Correct_FsFile_Name("") returns "_". 1601 // Correct_FsFile_Name("") returns "_".
377 // If extracting code removes empty folder prefixes from path (as it was in old version), 1602 // If extracting code removes empty folder prefixes from path (as it was in old version),
378 // Explorer can't find "_" folder in temp folder. 1603 // Explorer can't find "_" folder in temp folder.
379 // We can ask Explorer to copy parent temp folder "7zE" instead. 1604 // We can ask Explorer to copy parent temp folder "7zE" instead.
380
381 names.Clear(); 1605 names.Clear();
382 names.Add(dirPrefix2); 1606 names.Add(dirPrefix2);
383 break; 1607 break;
@@ -385,18 +1609,18 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
385 */ 1609 */
386 s = Get_Correct_FsFile_Name(s); 1610 s = Get_Correct_FsFile_Name(s);
387 } 1611 }
388 names.Add(fs2us(dirPrefix) + s); 1612 names.Add(dirPrefix + s);
389 } 1613 }
390 if (!CopyNamesToHGlobal(dataObjectSpec->hGlobal, names)) 1614 if (!CopyNamesToHGlobal(dataObjectSpec->m_hGlobal_HDROP_Final, names))
391 return; 1615 return;
392 } 1616 }
393 1617
394 CDropSource *dropSourceSpec = new CDropSource; 1618 CDropSource *dropSourceSpec = new CDropSource;
395 CMyComPtr<IDropSource> dropSource = dropSourceSpec; 1619 CMyComPtr<IDropSource> dropSource = dropSourceSpec;
396 dropSourceSpec->NeedExtract = !isFSFolder; 1620 dataObjectSpec->Panel = this;
397 dropSourceSpec->Panel = this; 1621 dataObjectSpec->Indices = indices;
398 dropSourceSpec->Indices = indices; 1622 dataObjectSpec->SrcDirPrefix_Temp = dirPrefix;
399 dropSourceSpec->Folder = fs2us(dirPrefix); 1623
400 dropSourceSpec->DataObjectSpec = dataObjectSpec; 1624 dropSourceSpec->DataObjectSpec = dataObjectSpec;
401 dropSourceSpec->DataObject = dataObjectSpec; 1625 dropSourceSpec->DataObject = dataObjectSpec;
402 1626
@@ -404,17 +1628,17 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
404 /* 1628 /*
405 CTime - file creation timestamp. 1629 CTime - file creation timestamp.
406 There are two operations in Windows with Drag and Drop: 1630 There are two operations in Windows with Drag and Drop:
407 COPY_OPERATION - icon with Plus sign - CTime will be set as current_time. 1631 COPY_OPERATION : icon with Plus sign : CTime will be set as current_time.
408 MOVE_OPERATION - icon without Plus sign - CTime will be preserved 1632 MOVE_OPERATION : icon without Plus sign : CTime will be preserved.
409 1633
410 Note: if we call DoDragDrop() with (effectsOK = DROPEFFECT_MOVE), then 1634 Note: if we call DoDragDrop() with (effectsOK = DROPEFFECT_MOVE), then
411 it will use MOVE_OPERATION and CTime will be preserved. 1635 it will use MOVE_OPERATION and CTime will be preserved.
412 But MoveFile() function doesn't preserve CTime, if different volumes are used. 1636 But MoveFile() function doesn't preserve CTime, if different volumes are used.
413 Why it's so? 1637 Why it's so?
414 Does DoDragDrop() use some another function (not MoveFile())? 1638 Does DoDragDrop() use some another function (not MoveFile())?
415 1639
416 if (effectsOK == DROPEFFECT_COPY) it works as COPY_OPERATION 1640 if (effectsOK == DROPEFFECT_COPY) it works as COPY_OPERATION
417 1641
418 if (effectsOK == DROPEFFECT_MOVE) drag works as MOVE_OPERATION 1642 if (effectsOK == DROPEFFECT_MOVE) drag works as MOVE_OPERATION
419 1643
420 if (effectsOK == (DROPEFFECT_COPY | DROPEFFECT_MOVE)) 1644 if (effectsOK == (DROPEFFECT_COPY | DROPEFFECT_MOVE))
@@ -431,7 +1655,7 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
431 We want to use MOVE_OPERATION for extracting from archive (open in 7-Zip) to Explorer: 1655 We want to use MOVE_OPERATION for extracting from archive (open in 7-Zip) to Explorer:
432 It has the following advantages: 1656 It has the following advantages:
433 1) it uses fast MOVE_OPERATION instead of slow COPY_OPERATION and DELETE, if same volume. 1657 1) it uses fast MOVE_OPERATION instead of slow COPY_OPERATION and DELETE, if same volume.
434 2) it preserved CTime 1658 2) it preserves CTime
435 1659
436 Some another programs support only COPY_OPERATION. 1660 Some another programs support only COPY_OPERATION.
437 So we can use (DROPEFFECT_COPY | DROPEFFECT_MOVE) 1661 So we can use (DROPEFFECT_COPY | DROPEFFECT_MOVE)
@@ -444,252 +1668,401 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
444 IDropSource *dropSource 1668 IDropSource *dropSource
445 IDataObject *dataObject 1669 IDataObject *dataObject
446 if DropTarget is 7-Zip window, then 7-Zip's 1670 if DropTarget is 7-Zip window, then 7-Zip's
447 IDropTarget::DragOver() sets Path in IDataObject. 1671 IDropTarget::DragOver() sets DestDirPrefix_FromTarget in IDataObject.
448 and 1672 and
449 IDropSource::QueryContinueDrag() sets NeedPostCopy, if Path is not epmty. 1673 IDropSource::QueryContinueDrag() sets DoNotProcessInTarget, if DestDirPrefix_FromTarget is not empty.
450 So we can detect destination path after DoDragDrop(). 1674 So we can detect destination path after DoDragDrop().
451 Now we don't know any good way to detect destination path for D&D to Explorer. 1675 Now we don't know any good way to detect destination path for D&D to Explorer.
452 */ 1676 */
453 1677
454 bool moveIsAllowed = isFSFolder;
455 /* 1678 /*
456 DWORD effectsOK = DROPEFFECT_COPY; 1679 DWORD effectsOK = DROPEFFECT_COPY;
457 if (moveIsAllowed) 1680 if (moveIsAllowed)
458 effectsOK |= DROPEFFECT_MOVE; 1681 effectsOK |= DROPEFFECT_MOVE;
459 */ 1682 */
460 1683 const bool moveIsAllowed = isFSFolder;
461 // 18.04: was changed
462 DWORD effectsOK = DROPEFFECT_MOVE | DROPEFFECT_COPY;
463
464 DWORD effect;
465 _panelCallback->DragBegin(); 1684 _panelCallback->DragBegin();
466 1685 PRF("=== DoDragDrop()");
467 HRESULT res = DoDragDrop(dataObject, dropSource, effectsOK, &effect); 1686 DWORD effect = 0;
468 1687 // 18.04: was changed
1688 const DWORD effectsOK = DROPEFFECT_MOVE | DROPEFFECT_COPY;
1689 // effectsOK |= (1 << 8); // for debug
1690 HRESULT res = ::DoDragDrop(dataObject, dropSource, effectsOK, &effect);
1691 PRF("=== After DoDragDrop()");
469 _panelCallback->DragEnd(); 1692 _panelCallback->DragEnd();
470 bool canceled = (res == DRAGDROP_S_CANCEL); 1693
1694 /*
1695 Win10 drag and drop to Explorer:
1696 DoDragDrop() output variables:
1697 for MOVE operation:
1698 {
1699 effect == DROPEFFECT_NONE;
1700 dropSourceSpec->m_PerformedDropEffect == DROPEFFECT_MOVE;
1701 }
1702 for COPY operation:
1703 {
1704 effect == DROPEFFECT_COPY;
1705 dropSourceSpec->m_PerformedDropEffect == DROPEFFECT_COPY;
1706 }
1707 DOCs: The source inspects the two values that can be returned by the target.
1708 If both are set to DROPEFFECT_MOVE, it completes the unoptimized move
1709 by deleting the original data. Otherwise, the target did an optimized
1710 move and the original data has been deleted.
1711
1712 We didn't see "unoptimized move" case (two values of DROPEFFECT_MOVE),
1713 where we still need to delete source files.
1714 So we don't delete files after DoDragDrop().
1715
1716 Also DOCs say for "optimized move":
1717 The target also calls the data object's IDataObject::SetData method and passes
1718 it a CFSTR_PERFORMEDDROPEFFECT format identifier set to DROPEFFECT_NONE.
1719 but actually in Win10 we always have
1720 (dropSourceSpec->m_PerformedDropEffect == DROPEFFECT_MOVE)
1721 for any MOVE operation.
1722 */
1723
1724 const bool canceled = (res == DRAGDROP_S_CANCEL);
471 1725
472 CDisableNotify disableNotify(*this); 1726 CDisableNotify disableNotify(*this);
473 1727
474 if (res == DRAGDROP_S_DROP) 1728 if (res == DRAGDROP_S_DROP)
475 { 1729 {
476 res = dropSourceSpec->Result; 1730 /* DRAGDROP_S_DROP is returned. It means that
477 if (dropSourceSpec->NeedPostCopy) 1731 - IDropTarget::Drop() was called,
478 if (!dataObjectSpec->Path.IsEmpty()) 1732 - IDropTarget::Drop() returned (ret_code >= 0)
1733 */
1734 res = dataObjectSpec->Copy_HRESULT;
1735 bool need_Process = dataObjectSpec->DoNotProcessInTarget;
1736 if (dataObjectSpec->m_Transfer_WasSet)
1737 {
1738 if (dataObjectSpec->m_Transfer.Target.FuncType == k_DragTargetMode_Drop_End)
1739 {
1740 if (dataObjectSpec->m_Transfer.Target.Flags & k_TargetFlags_MustBeProcessedBySource)
1741 need_Process = true;
1742 }
1743 }
1744
1745 if (need_Process)
1746 if (!dataObjectSpec->DestDirPrefix_FromTarget.IsEmpty())
479 { 1747 {
480 NFile::NName::NormalizeDirPathPrefix(dataObjectSpec->Path); 1748 if (!NFile::NName::IsAltStreamPrefixWithColon(dataObjectSpec->DestDirPrefix_FromTarget))
1749 NFile::NName::NormalizeDirPathPrefix(dataObjectSpec->DestDirPrefix_FromTarget);
481 CCopyToOptions options; 1750 CCopyToOptions options;
482 options.folder = dataObjectSpec->Path; 1751 options.folder = dataObjectSpec->DestDirPrefix_FromTarget;
483 // if MOVE is not allowed, we just use COPY operation 1752 // if MOVE is not allowed, we just use COPY operation
484 options.moveMode = (effect == DROPEFFECT_MOVE && moveIsAllowed); 1753 /* it was 7-zip's Target that set non-empty dataObjectSpec->DestDirPrefix_FromTarget.
485 res = CopyTo(options, indices, &dropSourceSpec->Messages); 1754 it means that target didn't completed operation,
1755 and we can use (effect) value returned by target via DoDragDrop().
1756 as indicator of type of operation
1757 */
1758 // options.moveMode = (moveIsAllowed && effect == DROPEFFECT_MOVE) // before v23.00:
1759 options.moveMode = moveIsAllowed;
1760 if (moveIsAllowed)
1761 {
1762 if (dataObjectSpec->m_Transfer_WasSet)
1763 options.moveMode = (
1764 dataObjectSpec->m_Transfer.Target.Cmd_Effect == DROPEFFECT_MOVE);
1765 else
1766 options.moveMode = (effect == DROPEFFECT_MOVE);
1767 // we expect (DROPEFFECT_MOVE) as indicator of move operation for Drag&Drop MOVE ver 22.01.
1768 }
1769 res = CopyTo(options, indices, &dataObjectSpec->Messages);
486 } 1770 }
487 /* 1771 /*
488 if (effect == DROPEFFECT_MOVE) 1772 if (effect & DROPEFFECT_MOVE)
489 RefreshListCtrl(selState); 1773 RefreshListCtrl(selState);
490 */ 1774 */
491 } 1775 }
492 else 1776 else
493 { 1777 {
494 // we ignore E_UNEXPECTED that is returned if we drag file to printer 1778 // we ignore E_UNEXPECTED that is returned if we drag file to printer
495 if (res != DRAGDROP_S_CANCEL && res != S_OK 1779 if (res != DRAGDROP_S_CANCEL
1780 && res != S_OK
496 && res != E_UNEXPECTED) 1781 && res != E_UNEXPECTED)
497 MessageBox_Error_HRESULT(res); 1782 MessageBox_Error_HRESULT(res);
498 1783 res = dataObjectSpec->Copy_HRESULT;
499 res = dropSourceSpec->Result;
500 } 1784 }
501 1785
502 if (!dropSourceSpec->Messages.IsEmpty()) 1786 if (!dataObjectSpec->Messages.IsEmpty())
503 { 1787 {
504 CMessagesDialog messagesDialog; 1788 CMessagesDialog messagesDialog;
505 messagesDialog.Messages = &dropSourceSpec->Messages; 1789 messagesDialog.Messages = &dataObjectSpec->Messages;
506 messagesDialog.Create((*this)); 1790 messagesDialog.Create((*this));
507 } 1791 }
508 1792
509 if (res != S_OK && res != E_ABORT) 1793 if (res != S_OK && res != E_ABORT)
510 { 1794 {
511 // we restore Notify before MessageBox_Error_HRESULT. So we will se files selection 1795 // we restore Notify before MessageBox_Error_HRESULT. So we will see files selection
512 disableNotify.Restore(); 1796 disableNotify.Restore();
513 // SetFocusToList(); 1797 // SetFocusToList();
514 MessageBox_Error_HRESULT(res); 1798 MessageBox_Error_HRESULT(res);
515 } 1799 }
516 if (res == S_OK && dropSourceSpec->Messages.IsEmpty() && !canceled) 1800 if (res == S_OK && dataObjectSpec->Messages.IsEmpty() && !canceled)
517 KillSelection(); 1801 KillSelection();
518} 1802}
519 1803
520void CDropTarget::QueryGetData(IDataObject *dataObject) 1804
1805
1806
1807
1808CDropTarget::CDropTarget():
1809 m_IsRightButton(false),
1810 m_GetTransfer_WasSuccess(false),
1811 m_DropIsAllowed(false),
1812 m_PanelDropIsAllowed(false),
1813 // m_DropHighlighted_SelectionIndex(-1),
1814 // m_SubFolderIndex(-1),
1815 m_Panel(NULL),
1816 m_IsAppTarget(false),
1817 m_TargetPath_WasSent_ToDataObject(false),
1818 m_TargetPath_NonEmpty_WasSent_ToDataObject(false),
1819 m_Transfer_WasSent_ToDataObject(false),
1820 App(NULL),
1821 SrcPanelIndex(-1),
1822 TargetPanelIndex(-1)
1823{
1824 m_Format_7zip_SetTargetFolder = RegisterClipboardFormat(k_Format_7zip_SetTargetFolder);
1825 m_Format_7zip_SetTransfer = RegisterClipboardFormat(k_Format_7zip_SetTransfer);
1826 m_Format_7zip_GetTransfer = RegisterClipboardFormat(k_Format_7zip_GetTransfer);
1827
1828 m_ProcessId = GetCurrentProcessId();
1829 // m_TransactionId = ((UInt64)m_ProcessId << 32) + 1;
1830 // ClearState();
1831}
1832
1833// clear internal state
1834void CDropTarget::ClearState()
1835{
1836 m_DataObject.Release();
1837 m_SourcePaths.Clear();
1838
1839 m_IsRightButton = false;
1840
1841 m_GetTransfer_WasSuccess = false;
1842 m_DropIsAllowed = false;
1843
1844 m_PanelDropIsAllowed = false;
1845 // m_SubFolderIndex = -1;
1846 // m_DropHighlighted_SubFolderName.Empty();
1847 m_Panel = NULL;
1848 m_IsAppTarget = false;
1849 m_TargetPath_WasSent_ToDataObject = false;
1850 m_TargetPath_NonEmpty_WasSent_ToDataObject = false;
1851 m_Transfer_WasSent_ToDataObject = false;
1852}
1853
1854/*
1855 IDataObject::QueryGetData() Determines whether the data object is capable of
1856 rendering the data as specified. Objects attempting a paste or drop
1857 operation can call this method before calling IDataObject::GetData
1858 to get an indication of whether the operation may be successful.
1859
1860 The client of a data object calls QueryGetData to determine whether
1861 passing the specified FORMATETC structure to a subsequent call to
1862 IDataObject::GetData is likely to be successful.
1863
1864 We check Try_QueryGetData with CF_HDROP
1865*/
1866/*
1867void CDropTarget::Try_QueryGetData(IDataObject *dataObject)
521{ 1868{
522 FORMATETC etc = { CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; 1869 FORMATETC etc = { CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
523 m_DropIsAllowed = (dataObject->QueryGetData(&etc) == S_OK); 1870 m_DropIsAllowed = (dataObject->QueryGetData(&etc) == S_OK);
524
525} 1871}
1872*/
526 1873
527static void MySetDropHighlighted(HWND hWnd, int index, bool enable) 1874static void ListView_SetItemState_DropHighlighted(
1875 NControl::CListView &listView, int index, bool highlighted)
528{ 1876{
1877 // LVIS_DROPHILITED : The item is highlighted as a drag-and-drop target
1878 /*
529 LVITEM item; 1879 LVITEM item;
530 item.mask = LVIF_STATE; 1880 item.mask = LVIF_STATE;
531 item.iItem = index; 1881 item.iItem = index;
532 item.iSubItem = 0; 1882 item.iSubItem = 0;
533 item.state = enable ? LVIS_DROPHILITED : 0; 1883 item.state = enable ? LVIS_DROPHILITED : 0;
534 item.stateMask = LVIS_DROPHILITED; 1884 item.stateMask = LVIS_DROPHILITED;
535 item.pszText = 0; 1885 item.pszText = NULL;
536 ListView_SetItem(hWnd, &item); 1886 listView.SetItem(&item);
1887 */
1888 listView.SetItemState(index, highlighted ? LVIS_DROPHILITED : 0, LVIS_DROPHILITED);
537} 1889}
538 1890
1891// Removes DropHighlighted state in ListView item, if it was set before
539void CDropTarget::RemoveSelection() 1892void CDropTarget::RemoveSelection()
540{ 1893{
541 if (m_SelectionIndex >= 0 && m_Panel) 1894 if (m_Panel)
542 MySetDropHighlighted(m_Panel->_listView, m_SelectionIndex, false); 1895 {
543 m_SelectionIndex = -1; 1896 m_Panel->m_DropHighlighted_SubFolderName.Empty();
1897 if (m_Panel->m_DropHighlighted_SelectionIndex >= 0)
1898 {
1899 ListView_SetItemState_DropHighlighted(m_Panel->_listView,
1900 m_Panel->m_DropHighlighted_SelectionIndex, false);
1901 m_Panel->m_DropHighlighted_SelectionIndex = -1;
1902 }
1903 }
544} 1904}
545 1905
546#ifdef UNDER_CE 1906#ifdef UNDER_CE
547#define ChildWindowFromPointEx(hwndParent, pt, uFlags) ChildWindowFromPoint(hwndParent, pt) 1907#define ChildWindowFromPointEx(hwndParent, pt, uFlags) ChildWindowFromPoint(hwndParent, pt)
548#endif 1908#endif
549 1909
550void CDropTarget::PositionCursor(POINTL ptl)
551{
552 m_SubFolderIndex = -1;
553 POINT pt;
554 pt.x = ptl.x;
555 pt.y = ptl.y;
556 1910
1911/*
1912 PositionCursor() function sets m_Panel under cursor drop, and
1913 m_SubFolderIndex/m_DropHighlighted_SubFolderName, if drop to some folder in Panel list.
1914*/
1915/*
1916PositionCursor() uses as input variables:
1917 m_DropIsAllowed must be set before PositionCursor()
1918 if (m_DropHighlighted_SelectionIndex >= 0 && m_Panel) it uses m_Panel and removes previous selection
1919PositionCursor() sets
1920 m_PanelDropIsAllowed
1921 m_Panel
1922 m_IsAppTarget
1923 m_SubFolderIndex
1924 m_DropHighlighted_SubFolderName
1925 m_DropHighlighted_SelectionIndex
1926*/
1927void CDropTarget::PositionCursor(const POINTL &ptl)
1928{
557 RemoveSelection(); 1929 RemoveSelection();
1930
1931 // m_SubFolderIndex = -1;
1932 // m_DropHighlighted_SubFolderName.Empty();
558 m_IsAppTarget = true; 1933 m_IsAppTarget = true;
559 m_Panel = NULL; 1934 m_Panel = NULL;
1935 m_PanelDropIsAllowed = false;
560 1936
561 m_PanelDropIsAllowed = true;
562 if (!m_DropIsAllowed) 1937 if (!m_DropIsAllowed)
563 return; 1938 return;
1939
1940 POINT pt;
1941 pt.x = ptl.x;
1942 pt.y = ptl.y;
564 { 1943 {
565 POINT pt2 = pt; 1944 POINT pt2 = pt;
566 App->_window.ScreenToClient(&pt2); 1945 if (App->_window.ScreenToClient(&pt2))
567 for (unsigned i = 0; i < kNumPanelsMax; i++) 1946 for (unsigned i = 0; i < kNumPanelsMax; i++)
568 if (App->IsPanelVisible(i)) 1947 if (App->IsPanelVisible(i))
569 if (App->Panels[i].IsEnabled()) 1948 {
570 if (ChildWindowFromPointEx(App->_window, pt2, 1949 CPanel *panel = &App->Panels[i];
571 CWP_SKIPINVISIBLE | CWP_SKIPDISABLED) == (HWND)App->Panels[i]) 1950 if (panel->IsEnabled())
1951 if (::ChildWindowFromPointEx(App->_window, pt2,
1952 CWP_SKIPINVISIBLE | CWP_SKIPDISABLED) == (HWND)*panel)
572 { 1953 {
573 m_Panel = &App->Panels[i]; 1954 m_Panel = panel;
574 m_IsAppTarget = false; 1955 m_IsAppTarget = false;
575 if ((int)i == SrcPanelIndex) 1956 if ((int)i == SrcPanelIndex)
576 { 1957 return; // we don't allow to drop to source panel
577 m_PanelDropIsAllowed = false;
578 return;
579 }
580 break; 1958 break;
581 } 1959 }
582 if (m_IsAppTarget) 1960 }
583 { 1961 }
584 if (TargetPanelIndex >= 0) 1962
585 m_Panel = &App->Panels[TargetPanelIndex]; 1963 m_PanelDropIsAllowed = true;
586 return; 1964
587 } 1965 if (!m_Panel)
1966 {
1967 if (TargetPanelIndex >= 0)
1968 m_Panel = &App->Panels[TargetPanelIndex];
1969 // we don't need to find item in panel
1970 return;
588 } 1971 }
589 1972
1973 // we will try to find and highlight drop folder item in listView under cursor
590 /* 1974 /*
591 m_PanelDropIsAllowed = m_Panel->DoesItSupportOperations(); 1975 m_PanelDropIsAllowed = m_Panel->DoesItSupportOperations();
592 if (!m_PanelDropIsAllowed) 1976 if (!m_PanelDropIsAllowed)
593 return; 1977 return;
594 */ 1978 */
595 1979 /* now we don't allow drop to subfolder under cursor, if dest panel is archive.
1980 Another code must be fixed for that case, where we must use m_SubFolderIndex/m_DropHighlighted_SubFolderName */
596 if (!m_Panel->IsFsOrPureDrivesFolder()) 1981 if (!m_Panel->IsFsOrPureDrivesFolder())
597 return; 1982 return;
598 1983
599 if (WindowFromPoint(pt) != (HWND)m_Panel->_listView) 1984 if (::WindowFromPoint(pt) != (HWND)m_Panel->_listView)
600 return; 1985 return;
601 1986
602 LVHITTESTINFO info; 1987 LVHITTESTINFO info;
603 m_Panel->_listView.ScreenToClient(&pt); 1988 m_Panel->_listView.ScreenToClient(&pt);
604 info.pt = pt; 1989 info.pt = pt;
605 int index = ListView_HitTest(m_Panel->_listView, &info); 1990 const int index = ListView_HitTest(m_Panel->_listView, &info);
606 if (index < 0) 1991 if (index < 0)
607 return; 1992 return;
608 int realIndex = m_Panel->GetRealItemIndex(index); 1993 const unsigned realIndex = m_Panel->GetRealItemIndex(index);
609 if (realIndex == kParentIndex) 1994 if (realIndex == kParentIndex)
610 return; 1995 return;
611 if (!m_Panel->IsItem_Folder(realIndex)) 1996 if (!m_Panel->IsItem_Folder(realIndex))
612 return; 1997 return;
613 m_SubFolderIndex = realIndex; 1998 // m_SubFolderIndex = (int)realIndex;
614 m_SubFolderName = m_Panel->GetItemName(m_SubFolderIndex); 1999 m_Panel->m_DropHighlighted_SubFolderName = m_Panel->GetItemName(realIndex);
615 MySetDropHighlighted(m_Panel->_listView, index, true); 2000 ListView_SetItemState_DropHighlighted(m_Panel->_listView, index, true);
616 m_SelectionIndex = index; 2001 m_Panel->m_DropHighlighted_SelectionIndex = index;
617} 2002}
618 2003
619bool CDropTarget::IsFsFolderPath() const
620{
621 if (!m_IsAppTarget && m_Panel)
622 return (m_Panel->IsFSFolder() || (m_Panel->IsFSDrivesFolder() && m_SelectionIndex >= 0));
623 return false;
624}
625 2004
626static void ReadUnicodeStrings(const wchar_t *p, size_t size, UStringVector &names) 2005/* returns true, if !m_IsAppTarget
2006 and target is FS folder or altStream folder
2007*/
2008
2009UInt32 CDropTarget::GetFolderType() const
627{ 2010{
628 names.Clear(); 2011 if (m_IsAppTarget || !m_Panel)
629 UString name; 2012 return k_FolderType_None;
630 for (;size > 0; size--) 2013 if (m_Panel->IsFSFolder() ||
631 { 2014 (m_Panel->IsFSDrivesFolder()
632 wchar_t c = *p++; 2015 && m_Panel->m_DropHighlighted_SelectionIndex >= 0))
633 if (c == 0) 2016 return k_FolderType_Fs;
634 { 2017 if (m_Panel->IsAltStreamsFolder())
635 if (name.IsEmpty()) 2018 return k_FolderType_AltStreams;
636 break; 2019 if (m_Panel->IsArcFolder())
637 names.Add(name); 2020 return k_FolderType_Archive;
638 name.Empty(); 2021 return k_FolderType_Unknown;
639 }
640 else
641 name += c;
642 }
643} 2022}
644 2023
645static void ReadAnsiStrings(const char *p, size_t size, UStringVector &names) 2024bool CDropTarget::IsFsFolderPath() const
646{ 2025{
647 names.Clear(); 2026 if (m_IsAppTarget || !m_Panel)
648 AString name; 2027 return false;
649 for (;size > 0; size--) 2028 if (m_Panel->IsFSFolder())
650 { 2029 return true;
651 char c = *p++; 2030 if (m_Panel->IsAltStreamsFolder())
652 if (c == 0) 2031 return true;
653 { 2032 return m_Panel->IsFSDrivesFolder() &&
654 if (name.IsEmpty()) 2033 m_Panel->m_DropHighlighted_SelectionIndex >= 0;
655 break;
656 names.Add(GetUnicodeString(name));
657 name.Empty();
658 }
659 else
660 name += c;
661 }
662} 2034}
663 2035
664static void GetNamesFromDataObject(IDataObject *dataObject, UStringVector &names) 2036
2037#define INIT_FORMATETC_HGLOBAL(type) { (type), NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }
2038
2039static bool DataObject_GetData_GetTransfer(IDataObject *dataObject,
2040 UINT a_Format_7zip_GetTransfer, CDataObject_GetTransfer &transfer)
665{ 2041{
666 names.Clear(); 2042 FORMATETC etc = INIT_FORMATETC_HGLOBAL((CLIPFORMAT)a_Format_7zip_GetTransfer);
667 FORMATETC etc = { CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; 2043 NCOM::CStgMedium medium;
668 STGMEDIUM medium; 2044 const HRESULT res = dataObject->GetData(&etc, &medium);
669 HRESULT res = dataObject->GetData(&etc, &medium);
670 if (res != S_OK) 2045 if (res != S_OK)
671 return; 2046 return false;
672 if (medium.tymed != TYMED_HGLOBAL) 2047 if (medium.tymed != TYMED_HGLOBAL)
673 return; 2048 return false;
674 { 2049 const size_t size = GlobalSize(medium.hGlobal);
675 NMemory::CGlobal global; 2050 if (size < sizeof(transfer))
676 global.Attach(medium.hGlobal); 2051 return false;
677 size_t blockSize = GlobalSize(medium.hGlobal); 2052 NMemory::CGlobalLock dropLock(medium.hGlobal);
678 NMemory::CGlobalLock dropLock(medium.hGlobal); 2053 const CDataObject_GetTransfer *t = (const CDataObject_GetTransfer *)dropLock.GetPointer();
679 const DROPFILES* dropFiles = (DROPFILES*)dropLock.GetPointer(); 2054 if (!t)
680 if (!dropFiles) 2055 return false;
681 return; 2056 if (!t->Check()) // isSetData
682 if (blockSize < dropFiles->pFiles) 2057 return false;
683 return; 2058 transfer = *t;
684 size_t size = blockSize - dropFiles->pFiles; 2059 return true;
685 const void *namesData = (const Byte *)dropFiles + dropFiles->pFiles;
686 if (dropFiles->fWide)
687 ReadUnicodeStrings((const wchar_t *)namesData, size / sizeof(wchar_t), names);
688 else
689 ReadAnsiStrings((const char *)namesData, size, names);
690 }
691} 2060}
692 2061
2062/*
2063 returns true, if all m_SourcePaths[] items are same drive
2064 as destination drop path in m_Panel
2065*/
693bool CDropTarget::IsItSameDrive() const 2066bool CDropTarget::IsItSameDrive() const
694{ 2067{
695 if (!m_Panel) 2068 if (!m_Panel)
@@ -705,9 +2078,10 @@ bool CDropTarget::IsItSameDrive() const
705 if (drive.IsEmpty()) 2078 if (drive.IsEmpty())
706 return false; 2079 return false;
707 } 2080 }
708 else if (m_Panel->IsFSDrivesFolder() && m_SelectionIndex >= 0) 2081 else if (m_Panel->IsFSDrivesFolder()
2082 && m_Panel->m_DropHighlighted_SelectionIndex >= 0)
709 { 2083 {
710 drive = m_SubFolderName; 2084 drive = m_Panel->m_DropHighlighted_SubFolderName;
711 drive.Add_PathSepar(); 2085 drive.Add_PathSepar();
712 } 2086 }
713 else 2087 else
@@ -721,16 +2095,18 @@ bool CDropTarget::IsItSameDrive() const
721 if (!m_SourcePaths[i].IsPrefixedBy_NoCase(drive)) 2095 if (!m_SourcePaths[i].IsPrefixedBy_NoCase(drive))
722 return false; 2096 return false;
723 } 2097 }
724
725 return true; 2098 return true;
726} 2099}
727 2100
728 2101
729/* 2102/*
730 There are 2 different actions, when we drag to 7-Zip: 2103 There are 2 different actions, when we drag to 7-Zip:
731 1) Drag from any external program except of Explorer to "7-Zip" FS folder. 2104 1) if target panel is "7-Zip" FS and any of the 2 cases:
732 We want to create new archive for that operation. 2105 - Drag from any non "7-Zip" program;
733 2) all another operation work as usual file COPY/MOVE 2106 or
2107 - Drag from "7-Zip" to non-panel area of "7-Zip".
2108 We want to create new archive for that operation with "Add to Archive" window.
2109 2) all another operations work as usual file COPY/MOVE
734 - Drag from "7-Zip" FS to "7-Zip" FS. 2110 - Drag from "7-Zip" FS to "7-Zip" FS.
735 COPY/MOVE are supported. 2111 COPY/MOVE are supported.
736 - Drag to open archive in 7-Zip. 2112 - Drag to open archive in 7-Zip.
@@ -740,217 +2116,891 @@ bool CDropTarget::IsItSameDrive() const
740 We replace COPY to MOVE. 2116 We replace COPY to MOVE.
741*/ 2117*/
742 2118
743DWORD CDropTarget::GetEffect(DWORD keyState, POINTL /* pt */, DWORD allowedEffect) 2119// we try to repeat Explorer's effects.
2120// out: 0 - means that use default effect
2121static DWORD GetEffect_ForKeys(DWORD keyState)
744{ 2122{
745 if (!m_DropIsAllowed || !m_PanelDropIsAllowed) 2123 if (keyState & MK_CONTROL)
746 return DROPEFFECT_NONE; 2124 {
2125 if (keyState & MK_ALT)
2126 return 0;
2127 if (keyState & MK_SHIFT)
2128 return DROPEFFECT_LINK; // CONTROL + SHIFT
2129 return DROPEFFECT_COPY; // CONTROL
2130 }
2131 // no CONTROL
2132 if (keyState & MK_SHIFT)
2133 {
2134 if (keyState & MK_ALT)
2135 return 0;
2136 return DROPEFFECT_MOVE; // SHIFT
2137 }
2138 // no CONTROL, no SHIFT
2139 if (keyState & MK_ALT)
2140 return DROPEFFECT_LINK; // ALT
2141 return 0;
2142}
747 2143
748 if (!IsFsFolderPath() || !m_SetPathIsOK)
749 allowedEffect &= ~DROPEFFECT_MOVE;
750 2144
751 DWORD effect = 0; 2145/* GetEffect() uses m_TargetPath_WasSentToDataObject
752 2146 to disale MOVE operation, if Source is not 7-Zip
753 if (keyState & MK_CONTROL) 2147*/
754 effect = allowedEffect & DROPEFFECT_COPY; 2148DWORD CDropTarget::GetEffect(DWORD keyState, POINTL /* pt */, DWORD allowedEffect) const
755 else if (keyState & MK_SHIFT) 2149{
756 effect = allowedEffect & DROPEFFECT_MOVE; 2150 // (DROPEFFECT_NONE == 0)
757 2151 if (!m_DropIsAllowed || !m_PanelDropIsAllowed)
2152 return 0;
2153 if (!IsFsFolderPath() || !m_TargetPath_WasSent_ToDataObject)
2154 {
2155 // we don't allow MOVE, if Target is archive or Source is not 7-Zip
2156 // disabled for debug:
2157 // allowedEffect &= ~DROPEFFECT_MOVE;
2158 }
2159 DWORD effect;
2160 {
2161 effect = GetEffect_ForKeys(keyState);
2162 if (effect == DROPEFFECT_LINK)
2163 return 0;
2164 effect &= allowedEffect;
2165 }
758 if (effect == 0) 2166 if (effect == 0)
759 { 2167 {
760 if (allowedEffect & DROPEFFECT_COPY) 2168 if (allowedEffect & DROPEFFECT_COPY)
761 effect = DROPEFFECT_COPY; 2169 effect = DROPEFFECT_COPY;
762 if (allowedEffect & DROPEFFECT_MOVE) 2170 if (allowedEffect & DROPEFFECT_MOVE)
763 { 2171 {
2172 /* MOVE operation can be optimized. So MOVE is preferred way
2173 for default action, if Source and Target are at same drive */
764 if (IsItSameDrive()) 2174 if (IsItSameDrive())
765 effect = DROPEFFECT_MOVE; 2175 effect = DROPEFFECT_MOVE;
766 } 2176 }
767 } 2177 }
768 if (effect == 0)
769 return DROPEFFECT_NONE;
770 return effect; 2178 return effect;
771} 2179}
772 2180
2181
2182/* returns:
2183 - target folder path prefix, if target is FS folder
2184 - empty string, if target is not FS folder
2185*/
773UString CDropTarget::GetTargetPath() const 2186UString CDropTarget::GetTargetPath() const
774{ 2187{
775 if (!IsFsFolderPath()) 2188 if (!IsFsFolderPath())
776 return UString(); 2189 return UString();
777 UString path = m_Panel->GetFsPath(); 2190 UString path = m_Panel->GetFsPath();
778 if (m_SubFolderIndex >= 0 && !m_SubFolderName.IsEmpty()) 2191 if (/* m_SubFolderIndex >= 0 && */
2192 !m_Panel->m_DropHighlighted_SubFolderName.IsEmpty())
779 { 2193 {
780 path += m_SubFolderName; 2194 path += m_Panel->m_DropHighlighted_SubFolderName;
781 path.Add_PathSepar(); 2195 path.Add_PathSepar();
782 } 2196 }
783 return path; 2197 return path;
784} 2198}
785 2199
786bool CDropTarget::SetPath(bool enablePath) const 2200
2201/*
2202if IDropSource is Win10-Explorer
2203--------------------------------
2204 As in MS DOCs:
2205 The source inspects the two (effect) values that can be returned by the target:
2206 1) SetData(CFSTR_PERFORMEDDROPEFFECT)
2207 2) returned value (*effect) by
2208 CDropTarget::Drop(IDataObject *dataObject, DWORD keyState,
2209 POINTL pt, DWORD *effect)
2210 If both are set to DROPEFFECT_MOVE, Explorer completes the unoptimized move by deleting
2211 the original data.
2212 // Otherwise, the target did an optimized move and the original data has been deleted.
2213*/
2214
2215
2216/*
2217 Send targetPath from target to dataObject (to Source)
2218 input: set (enablePath = false) to send empty path
2219 returns true, if SetData() returns S_OK : (source is 7-zip)
2220 returns false, if SetData() doesn't return S_OK : (source is Explorer)
2221*/
2222bool CDropTarget::SendToSource_TargetPath_enable(IDataObject *dataObject, bool enablePath)
787{ 2223{
788 UINT setFolderFormat = RegisterClipboardFormat(kSvenZipSetFolderFormat); 2224 m_TargetPath_NonEmpty_WasSent_ToDataObject = false;
789
790 FORMATETC etc = { (CLIPFORMAT)setFolderFormat, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
791 STGMEDIUM medium;
792 medium.tymed = etc.tymed;
793 medium.pUnkForRelease = 0;
794 UString path; 2225 UString path;
795 if (enablePath) 2226 if (enablePath)
796 path = GetTargetPath(); 2227 path = GetTargetPath();
797 size_t size = path.Len() + 1; 2228 PRF("CDropTarget::SetPath");
798 medium.hGlobal = GlobalAlloc(GHND | GMEM_SHARE, size * sizeof(wchar_t)); 2229 PRF_W(path);
2230 if (!dataObject || m_Format_7zip_SetTargetFolder == 0)
2231 return false;
2232 FORMATETC etc = INIT_FORMATETC_HGLOBAL((CLIPFORMAT)m_Format_7zip_SetTargetFolder);
2233 STGMEDIUM medium;
2234 medium.tymed = etc.tymed;
2235 medium.pUnkForRelease = NULL;
2236 const size_t num = path.Len() + 1; // + (1 << 19) // for debug
2237 medium.hGlobal = GlobalAlloc(GHND | GMEM_SHARE, num * sizeof(wchar_t));
799 if (!medium.hGlobal) 2238 if (!medium.hGlobal)
800 return false; 2239 return false;
2240 // Sleep(1000);
801 wchar_t *dest = (wchar_t *)GlobalLock(medium.hGlobal); 2241 wchar_t *dest = (wchar_t *)GlobalLock(medium.hGlobal);
802 if (!dest) 2242 // Sleep(1000);
2243 bool res = false;
2244 if (dest)
2245 {
2246 MyStringCopy(dest, (const wchar_t *)path);
2247 GlobalUnlock(medium.hGlobal);
2248 // OutputDebugString("m_DataObject->SetData");
2249 const BOOL release = FALSE; // that way is more simple for correct releasing.
2250 // TRUE; // for debug : is not good for some cases.
2251 /* If DropSource is Win10-Explorer, dataObject->SetData() returns E_NOTIMPL; */
2252 const HRESULT hres = dataObject->SetData(&etc, &medium, release);
2253 // Sleep(1000);
2254 res = (hres == S_OK);
2255 }
2256
2257 ReleaseStgMedium(&medium);
2258 if (res && !path.IsEmpty())
2259 m_TargetPath_NonEmpty_WasSent_ToDataObject = true;
2260 // Sleep(1000);
2261 return res;
2262}
2263
2264
2265void CDropTarget::SendToSource_auto(IDataObject *dataObject,
2266 const CTargetTransferInfo &info)
2267{
2268 /* we try to send target path to Source.
2269 If Source is 7-Zip, then it will accept k_Format_7zip_SetTargetFolder.
2270 That sent path will be non-Empty, if this target is FS folder and drop is allowed */
2271 bool need_Send = false;
2272 if ( info.FuncType == k_DragTargetMode_Enter
2273 || info.FuncType == k_DragTargetMode_Over
2274 || (info.FuncType == k_DragTargetMode_Drop_Begin
2275 // && targetOp_Cmd != NDragMenu::k_None
2276 && info.Cmd_Type != NDragMenu::k_Cancel))
2277 // if (!g_CreateArchive_for_Drag_from_7zip)
2278 need_Send = m_DropIsAllowed && m_PanelDropIsAllowed && IsFsFolderPath();
2279 m_TargetPath_WasSent_ToDataObject = SendToSource_TargetPath_enable(dataObject, need_Send);
2280 SendToSource_TransferInfo(dataObject, info);
2281}
2282
2283
2284bool CDropTarget::SendToSource_TransferInfo(IDataObject *dataObject,
2285 const CTargetTransferInfo &info)
2286{
2287 m_Transfer_WasSent_ToDataObject = false;
2288 PRF("CDropTarget::SendToSource_TransferInfo");
2289
2290 if (!dataObject || m_Format_7zip_SetTransfer == 0)
2291 return false;
2292 FORMATETC etc = INIT_FORMATETC_HGLOBAL((CLIPFORMAT)m_Format_7zip_SetTransfer);
2293 STGMEDIUM medium;
2294 medium.tymed = etc.tymed;
2295 medium.pUnkForRelease = NULL;
2296 CDataObject_SetTransfer transfer;
2297 const size_t size = sizeof(transfer); // + (1 << 19) // for debug
2298 // OutputDebugString("GlobalAlloc");
2299 medium.hGlobal = GlobalAlloc(GHND | GMEM_SHARE, size);
2300 // Sleep(1000);
2301 if (!medium.hGlobal)
2302 return false;
2303 // OutputDebugString("GlobalLock");
2304 void *dest = (wchar_t *)GlobalLock(medium.hGlobal);
2305 // Sleep(1000);
2306 bool res = false;
2307 if (dest)
803 { 2308 {
2309 transfer.Init();
2310 transfer.Target = info;
2311
2312 memcpy(dest, &transfer, sizeof(transfer));
804 GlobalUnlock(medium.hGlobal); 2313 GlobalUnlock(medium.hGlobal);
2314 // OutputDebugString("m_DataObject->SetData");
2315 const BOOL release = FALSE; // that way is more simple for correct releasing.
2316 // TRUE; // for debug : is not good for some cases
2317 const HRESULT hres = dataObject->SetData(&etc, &medium, release);
2318 res = (hres == S_OK);
2319 }
2320
2321 ReleaseStgMedium(&medium);
2322 if (res)
2323 m_Transfer_WasSent_ToDataObject = true;
2324 return res;
2325}
2326
2327
2328bool CDropTarget::SendToSource_UInt32(IDataObject *dataObject, UINT format, UInt32 value)
2329{
2330 PRF("CDropTarget::Send_UInt32 (Performed)");
2331
2332 if (!dataObject || format == 0)
805 return false; 2333 return false;
2334 FORMATETC etc = INIT_FORMATETC_HGLOBAL((CLIPFORMAT)format);
2335 STGMEDIUM medium;
2336 medium.tymed = etc.tymed;
2337 medium.pUnkForRelease = NULL;
2338 const size_t size = 4;
2339 medium.hGlobal = GlobalAlloc(GHND | GMEM_SHARE, size);
2340 if (!medium.hGlobal)
2341 return false;
2342 void *dest = GlobalLock(medium.hGlobal);
2343 bool res = false;
2344 if (dest)
2345 {
2346 *(UInt32 *)dest = value;
2347 GlobalUnlock(medium.hGlobal);
2348 // OutputDebugString("m_DataObject->SetData");
2349 const BOOL release = TRUE;
2350 // FALSE; // for debug
2351 /* If DropSource is Win10-Explorer, then (release == FALSE) doesn't work
2352 and dataObject->SetData() returns E_NOTIMPL;
2353 So we use release = TRUE; here */
2354 const HRESULT hres = dataObject->SetData(&etc, &medium, release);
2355 // we return here without calling ReleaseStgMedium().
2356 return (hres == S_OK);
2357 // Sleep(1000);
2358 /*
2359 if (we use release = TRUE), we expect that
2360 - SetData() will release medium, and
2361 - SetData() will set STGMEDIUM::tymed to (TYMED_NULL = 0).
2362 but some "incorrect" SetData() implementations can keep STGMEDIUM::tymed unchanged.
2363 And it's not safe to call ReleaseStgMedium() here for that case,
2364 because DropSource also could release medium.
2365 We can reset (medium.tymed = TYMED_NULL) manually here to disable
2366 unsafe medium releasing in ReleaseStgMedium().
2367 */
2368 /*
2369 if (release)
2370 {
2371 medium.tymed = TYMED_NULL;
2372 medium.pUnkForRelease = NULL;
2373 medium.hGlobal = NULL;
2374 }
2375 res = (hres == S_OK);
2376 */
806 } 2377 }
807 MyStringCopy(dest, (const wchar_t *)path); 2378 ReleaseStgMedium(&medium);
808 GlobalUnlock(medium.hGlobal);
809 bool res = m_DataObject->SetData(&etc, &medium, FALSE) == S_OK;
810 GlobalFree(medium.hGlobal);
811 return res; 2379 return res;
812} 2380}
813 2381
814bool CDropTarget::SetPath() 2382
2383void CDropTarget::LoadNames_From_DataObject(IDataObject *dataObject)
815{ 2384{
816 m_SetPathIsOK = SetPath(m_DropIsAllowed && m_PanelDropIsAllowed && IsFsFolderPath()); 2385 // "\\\\.\\" prefix is possible for long names
817 return m_SetPathIsOK; 2386 m_DropIsAllowed = NShell::DataObject_GetData_HDROP_or_IDLIST_Names(dataObject, m_SourcePaths) == S_OK;
818} 2387}
819 2388
820STDMETHODIMP CDropTarget::DragEnter(IDataObject * dataObject, DWORD keyState, 2389
821 POINTL pt, DWORD *effect) 2390Z7_COMWF_B CDropTarget::DragEnter(IDataObject *dataObject, DWORD keyState, POINTL pt, DWORD *effect)
822{ 2391{
823 GetNamesFromDataObject(dataObject, m_SourcePaths); 2392 /* *(effect):
824 QueryGetData(dataObject); 2393 - on input : value of the dwOKEffects parameter of the DoDragDrop() function.
2394 - on return : must contain one of the DROPEFFECT flags, which indicates
2395 what the result of the drop operation would be.
2396 (pt): the current cursor coordinates in screen coordinates.
2397 */
2398 PRF_(Print_Point("CDropTarget::DragEnter", keyState, pt, *effect))
2399 try {
2400
2401 if ((keyState & (MK_RBUTTON | MK_MBUTTON)) != 0)
2402 m_IsRightButton = true;
2403
2404 LoadNames_From_DataObject(dataObject);
2405 // Try_QueryGetData(dataObject);
2406 // we will use (m_DataObject) later in DragOver() and DragLeave().
825 m_DataObject = dataObject; 2407 m_DataObject = dataObject;
826 return DragOver(keyState, pt, effect); 2408 // return DragOver(keyState, pt, effect);
2409 PositionCursor(pt);
2410 CTargetTransferInfo target;
2411 target.FuncType = k_DragTargetMode_Enter;
2412 target.KeyState = keyState;
2413 target.Point = pt;
2414 target.OkEffects = *effect;
2415 SendToSource_Drag(target);
2416
2417 CDataObject_GetTransfer transfer;
2418 m_GetTransfer_WasSuccess = DataObject_GetData_GetTransfer(
2419 dataObject, m_Format_7zip_GetTransfer, transfer);
2420 if (m_GetTransfer_WasSuccess)
2421 {
2422 if (transfer.Flags & k_SourceFlags_LeftButton)
2423 m_IsRightButton = false;
2424 else if (transfer.Flags & k_SourceFlags_RightButton)
2425 m_IsRightButton = true;
2426 }
2427
2428 *effect = GetEffect(keyState, pt, *effect);
2429 return S_OK;
2430 } catch(...) { return E_FAIL; }
827} 2431}
828 2432
829 2433
830STDMETHODIMP CDropTarget::DragOver(DWORD keyState, POINTL pt, DWORD *effect) 2434Z7_COMWF_B CDropTarget::DragOver(DWORD keyState, POINTL pt, DWORD *effect)
831{ 2435{
2436 PRF_(Print_Point("CDropTarget::DragOver", keyState, pt, *effect))
2437 /*
2438 For efficiency reasons, a data object is not passed in IDropTarget::DragOver.
2439 The data object passed in the most recent call to IDropTarget::DragEnter
2440 is available and can be used.
2441
2442 When IDropTarget::DragOver has completed its operation, the DoDragDrop
2443 function calls IDropSource::GiveFeedback so the source application can display
2444 the appropriate visual feedback to the user.
2445 */
2446 /*
2447 we suppose that it's unexpected that (keyState) shows that mouse
2448 button is not pressed, because such cases will be processed by
2449 IDropSource::QueryContinueDrag() that returns DRAGDROP_S_DROP or DRAGDROP_S_CANCEL.
2450 So DragOver() will not be called.
2451 */
2452
2453 if ((keyState & MK_LBUTTON) == 0)
2454 {
2455 PRF4("CDropTarget::DragOver() (keyState & MK_LBUTTON) == 0");
2456 // g_Debug = true;
2457 }
2458
2459 try {
2460 /* we suppose that source names were not changed after DragEnter()
2461 so we don't request GetNames_From_DataObject() for each call of DragOver() */
832 PositionCursor(pt); 2462 PositionCursor(pt);
833 SetPath(); 2463 CTargetTransferInfo target;
2464 target.FuncType = k_DragTargetMode_Over;
2465 target.KeyState = keyState;
2466 target.Point = pt;
2467 target.OkEffects = *effect;
2468 SendToSource_Drag(target);
834 *effect = GetEffect(keyState, pt, *effect); 2469 *effect = GetEffect(keyState, pt, *effect);
2470 // *effect = 1 << 8; // for debug
835 return S_OK; 2471 return S_OK;
2472 } catch(...) { return E_FAIL; }
836} 2473}
837 2474
838 2475
839STDMETHODIMP CDropTarget::DragLeave() 2476Z7_COMWF_B CDropTarget::DragLeave()
840{ 2477{
2478 PRF4("CDropTarget::DragLeave");
2479 try {
841 RemoveSelection(); 2480 RemoveSelection();
842 SetPath(false); 2481 // we send empty TargetPath to 7-Zip Source to clear value of TargetPath that was sent before
843 m_DataObject.Release(); 2482
2483 CTargetTransferInfo target;
2484 target.FuncType = k_DragTargetMode_Leave;
2485 /*
2486 target.KeyState = 0;
2487 target.Point = pt;
2488 pt.x = 0; // -1
2489 pt.y = 0; // -1
2490 target.Effect = 0;
2491 */
2492 SendToSource_Drag(target);
2493 ClearState();
844 return S_OK; 2494 return S_OK;
2495 } catch(...) { return E_FAIL; }
845} 2496}
846 2497
847// We suppose that there was ::DragOver for same POINTL_pt before ::Drop
848// So SetPath() is same as in Drop.
849 2498
850STDMETHODIMP CDropTarget::Drop(IDataObject *dataObject, DWORD keyState, 2499static unsigned Drag_OnContextMenu(int xPos, int yPos, UInt32 cmdFlags);
851 POINTL pt, DWORD * effect) 2500
2501/*
2502 We suppose that there was DragEnter/DragOver for same (POINTL pt) before Drop().
2503 But we can work without DragEnter/DragOver too.
2504*/
2505Z7_COMWF_B CDropTarget::Drop(IDataObject *dataObject, DWORD keyState,
2506 POINTL pt, DWORD *effect)
852{ 2507{
853 QueryGetData(dataObject); 2508 PRF_(Print_Point("CDropTarget::Drop", keyState, pt, *effect))
2509 /* Drop() is called after SourceDrop::QueryContinueDrag() returned DRAGDROP_S_DROP.
2510 So it's possible that Source have done some operations already.
2511 */
2512 HRESULT hres = S_OK;
2513 bool needDrop_by_Source = false;
2514 DWORD opEffect = DROPEFFECT_NONE;
2515
2516 try {
2517 // we don't need m_DataObject reference anymore, because we use local (dataObject)
2518 m_DataObject.Release();
2519
2520 /* in normal case : we called LoadNames_From_DataObject() in DragEnter() already.
2521 But if by some reason DragEnter() was not called,
2522 we need to call LoadNames_From_DataObject() before PositionCursor().
2523 */
2524 if (!m_DropIsAllowed) LoadNames_From_DataObject(dataObject);
854 PositionCursor(pt); 2525 PositionCursor(pt);
855 m_DataObject = dataObject; 2526
856 bool needDrop = true; 2527 CPanel::CDisableTimerProcessing2 disableTimerProcessing(m_Panel);
857 if (m_DropIsAllowed && m_PanelDropIsAllowed) 2528 // CDisableNotify disableNotify2(m_Panel);
858 if (IsFsFolderPath()) 2529
859 needDrop = !SetPath(); 2530 UInt32 cmd = NDragMenu::k_None;
860 *effect = GetEffect(keyState, pt, *effect); 2531 UInt32 cmdEffect = DROPEFFECT_NONE;
861 if (m_DropIsAllowed && m_PanelDropIsAllowed) 2532 bool menu_WasShown = false;
2533 if (m_IsRightButton && m_Panel)
862 { 2534 {
863 if (needDrop) 2535 UInt32 flagsMask;
2536 if (m_Panel->IsArcFolder())
2537 flagsMask = (UInt32)1 << NDragMenu::k_Copy_ToArc;
2538 else
864 { 2539 {
865 UString path = GetTargetPath(); 2540 flagsMask = (UInt32)1 << NDragMenu::k_AddToArc;
866 if (m_IsAppTarget && m_Panel) 2541 if (IsFsFolderPath())
867 if (m_Panel->IsFSFolder()) 2542 flagsMask |= (UInt32)1 << NDragMenu::k_Copy_Base;
868 path = m_Panel->GetFsPath();
869 m_Panel->DropObject(dataObject, path);
870 } 2543 }
2544 // flagsMask |= (UInt32)1 << NDragMenu::k_Cancel;
2545 const UInt32 cmd32 = Drag_OnContextMenu(pt.x, pt.y, flagsMask);
2546 cmd = cmd32 & NDragMenu::k_MenuFlags_CmdMask;
2547 if (cmd32 & NDragMenu::k_MenuFlag_Copy)
2548 cmdEffect = DROPEFFECT_COPY;
2549 else if (cmd32 & NDragMenu::k_MenuFlag_Move)
2550 cmdEffect = DROPEFFECT_MOVE;
2551 opEffect = cmdEffect;
2552 menu_WasShown = true;
2553 }
2554 else
2555 {
2556 opEffect = GetEffect(keyState, pt, *effect);
2557 if (m_IsAppTarget)
2558 cmd = NDragMenu::k_AddToArc;
2559 else if (m_Panel)
2560 {
2561 if (IsFsFolderPath())
2562 {
2563 const bool is7zip = m_TargetPath_WasSent_ToDataObject;
2564 bool createNewArchive = false;
2565 if (is7zip)
2566 createNewArchive = false; // g_CreateArchive_for_Drag_from_7zip;
2567 else
2568 createNewArchive = true; // g_CreateArchive_for_Drag_from_Explorer;
2569
2570 if (createNewArchive)
2571 cmd = NDragMenu::k_AddToArc;
2572 else
2573 {
2574 if (opEffect != 0)
2575 cmd = NDragMenu::k_Copy_Base;
2576 cmdEffect = opEffect;
2577 }
2578 }
2579 else
2580 {
2581 /* if we are inside open archive:
2582 if archive support operations -> we will call operations
2583 if archive doesn't support operations -> we will create new archove
2584 */
2585 if (m_Panel->IsArcFolder()
2586 || m_Panel->DoesItSupportOperations())
2587 {
2588 cmd = NDragMenu::k_Copy_ToArc;
2589 // we don't want move to archive operation here.
2590 // so we force to DROPEFFECT_COPY.
2591 if (opEffect != DROPEFFECT_NONE)
2592 opEffect = DROPEFFECT_COPY;
2593 cmdEffect = opEffect;
2594 }
2595 else
2596 cmd = NDragMenu::k_AddToArc;
2597 }
2598 }
2599 }
2600
2601 if (cmd == 0)
2602 cmd = NDragMenu::k_AddToArc;
2603
2604 if (cmd == NDragMenu::k_AddToArc)
2605 {
2606 opEffect = DROPEFFECT_COPY;
2607 cmdEffect = DROPEFFECT_COPY;
2608 }
2609
2610 if (m_Panel)
2611 if (cmd == NDragMenu::k_Copy_ToArc)
2612 {
2613 const UString title = LangString(IDS_CONFIRM_FILE_COPY);
2614 UString s = LangString(cmdEffect == DROPEFFECT_MOVE ?
2615 IDS_MOVE_TO : IDS_COPY_TO);
2616 s.Add_LF();
2617 s += "\'";
2618 s += m_Panel->_currentFolderPrefix;
2619 s += "\'";
2620 s.Add_LF();
2621 s += LangString(IDS_WANT_TO_COPY_FILES);
2622 s += " ?";
2623 const int res = ::MessageBoxW(*m_Panel, s, title, MB_YESNOCANCEL | MB_ICONQUESTION);
2624 if (res != IDYES)
2625 cmd = NDragMenu::k_Cancel;
2626 }
2627
2628 CTargetTransferInfo target;
2629 target.FuncType = k_DragTargetMode_Drop_Begin;
2630 target.KeyState = keyState;
2631 target.Point = pt;
2632 target.OkEffects = *effect;
2633 target.Flags = 0;
2634
2635 target.Cmd_Effect = cmdEffect;
2636 target.Cmd_Type = cmd;
2637 target.FolderType = GetFolderType();
2638
2639 if (cmd == NDragMenu::k_Cancel)
2640 target.Flags |= k_TargetFlags_WasCanceled;
2641 if (menu_WasShown)
2642 target.Flags |= k_TargetFlags_MenuWasShown;
2643
2644 SendToSource_auto(dataObject, target);
2645
2646 CDataObject_GetTransfer transfer;
2647 m_GetTransfer_WasSuccess = DataObject_GetData_GetTransfer(
2648 dataObject, m_Format_7zip_GetTransfer, transfer);
2649
2650 /* The Source (for example, 7-zip) could change file names when drop was confirmed.
2651 So we must reload source file paths here */
2652 if (cmd != NDragMenu::k_Cancel)
2653 LoadNames_From_DataObject(dataObject);
2654
2655 if (cmd == NDragMenu::k_Cancel)
2656 {
2657 opEffect = DROPEFFECT_NONE;
2658 cmdEffect = DROPEFFECT_NONE;
2659 }
2660 else
2661 {
2662 if (m_GetTransfer_WasSuccess)
2663 needDrop_by_Source = ((transfer.Flags & k_SourceFlags_DoNotProcessInTarget) != 0);
2664 if (!needDrop_by_Source)
2665 {
2666 bool moveMode = (cmdEffect == DROPEFFECT_MOVE);
2667 bool needDrop = false;
2668 if (m_IsRightButton && m_Panel)
2669 needDrop = true;
2670 if (m_DropIsAllowed && m_PanelDropIsAllowed)
2671 {
2672 /* if non-empty TargetPath was sent successfully to DataObject,
2673 then the Source is 7-Zip, and that 7zip-Source can copy to FS operation.
2674 So we can disable Drop operation here for such case.
2675 */
2676 needDrop_by_Source = (cmd != NDragMenu::k_AddToArc
2677 && m_TargetPath_WasSent_ToDataObject
2678 && m_TargetPath_NonEmpty_WasSent_ToDataObject);
2679 needDrop = !(needDrop_by_Source);
2680 }
2681 if (needDrop)
2682 {
2683 UString path = GetTargetPath();
2684 if (m_IsAppTarget && m_Panel)
2685 if (m_Panel->IsFSFolder())
2686 path = m_Panel->GetFsPath();
2687
2688 UInt32 sourceFlags = 0;
2689 if (m_GetTransfer_WasSuccess)
2690 sourceFlags = transfer.Flags;
2691
2692 if (menu_WasShown)
2693 target.Flags |= k_TargetFlags_MenuWasShown;
2694
2695 target.Flags |= k_TargetFlags_WasProcessed;
2696
2697 RemoveSelection();
2698 // disableTimerProcessing.Restore();
2699 m_Panel->CompressDropFiles(m_SourcePaths, path,
2700 (cmd == NDragMenu::k_AddToArc), // createNewArchive,
2701 moveMode, sourceFlags,
2702 target.Flags
2703 );
2704 }
2705 }
2706 } // end of if (cmd != NDragMenu::k_Cancel)
2707 {
2708 /* note that, if (we send CFSTR_PERFORMEDDROPEFFECT as DROPEFFECT_MOVE
2709 and Drop() returns (*effect == DROPEFFECT_MOVE), then
2710 Win10-Explorer-Source will try to remove files just after Drop() exit.
2711 But our CompressFiles() could be run without waiting finishing.
2712 DOCs say, that we must send CFSTR_PERFORMEDDROPEFFECT
2713 - DROPEFFECT_NONE : for optimized move
2714 - DROPEFFECT_MOVE : for unoptimized move.
2715 But actually Win10-Explorer-Target sends (DROPEFFECT_MOVE) for move operation.
2716 And it still works as in optimized mode, because "unoptimized" deleting by Source will be performed
2717 if both conditions are met:
2718 1) DROPEFFECT_MOVE is sent to (CFSTR_PERFORMEDDROPEFFECT) and
2719 2) (*effect == DROPEFFECT_MOVE) is returend by Drop().
2720 We don't want to send DROPEFFECT_MOVE here to protect from
2721 deleting file by Win10-Explorer.
2722 We are not sure that allfile fieree processed by move.
2723 */
2724
2725 // for debug: we test the case when source tries to delete original files
2726 // bool res;
2727 // only CFSTR_PERFORMEDDROPEFFECT affects file removing in Win10-Explorer.
2728 // res = SendToSource_UInt32(dataObject, RegisterClipboardFormat(CFSTR_LOGICALPERFORMEDDROPEFFECT), DROPEFFECT_MOVE); // for debug
2729 /* res = */ SendToSource_UInt32(dataObject,
2730 RegisterClipboardFormat(CFSTR_PERFORMEDDROPEFFECT),
2731 cmd == NDragMenu::k_Cancel ? DROPEFFECT_NONE : DROPEFFECT_COPY);
2732 // res = res;
871 } 2733 }
872 RemoveSelection(); 2734 RemoveSelection();
873 m_DataObject.Release();
874 return S_OK;
875}
876 2735
877void CPanel::DropObject(IDataObject *dataObject, const UString &folderPath) 2736 target.FuncType = k_DragTargetMode_Drop_End;
878{ 2737 target.Cmd_Type = cmd;
879 UStringVector names; 2738 if (needDrop_by_Source)
880 GetNamesFromDataObject(dataObject, names); 2739 target.Flags |= k_TargetFlags_MustBeProcessedBySource;
881 CompressDropFiles(names, folderPath);
882}
883 2740
884/* 2741 SendToSource_TransferInfo(dataObject, target);
885void CPanel::CompressDropFiles(HDROP dr) 2742 } catch(...) { hres = E_FAIL; }
886{ 2743
887 UStringVector fileNames; 2744 ClearState();
2745 // *effect |= (1 << 10); // for debug
2746 // *effect = DROPEFFECT_COPY; // for debug
2747
2748 /*
2749 if we return (*effect == DROPEFFECT_MOVE) here,
2750 Explorer-Source at some conditions can treat it as (unoptimized move) mode,
2751 and Explorer-Source will remove source files after DoDragDrop()
2752 in that (unoptimized move) mode.
2753 We want to avoid such (unoptimized move) cases.
2754 So we don't return (*effect == DROPEFFECT_MOVE), here if Source is not 7-Zip.
2755 If source is 7-Zip that will do acual opeartion, then we can return DROPEFFECT_MOVE.
2756 */
2757 if (hres != S_OK || (opEffect == DROPEFFECT_MOVE && !needDrop_by_Source))
888 { 2758 {
889 NShell::CDrop drop(true); 2759 // opEffect = opEffect;
890 drop.Attach(dr); 2760 // opEffect = DROPEFFECT_NONE; // for debug disabled
891 drop.QueryFileNames(fileNames);
892 } 2761 }
893 CompressDropFiles(fileNamesUnicode); 2762
2763 *effect = opEffect;
2764 /* if (hres < 0), DoDragDrop() also will return (hres).
2765 if (hres >= 0), DoDragDrop() will return DRAGDROP_S_DROP;
2766 */
2767 return hres;
894} 2768}
895*/
896 2769
897static bool IsFolderInTemp(const FString &path) 2770
2771
2772// ---------- CPanel ----------
2773
2774
2775static bool Is_Path1_Prefixed_by_Path2(const UString &path, const UString &prefix)
898{ 2776{
899 FString tempPath; 2777 const unsigned len = prefix.Len();
900 if (!MyGetTempPath(tempPath)) 2778 if (path.Len() < len)
901 return false; 2779 return false;
902 if (tempPath.IsEmpty()) 2780 return CompareFileNames(path.Left(len), prefix) == 0;
2781}
2782
2783static bool IsFolderInTemp(const UString &path)
2784{
2785 FString tempPathF;
2786 if (!MyGetTempPath(tempPathF))
903 return false; 2787 return false;
904 unsigned len = tempPath.Len(); 2788 const UString tempPath = fs2us(tempPathF);
905 if (path.Len() < len) 2789 if (tempPath.IsEmpty())
906 return false; 2790 return false;
907 return CompareFileNames(path.Left(len), tempPath) == 0; 2791 return Is_Path1_Prefixed_by_Path2(path, tempPath);
908} 2792}
909 2793
910static bool AreThereNamesFromTemp(const UStringVector &fileNames) 2794static bool AreThereNamesFromTemp(const UStringVector &filePaths)
911{ 2795{
912 FString tempPathF; 2796 FString tempPathF;
913 if (!MyGetTempPath(tempPathF)) 2797 if (!MyGetTempPath(tempPathF))
914 return false; 2798 return false;
915 UString tempPath = fs2us(tempPathF); 2799 const UString tempPath = fs2us(tempPathF);
916 if (tempPath.IsEmpty()) 2800 if (tempPath.IsEmpty())
917 return false; 2801 return false;
918 FOR_VECTOR (i, fileNames) 2802 FOR_VECTOR (i, filePaths)
919 if (fileNames[i].IsPrefixedBy_NoCase(tempPath)) 2803 if (Is_Path1_Prefixed_by_Path2(filePaths[i], tempPath))
920 return true; 2804 return true;
921 return false; 2805 return false;
922} 2806}
923 2807
924void CPanel::CompressDropFiles(const UStringVector &fileNames, const UString &folderPath) 2808
2809/*
2810 empty folderPath means create new Archive to path of first fileName.
2811 createNewArchive == true : show "Add to archive ..." dialog with external program
2812 folderPath.IsEmpty() : create archive in folder of filePaths[0].
2813 createNewArchive == false :
2814 folderPath.IsEmpty() : copy to archive folder that is open in panel
2815 !folderPath.IsEmpty() : CopyFsItems() to folderPath.
2816*/
2817void CPanel::CompressDropFiles(
2818 const UStringVector &filePaths,
2819 const UString &folderPath,
2820 bool createNewArchive,
2821 bool moveMode,
2822 UInt32 sourceFlags,
2823 UInt32 &targetFlags
2824 )
925{ 2825{
926 if (fileNames.Size() == 0) 2826 if (filePaths.Size() == 0)
927 return; 2827 return;
928 bool createNewArchive = true; 2828 // createNewArchive = false; // for debug
929 if (!IsFSFolder())
930 createNewArchive = !DoesItSupportOperations();
931 2829
932 if (createNewArchive) 2830 if (createNewArchive)
933 { 2831 {
934 UString folderPath2 = folderPath; 2832 UString folderPath2 = folderPath;
2833 // folderPath2.Empty(); // for debug
935 if (folderPath2.IsEmpty()) 2834 if (folderPath2.IsEmpty())
936 { 2835 {
937 FString folderPath2F; 2836 {
938 GetOnlyDirPrefix(us2fs(fileNames.Front()), folderPath2F); 2837 FString folderPath2F;
939 folderPath2 = fs2us(folderPath2F); 2838 GetOnlyDirPrefix(us2fs(filePaths.Front()), folderPath2F);
940 if (IsFolderInTemp(folderPath2F)) 2839 folderPath2 = fs2us(folderPath2F);
2840 }
2841 if (IsFolderInTemp(folderPath2))
2842 {
2843 /* we don't want archive to be created in temp directory.
2844 so we change the path to root folder (non-temp) */
941 folderPath2 = ROOT_FS_FOLDER; 2845 folderPath2 = ROOT_FS_FOLDER;
2846 }
942 } 2847 }
2848
2849 UString arcName_base;
2850 const UString arcName = CreateArchiveName(filePaths,
2851 false, // isHash
2852 NULL, // CFileInfo *fi
2853 arcName_base);
943 2854
944 const UString arcName = CreateArchiveName(fileNames); 2855 bool needWait;
945 2856 if (sourceFlags & k_SourceFlags_WaitFinish)
946 CompressFiles(folderPath2, arcName, L"", 2857 needWait = true;
947 true, // addExtension 2858 else if (sourceFlags & k_SourceFlags_DoNotWaitFinish)
948 fileNames, 2859 needWait = false;
949 false, // email 2860 else if (sourceFlags & k_SourceFlags_TempFiles)
950 true, // showDialog 2861 needWait = true;
951 AreThereNamesFromTemp(fileNames) // waitFinish 2862 else
952 ); 2863 needWait = AreThereNamesFromTemp(filePaths);
2864
2865 targetFlags |= (needWait ?
2866 k_TargetFlags_WaitFinish :
2867 k_TargetFlags_DoNotWaitFinish);
2868
2869 CompressFiles(folderPath2, arcName,
2870 L"", // arcType
2871 true, // addExtension
2872 filePaths,
2873 false, // email
2874 true, // showDialog
2875 needWait);
953 } 2876 }
954 else 2877 else
955 CopyFromAsk(fileNames); 2878 {
2879 targetFlags |= k_TargetFlags_WaitFinish;
2880 if (!folderPath.IsEmpty())
2881 {
2882 CCopyToOptions options;
2883 options.moveMode = moveMode;
2884 options.folder = folderPath;
2885 options.showErrorMessages = true; // showErrorMessages is not used for this operation
2886 options.NeedRegistryZone = false;
2887 options.ZoneIdMode = NExtract::NZoneIdMode::kNone;
2888 // maybe we need more options here: FIXME
2889 /* HRESULT hres = */ CopyFsItems(options,
2890 filePaths,
2891 NULL // UStringVector *messages
2892 );
2893 // hres = hres;
2894 }
2895 else
2896 {
2897 CopyFromNoAsk(moveMode, filePaths);
2898 }
2899 }
2900}
2901
2902
2903
2904static unsigned Drag_OnContextMenu(int xPos, int yPos, UInt32 cmdFlags)
2905{
2906 CMenu menu;
2907 CMenuDestroyer menuDestroyer(menu);
2908 /*
2909 Esc key in shown menu doesn't work if we call Drag_OnContextMenu from ::Drop().
2910 We call SetFocus() tp solve that problem.
2911 But the focus will be changed to Target Window after Drag and Drop.
2912 Is it OK to use SetFocus() here ?
2913 Is there another way to enable Esc key ?
2914 */
2915 // _listView.SetFocus(); // for debug
2916 ::SetFocus(g_HWND);
2917 menu.CreatePopup();
2918 /*
2919 int defaultCmd; // = NDragMenu::k_Move;
2920 defaultCmd = NDragMenu::k_None;
2921 */
2922 for (unsigned i = 0; i < Z7_ARRAY_SIZE(NDragMenu::g_Pairs); i++)
2923 {
2924 const NDragMenu::CCmdLangPair &pair = NDragMenu::g_Pairs[i];
2925 const UInt32 cmdAndFlags = pair.CmdId_and_Flags;
2926 const UInt32 cmdId = cmdAndFlags & NDragMenu::k_MenuFlags_CmdMask;
2927 if (cmdId != NDragMenu::k_Cancel)
2928 if ((cmdFlags & ((UInt32)1 << cmdId)) == 0)
2929 continue;
2930 const UINT flags = MF_STRING;
2931 /*
2932 if (prop.IsVisible)
2933 flags |= MF_CHECKED;
2934 if (i == 0)
2935 flags |= MF_GRAYED;
2936 */
2937 // MF_DEFAULT doesn't work
2938 // if (i == 2) flags |= MF_DEFAULT;
2939 // if (i == 4) flags |= MF_HILITE;
2940 // if (cmd == defaultCmd) flags |= MF_HILITE;
2941 UString name = LangString(pair.LangId);
2942 if (name.IsEmpty())
2943 {
2944 if (cmdId == NDragMenu::k_Cancel)
2945 name = "Cancel";
2946 else
2947 name.Add_UInt32(pair.LangId);
2948 }
2949 if (cmdId == NDragMenu::k_Copy_ToArc)
2950 {
2951 // UString destPath = _currentFolderPrefix;
2952 /*
2953 UString destPath = LangString(IDS_CONTEXT_ARCHIVE);
2954 name = MyFormatNew(name, destPath);
2955 */
2956 name.Add_Space();
2957 name += LangString(IDS_CONTEXT_ARCHIVE);
2958 }
2959 if (cmdId == NDragMenu::k_Cancel)
2960 menu.AppendItem(MF_SEPARATOR, 0, (LPCTSTR)NULL);
2961 menu.AppendItem(flags, cmdAndFlags, name);
2962 }
2963 /*
2964 if (defaultCmd != 0)
2965 SetMenuDefaultItem(menu, (unsigned)defaultCmd,
2966 FALSE); // byPos
2967 */
2968 int menuResult = menu.Track(
2969 TPM_LEFTALIGN | TPM_RETURNCMD | TPM_NONOTIFY,
2970 xPos, yPos,
2971 g_HWND
2972 // _listView // for debug
2973 );
2974 /* menu.Track() return value is zero, if the user cancels
2975 the menu without making a selection, or if an error occurs */
2976 if (menuResult <= 0)
2977 menuResult = NDragMenu::k_Cancel;
2978 return (unsigned)menuResult;
2979}
2980
2981
2982
2983void CApp::CreateDragTarget()
2984{
2985 _dropTargetSpec = new CDropTarget();
2986 _dropTarget = _dropTargetSpec;
2987 _dropTargetSpec->App = (this);
2988}
2989
2990void CApp::SetFocusedPanel(unsigned index)
2991{
2992 LastFocusedPanel = index;
2993 _dropTargetSpec->TargetPanelIndex = (int)LastFocusedPanel;
2994}
2995
2996void CApp::DragBegin(unsigned panelIndex)
2997{
2998 _dropTargetSpec->TargetPanelIndex = (int)(NumPanels > 1 ? 1 - panelIndex : panelIndex);
2999 _dropTargetSpec->SrcPanelIndex = (int)panelIndex;
3000}
3001
3002void CApp::DragEnd()
3003{
3004 _dropTargetSpec->TargetPanelIndex = (int)LastFocusedPanel;
3005 _dropTargetSpec->SrcPanelIndex = -1;
956} 3006}
diff --git a/CPP/7zip/UI/FileManager/PanelFolderChange.cpp b/CPP/7zip/UI/FileManager/PanelFolderChange.cpp
index b91195f..a13b88d 100644
--- a/CPP/7zip/UI/FileManager/PanelFolderChange.cpp
+++ b/CPP/7zip/UI/FileManager/PanelFolderChange.cpp
@@ -133,8 +133,9 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, CO
133 133
134 CloseOpenFolders(); 134 CloseOpenFolders();
135 UString sysPath = path; 135 UString sysPath = path;
136 136 /* we will Empty() sysPath variable, if we need to BindToFolder()
137 unsigned prefixSize = NName::GetRootPrefixSize(sysPath); 137 directly with (path) variable */
138 const unsigned prefixSize = NName::GetRootPrefixSize(sysPath);
138 if (prefixSize == 0 || sysPath[prefixSize] == 0) 139 if (prefixSize == 0 || sysPath[prefixSize] == 0)
139 sysPath.Empty(); 140 sysPath.Empty();
140 141
@@ -142,6 +143,7 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, CO
142 if (!sysPath.IsEmpty() && sysPath.Back() == ':' && 143 if (!sysPath.IsEmpty() && sysPath.Back() == ':' &&
143 (sysPath.Len() != 2 || !NName::IsDrivePath2(sysPath))) 144 (sysPath.Len() != 2 || !NName::IsDrivePath2(sysPath)))
144 { 145 {
146 // if base item for alt streams prefix "base:" exists, we will use it
145 UString baseFile = sysPath; 147 UString baseFile = sysPath;
146 baseFile.DeleteBack(); 148 baseFile.DeleteBack();
147 if (NFind::DoesFileOrDirExist(us2fs(baseFile))) 149 if (NFind::DoesFileOrDirExist(us2fs(baseFile)))
@@ -153,22 +155,50 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, CO
153 155
154 while (!sysPath.IsEmpty()) 156 while (!sysPath.IsEmpty())
155 { 157 {
158 if (sysPath.Len() <= prefixSize)
159 {
160 path.DeleteFrom(prefixSize);
161 sysPath.Empty();
162 break;
163 }
164
165 fileInfo.ClearBase();
166 if (IsPathSepar(sysPath.Back()))
167 {
168 /* Windows 10 by default doesn't allow look "Local Settings" that is junction to "AppData\Local",
169 but it does allow look "Local Settings\Temp\*"
170 22.02: at first we try to use paths with slashes "path\" */
171 CFileInfo fi;
172 // CFindFile findFile;
173 // FString path2 = us2fs(sysPath);
174 // path2 += '*'; // CHAR_ANY_MASK;
175 // if (findFile.FindFirst(path2, fi))
176 CEnumerator enumerator;
177 enumerator.SetDirPrefix(us2fs(sysPath));
178 bool found = false;
179 if (enumerator.Next(fi, found))
180 {
181 // sysPath.DeleteBack();
182 fileInfo.SetAsDir();
183 fileInfo.Size = 0;
184 fileInfo.Name.Empty();
185 break;
186 }
187 sysPath.DeleteBack();
188 continue;
189 }
190
156 if (fileInfo.Find(us2fs(sysPath))) 191 if (fileInfo.Find(us2fs(sysPath)))
157 break; 192 break;
158 int pos = sysPath.ReverseFind_PathSepar(); 193 int pos = sysPath.ReverseFind_PathSepar();
159 if (pos < 0) 194 if (pos < 0)
195 {
160 sysPath.Empty(); 196 sysPath.Empty();
161 else 197 break;
198 }
162 { 199 {
163 /* 200 if ((unsigned)pos != sysPath.Len() - 1)
164 if (reducedParts.Size() > 0 || pos < (int)sysPath.Len() - 1)
165 reducedParts.Add(sysPath.Ptr(pos + 1));
166 */
167 #if defined(_WIN32) && !defined(UNDER_CE)
168 if (pos == 2 && NName::IsDrivePath2(sysPath) && sysPath.Len() > 3)
169 pos++; 201 pos++;
170 #endif
171
172 sysPath.DeleteFrom((unsigned)pos); 202 sysPath.DeleteFrom((unsigned)pos);
173 } 203 }
174 } 204 }
@@ -225,7 +255,7 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, CO
225 _folder->BindToFolder(fs2us(dirPrefix), &newFolder); 255 _folder->BindToFolder(fs2us(dirPrefix), &newFolder);
226 else 256 else
227 { 257 {
228 RINOK(res); 258 RINOK(res)
229 openRes.ArchiveIsOpened = true; 259 openRes.ArchiveIsOpened = true;
230 _parentFolders.Back().ParentFolderPath = fs2us(dirPrefix); 260 _parentFolders.Back().ParentFolderPath = fs2us(dirPrefix);
231 path.DeleteFrontal(sysPath.Len()); 261 path.DeleteFrontal(sysPath.Len());
@@ -248,12 +278,12 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, CO
248 for (unsigned curPos = 0; curPos != path.Len();) 278 for (unsigned curPos = 0; curPos != path.Len();)
249 { 279 {
250 UString s = path.Ptr(curPos); 280 UString s = path.Ptr(curPos);
251 int slashPos = NName::FindSepar(s); 281 const int slashPos = NName::FindSepar(s);
252 unsigned skipLen = s.Len(); 282 unsigned skipLen = s.Len();
253 if (slashPos >= 0) 283 if (slashPos >= 0)
254 { 284 {
255 s.DeleteFrom((unsigned)slashPos); 285 s.DeleteFrom((unsigned)slashPos);
256 skipLen = slashPos + 1; 286 skipLen = (unsigned)slashPos + 1;
257 } 287 }
258 288
259 CMyComPtr<IFolderFolder> newFolder; 289 CMyComPtr<IFolderFolder> newFolder;
@@ -262,13 +292,13 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, CO
262 curPos += skipLen; 292 curPos += skipLen;
263 else if (_folderAltStreams) 293 else if (_folderAltStreams)
264 { 294 {
265 int pos = s.Find(L':'); 295 const int pos = s.Find(L':');
266 if (pos >= 0) 296 if (pos >= 0)
267 { 297 {
268 UString baseName = s; 298 UString baseName = s;
269 baseName.DeleteFrom((unsigned)pos); 299 baseName.DeleteFrom((unsigned)pos);
270 if (_folderAltStreams->BindToAltStreams(baseName, &newFolder) == S_OK && newFolder) 300 if (_folderAltStreams->BindToAltStreams(baseName, &newFolder) == S_OK && newFolder)
271 curPos += pos + 1; 301 curPos += (unsigned)pos + 1;
272 } 302 }
273 } 303 }
274 304
@@ -516,14 +546,18 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result)
516 pathParts.DeleteBack(); 546 pathParts.DeleteBack();
517 for (i = 0; i < pathParts.Size(); i++) 547 for (i = 0; i < pathParts.Size(); i++)
518 { 548 {
519 UString name = pathParts[i]; 549 const UString name = pathParts[i];
520 sumPass += name; 550 sumPass += name;
521 sumPass.Add_PathSepar(); 551 sumPass.Add_PathSepar();
522 CFileInfo info; 552 CFileInfo info;
523 DWORD attrib = FILE_ATTRIBUTE_DIRECTORY; 553 DWORD attrib = FILE_ATTRIBUTE_DIRECTORY;
524 if (info.Find(us2fs(sumPass))) 554 if (info.Find(us2fs(sumPass)))
525 attrib = info.Attrib; 555 attrib = info.Attrib;
526 AddComboBoxItem(name.IsEmpty() ? L"\\" : name, GetRealIconIndex(us2fs(sumPass), attrib), i, false); 556 AddComboBoxItem(
557 name.IsEmpty() ? L"\\" : name,
558 GetRealIconIndex(us2fs(sumPass), attrib),
559 (int)i, // iIndent
560 false); // addToList
527 ComboBoxPaths.Add(sumPass); 561 ComboBoxPaths.Add(sumPass);
528 } 562 }
529 563
@@ -633,7 +667,7 @@ void CPanel::FoldersHistory()
633 if (listViewDialog.StringsWereChanged) 667 if (listViewDialog.StringsWereChanged)
634 { 668 {
635 _appState->FolderHistory.RemoveAll(); 669 _appState->FolderHistory.RemoveAll();
636 for (int i = listViewDialog.Strings.Size() - 1; i >= 0; i--) 670 for (int i = (int)listViewDialog.Strings.Size() - 1; i >= 0; i--)
637 _appState->FolderHistory.AddString(listViewDialog.Strings[i]); 671 _appState->FolderHistory.AddString(listViewDialog.Strings[i]);
638 if (listViewDialog.FocusedItemIndex >= 0) 672 if (listViewDialog.FocusedItemIndex >= 0)
639 selectString = listViewDialog.Strings[listViewDialog.FocusedItemIndex]; 673 selectString = listViewDialog.Strings[listViewDialog.FocusedItemIndex];
@@ -695,12 +729,12 @@ void CPanel::OpenParentFolder()
695 if (focusedName != L"\\\\." && 729 if (focusedName != L"\\\\." &&
696 focusedName != L"\\\\?") 730 focusedName != L"\\\\?")
697 { 731 {
698 int pos = focusedName.ReverseFind_PathSepar(); 732 const int pos = focusedName.ReverseFind_PathSepar();
699 if (pos >= 0) 733 if (pos >= 0)
700 { 734 {
701 parentFolderPrefix = focusedName; 735 parentFolderPrefix = focusedName;
702 parentFolderPrefix.DeleteFrom((unsigned)(pos + 1)); 736 parentFolderPrefix.DeleteFrom((unsigned)(pos + 1));
703 focusedName.DeleteFrontal(pos + 1); 737 focusedName.DeleteFrontal((unsigned)(pos + 1));
704 } 738 }
705 } 739 }
706 } 740 }
@@ -812,7 +846,7 @@ void CPanel::OpenDrivesFolder()
812 RefreshListCtrl(); 846 RefreshListCtrl();
813} 847}
814 848
815void CPanel::OpenFolder(int index) 849void CPanel::OpenFolder(unsigned index)
816{ 850{
817 if (index == kParentIndex) 851 if (index == kParentIndex)
818 { 852 {
@@ -820,7 +854,7 @@ void CPanel::OpenFolder(int index)
820 return; 854 return;
821 } 855 }
822 CMyComPtr<IFolderFolder> newFolder; 856 CMyComPtr<IFolderFolder> newFolder;
823 HRESULT res = _folder->BindToFolder(index, &newFolder); 857 const HRESULT res = _folder->BindToFolder((unsigned)index, &newFolder);
824 if (res != 0) 858 if (res != 0)
825 { 859 {
826 MessageBox_Error_HRESULT(res); 860 MessageBox_Error_HRESULT(res);
@@ -839,17 +873,17 @@ void CPanel::OpenFolder(int index)
839void CPanel::OpenAltStreams() 873void CPanel::OpenAltStreams()
840{ 874{
841 CRecordVector<UInt32> indices; 875 CRecordVector<UInt32> indices;
842 GetOperatedItemIndices(indices); 876 Get_ItemIndices_Operated(indices);
843 Int32 realIndex = -1; 877 Int32 realIndex = -1;
844 if (indices.Size() > 1) 878 if (indices.Size() > 1)
845 return; 879 return;
846 if (indices.Size() == 1) 880 if (indices.Size() == 1)
847 realIndex = indices[0]; 881 realIndex = (Int32)indices[0];
848 882
849 if (_folderAltStreams) 883 if (_folderAltStreams)
850 { 884 {
851 CMyComPtr<IFolderFolder> newFolder; 885 CMyComPtr<IFolderFolder> newFolder;
852 _folderAltStreams->BindToAltStreams(realIndex, &newFolder); 886 _folderAltStreams->BindToAltStreams((UInt32)realIndex, &newFolder);
853 if (newFolder) 887 if (newFolder)
854 { 888 {
855 CDisableTimerProcessing disableTimerProcessing(*this); 889 CDisableTimerProcessing disableTimerProcessing(*this);
@@ -864,7 +898,7 @@ void CPanel::OpenAltStreams()
864 #if defined(_WIN32) && !defined(UNDER_CE) 898 #if defined(_WIN32) && !defined(UNDER_CE)
865 UString path; 899 UString path;
866 if (realIndex >= 0) 900 if (realIndex >= 0)
867 path = GetItemFullPath(realIndex); 901 path = GetItemFullPath((UInt32)realIndex);
868 else 902 else
869 { 903 {
870 path = GetFsPath(); 904 path = GetFsPath();
diff --git a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
index 17301b5..bd65aef 100644
--- a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
+++ b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
@@ -68,7 +68,7 @@ class CProcessSnapshot
68{ 68{
69 HANDLE _handle; 69 HANDLE _handle;
70public: 70public:
71 CProcessSnapshot(): _handle(INVALID_HANDLE_VALUE) {}; 71 CProcessSnapshot(): _handle(INVALID_HANDLE_VALUE) {}
72 ~CProcessSnapshot() { Close(); } 72 ~CProcessSnapshot() { Close(); }
73 73
74 bool Close() 74 bool Close()
@@ -136,7 +136,7 @@ public:
136 void SetFromExtension(const char *ext) // ext must be low case 136 void SetFromExtension(const char *ext) // ext must be low case
137 { 137 {
138 ProgNames.Clear(); 138 ProgNames.Clear();
139 for (unsigned i = 0; i < ARRAY_SIZE(g_Progs); i++) 139 for (unsigned i = 0; i < Z7_ARRAY_SIZE(g_Progs); i++)
140 if (FindExtProg(g_Progs[i].Ext, ext)) 140 if (FindExtProg(g_Progs[i].Ext, ext))
141 { 141 {
142 ProgNames.Add(g_Progs[i].Prog); 142 ProgNames.Add(g_Progs[i].Prog);
@@ -220,22 +220,25 @@ static void My_GetProcessFileName(HANDLE hProcess, UString &path)
220 const unsigned maxPath = 1024; 220 const unsigned maxPath = 1024;
221 WCHAR temp[maxPath + 1]; 221 WCHAR temp[maxPath + 1];
222 222
223 const char *func_name = "GetProcessImageFileNameW"; 223 const char *func_name =
224 Func_GetProcessImageFileNameW my_func = (Func_GetProcessImageFileNameW) 224 "GetProcessImageFileNameW";
225 (void *)::GetProcAddress(::GetModuleHandleA("kernel32.dll"), func_name); 225 Func_GetProcessImageFileNameW my_func = Z7_GET_PROC_ADDRESS(
226 Func_GetProcessImageFileNameW, ::GetModuleHandleA("kernel32.dll"), func_name);
226 227
227 if (!my_func) 228 if (!my_func)
228 { 229 {
229 if (!g_Psapi_dll_module) 230 if (!g_Psapi_dll_module)
230 g_Psapi_dll_module = LoadLibraryW(L"Psapi.dll"); 231 g_Psapi_dll_module = LoadLibraryW(L"Psapi.dll");
231 if (g_Psapi_dll_module) 232 if (g_Psapi_dll_module)
232 my_func = (Func_GetProcessImageFileNameW)(void *)::GetProcAddress(g_Psapi_dll_module, func_name); 233 my_func = Z7_GET_PROC_ADDRESS(
234 Func_GetProcessImageFileNameW, g_Psapi_dll_module, func_name);
233 } 235 }
234 236
235 if (my_func) 237 if (my_func)
236 { 238 {
237 // DWORD num = GetProcessImageFileNameW(hProcess, temp, maxPath); 239 const DWORD num =
238 DWORD num = my_func(hProcess, temp, maxPath); 240 // GetProcessImageFileNameW(hProcess, temp, maxPath);
241 my_func(hProcess, temp, maxPath);
239 if (num != 0) 242 if (num != 0)
240 path = temp; 243 path = temp;
241 } 244 }
@@ -318,11 +321,13 @@ public:
318 void SetMainProcess(HANDLE h) 321 void SetMainProcess(HANDLE h)
319 { 322 {
320 #ifndef UNDER_CE 323 #ifndef UNDER_CE
321 324 const
322 Func_GetProcessId func = (Func_GetProcessId)(void *)::GetProcAddress(::GetModuleHandleA("kernel32.dll"), "GetProcessId"); 325 Func_GetProcessId func = Z7_GET_PROC_ADDRESS(
326 Func_GetProcessId, ::GetModuleHandleA("kernel32.dll"),
327 "GetProcessId");
323 if (func) 328 if (func)
324 { 329 {
325 DWORD id = func(h); 330 const DWORD id = func(h);
326 if (id != 0) 331 if (id != 0)
327 _ids.AddToUniqueSorted(id); 332 _ids.AddToUniqueSorted(id);
328 } 333 }
@@ -462,7 +467,7 @@ HRESULT CPanel::OpenAsArc(IInStream *inStream,
462 else 467 else
463 { 468 {
464 if (!folderLink.FileInfo.Find(folderLink.FilePath)) 469 if (!folderLink.FileInfo.Find(folderLink.FilePath))
465 return ::GetLastError(); 470 return GetLastError_noZero_HRESULT();
466 if (folderLink.FileInfo.IsDir()) 471 if (folderLink.FileInfo.IsDir())
467 return S_FALSE; 472 return S_FALSE;
468 folderLink.IsVirtual = false; 473 folderLink.IsVirtual = false;
@@ -471,14 +476,14 @@ HRESULT CPanel::OpenAsArc(IInStream *inStream,
471 folderLink.VirtualPath = virtualFilePath; 476 folderLink.VirtualPath = virtualFilePath;
472 477
473 CFfpOpen ffp; 478 CFfpOpen ffp;
474 HRESULT res = ffp.OpenFileFolderPlugin(inStream, 479 const HRESULT res = ffp.OpenFileFolderPlugin(inStream,
475 folderLink.FilePath.IsEmpty() ? us2fs(virtualFilePath) : folderLink.FilePath, 480 folderLink.FilePath.IsEmpty() ? us2fs(virtualFilePath) : folderLink.FilePath,
476 arcFormat, GetParent()); 481 arcFormat, GetParent());
477 482
478 openRes.Encrypted = ffp.Encrypted; 483 openRes.Encrypted = ffp.Encrypted;
479 openRes.ErrorMessage = ffp.ErrorMessage; 484 openRes.ErrorMessage = ffp.ErrorMessage;
480 485
481 RINOK(res); 486 RINOK(res)
482 487
483 folderLink.Password = ffp.Password; 488 folderLink.Password = ffp.Password;
484 folderLink.UsePassword = ffp.Encrypted; 489 folderLink.UsePassword = ffp.Encrypted;
@@ -571,7 +576,7 @@ HRESULT CPanel::OpenAsArc_Name(const UString &relPath, const UString &arcFormat
571} 576}
572 577
573 578
574HRESULT CPanel::OpenAsArc_Index(int index, const wchar_t *type 579HRESULT CPanel::OpenAsArc_Index(unsigned index, const wchar_t *type
575 // , bool showErrorMessage 580 // , bool showErrorMessage
576 ) 581 )
577{ 582{
@@ -653,36 +658,13 @@ static const char * const kStartExtensions =
653 " mak clw csproj vcproj sln dsp dsw" 658 " mak clw csproj vcproj sln dsp dsw"
654 " "; 659 " ";
655 660
656static bool FindExt(const char *p, const UString &name) 661// bool FindExt(const char *p, const UString &name, AString &s);
657{ 662bool FindExt(const char *p, const UString &name, CStringFinder &finder);
658 int dotPos = name.ReverseFind_Dot();
659 if (dotPos < 0 || dotPos == (int)name.Len() - 1)
660 return false;
661
662 AString s;
663 for (unsigned pos = dotPos + 1;; pos++)
664 {
665 wchar_t c = name[pos];
666 if (c == 0)
667 break;
668 if (c >= 0x80)
669 return false;
670 s += (char)MyCharLower_Ascii((char)c);
671 }
672 for (unsigned i = 0; p[i] != 0;)
673 {
674 unsigned j;
675 for (j = i; p[j] != ' '; j++);
676 if (s.Len() == j - i && memcmp(p + i, (const char *)s, s.Len()) == 0)
677 return true;
678 i = j + 1;
679 }
680 return false;
681}
682 663
683static bool DoItemAlwaysStart(const UString &name) 664static bool DoItemAlwaysStart(const UString &name)
684{ 665{
685 return FindExt(kStartExtensions, name); 666 CStringFinder finder;
667 return FindExt(kStartExtensions, name, finder);
686} 668}
687 669
688UString GetQuotedString(const UString &s); 670UString GetQuotedString(const UString &s);
@@ -754,10 +736,10 @@ static HRESULT StartEditApplication(const UString &path, bool useEditor, HWND wi
754 UStringVector params; 736 UStringVector params;
755 params.Add(path); 737 params.Add(path);
756 738
757 HRESULT res = StartAppWithParams(command, params, process); 739 const WRes res = StartAppWithParams(command, params, process);
758 if (res != SZ_OK) 740 if (res != 0)
759 ::MessageBoxW(window, LangString(IDS_CANNOT_START_EDITOR), L"7-Zip", MB_OK | MB_ICONSTOP); 741 ::MessageBoxW(window, LangString(IDS_CANNOT_START_EDITOR), L"7-Zip", MB_OK | MB_ICONSTOP);
760 return res; 742 return HRESULT_FROM_WIN32(res);
761} 743}
762 744
763 745
@@ -772,7 +754,7 @@ void CApp::DiffFiles()
772 } 754 }
773 755
774 CRecordVector<UInt32> indices; 756 CRecordVector<UInt32> indices;
775 panel.GetSelectedItemsIndices(indices); 757 panel.Get_ItemIndices_Selected(indices);
776 758
777 UString path1, path2; 759 UString path1, path2;
778 if (indices.Size() == 2) 760 if (indices.Size() == 2)
@@ -792,7 +774,7 @@ void CApp::DiffFiles()
792 774
793 path1 = panel.GetItemFullPath(indices[0]); 775 path1 = panel.GetItemFullPath(indices[0]);
794 CRecordVector<UInt32> indices2; 776 CRecordVector<UInt32> indices2;
795 destPanel.GetSelectedItemsIndices(indices2); 777 destPanel.Get_ItemIndices_Selected(indices2);
796 if (indices2.Size() == 1) 778 if (indices2.Size() == 1)
797 path2 = destPanel.GetItemFullPath(indices2[0]); 779 path2 = destPanel.GetItemFullPath(indices2[0]);
798 else 780 else
@@ -820,19 +802,19 @@ void CApp::DiffFiles(const UString &path1, const UString &path2)
820 params.Add(path1); 802 params.Add(path1);
821 params.Add(path2); 803 params.Add(path2);
822 804
823 HRESULT res; 805 WRes res;
824 { 806 {
825 CProcess process; 807 CProcess process;
826 res = StartAppWithParams(command, params, process); 808 res = StartAppWithParams(command, params, process);
827 } 809 }
828 if (res == SZ_OK) 810 if (res == 0)
829 return; 811 return;
830 ::MessageBoxW(_window, LangString(IDS_CANNOT_START_EDITOR), L"7-Zip", MB_OK | MB_ICONSTOP); 812 ::MessageBoxW(_window, LangString(IDS_CANNOT_START_EDITOR), L"7-Zip", MB_OK | MB_ICONSTOP);
831} 813}
832 814
833 815
834#ifndef _UNICODE 816#ifndef _UNICODE
835typedef BOOL (WINAPI * ShellExecuteExWP)(LPSHELLEXECUTEINFOW lpExecInfo); 817typedef BOOL (WINAPI * Func_ShellExecuteExW)(LPSHELLEXECUTEINFOW lpExecInfo);
836#endif 818#endif
837 819
838static HRESULT StartApplication(const UString &dir, const UString &path, HWND window, CProcess &process) 820static HRESULT StartApplication(const UString &dir, const UString &path, HWND window, CProcess &process)
@@ -844,7 +826,7 @@ static HRESULT StartApplication(const UString &dir, const UString &path, HWND wi
844 int dot = path2.ReverseFind_Dot(); 826 int dot = path2.ReverseFind_Dot();
845 int separ = path2.ReverseFind_PathSepar(); 827 int separ = path2.ReverseFind_PathSepar();
846 if (dot < 0 || dot < separ) 828 if (dot < 0 || dot < separ)
847 path2 += '.'; 829 path2.Add_Dot();
848 } 830 }
849 #endif 831 #endif
850 832
@@ -862,12 +844,15 @@ static HRESULT StartApplication(const UString &dir, const UString &path, HWND wi
862 execInfo.lpParameters = NULL; 844 execInfo.lpParameters = NULL;
863 execInfo.lpDirectory = dir.IsEmpty() ? NULL : (LPCWSTR)dir; 845 execInfo.lpDirectory = dir.IsEmpty() ? NULL : (LPCWSTR)dir;
864 execInfo.nShow = SW_SHOWNORMAL; 846 execInfo.nShow = SW_SHOWNORMAL;
865 execInfo.hProcess = 0; 847 execInfo.hProcess = NULL;
866 ShellExecuteExWP shellExecuteExW = (ShellExecuteExWP) 848 const
867 (void *)::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "ShellExecuteExW"); 849 Func_ShellExecuteExW
868 if (!shellExecuteExW) 850 f_ShellExecuteExW = Z7_GET_PROC_ADDRESS(
851 Func_ShellExecuteExW, ::GetModuleHandleW(L"shell32.dll"),
852 "ShellExecuteExW");
853 if (!f_ShellExecuteExW)
869 return 0; 854 return 0;
870 shellExecuteExW(&execInfo); 855 f_ShellExecuteExW(&execInfo);
871 result = (UINT32)(UINT_PTR)execInfo.hInstApp; 856 result = (UINT32)(UINT_PTR)execInfo.hInstApp;
872 process.Attach(execInfo.hProcess); 857 process.Attach(execInfo.hProcess);
873 } 858 }
@@ -895,7 +880,7 @@ static HRESULT StartApplication(const UString &dir, const UString &path, HWND wi
895 #endif 880 #endif
896 ; 881 ;
897 execInfo.nShow = SW_SHOWNORMAL; 882 execInfo.nShow = SW_SHOWNORMAL;
898 execInfo.hProcess = 0; 883 execInfo.hProcess = NULL;
899 ::ShellExecuteEx(&execInfo); 884 ::ShellExecuteEx(&execInfo);
900 result = (UINT32)(UINT_PTR)execInfo.hInstApp; 885 result = (UINT32)(UINT_PTR)execInfo.hInstApp;
901 process.Attach(execInfo.hProcess); 886 process.Attach(execInfo.hProcess);
@@ -927,7 +912,7 @@ static void StartApplicationDontWait(const UString &dir, const UString &path, HW
927 StartApplication(dir, path, window, process); 912 StartApplication(dir, path, window, process);
928} 913}
929 914
930void CPanel::EditItem(int index, bool useEditor) 915void CPanel::EditItem(unsigned index, bool useEditor)
931{ 916{
932 if (!_parentFolders.IsEmpty()) 917 if (!_parentFolders.IsEmpty())
933 { 918 {
@@ -939,7 +924,7 @@ void CPanel::EditItem(int index, bool useEditor)
939} 924}
940 925
941 926
942void CPanel::OpenFolderExternal(int index) 927void CPanel::OpenFolderExternal(unsigned index)
943{ 928{
944 UString prefix = GetFsPath(); 929 UString prefix = GetFsPath();
945 UString path = prefix; 930 UString path = prefix;
@@ -1010,9 +995,10 @@ bool CPanel::IsVirus_Message(const UString &name)
1010 } 995 }
1011 if (i != name2.Len()) 996 if (i != name2.Len())
1012 { 997 {
998 CStringFinder finder;
1013 UString name3 = name2; 999 UString name3 = name2;
1014 name3.DeleteFrom(i); 1000 name3.DeleteFrom(i);
1015 if (FindExt(kExeExtensions, name3)) 1001 if (FindExt(kExeExtensions, name3, finder))
1016 isVirus = true; 1002 isVirus = true;
1017 } 1003 }
1018 } 1004 }
@@ -1025,13 +1011,13 @@ bool CPanel::IsVirus_Message(const UString &name)
1025 1011
1026 if (!isSpaceError) 1012 if (!isSpaceError)
1027 { 1013 {
1028 int pos1 = s.Find(L'('); 1014 const int pos1 = s.Find(L'(');
1029 if (pos1 >= 0) 1015 if (pos1 >= 0)
1030 { 1016 {
1031 int pos2 = s.Find(L')', pos1 + 1); 1017 const int pos2 = s.Find(L')', (unsigned)pos1 + 1);
1032 if (pos2 >= 0) 1018 if (pos2 >= 0)
1033 { 1019 {
1034 s.Delete(pos1, pos2 + 1 - pos1); 1020 s.Delete((unsigned)pos1, (unsigned)pos2 + 1 - (unsigned)pos1);
1035 if (pos1 > 0 && s[pos1 - 1] == ' ' && s[pos1] == '.') 1021 if (pos1 > 0 && s[pos1 - 1] == ' ' && s[pos1] == '.')
1036 s.Delete(pos1 - 1); 1022 s.Delete(pos1 - 1);
1037 } 1023 }
@@ -1050,10 +1036,10 @@ bool CPanel::IsVirus_Message(const UString &name)
1050} 1036}
1051 1037
1052 1038
1053void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal, const wchar_t *type) 1039void CPanel::OpenItem(unsigned index, bool tryInternal, bool tryExternal, const wchar_t *type)
1054{ 1040{
1055 CDisableTimerProcessing disableTimerProcessing(*this); 1041 CDisableTimerProcessing disableTimerProcessing(*this);
1056 UString name = GetItemRelPath2(index); 1042 const UString name = GetItemRelPath2(index);
1057 1043
1058 if (tryExternal) 1044 if (tryExternal)
1059 if (IsVirus_Message(name)) 1045 if (IsVirus_Message(name))
@@ -1096,7 +1082,7 @@ void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal, const wchar
1096 1082
1097class CThreadCopyFrom: public CProgressThreadVirt 1083class CThreadCopyFrom: public CProgressThreadVirt
1098{ 1084{
1099 HRESULT ProcessVirt(); 1085 HRESULT ProcessVirt() Z7_override;
1100public: 1086public:
1101 UString FullPath; 1087 UString FullPath;
1102 UInt32 ItemIndex; 1088 UInt32 ItemIndex;
@@ -1133,7 +1119,7 @@ HRESULT CPanel::OnOpenItemChanged(UInt32 index, const wchar_t *fullFilePath,
1133 t.UpdateCallbackSpec->Password = password; 1119 t.UpdateCallbackSpec->Password = password;
1134 1120
1135 1121
1136 RINOK(t.Create(GetItemName(index), (HWND)*this)); 1122 RINOK(t.Create(GetItemName(index), (HWND)*this))
1137 return t.Result; 1123 return t.Result;
1138} 1124}
1139 1125
@@ -1292,7 +1278,7 @@ static THREAD_FUNC_DECL MyThreadFunction(void *param)
1292 1278
1293 if (firstPass && indices.Size() == 1) 1279 if (firstPass && indices.Size() == 1)
1294 { 1280 {
1295 DWORD curTime = GetTickCount() - startTime; 1281 const DWORD curTime = GetTickCount() - startTime;
1296 1282
1297 /* 1283 /*
1298 if (curTime > 5 * 1000) 1284 if (curTime > 5 * 1000)
@@ -1312,7 +1298,7 @@ static THREAD_FUNC_DECL MyThreadFunction(void *param)
1312 DEBUG_PRINT_NUM(" -- firstPass -- time = ", curTime) 1298 DEBUG_PRINT_NUM(" -- firstPass -- time = ", curTime)
1313 } 1299 }
1314 1300
1315 processes.DisableWait(indices[waitResult]); 1301 processes.DisableWait(indices[(unsigned)waitResult]);
1316 } 1302 }
1317 1303
1318 firstPass = false; 1304 firstPass = false;
@@ -1324,7 +1310,7 @@ static THREAD_FUNC_DECL MyThreadFunction(void *param)
1324 } 1310 }
1325 1311
1326 1312
1327 DWORD curTime = GetTickCount() - startTime; 1313 const DWORD curTime = GetTickCount() - startTime;
1328 1314
1329 DEBUG_PRINT_NUM("after time = ", curTime) 1315 DEBUG_PRINT_NUM("after time = ", curTime)
1330 1316
@@ -1444,15 +1430,14 @@ static bool WriteZoneFile(CFSTR fileName, const CByteBuffer &buf)
1444*/ 1430*/
1445 1431
1446/* 1432/*
1447class CBufSeqOutStream_WithFile: 1433Z7_CLASS_IMP_COM_1(
1448 public ISequentialOutStream, 1434 CBufSeqOutStream_WithFile
1449 public CMyUnknownImp 1435 , ISequentialOutStream
1450{ 1436)
1451 Byte *_buffer; 1437 Byte *_buffer;
1452 size_t _size; 1438 size_t _size;
1453 size_t _pos; 1439 size_t _pos;
1454 1440
1455
1456 size_t _fileWritePos; 1441 size_t _fileWritePos;
1457 bool fileMode; 1442 bool fileMode;
1458public: 1443public:
@@ -1478,9 +1463,6 @@ public:
1478 1463
1479 HRESULT FlushToFile(); 1464 HRESULT FlushToFile();
1480 size_t GetPos() const { return _pos; } 1465 size_t GetPos() const { return _pos; }
1481
1482 MY_UNKNOWN_IMP
1483 STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
1484}; 1466};
1485 1467
1486static const UInt32 kBlockSize = ((UInt32)1 << 31); 1468static const UInt32 kBlockSize = ((UInt32)1 << 31);
@@ -1565,7 +1547,7 @@ tryInternal tryExternal
1565 alwaysStart(name) : external 1547 alwaysStart(name) : external
1566*/ 1548*/
1567 1549
1568void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bool editMode, bool useEditor, const wchar_t *type) 1550void CPanel::OpenItemInArchive(unsigned index, bool tryInternal, bool tryExternal, bool editMode, bool useEditor, const wchar_t *type)
1569{ 1551{
1570 // we don't want to change hash data here 1552 // we don't want to change hash data here
1571 if (IsHashFolder()) 1553 if (IsHashFolder())
@@ -1830,7 +1812,7 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
1830 // win7 / win10 work so for some extensions (pdf, html ..); 1812 // win7 / win10 work so for some extensions (pdf, html ..);
1831 DEBUG_PRINT("#### (HANDLE)process == 0"); 1813 DEBUG_PRINT("#### (HANDLE)process == 0");
1832 // return; 1814 // return;
1833 if (res != SZ_OK) 1815 if (res != S_OK)
1834 return; 1816 return;
1835 } 1817 }
1836 1818
@@ -1839,7 +1821,7 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
1839 tpi->FileIndex = index; 1821 tpi->FileIndex = index;
1840 tpi->RelPath = relPath; 1822 tpi->RelPath = relPath;
1841 1823
1842 if ((HANDLE)process != 0) 1824 if ((HANDLE)process)
1843 tpi->Processes.SetMainProcess(process.Detach()); 1825 tpi->Processes.SetMainProcess(process.Detach());
1844 1826
1845 ::CThread th; 1827 ::CThread th;
diff --git a/CPP/7zip/UI/FileManager/PanelItems.cpp b/CPP/7zip/UI/FileManager/PanelItems.cpp
index 3cccf27..0cb33d8 100644
--- a/CPP/7zip/UI/FileManager/PanelItems.cpp
+++ b/CPP/7zip/UI/FileManager/PanelItems.cpp
@@ -41,7 +41,7 @@ static bool GetColumnVisible(PROPID propID, bool isFsFolder)
41 return true; 41 return true;
42} 42}
43 43
44static int GetColumnWidth(PROPID propID, VARTYPE /* varType */) 44static unsigned GetColumnWidth(PROPID propID, VARTYPE /* varType */)
45{ 45{
46 switch (propID) 46 switch (propID)
47 { 47 {
@@ -216,7 +216,7 @@ HRESULT CPanel::InitColumns()
216 item.IsVisible = isVisible; 216 item.IsVisible = isVisible;
217 item.Width = columnInfo.Width; 217 item.Width = columnInfo.Width;
218 if (isVisible) 218 if (isVisible)
219 item.Order = order++; 219 item.Order = (int)(order++);
220 continue; 220 continue;
221 } 221 }
222 } 222 }
@@ -225,14 +225,14 @@ HRESULT CPanel::InitColumns()
225 { 225 {
226 CPropColumn &item = _columns[i]; 226 CPropColumn &item = _columns[i];
227 if (item.IsVisible && item.Order < 0) 227 if (item.IsVisible && item.Order < 0)
228 item.Order = order++; 228 item.Order = (int)(order++);
229 } 229 }
230 230
231 for (i = 0; i < _columns.Size(); i++) 231 for (i = 0; i < _columns.Size(); i++)
232 { 232 {
233 CPropColumn &item = _columns[i]; 233 CPropColumn &item = _columns[i];
234 if (item.Order < 0) 234 if (item.Order < 0)
235 item.Order = order++; 235 item.Order = (int)(order++);
236 } 236 }
237 237
238 CPropColumns newColumns; 238 CPropColumns newColumns;
@@ -285,14 +285,14 @@ HRESULT CPanel::InitColumns()
285 { 285 {
286 const CPropColumn &prop = newColumns[i]; 286 const CPropColumn &prop = newColumns[i];
287 if (prop.Order < (int)newColumns.Size() && columns[prop.Order] == -1) 287 if (prop.Order < (int)newColumns.Size() && columns[prop.Order] == -1)
288 columns[prop.Order] = i; 288 columns[prop.Order] = (int)i;
289 else 289 else
290 orderError = true; 290 orderError = true;
291 } 291 }
292 292
293 for (;;) 293 for (;;)
294 { 294 {
295 unsigned numColumns = _visibleColumns.Size(); 295 const unsigned numColumns = _visibleColumns.Size();
296 if (numColumns == 0) 296 if (numColumns == 0)
297 break; 297 break;
298 DeleteColumn(numColumns - 1); 298 DeleteColumn(numColumns - 1);
@@ -319,14 +319,14 @@ void CPanel::DeleteColumn(unsigned index)
319 319
320void CPanel::AddColumn(const CPropColumn &prop) 320void CPanel::AddColumn(const CPropColumn &prop)
321{ 321{
322 const int index = _visibleColumns.Size(); 322 const unsigned index = _visibleColumns.Size();
323 323
324 LV_COLUMNW column; 324 LV_COLUMNW column;
325 column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_ORDER; 325 column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_ORDER;
326 column.cx = prop.Width; 326 column.cx = (int)prop.Width;
327 column.fmt = GetColumnAlign(prop.ID, prop.Type); 327 column.fmt = GetColumnAlign(prop.ID, prop.Type);
328 column.iOrder = index; // must be <= _listView.ItemCount 328 column.iOrder = (int)index; // must be <= _listView.ItemCount
329 column.iSubItem = index; // must be <= _listView.ItemCount 329 column.iSubItem = (int)index; // must be <= _listView.ItemCount
330 column.pszText = const_cast<wchar_t *>((const wchar_t *)prop.Name); 330 column.pszText = const_cast<wchar_t *>((const wchar_t *)prop.Name);
331 331
332 _visibleColumns.Add(prop); 332 _visibleColumns.Add(prop);
@@ -346,7 +346,7 @@ int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData);
346void CPanel::GetSelectedNames(UStringVector &selectedNames) 346void CPanel::GetSelectedNames(UStringVector &selectedNames)
347{ 347{
348 CRecordVector<UInt32> indices; 348 CRecordVector<UInt32> indices;
349 GetSelectedItemsIndices(indices); 349 Get_ItemIndices_Selected(indices);
350 selectedNames.ClearAndReserve(indices.Size()); 350 selectedNames.ClearAndReserve(indices.Size());
351 FOR_VECTOR (i, indices) 351 FOR_VECTOR (i, indices)
352 selectedNames.AddInReserved(GetItemRelPath(indices[i])); 352 selectedNames.AddInReserved(GetItemRelPath(indices[i]));
@@ -364,7 +364,7 @@ void CPanel::GetSelectedNames(UStringVector &selectedNames)
364 item.mask = LVIF_TEXT | LVIF_PARAM; 364 item.mask = LVIF_TEXT | LVIF_PARAM;
365 if (!_listView.GetItem(&item)) 365 if (!_listView.GetItem(&item))
366 continue; 366 continue;
367 int realIndex = GetRealIndex(item); 367 const unsigned realIndex = GetRealIndex(item);
368 if (realIndex == kParentIndex) 368 if (realIndex == kParentIndex)
369 continue; 369 continue;
370 if (_selectedStatusVector[realIndex]) 370 if (_selectedStatusVector[realIndex])
@@ -384,7 +384,7 @@ void CPanel::SaveSelectedState(CSelectedState &s)
384 { 384 {
385 if (s.FocusedItem >= 0) 385 if (s.FocusedItem >= 0)
386 { 386 {
387 int realIndex = GetRealItemIndex(s.FocusedItem); 387 const unsigned realIndex = GetRealItemIndex(s.FocusedItem);
388 if (realIndex != kParentIndex) 388 if (realIndex != kParentIndex)
389 { 389 {
390 s.FocusedName = GetItemRelPath(realIndex); 390 s.FocusedName = GetItemRelPath(realIndex);
@@ -422,10 +422,11 @@ HRESULT CPanel::RefreshListCtrl(const CSelectedState &s)
422} 422}
423*/ 423*/
424 424
425HRESULT CPanel::RefreshListCtrl_SaveFocused() 425HRESULT CPanel::RefreshListCtrl_SaveFocused(bool onTimer)
426{ 426{
427 CSelectedState state; 427 CSelectedState state;
428 SaveSelectedState(state); 428 SaveSelectedState(state);
429 state.CalledFromTimer = onTimer;
429 return RefreshListCtrl(state); 430 return RefreshListCtrl(state);
430} 431}
431 432
@@ -437,7 +438,7 @@ void CPanel::SetFocusedSelectedItem(int index, bool select)
437 _listView.SetItemState(index, state, state); 438 _listView.SetItemState(index, state, state);
438 if (!_mySelectMode && select) 439 if (!_mySelectMode && select)
439 { 440 {
440 int realIndex = GetRealItemIndex(index); 441 const unsigned realIndex = GetRealItemIndex(index);
441 if (realIndex != kParentIndex) 442 if (realIndex != kParentIndex)
442 _selectedStatusVector[realIndex] = true; 443 _selectedStatusVector[realIndex] = true;
443 } 444 }
@@ -464,6 +465,9 @@ extern UInt32 g_NumMessages;
464 465
465HRESULT CPanel::RefreshListCtrl(const CSelectedState &state) 466HRESULT CPanel::RefreshListCtrl(const CSelectedState &state)
466{ 467{
468 m_DropHighlighted_SelectionIndex = -1;
469 m_DropHighlighted_SubFolderName.Empty();
470
467 if (!_folder) 471 if (!_folder)
468 return S_OK; 472 return S_OK;
469 473
@@ -474,7 +478,8 @@ HRESULT CPanel::RefreshListCtrl(const CSelectedState &state)
474 */ 478 */
475 479
476 _dontShowMode = false; 480 _dontShowMode = false;
477 LoadFullPathAndShow(); 481 if (!state.CalledFromTimer)
482 LoadFullPathAndShow();
478 // OutputDebugStringA("=======\n"); 483 // OutputDebugStringA("=======\n");
479 // OutputDebugStringA("s1 \n"); 484 // OutputDebugStringA("s1 \n");
480 CDisableTimerProcessing timerProcessing(*this); 485 CDisableTimerProcessing timerProcessing(*this);
@@ -506,11 +511,13 @@ HRESULT CPanel::RefreshListCtrl(const CSelectedState &state)
506 511
507 // m_Files.Clear(); 512 // m_Files.Clear();
508 513
514 /*
509 if (!_folder) 515 if (!_folder)
510 { 516 {
511 // throw 1; 517 // throw 1;
512 SetToRootFolder(); 518 SetToRootFolder();
513 } 519 }
520 */
514 521
515 _headerToolBar.EnableButton(kParentFolderID, !IsRootFolder()); 522 _headerToolBar.EnableButton(kParentFolderID, !IsRootFolder());
516 523
@@ -530,16 +537,44 @@ HRESULT CPanel::RefreshListCtrl(const CSelectedState &state)
530 } 537 }
531 */ 538 */
532 539
540 _isDirVector.Clear();
533 // DWORD tickCount1 = GetTickCount(); 541 // DWORD tickCount1 = GetTickCount();
534 RINOK(_folder->LoadItems()); 542 IFolderFolder *folder = _folder;
543 RINOK(_folder->LoadItems())
535 // DWORD tickCount2 = GetTickCount(); 544 // DWORD tickCount2 = GetTickCount();
536 RINOK(InitColumns());
537
538 // OutputDebugString(TEXT("Start Dir\n")); 545 // OutputDebugString(TEXT("Start Dir\n"));
546 RINOK(InitColumns())
547
539 UInt32 numItems; 548 UInt32 numItems;
540 _folder->GetNumberOfItems(&numItems); 549 _folder->GetNumberOfItems(&numItems);
550 {
551 NCOM::CPropVariant prop;
552 _isDirVector.ClearAndSetSize(numItems);
553 bool *vec = (bool *)&_isDirVector.Front();
554 HRESULT hres = S_OK;
555 unsigned i;
556 for (i = 0; i < numItems; i++)
557 {
558 hres = folder->GetProperty(i, kpidIsDir, &prop);
559 if (hres != S_OK)
560 break;
561 bool v = false;
562 if (prop.vt == VT_BOOL)
563 v = VARIANT_BOOLToBool(prop.boolVal);
564 else if (prop.vt != VT_EMPTY)
565 break;
566 vec[i] = v;
567 }
568 if (i != numItems)
569 {
570 _isDirVector.Clear();
571 if (hres == S_OK)
572 hres = E_FAIL;
573 }
574 RINOK(hres)
575 }
541 576
542 bool showDots = _showDots && !IsRootFolder(); 577 const bool showDots = _showDots && !IsRootFolder();
543 578
544 _listView.SetItemCount(numItems + (showDots ? 1 : 0)); 579 _listView.SetItemCount(numItems + (showDots ? 1 : 0));
545 580
@@ -582,20 +617,20 @@ HRESULT CPanel::RefreshListCtrl(const CSelectedState &state)
582 617
583 if (showDots) 618 if (showDots)
584 { 619 {
585 UString itemName (".."); 620 const UString itemName ("..");
586 item.iItem = listViewItemCount; 621 item.iItem = listViewItemCount;
587 if (itemName == state.FocusedName) 622 if (itemName == state.FocusedName)
588 cursorIndex = listViewItemCount; 623 cursorIndex = listViewItemCount;
589 item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; 624 item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
590 int subItem = 0; 625 int subItem = 0;
591 item.iSubItem = subItem++; 626 item.iSubItem = subItem++;
592 item.lParam = kParentIndex; 627 item.lParam = (LPARAM)(int)kParentIndex;
593 #ifdef USE_EMBED_ITEM 628 #ifdef USE_EMBED_ITEM
594 item.pszText = const_cast<wchar_t *>((const wchar_t *)itemName); 629 item.pszText = const_cast<wchar_t *>((const wchar_t *)itemName);
595 #else 630 #else
596 item.pszText = LPSTR_TEXTCALLBACKW; 631 item.pszText = LPSTR_TEXTCALLBACKW;
597 #endif 632 #endif
598 UInt32 attrib = FILE_ATTRIBUTE_DIRECTORY; 633 const UInt32 attrib = FILE_ATTRIBUTE_DIRECTORY;
599 item.iImage = _extToIconMap.GetIconIndex(attrib, itemName); 634 item.iImage = _extToIconMap.GetIconIndex(attrib, itemName);
600 if (item.iImage < 0) 635 if (item.iImage < 0)
601 item.iImage = 0; 636 item.iImage = 0;
@@ -671,7 +706,7 @@ HRESULT CPanel::RefreshListCtrl(const CSelectedState &state)
671 item.iItem = listViewItemCount; 706 item.iItem = listViewItemCount;
672 707
673 item.iSubItem = subItem++; 708 item.iSubItem = subItem++;
674 item.lParam = i; 709 item.lParam = (LPARAM)i;
675 710
676 /* 711 /*
677 int finish = nameLen - 4; 712 int finish = nameLen - 4;
@@ -731,7 +766,7 @@ HRESULT CPanel::RefreshListCtrl(const CSelectedState &state)
731 UInt32 attrib = 0; 766 UInt32 attrib = 0;
732 { 767 {
733 NCOM::CPropVariant prop; 768 NCOM::CPropVariant prop;
734 RINOK(_folder->GetProperty(i, kpidAttrib, &prop)); 769 RINOK(_folder->GetProperty(i, kpidAttrib, &prop))
735 if (prop.vt == VT_UI4) 770 if (prop.vt == VT_UI4)
736 attrib = prop.ulVal; 771 attrib = prop.ulVal;
737 } 772 }
@@ -844,7 +879,7 @@ HRESULT CPanel::RefreshListCtrl(const CSelectedState &state)
844} 879}
845 880
846 881
847void CPanel::GetSelectedItemsIndices(CRecordVector<UInt32> &indices) const 882void CPanel::Get_ItemIndices_Selected(CRecordVector<UInt32> &indices) const
848{ 883{
849 indices.Clear(); 884 indices.Clear();
850 /* 885 /*
@@ -858,46 +893,49 @@ void CPanel::GetSelectedItemsIndices(CRecordVector<UInt32> &indices) const
858 HeapSort(&indices.Front(), indices.Size()); 893 HeapSort(&indices.Front(), indices.Size());
859 */ 894 */
860 const bool *v = &_selectedStatusVector.Front(); 895 const bool *v = &_selectedStatusVector.Front();
861 unsigned size = _selectedStatusVector.Size(); 896 const unsigned size = _selectedStatusVector.Size();
862 for (unsigned i = 0; i < size; i++) 897 for (unsigned i = 0; i < size; i++)
863 if (v[i]) 898 if (v[i])
864 indices.Add(i); 899 indices.Add(i);
865} 900}
866 901
867 902
868void CPanel::GetOperatedItemIndices(CRecordVector<UInt32> &indices) const 903void CPanel::Get_ItemIndices_Operated(CRecordVector<UInt32> &indices) const
869{ 904{
870 GetSelectedItemsIndices(indices); 905 Get_ItemIndices_Selected(indices);
871 if (!indices.IsEmpty()) 906 if (!indices.IsEmpty())
872 return; 907 return;
873 if (_listView.GetSelectedCount() == 0) 908 if (_listView.GetSelectedCount() == 0)
874 return; 909 return;
875 int focusedItem = _listView.GetFocusedItem(); 910 const int focusedItem = _listView.GetFocusedItem();
876 if (focusedItem >= 0) 911 if (focusedItem >= 0)
877 { 912 {
878 if (_listView.IsItemSelected(focusedItem)) 913 if (_listView.IsItemSelected(focusedItem))
879 { 914 {
880 int realIndex = GetRealItemIndex(focusedItem); 915 const unsigned realIndex = GetRealItemIndex(focusedItem);
881 if (realIndex != kParentIndex) 916 if (realIndex != kParentIndex)
882 indices.Add(realIndex); 917 indices.Add(realIndex);
883 } 918 }
884 } 919 }
885} 920}
886 921
887void CPanel::GetAllItemIndices(CRecordVector<UInt32> &indices) const 922void CPanel::Get_ItemIndices_All(CRecordVector<UInt32> &indices) const
888{ 923{
889 indices.Clear(); 924 indices.Clear();
890 UInt32 numItems; 925 UInt32 numItems;
891 if (_folder->GetNumberOfItems(&numItems) == S_OK) 926 if (_folder->GetNumberOfItems(&numItems) != S_OK)
892 for (UInt32 i = 0; i < numItems; i++) 927 return;
893 indices.Add(i); 928 indices.ClearAndSetSize(numItems);
929 UInt32 *vec = (UInt32 *)&indices.Front();
930 for (UInt32 i = 0; i < numItems; i++)
931 vec[i] = i;
894} 932}
895 933
896void CPanel::GetOperatedIndicesSmart(CRecordVector<UInt32> &indices) const 934void CPanel::Get_ItemIndices_OperSmart(CRecordVector<UInt32> &indices) const
897{ 935{
898 GetOperatedItemIndices(indices); 936 Get_ItemIndices_Operated(indices);
899 if (indices.IsEmpty() || (indices.Size() == 1 && indices[0] == (UInt32)(Int32)-1)) 937 if (indices.IsEmpty() || (indices.Size() == 1 && indices[0] == (UInt32)(Int32)-1))
900 GetAllItemIndices(indices); 938 Get_ItemIndices_All(indices);
901} 939}
902 940
903/* 941/*
@@ -907,14 +945,14 @@ void CPanel::GetOperatedListViewIndices(CRecordVector<UInt32> &indices) const
907 int numItems = _listView.GetItemCount(); 945 int numItems = _listView.GetItemCount();
908 for (int i = 0; i < numItems; i++) 946 for (int i = 0; i < numItems; i++)
909 { 947 {
910 int realIndex = GetRealItemIndex(i); 948 const unsigned realIndex = GetRealItemIndex(i);
911 if (realIndex >= 0) 949 if (realIndex >= 0)
912 if (_selectedStatusVector[realIndex]) 950 if (_selectedStatusVector[realIndex])
913 indices.Add(i); 951 indices.Add(i);
914 } 952 }
915 if (indices.IsEmpty()) 953 if (indices.IsEmpty())
916 { 954 {
917 int focusedItem = _listView.GetFocusedItem(); 955 const int focusedItem = _listView.GetFocusedItem();
918 if (focusedItem >= 0) 956 if (focusedItem >= 0)
919 indices.Add(focusedItem); 957 indices.Add(focusedItem);
920 } 958 }
@@ -931,7 +969,7 @@ void CPanel::EditItem(bool useEditor)
931 { 969 {
932 bool needRefresh = false; 970 bool needRefresh = false;
933 CRecordVector<UInt32> indices; 971 CRecordVector<UInt32> indices;
934 GetOperatedItemIndices(indices); 972 Get_ItemIndices_Operated(indices);
935 FOR_VECTOR (i, indices) 973 FOR_VECTOR (i, indices)
936 { 974 {
937 UInt32 index = indices[i]; 975 UInt32 index = indices[i];
@@ -952,10 +990,10 @@ void CPanel::EditItem(bool useEditor)
952 } 990 }
953 991
954 992
955 int focusedItem = _listView.GetFocusedItem(); 993 const int focusedItem = _listView.GetFocusedItem();
956 if (focusedItem < 0) 994 if (focusedItem < 0)
957 return; 995 return;
958 int realIndex = GetRealItemIndex(focusedItem); 996 const unsigned realIndex = GetRealItemIndex(focusedItem);
959 if (realIndex == kParentIndex) 997 if (realIndex == kParentIndex)
960 return; 998 return;
961 if (!IsItem_Folder(realIndex)) 999 if (!IsItem_Folder(realIndex))
@@ -964,10 +1002,10 @@ void CPanel::EditItem(bool useEditor)
964 1002
965void CPanel::OpenFocusedItemAsInternal(const wchar_t *type) 1003void CPanel::OpenFocusedItemAsInternal(const wchar_t *type)
966{ 1004{
967 int focusedItem = _listView.GetFocusedItem(); 1005 const int focusedItem = _listView.GetFocusedItem();
968 if (focusedItem < 0) 1006 if (focusedItem < 0)
969 return; 1007 return;
970 int realIndex = GetRealItemIndex(focusedItem); 1008 const unsigned realIndex = GetRealItemIndex(focusedItem);
971 if (IsItem_Folder(realIndex)) 1009 if (IsItem_Folder(realIndex))
972 OpenFolder(realIndex); 1010 OpenFolder(realIndex);
973 else 1011 else
@@ -977,17 +1015,17 @@ void CPanel::OpenFocusedItemAsInternal(const wchar_t *type)
977void CPanel::OpenSelectedItems(bool tryInternal) 1015void CPanel::OpenSelectedItems(bool tryInternal)
978{ 1016{
979 CRecordVector<UInt32> indices; 1017 CRecordVector<UInt32> indices;
980 GetOperatedItemIndices(indices); 1018 Get_ItemIndices_Operated(indices);
981 if (indices.Size() > 20) 1019 if (indices.Size() > 20)
982 { 1020 {
983 MessageBox_Error_LangID(IDS_TOO_MANY_ITEMS); 1021 MessageBox_Error_LangID(IDS_TOO_MANY_ITEMS);
984 return; 1022 return;
985 } 1023 }
986 1024
987 int focusedItem = _listView.GetFocusedItem(); 1025 const int focusedItem = _listView.GetFocusedItem();
988 if (focusedItem >= 0) 1026 if (focusedItem >= 0)
989 { 1027 {
990 int realIndex = GetRealItemIndex(focusedItem); 1028 const unsigned realIndex = GetRealItemIndex(focusedItem);
991 if (realIndex == kParentIndex && (tryInternal || indices.Size() == 0) && _listView.IsItemSelected(focusedItem)) 1029 if (realIndex == kParentIndex && (tryInternal || indices.Size() == 0) && _listView.IsItemSelected(focusedItem))
992 indices.Insert(0, realIndex); 1030 indices.Insert(0, realIndex);
993 } 1031 }
@@ -1016,7 +1054,7 @@ void CPanel::OpenSelectedItems(bool tryInternal)
1016 } 1054 }
1017} 1055}
1018 1056
1019UString CPanel::GetItemName(int itemIndex) const 1057UString CPanel::GetItemName(unsigned itemIndex) const
1020{ 1058{
1021 if (itemIndex == kParentIndex) 1059 if (itemIndex == kParentIndex)
1022 return L".."; 1060 return L"..";
@@ -1028,7 +1066,7 @@ UString CPanel::GetItemName(int itemIndex) const
1028 return prop.bstrVal; 1066 return prop.bstrVal;
1029} 1067}
1030 1068
1031UString CPanel::GetItemName_for_Copy(int itemIndex) const 1069UString CPanel::GetItemName_for_Copy(unsigned itemIndex) const
1032{ 1070{
1033 if (itemIndex == kParentIndex) 1071 if (itemIndex == kParentIndex)
1034 return L".."; 1072 return L"..";
@@ -1048,7 +1086,7 @@ UString CPanel::GetItemName_for_Copy(int itemIndex) const
1048 return Get_Correct_FsFile_Name(s); 1086 return Get_Correct_FsFile_Name(s);
1049} 1087}
1050 1088
1051void CPanel::GetItemName(int itemIndex, UString &s) const 1089void CPanel::GetItemName(unsigned itemIndex, UString &s) const
1052{ 1090{
1053 if (itemIndex == kParentIndex) 1091 if (itemIndex == kParentIndex)
1054 { 1092 {
@@ -1063,7 +1101,7 @@ void CPanel::GetItemName(int itemIndex, UString &s) const
1063 s.SetFromBstr(prop.bstrVal); 1101 s.SetFromBstr(prop.bstrVal);
1064} 1102}
1065 1103
1066UString CPanel::GetItemPrefix(int itemIndex) const 1104UString CPanel::GetItemPrefix(unsigned itemIndex) const
1067{ 1105{
1068 if (itemIndex == kParentIndex) 1106 if (itemIndex == kParentIndex)
1069 return UString(); 1107 return UString();
@@ -1076,12 +1114,12 @@ UString CPanel::GetItemPrefix(int itemIndex) const
1076 return prefix; 1114 return prefix;
1077} 1115}
1078 1116
1079UString CPanel::GetItemRelPath(int itemIndex) const 1117UString CPanel::GetItemRelPath(unsigned itemIndex) const
1080{ 1118{
1081 return GetItemPrefix(itemIndex) + GetItemName(itemIndex); 1119 return GetItemPrefix(itemIndex) + GetItemName(itemIndex);
1082} 1120}
1083 1121
1084UString CPanel::GetItemRelPath2(int itemIndex) const 1122UString CPanel::GetItemRelPath2(unsigned itemIndex) const
1085{ 1123{
1086 UString s = GetItemRelPath(itemIndex); 1124 UString s = GetItemRelPath(itemIndex);
1087 #if defined(_WIN32) && !defined(UNDER_CE) 1125 #if defined(_WIN32) && !defined(UNDER_CE)
@@ -1094,7 +1132,50 @@ UString CPanel::GetItemRelPath2(int itemIndex) const
1094 return s; 1132 return s;
1095} 1133}
1096 1134
1097UString CPanel::GetItemFullPath(int itemIndex) const 1135
1136void CPanel::Add_ItemRelPath2_To_String(unsigned itemIndex, UString &s) const
1137{
1138 if (itemIndex == kParentIndex)
1139 {
1140 s += "..";
1141 return;
1142 }
1143
1144 const unsigned start = s.Len();
1145 NCOM::CPropVariant prop;
1146 if (_folder->GetProperty(itemIndex, kpidPrefix, &prop) != S_OK)
1147 throw 2723400;
1148 if (prop.vt == VT_BSTR)
1149 s += prop.bstrVal;
1150
1151 const wchar_t *name = NULL;
1152 unsigned nameLen = 0;
1153
1154 if (_folderGetItemName)
1155 _folderGetItemName->GetItemName(itemIndex, &name, &nameLen);
1156 if (name)
1157 s += name;
1158 else
1159 {
1160 prop.Clear();
1161 if (_folder->GetProperty(itemIndex, kpidName, &prop) != S_OK)
1162 throw 2723400;
1163 if (prop.vt != VT_BSTR)
1164 throw 2723401;
1165 s += prop.bstrVal;
1166 }
1167
1168 #if defined(_WIN32) && !defined(UNDER_CE)
1169 if (s.Len() - start == 2 && NFile::NName::IsDrivePath2(s.Ptr(start)))
1170 {
1171 if (IsFSDrivesFolder() && !IsDeviceDrivesPrefix())
1172 s.Add_PathSepar();
1173 }
1174 #endif
1175}
1176
1177
1178UString CPanel::GetItemFullPath(unsigned itemIndex) const
1098{ 1179{
1099 return GetFsPath() + GetItemRelPath2(itemIndex); 1180 return GetFsPath() + GetItemRelPath2(itemIndex);
1100} 1181}
@@ -1111,28 +1192,30 @@ bool CPanel::GetItem_BoolProp(UInt32 itemIndex, PROPID propID) const
1111 throw 2723401; 1192 throw 2723401;
1112} 1193}
1113 1194
1114bool CPanel::IsItem_Deleted(int itemIndex) const 1195bool CPanel::IsItem_Deleted(unsigned itemIndex) const
1115{ 1196{
1116 if (itemIndex == kParentIndex) 1197 if (itemIndex == kParentIndex)
1117 return false; 1198 return false;
1118 return GetItem_BoolProp(itemIndex, kpidIsDeleted); 1199 return GetItem_BoolProp(itemIndex, kpidIsDeleted);
1119} 1200}
1120 1201
1121bool CPanel::IsItem_Folder(int itemIndex) const 1202bool CPanel::IsItem_Folder(unsigned itemIndex) const
1122{ 1203{
1123 if (itemIndex == kParentIndex) 1204 if (itemIndex == kParentIndex)
1124 return true; 1205 return true;
1206 if (itemIndex < _isDirVector.Size())
1207 return _isDirVector[itemIndex];
1125 return GetItem_BoolProp(itemIndex, kpidIsDir); 1208 return GetItem_BoolProp(itemIndex, kpidIsDir);
1126} 1209}
1127 1210
1128bool CPanel::IsItem_AltStream(int itemIndex) const 1211bool CPanel::IsItem_AltStream(unsigned itemIndex) const
1129{ 1212{
1130 if (itemIndex == kParentIndex) 1213 if (itemIndex == kParentIndex)
1131 return false; 1214 return false;
1132 return GetItem_BoolProp(itemIndex, kpidIsAltStream); 1215 return GetItem_BoolProp(itemIndex, kpidIsAltStream);
1133} 1216}
1134 1217
1135UInt64 CPanel::GetItem_UInt64Prop(int itemIndex, PROPID propID) const 1218UInt64 CPanel::GetItem_UInt64Prop(unsigned itemIndex, PROPID propID) const
1136{ 1219{
1137 if (itemIndex == kParentIndex) 1220 if (itemIndex == kParentIndex)
1138 return 0; 1221 return 0;
@@ -1145,7 +1228,7 @@ UInt64 CPanel::GetItem_UInt64Prop(int itemIndex, PROPID propID) const
1145 return 0; 1228 return 0;
1146} 1229}
1147 1230
1148UInt64 CPanel::GetItemSize(int itemIndex) const 1231UInt64 CPanel::GetItemSize(unsigned itemIndex) const
1149{ 1232{
1150 if (itemIndex == kParentIndex) 1233 if (itemIndex == kParentIndex)
1151 return 0; 1234 return 0;
@@ -1169,7 +1252,7 @@ void CPanel::SaveListViewInfo()
1169 if (!_listView.GetColumn(i, &winColumnInfo)) 1252 if (!_listView.GetColumn(i, &winColumnInfo))
1170 throw 1; 1253 throw 1;
1171 prop.Order = winColumnInfo.iOrder; 1254 prop.Order = winColumnInfo.iOrder;
1172 prop.Width = winColumnInfo.cx; 1255 prop.Width = (UInt32)(Int32)winColumnInfo.cx;
1173 } 1256 }
1174 1257
1175 CListViewInfo viewInfo; 1258 CListViewInfo viewInfo;
@@ -1247,22 +1330,22 @@ void CPanel::ShowColumnsContextMenu(int x, int y)
1247 menu.AppendItem(flags, kCommandStart + i, prop.Name); 1330 menu.AppendItem(flags, kCommandStart + i, prop.Name);
1248 } 1331 }
1249 1332
1250 int menuResult = menu.Track(TPM_LEFTALIGN | TPM_RETURNCMD | TPM_NONOTIFY, x, y, _listView); 1333 const int menuResult = menu.Track(TPM_LEFTALIGN | TPM_RETURNCMD | TPM_NONOTIFY, x, y, _listView);
1251 1334
1252 if (menuResult >= kCommandStart && menuResult <= kCommandStart + (int)_columns.Size()) 1335 if (menuResult >= kCommandStart && menuResult <= kCommandStart + (int)_columns.Size())
1253 { 1336 {
1254 int index = menuResult - kCommandStart; 1337 const unsigned index = (unsigned)(menuResult - kCommandStart);
1255 CPropColumn &prop = _columns[index]; 1338 CPropColumn &prop = _columns[index];
1256 prop.IsVisible = !prop.IsVisible; 1339 prop.IsVisible = !prop.IsVisible;
1257 1340
1258 if (prop.IsVisible) 1341 if (prop.IsVisible)
1259 { 1342 {
1260 prop.Order = _visibleColumns.Size(); 1343 prop.Order = (int)_visibleColumns.Size();
1261 AddColumn(prop); 1344 AddColumn(prop);
1262 } 1345 }
1263 else 1346 else
1264 { 1347 {
1265 int visibleIndex = _visibleColumns.FindItem_for_PropID(prop.ID); 1348 const int visibleIndex = _visibleColumns.FindItem_for_PropID(prop.ID);
1266 if (visibleIndex >= 0) 1349 if (visibleIndex >= 0)
1267 { 1350 {
1268 /* 1351 /*
@@ -1277,15 +1360,15 @@ void CPanel::ShowColumnsContextMenu(int x, int y)
1277 _sortID = kpidName; 1360 _sortID = kpidName;
1278 _ascending = true; 1361 _ascending = true;
1279 } 1362 }
1280 DeleteColumn(visibleIndex); 1363 DeleteColumn((unsigned)visibleIndex);
1281 } 1364 }
1282 } 1365 }
1283 } 1366 }
1284} 1367}
1285 1368
1286void CPanel::OnReload() 1369void CPanel::OnReload(bool onTimer)
1287{ 1370{
1288 HRESULT res = RefreshListCtrl_SaveFocused(); 1371 const HRESULT res = RefreshListCtrl_SaveFocused(onTimer);
1289 if (res != S_OK) 1372 if (res != S_OK)
1290 MessageBox_Error_HRESULT(res); 1373 MessageBox_Error_HRESULT(res);
1291} 1374}
@@ -1304,5 +1387,5 @@ void CPanel::OnTimer()
1304 return; 1387 return;
1305 if (wasChanged == 0) 1388 if (wasChanged == 0)
1306 return; 1389 return;
1307 OnReload(); 1390 OnReload(true); // onTimer
1308} 1391}
diff --git a/CPP/7zip/UI/FileManager/PanelKey.cpp b/CPP/7zip/UI/FileManager/PanelKey.cpp
index 3ab478e..a4ea489 100644
--- a/CPP/7zip/UI/FileManager/PanelKey.cpp
+++ b/CPP/7zip/UI/FileManager/PanelKey.cpp
@@ -29,9 +29,9 @@ static const CVKeyPropIDPair g_VKeyPropIDPairs[] =
29 29
30static int FindVKeyPropIDPair(WORD vKey) 30static int FindVKeyPropIDPair(WORD vKey)
31{ 31{
32 for (unsigned i = 0; i < ARRAY_SIZE(g_VKeyPropIDPairs); i++) 32 for (unsigned i = 0; i < Z7_ARRAY_SIZE(g_VKeyPropIDPairs); i++)
33 if (g_VKeyPropIDPairs[i].VKey == vKey) 33 if (g_VKeyPropIDPairs[i].VKey == vKey)
34 return i; 34 return (int)i;
35 return -1; 35 return -1;
36} 36}
37 37
@@ -43,17 +43,18 @@ bool CPanel::OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result)
43 _panelCallback->OnTab(); 43 _panelCallback->OnTab();
44 return false; 44 return false;
45 } 45 }
46 bool alt = IsKeyDown(VK_MENU); 46 const bool alt = IsKeyDown(VK_MENU);
47 bool ctrl = IsKeyDown(VK_CONTROL); 47 const bool ctrl = IsKeyDown(VK_CONTROL);
48 // bool leftCtrl = IsKeyDown(VK_LCONTROL); 48 // const bool leftCtrl = IsKeyDown(VK_LCONTROL);
49 bool rightCtrl = IsKeyDown(VK_RCONTROL); 49 const bool rightCtrl = IsKeyDown(VK_RCONTROL);
50 bool shift = IsKeyDown(VK_SHIFT); 50 const bool shift = IsKeyDown(VK_SHIFT);
51 result = 0; 51 result = 0;
52 52
53 if (keyDownInfo->wVKey >= '0' && keyDownInfo->wVKey <= '9' && 53 if (keyDownInfo->wVKey >= '0' &&
54 keyDownInfo->wVKey <= '9' &&
54 (rightCtrl || alt)) 55 (rightCtrl || alt))
55 { 56 {
56 int index = keyDownInfo->wVKey - '0'; 57 const unsigned index = (unsigned)(keyDownInfo->wVKey - '0');
57 if (shift) 58 if (shift)
58 { 59 {
59 SetBookmark(index); 60 SetBookmark(index);
@@ -67,7 +68,8 @@ bool CPanel::OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result)
67 } 68 }
68 69
69 if ((keyDownInfo->wVKey == VK_F2 || 70 if ((keyDownInfo->wVKey == VK_F2 ||
70 keyDownInfo->wVKey == VK_F1) && alt && !ctrl && !shift) 71 keyDownInfo->wVKey == VK_F1)
72 && alt && !ctrl && !shift)
71 { 73 {
72 _panelCallback->SetFocusToPath(keyDownInfo->wVKey == VK_F1 ? 0 : 1); 74 _panelCallback->SetFocusToPath(keyDownInfo->wVKey == VK_F1 ? 0 : 1);
73 return true; 75 return true;
@@ -80,7 +82,7 @@ bool CPanel::OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result)
80 82
81 if (keyDownInfo->wVKey >= VK_F3 && keyDownInfo->wVKey <= VK_F12 && ctrl) 83 if (keyDownInfo->wVKey >= VK_F3 && keyDownInfo->wVKey <= VK_F12 && ctrl)
82 { 84 {
83 int index = FindVKeyPropIDPair(keyDownInfo->wVKey); 85 const int index = FindVKeyPropIDPair(keyDownInfo->wVKey);
84 if (index >= 0) 86 if (index >= 0)
85 SortItemsWithPropID(g_VKeyPropIDPairs[index].PropID); 87 SortItemsWithPropID(g_VKeyPropIDPairs[index].PropID);
86 } 88 }
@@ -313,6 +315,14 @@ bool CPanel::OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result)
313 return true; 315 return true;
314 } 316 }
315 return false; 317 return false;
318 case 'W':
319 if (ctrl)
320 {
321 // SendMessage();
322 PostMessage(g_HWND, WM_COMMAND, IDCLOSE, 0);
323 return true;
324 }
325 return false;
316 case 'Z': 326 case 'Z':
317 if (ctrl) 327 if (ctrl)
318 { 328 {
@@ -326,7 +336,7 @@ bool CPanel::OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result)
326 case '4': 336 case '4':
327 if (ctrl) 337 if (ctrl)
328 { 338 {
329 int styleIndex = keyDownInfo->wVKey - '1'; 339 const unsigned styleIndex = (unsigned)(keyDownInfo->wVKey - '1');
330 SetListViewMode(styleIndex); 340 SetListViewMode(styleIndex);
331 return true; 341 return true;
332 } 342 }
diff --git a/CPP/7zip/UI/FileManager/PanelListNotify.cpp b/CPP/7zip/UI/FileManager/PanelListNotify.cpp
index d2114f1..2fb0e87 100644
--- a/CPP/7zip/UI/FileManager/PanelListNotify.cpp
+++ b/CPP/7zip/UI/FileManager/PanelListNotify.cpp
@@ -289,8 +289,8 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
289 const void *data; 289 const void *data;
290 UInt32 dataSize; 290 UInt32 dataSize;
291 UInt32 propType; 291 UInt32 propType;
292 RINOK(_folderRawProps->GetRawProp(realIndex, propID, &data, &dataSize, &propType)); 292 RINOK(_folderRawProps->GetRawProp(realIndex, propID, &data, &dataSize, &propType))
293 unsigned limit = item.cchTextMax - 1; 293 const unsigned limit = (unsigned)item.cchTextMax - 1;
294 if (dataSize == 0) 294 if (dataSize == 0)
295 { 295 {
296 text[0] = 0; 296 text[0] = 0;
@@ -425,11 +425,11 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
425 if (name) 425 if (name)
426 { 426 {
427 unsigned dest = 0; 427 unsigned dest = 0;
428 unsigned limit = item.cchTextMax - 1; 428 const unsigned limit = (unsigned)item.cchTextMax - 1;
429 429
430 for (unsigned i = 0; dest < limit;) 430 for (unsigned i = 0; dest < limit;)
431 { 431 {
432 wchar_t c = name[i++]; 432 const wchar_t c = name[i++];
433 if (c == 0) 433 if (c == 0)
434 break; 434 break;
435 text[dest++] = c; 435 text[dest++] = c;
@@ -488,10 +488,10 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
488 if (name) 488 if (name)
489 { 489 {
490 unsigned dest = 0; 490 unsigned dest = 0;
491 unsigned limit = item.cchTextMax - 1; 491 const unsigned limit = (unsigned)item.cchTextMax - 1;
492 for (unsigned i = 0; dest < limit;) 492 for (unsigned i = 0; dest < limit;)
493 { 493 {
494 wchar_t c = name[i++]; 494 const wchar_t c = name[i++];
495 if (c == 0) 495 if (c == 0)
496 break; 496 break;
497 text[dest++] = c; 497 text[dest++] = c;
@@ -502,7 +502,7 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
502 } 502 }
503 } 503 }
504 504
505 HRESULT res = _folder->GetProperty(realIndex, propID, &prop); 505 const HRESULT res = _folder->GetProperty(realIndex, propID, &prop);
506 506
507 if (res != S_OK) 507 if (res != S_OK)
508 { 508 {
@@ -517,7 +517,7 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
517 } 517 }
518 else if (prop.vt == VT_BSTR) 518 else if (prop.vt == VT_BSTR)
519 { 519 {
520 unsigned limit = item.cchTextMax - 1; 520 const unsigned limit = (unsigned)item.cchTextMax - 1;
521 const wchar_t *src = prop.bstrVal; 521 const wchar_t *src = prop.bstrVal;
522 unsigned i; 522 unsigned i;
523 for (i = 0; i < limit; i++) 523 for (i = 0; i < limit; i++)
@@ -535,10 +535,10 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
535 char temp[64]; 535 char temp[64];
536 ConvertPropertyToShortString2(temp, prop, propID, _timestampLevel); 536 ConvertPropertyToShortString2(temp, prop, propID, _timestampLevel);
537 unsigned i; 537 unsigned i;
538 unsigned limit = item.cchTextMax - 1; 538 const unsigned limit = (unsigned)item.cchTextMax - 1;
539 for (i = 0; i < limit; i++) 539 for (i = 0; i < limit; i++)
540 { 540 {
541 wchar_t c = (Byte)temp[i]; 541 const wchar_t c = (Byte)temp[i];
542 if (c == 0) 542 if (c == 0)
543 break; 543 break;
544 text[i] = c; 544 text[i] = c;
@@ -555,11 +555,11 @@ extern DWORD g_ComCtl32Version;
555 555
556void CPanel::OnItemChanged(NMLISTVIEW *item) 556void CPanel::OnItemChanged(NMLISTVIEW *item)
557{ 557{
558 int index = (int)item->lParam; 558 const unsigned index = (unsigned)item->lParam;
559 if (index == kParentIndex) 559 if (index == kParentIndex)
560 return; 560 return;
561 bool oldSelected = (item->uOldState & LVIS_SELECTED) != 0; 561 const bool oldSelected = (item->uOldState & LVIS_SELECTED) != 0;
562 bool newSelected = (item->uNewState & LVIS_SELECTED) != 0; 562 const bool newSelected = (item->uNewState & LVIS_SELECTED) != 0;
563 // Don't change this code. It works only with such check 563 // Don't change this code. It works only with such check
564 if (oldSelected != newSelected) 564 if (oldSelected != newSelected)
565 _selectedStatusVector[index] = newSelected; 565 _selectedStatusVector[index] = newSelected;
@@ -712,7 +712,13 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result)
712 } 712 }
713 case LVN_BEGINDRAG: 713 case LVN_BEGINDRAG:
714 { 714 {
715 OnDrag((LPNMLISTVIEW)header); 715 OnDrag((LPNMLISTVIEW)header, false);
716 Post_Refresh_StatusBar();
717 break;
718 }
719 case LVN_BEGINRDRAG:
720 {
721 OnDrag((LPNMLISTVIEW)header, true);
716 Post_Refresh_StatusBar(); 722 Post_Refresh_StatusBar();
717 break; 723 break;
718 } 724 }
@@ -739,7 +745,7 @@ bool CPanel::OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result)
739 lplvcd->clrTextBk = GetBkColorForItem(lplvcd->nmcd.dwItemSpec, 745 lplvcd->clrTextBk = GetBkColorForItem(lplvcd->nmcd.dwItemSpec,
740 lplvcd->nmcd.lItemlParam); 746 lplvcd->nmcd.lItemlParam);
741 */ 747 */
742 int realIndex = (int)lplvcd->nmcd.lItemlParam; 748 const unsigned realIndex = (unsigned)lplvcd->nmcd.lItemlParam;
743 lplvcd->clrTextBk = _listView.GetBkColor(); 749 lplvcd->clrTextBk = _listView.GetBkColor();
744 if (_mySelectMode) 750 if (_mySelectMode)
745 { 751 {
@@ -793,40 +799,44 @@ void CPanel::Refresh_StatusBar()
793 // DWORD dw = GetTickCount(); 799 // DWORD dw = GetTickCount();
794 800
795 CRecordVector<UInt32> indices; 801 CRecordVector<UInt32> indices;
796 GetOperatedItemIndices(indices); 802 Get_ItemIndices_Operated(indices);
797
798 wchar_t temp[32];
799 ConvertUInt32ToString(indices.Size(), temp);
800 wcscat(temp, L" / ");
801 ConvertUInt32ToString(_selectedStatusVector.Size(), temp + wcslen(temp));
802
803 // UString s1 = MyFormatNew(g_App.LangString_N_SELECTED_ITEMS, NumberToString(indices.Size()));
804 // UString s1 = MyFormatNew(IDS_N_SELECTED_ITEMS, NumberToString(indices.Size()));
805 _statusBar.SetText(0, MyFormatNew(g_App.LangString_N_SELECTED_ITEMS, temp));
806 // _statusBar.SetText(0, MyFormatNew(IDS_N_SELECTED_ITEMS, NumberToString(indices.Size())));
807 803
808 wchar_t selectSizeString[32]; 804 {
809 selectSizeString[0] = 0; 805 UString s;
806 s.Add_UInt32(indices.Size());
807 s += " / ";
808 s.Add_UInt32(_selectedStatusVector.Size());
809
810 // UString s1 = MyFormatNew(g_App.LangString_N_SELECTED_ITEMS, NumberToString(indices.Size()));
811 // UString s1 = MyFormatNew(IDS_N_SELECTED_ITEMS, NumberToString(indices.Size()));
812 _statusBar.SetText(0, MyFormatNew(g_App.LangString_N_SELECTED_ITEMS, s));
813 // _statusBar.SetText(0, MyFormatNew(IDS_N_SELECTED_ITEMS, NumberToString(indices.Size())));
814 }
810 815
811 if (indices.Size() > 0)
812 { 816 {
813 // for (unsigned ttt = 0; ttt < 1000; ttt++) { 817 wchar_t selectSizeString[32];
814 UInt64 totalSize = 0; 818 selectSizeString[0] = 0;
815 FOR_VECTOR (i, indices) 819
816 totalSize += GetItemSize(indices[i]); 820 if (indices.Size() > 0)
817 ConvertSizeToString(totalSize, selectSizeString); 821 {
818 // } 822 // for (unsigned ttt = 0; ttt < 1000; ttt++) {
823 UInt64 totalSize = 0;
824 FOR_VECTOR (i, indices)
825 totalSize += GetItemSize(indices[i]);
826 ConvertSizeToString(totalSize, selectSizeString);
827 // }
828 }
829 _statusBar.SetText(1, selectSizeString);
819 } 830 }
820 _statusBar.SetText(1, selectSizeString);
821 831
822 int focusedItem = _listView.GetFocusedItem(); 832 const int focusedItem = _listView.GetFocusedItem();
823 wchar_t sizeString[32]; 833 wchar_t sizeString[32];
824 sizeString[0] = 0; 834 sizeString[0] = 0;
825 wchar_t dateString[32]; 835 wchar_t dateString[32];
826 dateString[0] = 0; 836 dateString[0] = 0;
827 if (focusedItem >= 0 && _listView.GetSelectedCount() > 0) 837 if (focusedItem >= 0 && _listView.GetSelectedCount() > 0)
828 { 838 {
829 int realIndex = GetRealItemIndex(focusedItem); 839 const unsigned realIndex = GetRealItemIndex(focusedItem);
830 if (realIndex != kParentIndex) 840 if (realIndex != kParentIndex)
831 { 841 {
832 ConvertSizeToString(GetItemSize(realIndex), sizeString); 842 ConvertSizeToString(GetItemSize(realIndex), sizeString);
diff --git a/CPP/7zip/UI/FileManager/PanelMenu.cpp b/CPP/7zip/UI/FileManager/PanelMenu.cpp
index 9e86951..f0afe15 100644
--- a/CPP/7zip/UI/FileManager/PanelMenu.cpp
+++ b/CPP/7zip/UI/FileManager/PanelMenu.cpp
@@ -20,8 +20,10 @@
20#include "MyLoadMenu.h" 20#include "MyLoadMenu.h"
21#include "PropertyName.h" 21#include "PropertyName.h"
22 22
23#include "resource.h"
24#include "PropertyNameRes.h" 23#include "PropertyNameRes.h"
24#include "resource.h"
25
26// #define SHOW_DEBUG_PANEL_MENU
25 27
26using namespace NWindows; 28using namespace NWindows;
27 29
@@ -32,13 +34,33 @@ LONG g_DllRefCount = 0;
32static const UINT kSevenZipStartMenuID = kMenuCmdID_Plugin_Start; 34static const UINT kSevenZipStartMenuID = kMenuCmdID_Plugin_Start;
33static const UINT kSystemStartMenuID = kMenuCmdID_Plugin_Start + 400; 35static const UINT kSystemStartMenuID = kMenuCmdID_Plugin_Start + 400;
34 36
37
38#ifdef SHOW_DEBUG_PANEL_MENU
39static void Print_Ptr(void *p, const char *s)
40{
41 char temp[32];
42 ConvertUInt64ToHex((UInt64)(void *)p, temp);
43 AString m;
44 m += temp;
45 m.Add_Space();
46 m += s;
47 OutputDebugStringA(m);
48}
49#define ODS(sz) { Print_Ptr(this, sz); }
50#define ODS_U(s) { OutputDebugStringW(s); }
51#else
52#define ODS(sz)
53#define ODS_U(s)
54#endif
55
56
35void CPanel::InvokeSystemCommand(const char *command) 57void CPanel::InvokeSystemCommand(const char *command)
36{ 58{
37 NCOM::CComInitializer comInitializer; 59 NCOM::CComInitializer comInitializer;
38 if (!IsFsOrPureDrivesFolder()) 60 if (!IsFsOrPureDrivesFolder())
39 return; 61 return;
40 CRecordVector<UInt32> operatedIndices; 62 CRecordVector<UInt32> operatedIndices;
41 GetOperatedItemIndices(operatedIndices); 63 Get_ItemIndices_Operated(operatedIndices);
42 if (operatedIndices.IsEmpty()) 64 if (operatedIndices.IsEmpty())
43 return; 65 return;
44 CMyComPtr<IContextMenu> contextMenu; 66 CMyComPtr<IContextMenu> contextMenu;
@@ -173,7 +195,7 @@ void CPanel::Properties()
173 // message.SelectFirst = false; 195 // message.SelectFirst = false;
174 196
175 CRecordVector<UInt32> operatedIndices; 197 CRecordVector<UInt32> operatedIndices;
176 GetOperatedItemIndices(operatedIndices); 198 Get_ItemIndices_Operated(operatedIndices);
177 199
178 if (operatedIndices.Size() == 1) 200 if (operatedIndices.Size() == 1)
179 { 201 {
@@ -346,7 +368,7 @@ void CPanel::Properties()
346 UInt32 numProps; 368 UInt32 numProps;
347 if (getProps->GetArcNumProps(level, &numProps) == S_OK) 369 if (getProps->GetArcNumProps(level, &numProps) == S_OK)
348 { 370 {
349 const int kNumSpecProps = ARRAY_SIZE(kSpecProps); 371 const int kNumSpecProps = Z7_ARRAY_SIZE(kSpecProps);
350 372
351 AddSeparator(message); 373 AddSeparator(message);
352 374
@@ -357,7 +379,7 @@ void CPanel::Properties()
357 VARTYPE vt; 379 VARTYPE vt;
358 if (i < 0) 380 if (i < 0)
359 propID = kSpecProps[i + kNumSpecProps]; 381 propID = kSpecProps[i + kNumSpecProps];
360 else if (getProps->GetArcPropInfo(level, i, &name, &propID, &vt) != S_OK) 382 else if (getProps->GetArcPropInfo(level, (UInt32)i, &name, &propID, &vt) != S_OK)
361 continue; 383 continue;
362 NCOM::CPropVariant prop; 384 NCOM::CPropVariant prop;
363 if (getProps->GetArcProp(level, propID, &prop) != S_OK) 385 if (getProps->GetArcProp(level, propID, &prop) != S_OK)
@@ -369,12 +391,12 @@ void CPanel::Properties()
369 391
370 if (level2 < numLevels - 1) 392 if (level2 < numLevels - 1)
371 { 393 {
372 UInt32 level = numLevels - 1 - level2; 394 const UInt32 level = numLevels - 1 - level2;
373 UInt32 numProps; 395 UInt32 numProps;
374 if (getProps->GetArcNumProps2(level, &numProps) == S_OK) 396 if (getProps->GetArcNumProps2(level, &numProps) == S_OK)
375 { 397 {
376 AddSeparatorSmall(message); 398 AddSeparatorSmall(message);
377 for (Int32 i = 0; i < (Int32)numProps; i++) 399 for (UInt32 i = 0; i < numProps; i++)
378 { 400 {
379 CMyComBSTR name; 401 CMyComBSTR name;
380 PROPID propID; 402 PROPID propID;
@@ -393,11 +415,11 @@ void CPanel::Properties()
393 { 415 {
394 // we ERROR message for NonOpen level 416 // we ERROR message for NonOpen level
395 bool needSep = true; 417 bool needSep = true;
396 const int kNumSpecProps = ARRAY_SIZE(kSpecProps); 418 const int kNumSpecProps = Z7_ARRAY_SIZE(kSpecProps);
397 for (Int32 i = -(int)kNumSpecProps; i < 0; i++) 419 for (Int32 i = -(int)kNumSpecProps; i < 0; i++)
398 { 420 {
399 CMyComBSTR name; 421 CMyComBSTR name;
400 PROPID propID = kSpecProps[i + kNumSpecProps]; 422 const PROPID propID = kSpecProps[i + kNumSpecProps];
401 NCOM::CPropVariant prop; 423 NCOM::CPropVariant prop;
402 if (getProps->GetArcProp(numLevels, propID, &prop) != S_OK) 424 if (getProps->GetArcProp(numLevels, propID, &prop) != S_OK)
403 continue; 425 continue;
@@ -440,7 +462,7 @@ void CPanel::EditCopy()
440 */ 462 */
441 UString s; 463 UString s;
442 CRecordVector<UInt32> indices; 464 CRecordVector<UInt32> indices;
443 GetSelectedItemsIndices(indices); 465 Get_ItemIndices_Selected(indices);
444 FOR_VECTOR (i, indices) 466 FOR_VECTOR (i, indices)
445 { 467 {
446 if (i != 0) 468 if (i != 0)
@@ -486,15 +508,25 @@ struct CFolderPidls
486}; 508};
487 509
488 510
511static HRESULT ShellFolder_ParseDisplayName(IShellFolder *shellFolder,
512 HWND hwnd, const UString &path, LPITEMIDLIST *ppidl)
513{
514 ULONG eaten = 0;
515 return shellFolder->ParseDisplayName(hwnd, NULL,
516 path.Ptr_non_const(), &eaten, ppidl, NULL);
517}
518
519
489HRESULT CPanel::CreateShellContextMenu( 520HRESULT CPanel::CreateShellContextMenu(
490 const CRecordVector<UInt32> &operatedIndices, 521 const CRecordVector<UInt32> &operatedIndices,
491 CMyComPtr<IContextMenu> &systemContextMenu) 522 CMyComPtr<IContextMenu> &systemContextMenu)
492{ 523{
524 ODS("==== CPanel::CreateShellContextMenu");
493 systemContextMenu.Release(); 525 systemContextMenu.Release();
494 const UString folderPath = GetFsPath(); 526 UString folderPath = GetFsPath();
495 527
496 CMyComPtr<IShellFolder> desktopFolder; 528 CMyComPtr<IShellFolder> desktopFolder;
497 RINOK(::SHGetDesktopFolder(&desktopFolder)); 529 RINOK(::SHGetDesktopFolder(&desktopFolder))
498 if (!desktopFolder) 530 if (!desktopFolder)
499 { 531 {
500 // ShowMessage("Failed to get Desktop folder"); 532 // ShowMessage("Failed to get Desktop folder");
@@ -502,24 +534,37 @@ HRESULT CPanel::CreateShellContextMenu(
502 } 534 }
503 535
504 CFolderPidls pidls; 536 CFolderPidls pidls;
505 DWORD eaten; 537 // NULL is allowed for parentHWND in ParseDisplayName()
506 538 const HWND parentHWND_for_ParseDisplayName = GetParent();
507 // if (folderPath.IsEmpty()), then ParseDisplayName returns pidls of "My Computer" 539 // if (folderPath.IsEmpty()), then ParseDisplayName returns pidls of "My Computer"
508 RINOK(desktopFolder->ParseDisplayName( 540 /* win10: ParseDisplayName() supports folder path with tail slash
509 GetParent(), NULL, folderPath.Ptr_non_const(), 541 ParseDisplayName() returns {
510 &eaten, &pidls.parent, NULL)); 542 E_INVALIDARG : path with super path prefix "\\\\?\\"
543 ERROR_FILE_NOT_FOUND : path for network share (\\server\path1\long path2") larger than MAX_PATH
544 } */
545 const HRESULT res = ShellFolder_ParseDisplayName(desktopFolder,
546 parentHWND_for_ParseDisplayName,
547 folderPath, &pidls.parent);
548 if (res != S_OK)
549 {
550 ODS_U(folderPath);
551 if (res != E_INVALIDARG)
552 return res;
553 if (!NFile::NName::If_IsSuperPath_RemoveSuperPrefix(folderPath))
554 return res;
555 RINOK(ShellFolder_ParseDisplayName(desktopFolder,
556 parentHWND_for_ParseDisplayName,
557 folderPath, &pidls.parent))
558 }
559 if (!pidls.parent)
560 return E_FAIL;
511 561
512 /* 562 /*
513 STRRET pName; 563 UString path2;
514 res = desktopFolder->GetDisplayNameOf(pidls.parent, SHGDN_NORMAL, &pName); 564 NShell::GetPathFromIDList(pidls.parent, path2);
515 WCHAR dir[MAX_PATH]; 565 ODS_U(path2);
516 if (!SHGetPathFromIDListW(pidls.parent, dir))
517 dir[0] = 0;
518 */ 566 */
519 567
520 if (!pidls.parent)
521 return E_FAIL;
522
523 if (operatedIndices.IsEmpty()) 568 if (operatedIndices.IsEmpty())
524 { 569 {
525 // how to get IContextMenu, if there are no selected files? 570 // how to get IContextMenu, if there are no selected files?
@@ -549,28 +594,37 @@ HRESULT CPanel::CreateShellContextMenu(
549 594
550 CMyComPtr<IShellFolder> parentFolder; 595 CMyComPtr<IShellFolder> parentFolder;
551 RINOK(desktopFolder->BindToObject(pidls.parent, 596 RINOK(desktopFolder->BindToObject(pidls.parent,
552 NULL, IID_IShellFolder, (void**)&parentFolder)); 597 NULL, IID_IShellFolder, (void**)&parentFolder))
553 if (!parentFolder) 598 if (!parentFolder)
554 {
555 // ShowMessage("Invalid file name");
556 return E_FAIL; 599 return E_FAIL;
557 } 600
601 ODS("==== CPanel::CreateShellContextMenu pidls START");
558 602
559 pidls.items.ClearAndReserve(operatedIndices.Size()); 603 pidls.items.ClearAndReserve(operatedIndices.Size());
604 UString fileName;
560 FOR_VECTOR (i, operatedIndices) 605 FOR_VECTOR (i, operatedIndices)
561 { 606 {
562 LPITEMIDLIST pidl; 607 fileName.Empty();
563 const UString fileName = GetItemRelPath2(operatedIndices[i]); 608 Add_ItemRelPath2_To_String(operatedIndices[i], fileName);
564 RINOK(parentFolder->ParseDisplayName(GetParent(), 0, 609 /* ParseDisplayName() in win10 returns:
565 fileName.Ptr_non_const(), &eaten, &pidl, 0)); 610 E_INVALIDARG : if empty name, or path with dots only: "." , ".."
611 HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) : if there is no such file
612 */
613 LPITEMIDLIST pidl = NULL;
614 RINOK(ShellFolder_ParseDisplayName(parentFolder,
615 parentHWND_for_ParseDisplayName,
616 fileName, &pidl))
617 if (!pidl)
618 return E_FAIL;
566 pidls.items.AddInReserved(pidl); 619 pidls.items.AddInReserved(pidl);
567 } 620 }
568
569 // Get IContextMenu for items
570 621
571 RINOK(parentFolder->GetUIObjectOf(GetParent(), pidls.items.Size(), 622 ODS("==== CPanel::CreateShellContextMenu pidls END");
572 (LPCITEMIDLIST *)(void *)&pidls.items.Front(), IID_IContextMenu, 0, (void**)&systemContextMenu)); 623 // Get IContextMenu for items
573 624 RINOK(parentFolder->GetUIObjectOf(GetParent(),
625 pidls.items.Size(), (LPCITEMIDLIST *)(void *)&pidls.items.Front(),
626 IID_IContextMenu, NULL, (void**)&systemContextMenu))
627 ODS("==== CPanel::CreateShellContextMenu GetUIObjectOf finished");
574 if (!systemContextMenu) 628 if (!systemContextMenu)
575 { 629 {
576 // ShowMessage("Unable to get context menu interface"); 630 // ShowMessage("Unable to get context menu interface");
@@ -579,14 +633,11 @@ HRESULT CPanel::CreateShellContextMenu(
579 return S_OK; 633 return S_OK;
580} 634}
581 635
636
582// #define SHOW_DEBUG_FM_CTX_MENU 637// #define SHOW_DEBUG_FM_CTX_MENU
583 638
584#ifdef SHOW_DEBUG_FM_CTX_MENU 639#ifdef SHOW_DEBUG_FM_CTX_MENU
585 640
586#include <stdio.h>
587
588// #include Common/IntToString.h"
589
590static void PrintHex(UString &s, UInt32 v) 641static void PrintHex(UString &s, UInt32 v)
591{ 642{
592 char sz[32]; 643 char sz[32];
@@ -597,16 +648,14 @@ static void PrintHex(UString &s, UInt32 v)
597static void PrintContextStr(UString &s, IContextMenu *ctxm, unsigned i, unsigned id, const char *name) 648static void PrintContextStr(UString &s, IContextMenu *ctxm, unsigned i, unsigned id, const char *name)
598{ 649{
599 s += " | "; 650 s += " | ";
600 name = name; 651 s += name;
601 // s += name; 652 s += ": ";
602 // s += ": ";
603
604 UString s1; 653 UString s1;
605 { 654 {
606 char buf[256]; 655 char buf[256];
607 buf[0] = 0; 656 buf[0] = 0;
608 HRESULT res = ctxm->GetCommandString(i, id, 657 const HRESULT res = ctxm->GetCommandString(i, id,
609 NULL, buf, ARRAY_SIZE(buf) - 1); 658 NULL, buf, Z7_ARRAY_SIZE(buf) - 1);
610 if (res != S_OK) 659 if (res != S_OK)
611 { 660 {
612 PrintHex(s1, res); 661 PrintHex(s1, res);
@@ -614,13 +663,12 @@ static void PrintContextStr(UString &s, IContextMenu *ctxm, unsigned i, unsigned
614 } 663 }
615 s1 += GetUnicodeString(buf); 664 s1 += GetUnicodeString(buf);
616 } 665 }
617
618 UString s2; 666 UString s2;
619 { 667 {
620 wchar_t buf2[256]; 668 wchar_t buf2[256];
621 buf2[0] = 0; 669 buf2[0] = 0;
622 HRESULT res = ctxm->GetCommandString(i, id | GCS_UNICODE, 670 const HRESULT res = ctxm->GetCommandString(i, id | GCS_UNICODE,
623 NULL, (char *)buf2, ARRAY_SIZE(buf2) - 1); 671 NULL, (char *)buf2, Z7_ARRAY_SIZE(buf2) - sizeof(wchar_t));
624 if (res != S_OK) 672 if (res != S_OK)
625 { 673 {
626 PrintHex(s2, res); 674 PrintHex(s2, res);
@@ -628,7 +676,6 @@ static void PrintContextStr(UString &s, IContextMenu *ctxm, unsigned i, unsigned
628 } 676 }
629 s2 += buf2; 677 s2 += buf2;
630 } 678 }
631
632 s += s1; 679 s += s1;
633 if (s2.Compare(s1) != 0) 680 if (s2.Compare(s1) != 0)
634 { 681 {
@@ -637,7 +684,6 @@ static void PrintContextStr(UString &s, IContextMenu *ctxm, unsigned i, unsigned
637 } 684 }
638} 685}
639 686
640
641static void PrintAllContextItems(IContextMenu *ctxm, unsigned num) 687static void PrintAllContextItems(IContextMenu *ctxm, unsigned num)
642{ 688{
643 for (unsigned i = 0; i < num; i++) 689 for (unsigned i = 0; i < num; i++)
@@ -645,35 +691,18 @@ static void PrintAllContextItems(IContextMenu *ctxm, unsigned num)
645 UString s; 691 UString s;
646 s.Add_UInt32(i); 692 s.Add_UInt32(i);
647 s += ": "; 693 s += ": ";
648
649 /*
650 UString valid;
651 {
652 char name[256];
653 HRESULT res = ctxm->GetCommandString(i, GCS_VALIDATEA,
654 NULL, name, ARRAY_SIZE(name) - 1);
655
656 if (res == S_OK)
657 {
658 // valid = "valid";
659 }
660 else if (res == S_FALSE)
661 valid = "non-valid";
662 else
663 PrintHex(valid, res);
664 }
665 s += valid;
666 */
667
668 PrintContextStr(s, ctxm, i, GCS_VALIDATEA, "valid"); 694 PrintContextStr(s, ctxm, i, GCS_VALIDATEA, "valid");
669 PrintContextStr(s, ctxm, i, GCS_VERBA, "v"); 695 PrintContextStr(s, ctxm, i, GCS_VERBA, "verb");
670 PrintContextStr(s, ctxm, i, GCS_HELPTEXTA, "h"); 696 PrintContextStr(s, ctxm, i, GCS_HELPTEXTA, "helptext");
671 OutputDebugStringW(s); 697 OutputDebugStringW(s);
672 } 698 }
673} 699}
700
674#endif 701#endif
675 702
703
676void CPanel::CreateSystemMenu(HMENU menuSpec, 704void CPanel::CreateSystemMenu(HMENU menuSpec,
705 bool showExtendedVerbs,
677 const CRecordVector<UInt32> &operatedIndices, 706 const CRecordVector<UInt32> &operatedIndices,
678 CMyComPtr<IContextMenu> &systemContextMenu) 707 CMyComPtr<IContextMenu> &systemContextMenu)
679{ 708{
@@ -722,19 +751,13 @@ void CPanel::CreateSystemMenu(HMENU menuSpec,
722 CMenuDestroyer menuDestroyer(popupMenu); 751 CMenuDestroyer menuDestroyer(popupMenu);
723 if (!popupMenu.CreatePopup()) 752 if (!popupMenu.CreatePopup())
724 throw 210503; 753 throw 210503;
725 754 const HMENU hMenu = popupMenu;
726 HMENU hMenu = popupMenu; 755 DWORD flags = CMF_EXPLORE;
727 756 if (showExtendedVerbs)
728 DWORD Flags = CMF_EXPLORE; 757 flags |= Z7_WIN_CMF_EXTENDEDVERBS;
729 // Optionally the shell will show the extended 758 ODS("=== systemContextMenu->QueryContextMenu START");
730 // context menu on some operating systems when 759 const HRESULT res = systemContextMenu->QueryContextMenu(hMenu, 0, kSystemStartMenuID, 0x7FFF, flags);
731 // the shift key is held down at the time the 760 ODS("=== systemContextMenu->QueryContextMenu END");
732 // context menu is invoked. The following is
733 // commented out but you can uncommnent this
734 // line to show the extended context menu.
735 // Flags |= 0x00000080;
736 HRESULT res = systemContextMenu->QueryContextMenu(hMenu, 0, kSystemStartMenuID, 0x7FFF, Flags);
737
738 if (SUCCEEDED(res)) 761 if (SUCCEEDED(res))
739 { 762 {
740 #ifdef SHOW_DEBUG_FM_CTX_MENU 763 #ifdef SHOW_DEBUG_FM_CTX_MENU
@@ -779,11 +802,13 @@ void CPanel::CreateSystemMenu(HMENU menuSpec,
779 802
780void CPanel::CreateFileMenu(HMENU menuSpec) 803void CPanel::CreateFileMenu(HMENU menuSpec)
781{ 804{
782 CreateFileMenu(menuSpec, _sevenZipContextMenu, _systemContextMenu, true); 805 CreateFileMenu(menuSpec, _sevenZipContextMenu, _systemContextMenu, true); // programMenu
783} 806}
784 807
785void CPanel::CreateSevenZipMenu(HMENU menuSpec, 808void CPanel::CreateSevenZipMenu(HMENU menuSpec,
809 bool showExtendedVerbs,
786 const CRecordVector<UInt32> &operatedIndices, 810 const CRecordVector<UInt32> &operatedIndices,
811 int firstDirIndex,
787 CMyComPtr<IContextMenu> &sevenZipContextMenu) 812 CMyComPtr<IContextMenu> &sevenZipContextMenu)
788{ 813{
789 sevenZipContextMenu.Release(); 814 sevenZipContextMenu.Release();
@@ -802,22 +827,23 @@ void CPanel::CreateSevenZipMenu(HMENU menuSpec,
802 if (contextMenu.QueryInterface(IID_IInitContextMenu, &initContextMenu) != S_OK) 827 if (contextMenu.QueryInterface(IID_IInitContextMenu, &initContextMenu) != S_OK)
803 return; 828 return;
804 */ 829 */
805 UString currentFolderUnicode = GetFsPath(); 830 ODS("=== FileName List Add START")
806 UStringVector names; 831 // for (unsigned y = 0; y < 10000; y++, contextMenuSpec->_fileNames.Clear())
807 unsigned i; 832 GetFilePaths(operatedIndices, contextMenuSpec->_fileNames);
808 for (i = 0; i < operatedIndices.Size(); i++) 833 ODS("=== FileName List Add END")
809 names.Add(currentFolderUnicode + GetItemRelPath2(operatedIndices[i])); 834 contextMenuSpec->Init_For_7zFM();
810 CRecordVector<const wchar_t *> namePointers; 835 contextMenuSpec->_attribs.FirstDirIndex = firstDirIndex;
811 for (i = 0; i < operatedIndices.Size(); i++)
812 namePointers.Add(names[i]);
813
814 // NFile::NDirectory::MySetCurrentDirectory(currentFolderUnicode);
815 if (contextMenuSpec->InitContextMenu(currentFolderUnicode, &namePointers.Front(),
816 operatedIndices.Size()) == S_OK)
817 { 836 {
818 HRESULT res = contextMenu->QueryContextMenu(menu, 0, kSevenZipStartMenuID, 837 DWORD flags = CMF_EXPLORE;
819 kSystemStartMenuID - 1, 0); 838 if (showExtendedVerbs)
820 bool sevenZipMenuCreated = SUCCEEDED(res); 839 flags |= Z7_WIN_CMF_EXTENDEDVERBS;
840 const HRESULT res = contextMenu->QueryContextMenu(menu,
841 0, // indexMenu
842 kSevenZipStartMenuID, // first
843 kSystemStartMenuID - 1, // last
844 flags);
845 ODS("=== contextMenu->QueryContextMenu END")
846 const bool sevenZipMenuCreated = SUCCEEDED(res);
821 if (sevenZipMenuCreated) 847 if (sevenZipMenuCreated)
822 { 848 {
823 // if (res != 0) 849 // if (res != 0)
@@ -834,7 +860,6 @@ void CPanel::CreateSevenZipMenu(HMENU menuSpec,
834 { 860 {
835 // MessageBox_Error_HRESULT_Caption(res, L"QueryContextMenu"); 861 // MessageBox_Error_HRESULT_Caption(res, L"QueryContextMenu");
836 } 862 }
837
838 // int code = HRESULT_CODE(res); 863 // int code = HRESULT_CODE(res);
839 // int nextItemID = code; 864 // int nextItemID = code;
840 } 865 }
@@ -917,19 +942,22 @@ void CPanel::CreateFileMenu(HMENU menuSpec,
917 sevenZipContextMenu.Release(); 942 sevenZipContextMenu.Release();
918 systemContextMenu.Release(); 943 systemContextMenu.Release();
919 944
945 const bool showExtendedVerbs = IsKeyDown(VK_SHIFT);
946
920 CRecordVector<UInt32> operatedIndices; 947 CRecordVector<UInt32> operatedIndices;
921 GetOperatedItemIndices(operatedIndices); 948 Get_ItemIndices_Operated(operatedIndices);
949 const int firstDirIndex = FindDir_InOperatedList(operatedIndices);
922 950
923 CMenu menu; 951 CMenu menu;
924 menu.Attach(menuSpec); 952 menu.Attach(menuSpec);
925 953
926 if (!IsArcFolder()) 954 if (!IsArcFolder())
927 { 955 {
928 CreateSevenZipMenu(menu, operatedIndices, sevenZipContextMenu); 956 CreateSevenZipMenu(menu, showExtendedVerbs, operatedIndices, firstDirIndex, sevenZipContextMenu);
929 // CreateSystemMenu is very slow if you call it inside ZIP archive with big number of files 957 // CreateSystemMenu is very slow if you call it inside ZIP archive with big number of files
930 // Windows probably can parse items inside ZIP archive. 958 // Windows probably can parse items inside ZIP archive.
931 if (g_App.ShowSystemMenu) 959 if (g_App.ShowSystemMenu)
932 CreateSystemMenu(menu, operatedIndices, systemContextMenu); 960 CreateSystemMenu(menu, showExtendedVerbs, operatedIndices, systemContextMenu);
933 } 961 }
934 962
935 /* 963 /*
@@ -937,19 +965,13 @@ void CPanel::CreateFileMenu(HMENU menuSpec,
937 menu.AppendItem(MF_SEPARATOR, 0, (LPCTSTR)0); 965 menu.AppendItem(MF_SEPARATOR, 0, (LPCTSTR)0);
938 */ 966 */
939 967
940 unsigned i;
941 for (i = 0; i < operatedIndices.Size(); i++)
942 if (IsItem_Folder(operatedIndices[i]))
943 break;
944 bool allAreFiles = (i == operatedIndices.Size());
945
946 CFileMenu fm; 968 CFileMenu fm;
947 969
948 fm.readOnly = IsThereReadOnlyFolder(); 970 fm.readOnly = IsThereReadOnlyFolder();
949 fm.isHashFolder = IsHashFolder(); 971 fm.isHashFolder = IsHashFolder();
950 fm.isFsFolder = Is_IO_FS_Folder(); 972 fm.isFsFolder = Is_IO_FS_Folder();
951 fm.programMenu = programMenu; 973 fm.programMenu = programMenu;
952 fm.allAreFiles = allAreFiles; 974 fm.allAreFiles = (firstDirIndex == -1);
953 fm.numItems = operatedIndices.Size(); 975 fm.numItems = operatedIndices.Size();
954 976
955 fm.isAltStreamsSupported = false; 977 fm.isAltStreamsSupported = false;
@@ -961,7 +983,7 @@ void CPanel::CreateFileMenu(HMENU menuSpec,
961 { 983 {
962 if (operatedIndices.Size() <= 1) 984 if (operatedIndices.Size() <= 1)
963 { 985 {
964 Int32 realIndex = -1; 986 UInt32 realIndex = (UInt32)(Int32)-1;
965 if (operatedIndices.Size() == 1) 987 if (operatedIndices.Size() == 1)
966 realIndex = operatedIndices[0]; 988 realIndex = operatedIndices[0];
967 Int32 val = 0; 989 Int32 val = 0;
@@ -977,7 +999,7 @@ void CPanel::CreateFileMenu(HMENU menuSpec,
977 fm.isAltStreamsSupported = IsFolder_with_FsItems(); 999 fm.isAltStreamsSupported = IsFolder_with_FsItems();
978 } 1000 }
979 1001
980 fm.Load(menu, menu.GetItemCount()); 1002 fm.Load(menu, (unsigned)menu.GetItemCount());
981} 1003}
982 1004
983bool CPanel::InvokePluginCommand(unsigned id) 1005bool CPanel::InvokePluginCommand(unsigned id)
@@ -987,6 +1009,7 @@ bool CPanel::InvokePluginCommand(unsigned id)
987 1009
988#if defined(_MSC_VER) && !defined(UNDER_CE) 1010#if defined(_MSC_VER) && !defined(UNDER_CE)
989#define use_CMINVOKECOMMANDINFOEX 1011#define use_CMINVOKECOMMANDINFOEX
1012/* CMINVOKECOMMANDINFOEX depends from (_WIN32_IE >= 0x0400) */
990#endif 1013#endif
991 1014
992bool CPanel::InvokePluginCommand(unsigned id, 1015bool CPanel::InvokePluginCommand(unsigned id,
@@ -1096,7 +1119,7 @@ bool CPanel::OnContextMenu(HANDLE windowHandle, int xPos, int yPos)
1096 */ 1119 */
1097 1120
1098 CRecordVector<UInt32> operatedIndices; 1121 CRecordVector<UInt32> operatedIndices;
1099 GetOperatedItemIndices(operatedIndices); 1122 Get_ItemIndices_Operated(operatedIndices);
1100 1123
1101 // negative x,y are possible for multi-screen modes. 1124 // negative x,y are possible for multi-screen modes.
1102 // x=-1 && y=-1 for keyboard call (SHIFT+F10 and others). 1125 // x=-1 && y=-1 for keyboard call (SHIFT+F10 and others).
@@ -1130,9 +1153,9 @@ bool CPanel::OnContextMenu(HANDLE windowHandle, int xPos, int yPos)
1130 1153
1131 CMyComPtr<IContextMenu> sevenZipContextMenu; 1154 CMyComPtr<IContextMenu> sevenZipContextMenu;
1132 CMyComPtr<IContextMenu> systemContextMenu; 1155 CMyComPtr<IContextMenu> systemContextMenu;
1133 CreateFileMenu(menu, sevenZipContextMenu, systemContextMenu, false); 1156 CreateFileMenu(menu, sevenZipContextMenu, systemContextMenu, false); // programMenu
1134 1157
1135 unsigned id = menu.Track(TPM_LEFTALIGN 1158 const unsigned id = (unsigned)menu.Track(TPM_LEFTALIGN
1136 #ifndef UNDER_CE 1159 #ifndef UNDER_CE
1137 | TPM_RIGHTBUTTON 1160 | TPM_RIGHTBUTTON
1138 #endif 1161 #endif
diff --git a/CPP/7zip/UI/FileManager/PanelOperations.cpp b/CPP/7zip/UI/FileManager/PanelOperations.cpp
index a683b5e..b61f4e9 100644
--- a/CPP/7zip/UI/FileManager/PanelOperations.cpp
+++ b/CPP/7zip/UI/FileManager/PanelOperations.cpp
@@ -24,9 +24,6 @@ using namespace NWindows;
24using namespace NFile; 24using namespace NFile;
25using namespace NName; 25using namespace NName;
26 26
27#define MY_CAST_FUNC (void(*)())
28// #define MY_CAST_FUNC
29
30#ifndef _UNICODE 27#ifndef _UNICODE
31extern bool g_IsNT; 28extern bool g_IsNT;
32#endif 29#endif
@@ -40,7 +37,7 @@ enum EFolderOpType
40 37
41class CThreadFolderOperations: public CProgressThreadVirt 38class CThreadFolderOperations: public CProgressThreadVirt
42{ 39{
43 HRESULT ProcessVirt(); 40 HRESULT ProcessVirt() Z7_override;
44public: 41public:
45 EFolderOpType OpType; 42 EFolderOpType OpType;
46 UString Name; 43 UString Name;
@@ -58,7 +55,7 @@ public:
58HRESULT CThreadFolderOperations::ProcessVirt() 55HRESULT CThreadFolderOperations::ProcessVirt()
59{ 56{
60 NCOM::CComInitializer comInitializer; 57 NCOM::CComInitializer comInitializer;
61 switch (OpType) 58 switch ((int)OpType)
62 { 59 {
63 case FOLDER_TYPE_CREATE_FOLDER: 60 case FOLDER_TYPE_CREATE_FOLDER:
64 return FolderOperations->CreateFolder(Name, UpdateCallback); 61 return FolderOperations->CreateFolder(Name, UpdateCallback);
@@ -94,7 +91,7 @@ HRESULT CThreadFolderOperations::DoOperation(CPanel &panel, const UString &progr
94 MainTitle = "7-Zip"; // LangString(IDS_APP_TITLE); 91 MainTitle = "7-Zip"; // LangString(IDS_APP_TITLE);
95 MainAddTitle = progressTitle + L' '; 92 MainAddTitle = progressTitle + L' ';
96 93
97 RINOK(Create(progressTitle, MainWindow)); 94 RINOK(Create(progressTitle, MainWindow))
98 return Result; 95 return Result;
99} 96}
100 97
@@ -116,7 +113,7 @@ void CPanel::DeleteItems(bool NON_CE_VAR(toRecycleBin))
116{ 113{
117 CDisableTimerProcessing disableTimerProcessing(*this); 114 CDisableTimerProcessing disableTimerProcessing(*this);
118 CRecordVector<UInt32> indices; 115 CRecordVector<UInt32> indices;
119 GetOperatedItemIndices(indices); 116 Get_ItemIndices_Operated(indices);
120 if (indices.IsEmpty()) 117 if (indices.IsEmpty())
121 return; 118 return;
122 CSelectedState state; 119 CSelectedState state;
@@ -141,7 +138,7 @@ void CPanel::DeleteItems(bool NON_CE_VAR(toRecycleBin))
141 fo.hwnd = GetParent(); 138 fo.hwnd = GetParent();
142 fo.wFunc = FO_DELETE; 139 fo.wFunc = FO_DELETE;
143 fo.pFrom = (const CHAR *)buffer; 140 fo.pFrom = (const CHAR *)buffer;
144 fo.pTo = 0; 141 fo.pTo = NULL;
145 fo.fFlags = 0; 142 fo.fFlags = 0;
146 if (toRecycleBin) 143 if (toRecycleBin)
147 fo.fFlags |= FOF_ALLOWUNDO; 144 fo.fFlags |= FOF_ALLOWUNDO;
@@ -150,8 +147,8 @@ void CPanel::DeleteItems(bool NON_CE_VAR(toRecycleBin))
150 // fo.fFlags |= FOF_SILENT; 147 // fo.fFlags |= FOF_SILENT;
151 // fo.fFlags |= FOF_WANTNUKEWARNING; 148 // fo.fFlags |= FOF_WANTNUKEWARNING;
152 fo.fAnyOperationsAborted = FALSE; 149 fo.fAnyOperationsAborted = FALSE;
153 fo.hNameMappings = 0; 150 fo.hNameMappings = NULL;
154 fo.lpszProgressTitle = 0; 151 fo.lpszProgressTitle = NULL;
155 /* int res = */ ::SHFileOperationA(&fo); 152 /* int res = */ ::SHFileOperationA(&fo);
156 } 153 }
157 else 154 else
@@ -184,23 +181,24 @@ void CPanel::DeleteItems(bool NON_CE_VAR(toRecycleBin))
184 fo.hwnd = GetParent(); 181 fo.hwnd = GetParent();
185 fo.wFunc = FO_DELETE; 182 fo.wFunc = FO_DELETE;
186 fo.pFrom = (const WCHAR *)buffer; 183 fo.pFrom = (const WCHAR *)buffer;
187 fo.pTo = 0; 184 fo.pTo = NULL;
188 fo.fFlags = 0; 185 fo.fFlags = 0;
189 if (toRecycleBin) 186 if (toRecycleBin)
190 fo.fFlags |= FOF_ALLOWUNDO; 187 fo.fFlags |= FOF_ALLOWUNDO;
191 fo.fAnyOperationsAborted = FALSE; 188 fo.fAnyOperationsAborted = FALSE;
192 fo.hNameMappings = 0; 189 fo.hNameMappings = NULL;
193 fo.lpszProgressTitle = 0; 190 fo.lpszProgressTitle = NULL;
194 // int res; 191 // int res;
195 #ifdef _UNICODE 192 #ifdef _UNICODE
196 /* res = */ ::SHFileOperationW(&fo); 193 /* res = */ ::SHFileOperationW(&fo);
197 #else 194 #else
198 Func_SHFileOperationW shFileOperationW = (Func_SHFileOperationW) 195 Func_SHFileOperationW
199 MY_CAST_FUNC 196 f_SHFileOperationW = Z7_GET_PROC_ADDRESS(
200 ::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "SHFileOperationW"); 197 Func_SHFileOperationW, ::GetModuleHandleW(L"shell32.dll"),
201 if (!shFileOperationW) 198 "SHFileOperationW");
199 if (!f_SHFileOperationW)
202 return; 200 return;
203 /* res = */ shFileOperationW(&fo); 201 /* res = */ f_SHFileOperationW(&fo);
204 #endif 202 #endif
205 } 203 }
206 } 204 }
@@ -225,7 +223,7 @@ void CPanel::DeleteItems(bool NON_CE_VAR(toRecycleBin))
225 UString messageParam; 223 UString messageParam;
226 if (indices.Size() == 1) 224 if (indices.Size() == 1)
227 { 225 {
228 int index = indices[0]; 226 const unsigned index = indices[0];
229 messageParam = GetItemRelPath2(index); 227 messageParam = GetItemRelPath2(index);
230 if (IsItem_Folder(index)) 228 if (IsItem_Folder(index))
231 { 229 {
@@ -262,7 +260,7 @@ void CPanel::DeleteItems(bool NON_CE_VAR(toRecycleBin))
262 260
263BOOL CPanel::OnBeginLabelEdit(LV_DISPINFOW * lpnmh) 261BOOL CPanel::OnBeginLabelEdit(LV_DISPINFOW * lpnmh)
264{ 262{
265 int realIndex = GetRealIndex(lpnmh->item); 263 const unsigned realIndex = GetRealIndex(lpnmh->item);
266 if (realIndex == kParentIndex) 264 if (realIndex == kParentIndex)
267 return TRUE; 265 return TRUE;
268 if (IsThereReadOnlyFolder()) 266 if (IsThereReadOnlyFolder())
@@ -314,7 +312,7 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh)
314 312
315 SaveSelectedState(_selectedState); 313 SaveSelectedState(_selectedState);
316 314
317 int realIndex = GetRealIndex(lpnmh->item); 315 const unsigned realIndex = GetRealIndex(lpnmh->item);
318 if (realIndex == kParentIndex) 316 if (realIndex == kParentIndex)
319 return FALSE; 317 return FALSE;
320 const UString prefix = GetItemPrefix(realIndex); 318 const UString prefix = GetItemPrefix(realIndex);
@@ -454,14 +452,14 @@ void CPanel::CreateFile()
454 newName = correctName; 452 newName = correctName;
455 } 453 }
456 454
457 HRESULT result = _folderOperations->CreateFile(newName, 0); 455 const HRESULT result = _folderOperations->CreateFile(newName, NULL);
458 if (result != S_OK) 456 if (result != S_OK)
459 { 457 {
460 MessageBox_Error_HRESULT_Caption(result, LangString(IDS_CREATE_FILE_ERROR)); 458 MessageBox_Error_HRESULT_Caption(result, LangString(IDS_CREATE_FILE_ERROR));
461 // MessageBoxErrorForUpdate(result, IDS_CREATE_FILE_ERROR); 459 // MessageBoxErrorForUpdate(result, IDS_CREATE_FILE_ERROR);
462 return; 460 return;
463 } 461 }
464 int pos = newName.Find(WCHAR_PATH_SEPARATOR); 462 const int pos = newName.Find(WCHAR_PATH_SEPARATOR);
465 if (pos >= 0) 463 if (pos >= 0)
466 newName.DeleteFrom((unsigned)pos); 464 newName.DeleteFrom((unsigned)pos);
467 if (!_mySelectMode) 465 if (!_mySelectMode)
@@ -488,10 +486,10 @@ void CPanel::ChangeComment()
488 if (!CheckBeforeUpdate(IDS_COMMENT)) 486 if (!CheckBeforeUpdate(IDS_COMMENT))
489 return; 487 return;
490 CDisableTimerProcessing disableTimerProcessing2(*this); 488 CDisableTimerProcessing disableTimerProcessing2(*this);
491 int index = _listView.GetFocusedItem(); 489 const int index = _listView.GetFocusedItem();
492 if (index < 0) 490 if (index < 0)
493 return; 491 return;
494 int realIndex = GetRealItemIndex(index); 492 const unsigned realIndex = GetRealItemIndex(index);
495 if (realIndex == kParentIndex) 493 if (realIndex == kParentIndex)
496 return; 494 return;
497 CSelectedState state; 495 CSelectedState state;
@@ -506,7 +504,7 @@ void CPanel::ChangeComment()
506 else if (propVariant.vt != VT_EMPTY) 504 else if (propVariant.vt != VT_EMPTY)
507 return; 505 return;
508 } 506 }
509 UString name = GetItemRelPath2(realIndex); 507 const UString name = GetItemRelPath2(realIndex);
510 CComboDialog dlg; 508 CComboDialog dlg;
511 dlg.Title = name; 509 dlg.Title = name;
512 dlg.Title += " : "; 510 dlg.Title += " : ";
@@ -518,7 +516,7 @@ void CPanel::ChangeComment()
518 NCOM::CPropVariant propVariant (dlg.Value); 516 NCOM::CPropVariant propVariant (dlg.Value);
519 517
520 CDisableNotify disableNotify(*this); 518 CDisableNotify disableNotify(*this);
521 HRESULT result = _folderOperations->SetProperty(realIndex, kpidComment, &propVariant, NULL); 519 const HRESULT result = _folderOperations->SetProperty(realIndex, kpidComment, &propVariant, NULL);
522 if (result != S_OK) 520 if (result != S_OK)
523 { 521 {
524 if (result == E_NOINTERFACE) 522 if (result == E_NOINTERFACE)
diff --git a/CPP/7zip/UI/FileManager/PanelSelect.cpp b/CPP/7zip/UI/FileManager/PanelSelect.cpp
index eab9e1a..f7a16dd 100644
--- a/CPP/7zip/UI/FileManager/PanelSelect.cpp
+++ b/CPP/7zip/UI/FileManager/PanelSelect.cpp
@@ -15,7 +15,7 @@ void CPanel::OnShiftSelectMessage()
15{ 15{
16 if (!_mySelectMode) 16 if (!_mySelectMode)
17 return; 17 return;
18 int focusedItem = _listView.GetFocusedItem(); 18 const int focusedItem = _listView.GetFocusedItem();
19 if (focusedItem < 0) 19 if (focusedItem < 0)
20 return; 20 return;
21 if (!_selectionIsDefined) 21 if (!_selectionIsDefined)
@@ -26,7 +26,7 @@ void CPanel::OnShiftSelectMessage()
26 int numItems = _listView.GetItemCount(); 26 int numItems = _listView.GetItemCount();
27 for (int i = 0; i < numItems; i++) 27 for (int i = 0; i < numItems; i++)
28 { 28 {
29 int realIndex = GetRealItemIndex(i); 29 const unsigned realIndex = GetRealItemIndex(i);
30 if (realIndex == kParentIndex) 30 if (realIndex == kParentIndex)
31 continue; 31 continue;
32 if (i >= startItem && i <= finishItem) 32 if (i >= startItem && i <= finishItem)
@@ -44,10 +44,10 @@ void CPanel::OnArrowWithShift()
44{ 44{
45 if (!_mySelectMode) 45 if (!_mySelectMode)
46 return; 46 return;
47 int focusedItem = _listView.GetFocusedItem(); 47 const int focusedItem = _listView.GetFocusedItem();
48 if (focusedItem < 0) 48 if (focusedItem < 0)
49 return; 49 return;
50 int realIndex = GetRealItemIndex(focusedItem); 50 const unsigned realIndex = GetRealItemIndex(focusedItem);
51 51
52 if (_selectionIsDefined) 52 if (_selectionIsDefined)
53 { 53 {
@@ -84,11 +84,11 @@ void CPanel::OnInsert()
84 // _listView.SetItemState_Selected(focusedItem); 84 // _listView.SetItemState_Selected(focusedItem);
85 */ 85 */
86 86
87 int focusedItem = _listView.GetFocusedItem(); 87 const int focusedItem = _listView.GetFocusedItem();
88 if (focusedItem < 0) 88 if (focusedItem < 0)
89 return; 89 return;
90 90
91 int realIndex = GetRealItemIndex(focusedItem); 91 const unsigned realIndex = GetRealItemIndex(focusedItem);
92 if (realIndex != kParentIndex) 92 if (realIndex != kParentIndex)
93 { 93 {
94 bool isSelected = !_selectedStatusVector[realIndex]; 94 bool isSelected = !_selectedStatusVector[realIndex];
@@ -109,10 +109,10 @@ void CPanel::OnInsert()
109/* 109/*
110void CPanel::OnUpWithShift() 110void CPanel::OnUpWithShift()
111{ 111{
112 int focusedItem = _listView.GetFocusedItem(); 112 const int focusedItem = _listView.GetFocusedItem();
113 if (focusedItem < 0) 113 if (focusedItem < 0)
114 return; 114 return;
115 int index = GetRealItemIndex(focusedItem); 115 const int index = GetRealItemIndex(focusedItem);
116 if (index == kParentIndex) 116 if (index == kParentIndex)
117 return; 117 return;
118 _selectedStatusVector[index] = !_selectedStatusVector[index]; 118 _selectedStatusVector[index] = !_selectedStatusVector[index];
@@ -121,10 +121,10 @@ void CPanel::OnUpWithShift()
121 121
122void CPanel::OnDownWithShift() 122void CPanel::OnDownWithShift()
123{ 123{
124 int focusedItem = _listView.GetFocusedItem(); 124 const int focusedItem = _listView.GetFocusedItem();
125 if (focusedItem < 0) 125 if (focusedItem < 0)
126 return; 126 return;
127 int index = GetRealItemIndex(focusedItem); 127 const int index = GetRealItemIndex(focusedItem);
128 if (index == kParentIndex) 128 if (index == kParentIndex)
129 return; 129 return;
130 _selectedStatusVector[index] = !_selectedStatusVector[index]; 130 _selectedStatusVector[index] = !_selectedStatusVector[index];
@@ -141,7 +141,7 @@ void CPanel::UpdateSelection()
141 int numItems = _listView.GetItemCount(); 141 int numItems = _listView.GetItemCount();
142 for (int i = 0; i < numItems; i++) 142 for (int i = 0; i < numItems; i++)
143 { 143 {
144 int realIndex = GetRealItemIndex(i); 144 const unsigned realIndex = GetRealItemIndex(i);
145 if (realIndex != kParentIndex) 145 if (realIndex != kParentIndex)
146 _listView.SetItemState_Selected(i, _selectedStatusVector[realIndex]); 146 _listView.SetItemState_Selected(i, _selectedStatusVector[realIndex]);
147 } 147 }
@@ -168,10 +168,10 @@ void CPanel::SelectSpec(bool selectMode)
168 168
169void CPanel::SelectByType(bool selectMode) 169void CPanel::SelectByType(bool selectMode)
170{ 170{
171 int focusedItem = _listView.GetFocusedItem(); 171 const int focusedItem = _listView.GetFocusedItem();
172 if (focusedItem < 0) 172 if (focusedItem < 0)
173 return; 173 return;
174 int realIndex = GetRealItemIndex(focusedItem); 174 const unsigned realIndex = GetRealItemIndex(focusedItem);
175 UString name = GetItemName(realIndex); 175 UString name = GetItemName(realIndex);
176 bool isItemFolder = IsItem_Folder(realIndex); 176 bool isItemFolder = IsItem_Folder(realIndex);
177 177
@@ -214,10 +214,12 @@ void CPanel::InvertSelection()
214{ 214{
215 if (!_mySelectMode) 215 if (!_mySelectMode)
216 { 216 {
217 /*
217 unsigned numSelected = 0; 218 unsigned numSelected = 0;
218 FOR_VECTOR (i, _selectedStatusVector) 219 FOR_VECTOR (i, _selectedStatusVector)
219 if (_selectedStatusVector[i]) 220 if (_selectedStatusVector[i])
220 numSelected++; 221 numSelected++;
222 */
221 // 17.02: fixed : now we invert item even, if single item is selected 223 // 17.02: fixed : now we invert item even, if single item is selected
222 /* 224 /*
223 if (numSelected == 1) 225 if (numSelected == 1)
@@ -225,7 +227,7 @@ void CPanel::InvertSelection()
225 int focused = _listView.GetFocusedItem(); 227 int focused = _listView.GetFocusedItem();
226 if (focused >= 0) 228 if (focused >= 0)
227 { 229 {
228 int realIndex = GetRealItemIndex(focused); 230 const unsigned realIndex = GetRealItemIndex(focused);
229 if (realIndex >= 0) 231 if (realIndex >= 0)
230 if (_selectedStatusVector[realIndex]) 232 if (_selectedStatusVector[realIndex])
231 _selectedStatusVector[realIndex] = false; 233 _selectedStatusVector[realIndex] = false;
@@ -251,7 +253,7 @@ void CPanel::KillSelection()
251 { 253 {
252 // CPanel::OnItemChanged notify for LVIS_SELECTED change doesn't work here. Why? 254 // CPanel::OnItemChanged notify for LVIS_SELECTED change doesn't work here. Why?
253 // so we change _selectedStatusVector[realIndex] here. 255 // so we change _selectedStatusVector[realIndex] here.
254 int realIndex = GetRealItemIndex(focused); 256 const unsigned realIndex = GetRealItemIndex(focused);
255 if (realIndex != kParentIndex) 257 if (realIndex != kParentIndex)
256 _selectedStatusVector[realIndex] = true; 258 _selectedStatusVector[realIndex] = true;
257 _listView.SetItemState_Selected(focused); 259 _listView.SetItemState_Selected(focused);
@@ -273,19 +275,19 @@ void CPanel::OnLeftClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActivate)
273 if ((itemActivate->uKeyFlags & LVKF_SHIFT) != 0) 275 if ((itemActivate->uKeyFlags & LVKF_SHIFT) != 0)
274 { 276 {
275 // int focusedIndex = _listView.GetFocusedItem(); 277 // int focusedIndex = _listView.GetFocusedItem();
276 int focusedIndex = _startGroupSelect; 278 const int focusedIndex = _startGroupSelect;
277 if (focusedIndex < 0) 279 if (focusedIndex < 0)
278 return; 280 return;
279 int startItem = MyMin(focusedIndex, indexInList); 281 const int startItem = MyMin(focusedIndex, indexInList);
280 int finishItem = MyMax(focusedIndex, indexInList); 282 const int finishItem = MyMax(focusedIndex, indexInList);
281 283
282 int numItems = _listView.GetItemCount(); 284 const int numItems = _listView.GetItemCount();
283 for (int i = 0; i < numItems; i++) 285 for (int i = 0; i < numItems; i++)
284 { 286 {
285 int realIndex = GetRealItemIndex(i); 287 const unsigned realIndex = GetRealItemIndex(i);
286 if (realIndex == kParentIndex) 288 if (realIndex == kParentIndex)
287 continue; 289 continue;
288 bool selected = (i >= startItem && i <= finishItem); 290 const bool selected = (i >= startItem && i <= finishItem);
289 if (_selectedStatusVector[realIndex] != selected) 291 if (_selectedStatusVector[realIndex] != selected)
290 { 292 {
291 _selectedStatusVector[realIndex] = selected; 293 _selectedStatusVector[realIndex] = selected;
@@ -301,7 +303,7 @@ void CPanel::OnLeftClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActivate)
301 #ifndef UNDER_CE 303 #ifndef UNDER_CE
302 if ((itemActivate->uKeyFlags & LVKF_CONTROL) != 0) 304 if ((itemActivate->uKeyFlags & LVKF_CONTROL) != 0)
303 { 305 {
304 int realIndex = GetRealItemIndex(indexInList); 306 const unsigned realIndex = GetRealItemIndex(indexInList);
305 if (realIndex != kParentIndex) 307 if (realIndex != kParentIndex)
306 { 308 {
307 _selectedStatusVector[realIndex] = !_selectedStatusVector[realIndex]; 309 _selectedStatusVector[realIndex] = !_selectedStatusVector[realIndex];
diff --git a/CPP/7zip/UI/FileManager/PanelSort.cpp b/CPP/7zip/UI/FileManager/PanelSort.cpp
index d26acb7..f95f8ee 100644
--- a/CPP/7zip/UI/FileManager/PanelSort.cpp
+++ b/CPP/7zip/UI/FileManager/PanelSort.cpp
@@ -52,8 +52,8 @@ int CompareFileNames_ForFolderList(const wchar_t *s1, const wchar_t *s2)
52 52
53static int CompareFileNames_Le16(const Byte *s1, unsigned size1, const Byte *s2, unsigned size2) 53static int CompareFileNames_Le16(const Byte *s1, unsigned size1, const Byte *s2, unsigned size2)
54{ 54{
55 size1 &= ~1; 55 size1 &= ~1u;
56 size2 &= ~1; 56 size2 &= ~1u;
57 for (unsigned i = 0;; i += 2) 57 for (unsigned i = 0;; i += 2)
58 { 58 {
59 if (i >= size1) 59 if (i >= size1)
@@ -76,8 +76,8 @@ static int CompareFileNames_Le16(const Byte *s1, unsigned size1, const Byte *s2,
76 76
77static inline const wchar_t *GetExtensionPtr(const UString &name) 77static inline const wchar_t *GetExtensionPtr(const UString &name)
78{ 78{
79 int dotPos = name.ReverseFind_Dot(); 79 const int dotPos = name.ReverseFind_Dot();
80 return name.Ptr((dotPos < 0) ? name.Len() : dotPos); 80 return name.Ptr(dotPos < 0 ? name.Len() : (unsigned)dotPos);
81} 81}
82 82
83void CPanel::SetSortRawStatus() 83void CPanel::SetSortRawStatus()
@@ -142,9 +142,9 @@ static int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
142 // if (panel->_sortIndex == 0) 142 // if (panel->_sortIndex == 0)
143 case kpidName: 143 case kpidName:
144 { 144 {
145 const UString name1 = panel->GetItemName((int)lParam1); 145 const UString name1 = panel->GetItemName((unsigned)lParam1);
146 const UString name2 = panel->GetItemName((int)lParam2); 146 const UString name2 = panel->GetItemName((unsigned)lParam2);
147 int res = CompareFileNames_ForFolderList(name1, name2); 147 const int res = CompareFileNames_ForFolderList(name1, name2);
148 /* 148 /*
149 if (res != 0 || !panel->_flatMode) 149 if (res != 0 || !panel->_flatMode)
150 return res; 150 return res;
@@ -156,8 +156,8 @@ static int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
156 } 156 }
157 case kpidExtension: 157 case kpidExtension:
158 { 158 {
159 const UString name1 = panel->GetItemName((int)lParam1); 159 const UString name1 = panel->GetItemName((unsigned)lParam1);
160 const UString name2 = panel->GetItemName((int)lParam2); 160 const UString name2 = panel->GetItemName((unsigned)lParam2);
161 return CompareFileNames_ForFolderList( 161 return CompareFileNames_ForFolderList(
162 GetExtensionPtr(name1), 162 GetExtensionPtr(name1),
163 GetExtensionPtr(name2)); 163 GetExtensionPtr(name2));
@@ -186,18 +186,18 @@ int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData);
186int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData) 186int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
187{ 187{
188 if (lpData == 0) return 0; 188 if (lpData == 0) return 0;
189 if (lParam1 == kParentIndex) return -1; 189 if (lParam1 == (int)kParentIndex) return -1;
190 if (lParam2 == kParentIndex) return 1; 190 if (lParam2 == (int)kParentIndex) return 1;
191 191
192 CPanel *panel = (CPanel*)lpData; 192 CPanel *panel = (CPanel*)lpData;
193 193
194 bool isDir1 = panel->IsItem_Folder((int)lParam1); 194 const bool isDir1 = panel->IsItem_Folder((unsigned)lParam1);
195 bool isDir2 = panel->IsItem_Folder((int)lParam2); 195 const bool isDir2 = panel->IsItem_Folder((unsigned)lParam2);
196 196
197 if (isDir1 && !isDir2) return -1; 197 if (isDir1 && !isDir2) return -1;
198 if (isDir2 && !isDir1) return 1; 198 if (isDir2 && !isDir1) return 1;
199 199
200 int result = CompareItems2(lParam1, lParam2, lpData); 200 const int result = CompareItems2(lParam1, lParam2, lpData);
201 return panel->_ascending ? result: (-result); 201 return panel->_ascending ? result: (-result);
202} 202}
203 203
diff --git a/CPP/7zip/UI/FileManager/PanelSplitFile.cpp b/CPP/7zip/UI/FileManager/PanelSplitFile.cpp
index 00a0d80..64aa039 100644
--- a/CPP/7zip/UI/FileManager/PanelSplitFile.cpp
+++ b/CPP/7zip/UI/FileManager/PanelSplitFile.cpp
@@ -30,7 +30,7 @@ struct CVolSeqName
30{ 30{
31 UString UnchangedPart; 31 UString UnchangedPart;
32 UString ChangedPart; 32 UString ChangedPart;
33 CVolSeqName(): ChangedPart("000") {}; 33 CVolSeqName(): ChangedPart("000") {}
34 34
35 void SetNumDigits(UInt64 numVolumes) 35 void SetNumDigits(UInt64 numVolumes)
36 { 36 {
@@ -64,13 +64,13 @@ UString CVolSeqName::GetNextName()
64{ 64{
65 for (int i = (int)ChangedPart.Len() - 1; i >= 0; i--) 65 for (int i = (int)ChangedPart.Len() - 1; i >= 0; i--)
66 { 66 {
67 wchar_t c = ChangedPart[i]; 67 const wchar_t c = ChangedPart[i];
68 if (c != L'9') 68 if (c != L'9')
69 { 69 {
70 ChangedPart.ReplaceOneCharAtPos(i, (wchar_t)(c + 1)); 70 ChangedPart.ReplaceOneCharAtPos((unsigned)i, (wchar_t)(c + 1));
71 break; 71 break;
72 } 72 }
73 ChangedPart.ReplaceOneCharAtPos(i, L'0'); 73 ChangedPart.ReplaceOneCharAtPos((unsigned)i, L'0');
74 if (i == 0) 74 if (i == 0)
75 ChangedPart.InsertAtFront(L'1'); 75 ChangedPart.InsertAtFront(L'1');
76 } 76 }
@@ -79,7 +79,7 @@ UString CVolSeqName::GetNextName()
79 79
80class CThreadSplit: public CProgressThreadVirt 80class CThreadSplit: public CProgressThreadVirt
81{ 81{
82 HRESULT ProcessVirt(); 82 HRESULT ProcessVirt() Z7_override;
83public: 83public:
84 FString FilePath; 84 FString FilePath;
85 FString VolBasePath; 85 FString VolBasePath;
@@ -142,7 +142,7 @@ HRESULT CThreadSplit::ProcessVirt()
142{ 142{
143 NIO::CInFile inFile; 143 NIO::CInFile inFile;
144 if (!inFile.Open(FilePath)) 144 if (!inFile.Open(FilePath))
145 return GetLastError(); 145 return GetLastError_noZero_HRESULT();
146 146
147 CPreAllocOutFile outFile; 147 CPreAllocOutFile outFile;
148 148
@@ -155,7 +155,7 @@ HRESULT CThreadSplit::ProcessVirt()
155 155
156 UInt64 length; 156 UInt64 length;
157 if (!inFile.GetLength(length)) 157 if (!inFile.GetLength(length))
158 return GetLastError(); 158 return GetLastError_noZero_HRESULT();
159 159
160 CProgressSync &sync = Sync; 160 CProgressSync &sync = Sync;
161 sync.Set_NumBytesTotal(length); 161 sync.Set_NumBytesTotal(length);
@@ -181,7 +181,7 @@ HRESULT CThreadSplit::ProcessVirt()
181 } 181 }
182 UInt32 processedSize; 182 UInt32 processedSize;
183 if (!inFile.Read(buffer, needSize, processedSize)) 183 if (!inFile.Read(buffer, needSize, processedSize))
184 return GetLastError(); 184 return GetLastError_noZero_HRESULT();
185 if (processedSize == 0) 185 if (processedSize == 0)
186 return S_OK; 186 return S_OK;
187 needSize = processedSize; 187 needSize = processedSize;
@@ -189,12 +189,12 @@ HRESULT CThreadSplit::ProcessVirt()
189 if (outFile.Written == 0) 189 if (outFile.Written == 0)
190 { 190 {
191 FString name = VolBasePath; 191 FString name = VolBasePath;
192 name += '.'; 192 name.Add_Dot();
193 name += us2fs(seqName.GetNextName()); 193 name += us2fs(seqName.GetNextName());
194 sync.Set_FilePath(fs2us(name)); 194 sync.Set_FilePath(fs2us(name));
195 if (!outFile.File.Create(name, false)) 195 if (!outFile.File.Create(name, false))
196 { 196 {
197 HRESULT res = GetLastError(); 197 const HRESULT res = GetLastError_noZero_HRESULT();
198 AddErrorPath(name); 198 AddErrorPath(name);
199 return res; 199 return res;
200 } 200 }
@@ -209,7 +209,7 @@ HRESULT CThreadSplit::ProcessVirt()
209 } 209 }
210 210
211 if (!outFile.Write(buffer, needSize, processedSize)) 211 if (!outFile.Write(buffer, needSize, processedSize))
212 return GetLastError(); 212 return GetLastError_noZero_HRESULT();
213 if (needSize != processedSize) 213 if (needSize != processedSize)
214 throw g_Message_FileWriteError; 214 throw g_Message_FileWriteError;
215 215
@@ -225,7 +225,7 @@ HRESULT CThreadSplit::ProcessVirt()
225 225
226 if (pos - prev >= ((UInt32)1 << 22) || outFile.Written == 0) 226 if (pos - prev >= ((UInt32)1 << 22) || outFile.Written == 0)
227 { 227 {
228 RINOK(sync.Set_NumBytesCur(pos)); 228 RINOK(sync.Set_NumBytesCur(pos))
229 prev = pos; 229 prev = pos;
230 } 230 }
231 } 231 }
@@ -234,7 +234,7 @@ HRESULT CThreadSplit::ProcessVirt()
234 234
235void CApp::Split() 235void CApp::Split()
236{ 236{
237 int srcPanelIndex = GetFocusedPanelIndex(); 237 const unsigned srcPanelIndex = GetFocusedPanelIndex();
238 CPanel &srcPanel = Panels[srcPanelIndex]; 238 CPanel &srcPanel = Panels[srcPanelIndex];
239 if (!srcPanel.Is_IO_FS_Folder()) 239 if (!srcPanel.Is_IO_FS_Folder())
240 { 240 {
@@ -242,7 +242,7 @@ void CApp::Split()
242 return; 242 return;
243 } 243 }
244 CRecordVector<UInt32> indices; 244 CRecordVector<UInt32> indices;
245 srcPanel.GetOperatedItemIndices(indices); 245 srcPanel.Get_ItemIndices_Operated(indices);
246 if (indices.IsEmpty()) 246 if (indices.IsEmpty())
247 return; 247 return;
248 if (indices.Size() != 1) 248 if (indices.Size() != 1)
@@ -250,7 +250,7 @@ void CApp::Split()
250 srcPanel.MessageBox_Error_LangID(IDS_SELECT_ONE_FILE); 250 srcPanel.MessageBox_Error_LangID(IDS_SELECT_ONE_FILE);
251 return; 251 return;
252 } 252 }
253 int index = indices[0]; 253 const unsigned index = indices[0];
254 if (srcPanel.IsItem_Folder(index)) 254 if (srcPanel.IsItem_Folder(index))
255 { 255 {
256 srcPanel.MessageBox_Error_LangID(IDS_SELECT_ONE_FILE); 256 srcPanel.MessageBox_Error_LangID(IDS_SELECT_ONE_FILE);
@@ -258,7 +258,7 @@ void CApp::Split()
258 } 258 }
259 const UString itemName = srcPanel.GetItemName(index); 259 const UString itemName = srcPanel.GetItemName(index);
260 260
261 UString srcPath = srcPanel.GetFsPath() + srcPanel.GetItemPrefix(index); 261 const UString srcPath = srcPanel.GetFsPath() + srcPanel.GetItemPrefix(index);
262 UString path = srcPath; 262 UString path = srcPath;
263 unsigned destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex); 263 unsigned destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
264 CPanel &destPanel = Panels[destPanelIndex]; 264 CPanel &destPanel = Panels[destPanelIndex];
@@ -297,7 +297,7 @@ void CApp::Split()
297 NName::NormalizeDirPathPrefix(path); 297 NName::NormalizeDirPathPrefix(path);
298 if (!CreateComplexDir(us2fs(path))) 298 if (!CreateComplexDir(us2fs(path)))
299 { 299 {
300 DWORD lastError = ::GetLastError(); 300 const HRESULT lastError = GetLastError_noZero_HRESULT();
301 srcPanel.MessageBox_Error_2Lines_Message_HRESULT(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, path), lastError); 301 srcPanel.MessageBox_Error_2Lines_Message_HRESULT(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, path), lastError);
302 return; 302 return;
303 } 303 }
@@ -308,8 +308,8 @@ void CApp::Split()
308 308
309 CProgressDialog &progressDialog = spliter; 309 CProgressDialog &progressDialog = spliter;
310 310
311 UString progressWindowTitle ("7-Zip"); // LangString(IDS_APP_TITLE, 0x03000000); 311 const UString progressWindowTitle ("7-Zip"); // LangString(IDS_APP_TITLE, 0x03000000);
312 UString title = LangString(IDS_SPLITTING); 312 const UString title = LangString(IDS_SPLITTING);
313 313
314 progressDialog.ShowCompressionInfo = false; 314 progressDialog.ShowCompressionInfo = false;
315 315
@@ -344,7 +344,7 @@ void CApp::Split()
344 344
345class CThreadCombine: public CProgressThreadVirt 345class CThreadCombine: public CProgressThreadVirt
346{ 346{
347 HRESULT ProcessVirt(); 347 HRESULT ProcessVirt() Z7_override;
348public: 348public:
349 FString InputDirPrefix; 349 FString InputDirPrefix;
350 FStringVector Names; 350 FStringVector Names;
@@ -357,7 +357,7 @@ HRESULT CThreadCombine::ProcessVirt()
357 NIO::COutFile outFile; 357 NIO::COutFile outFile;
358 if (!outFile.Create(OutputPath, false)) 358 if (!outFile.Create(OutputPath, false))
359 { 359 {
360 HRESULT res = GetLastError(); 360 const HRESULT res = GetLastError_noZero_HRESULT();
361 AddErrorPath(OutputPath); 361 AddErrorPath(OutputPath);
362 return res; 362 return res;
363 } 363 }
@@ -376,7 +376,7 @@ HRESULT CThreadCombine::ProcessVirt()
376 const FString nextName = InputDirPrefix + Names[i]; 376 const FString nextName = InputDirPrefix + Names[i];
377 if (!inFile.Open(nextName)) 377 if (!inFile.Open(nextName))
378 { 378 {
379 HRESULT res = GetLastError(); 379 const HRESULT res = GetLastError_noZero_HRESULT();
380 AddErrorPath(nextName); 380 AddErrorPath(nextName);
381 return res; 381 return res;
382 } 382 }
@@ -386,23 +386,23 @@ HRESULT CThreadCombine::ProcessVirt()
386 UInt32 processedSize; 386 UInt32 processedSize;
387 if (!inFile.Read(buffer, kBufSize, processedSize)) 387 if (!inFile.Read(buffer, kBufSize, processedSize))
388 { 388 {
389 HRESULT res = GetLastError(); 389 const HRESULT res = GetLastError_noZero_HRESULT();
390 AddErrorPath(nextName); 390 AddErrorPath(nextName);
391 return res; 391 return res;
392 } 392 }
393 if (processedSize == 0) 393 if (processedSize == 0)
394 break; 394 break;
395 UInt32 needSize = processedSize; 395 const UInt32 needSize = processedSize;
396 if (!outFile.Write(buffer, needSize, processedSize)) 396 if (!outFile.Write(buffer, needSize, processedSize))
397 { 397 {
398 HRESULT res = GetLastError(); 398 const HRESULT res = GetLastError_noZero_HRESULT();
399 AddErrorPath(OutputPath); 399 AddErrorPath(OutputPath);
400 return res; 400 return res;
401 } 401 }
402 if (needSize != processedSize) 402 if (needSize != processedSize)
403 throw g_Message_FileWriteError; 403 throw g_Message_FileWriteError;
404 pos += processedSize; 404 pos += processedSize;
405 RINOK(sync.Set_NumBytesCur(pos)); 405 RINOK(sync.Set_NumBytesCur(pos))
406 } 406 }
407 } 407 }
408 return S_OK; 408 return S_OK;
@@ -418,7 +418,7 @@ static void AddInfoFileName(UString &dest, const UString &name)
418 418
419void CApp::Combine() 419void CApp::Combine()
420{ 420{
421 int srcPanelIndex = GetFocusedPanelIndex(); 421 const unsigned srcPanelIndex = GetFocusedPanelIndex();
422 CPanel &srcPanel = Panels[srcPanelIndex]; 422 CPanel &srcPanel = Panels[srcPanelIndex];
423 if (!srcPanel.IsFSFolder()) 423 if (!srcPanel.IsFSFolder())
424 { 424 {
@@ -426,10 +426,10 @@ void CApp::Combine()
426 return; 426 return;
427 } 427 }
428 CRecordVector<UInt32> indices; 428 CRecordVector<UInt32> indices;
429 srcPanel.GetOperatedItemIndices(indices); 429 srcPanel.Get_ItemIndices_Operated(indices);
430 if (indices.IsEmpty()) 430 if (indices.IsEmpty())
431 return; 431 return;
432 int index = indices[0]; 432 const unsigned index = indices[0];
433 if (indices.Size() != 1 || srcPanel.IsItem_Folder(index)) 433 if (indices.Size() != 1 || srcPanel.IsItem_Folder(index))
434 { 434 {
435 srcPanel.MessageBox_Error_LangID(IDS_COMBINE_SELECT_ONE_FILE); 435 srcPanel.MessageBox_Error_LangID(IDS_COMBINE_SELECT_ONE_FILE);
@@ -510,7 +510,7 @@ void CApp::Combine()
510 NName::NormalizeDirPathPrefix(path); 510 NName::NormalizeDirPathPrefix(path);
511 if (!CreateComplexDir(us2fs(path))) 511 if (!CreateComplexDir(us2fs(path)))
512 { 512 {
513 DWORD lastError = ::GetLastError(); 513 const HRESULT lastError = GetLastError_noZero_HRESULT();
514 srcPanel.MessageBox_Error_2Lines_Message_HRESULT(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, path), lastError); 514 srcPanel.MessageBox_Error_2Lines_Message_HRESULT(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, path), lastError);
515 return; 515 return;
516 } 516 }
@@ -537,8 +537,8 @@ void CApp::Combine()
537 CProgressDialog &progressDialog = combiner; 537 CProgressDialog &progressDialog = combiner;
538 progressDialog.ShowCompressionInfo = false; 538 progressDialog.ShowCompressionInfo = false;
539 539
540 UString progressWindowTitle ("7-Zip"); // LangString(IDS_APP_TITLE, 0x03000000); 540 const UString progressWindowTitle ("7-Zip"); // LangString(IDS_APP_TITLE, 0x03000000);
541 UString title = LangString(IDS_COMBINING); 541 const UString title = LangString(IDS_COMBINING);
542 542
543 progressDialog.MainWindow = _window; 543 progressDialog.MainWindow = _window;
544 progressDialog.MainTitle = progressWindowTitle; 544 progressDialog.MainTitle = progressWindowTitle;
diff --git a/CPP/7zip/UI/FileManager/PasswordDialog.cpp b/CPP/7zip/UI/FileManager/PasswordDialog.cpp
index 6ead39c..bf99580 100644
--- a/CPP/7zip/UI/FileManager/PasswordDialog.cpp
+++ b/CPP/7zip/UI/FileManager/PasswordDialog.cpp
@@ -4,11 +4,11 @@
4 4
5#include "PasswordDialog.h" 5#include "PasswordDialog.h"
6 6
7#ifdef LANG 7#ifdef Z7_LANG
8#include "LangUtils.h" 8#include "LangUtils.h"
9#endif 9#endif
10 10
11#ifdef LANG 11#ifdef Z7_LANG
12static const UInt32 kLangIDs[] = 12static const UInt32 kLangIDs[] =
13{ 13{
14 IDT_PASSWORD_ENTER, 14 IDT_PASSWORD_ENTER,
@@ -30,9 +30,9 @@ void CPasswordDialog::SetTextSpec()
30 30
31bool CPasswordDialog::OnInit() 31bool CPasswordDialog::OnInit()
32{ 32{
33 #ifdef LANG 33 #ifdef Z7_LANG
34 LangSetWindowText(*this, IDD_PASSWORD); 34 LangSetWindowText(*this, IDD_PASSWORD);
35 LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); 35 LangSetDlgItems(*this, kLangIDs, Z7_ARRAY_SIZE(kLangIDs));
36 #endif 36 #endif
37 _passwordEdit.Attach(GetItem(IDE_PASSWORD_PASSWORD)); 37 _passwordEdit.Attach(GetItem(IDE_PASSWORD_PASSWORD));
38 CheckButton(IDX_PASSWORD_SHOW, ShowPassword); 38 CheckButton(IDX_PASSWORD_SHOW, ShowPassword);
@@ -40,7 +40,7 @@ bool CPasswordDialog::OnInit()
40 return CModalDialog::OnInit(); 40 return CModalDialog::OnInit();
41} 41}
42 42
43bool CPasswordDialog::OnButtonClicked(int buttonID, HWND buttonHWND) 43bool CPasswordDialog::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
44{ 44{
45 if (buttonID == IDX_PASSWORD_SHOW) 45 if (buttonID == IDX_PASSWORD_SHOW)
46 { 46 {
diff --git a/CPP/7zip/UI/FileManager/PasswordDialog.h b/CPP/7zip/UI/FileManager/PasswordDialog.h
index 339ebda..e05c4ad 100644
--- a/CPP/7zip/UI/FileManager/PasswordDialog.h
+++ b/CPP/7zip/UI/FileManager/PasswordDialog.h
@@ -1,7 +1,7 @@
1// PasswordDialog.h 1// PasswordDialog.h
2 2
3#ifndef __PASSWORD_DIALOG_H 3#ifndef ZIP7_INC_PASSWORD_DIALOG_H
4#define __PASSWORD_DIALOG_H 4#define ZIP7_INC_PASSWORD_DIALOG_H
5 5
6#include "../../../Windows/Control/Dialog.h" 6#include "../../../Windows/Control/Dialog.h"
7#include "../../../Windows/Control/Edit.h" 7#include "../../../Windows/Control/Edit.h"
@@ -12,9 +12,9 @@ class CPasswordDialog: public NWindows::NControl::CModalDialog
12{ 12{
13 NWindows::NControl::CEdit _passwordEdit; 13 NWindows::NControl::CEdit _passwordEdit;
14 14
15 virtual void OnOK(); 15 virtual void OnOK() Z7_override;
16 virtual bool OnInit(); 16 virtual bool OnInit() Z7_override;
17 virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); 17 virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
18 void SetTextSpec(); 18 void SetTextSpec();
19 void ReadControls(); 19 void ReadControls();
20public: 20public:
@@ -22,7 +22,7 @@ public:
22 bool ShowPassword; 22 bool ShowPassword;
23 23
24 CPasswordDialog(): ShowPassword(false) {} 24 CPasswordDialog(): ShowPassword(false) {}
25 INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_PASSWORD, parentWindow); } 25 INT_PTR Create(HWND parentWindow = NULL) { return CModalDialog::Create(IDD_PASSWORD, parentWindow); }
26}; 26};
27 27
28#endif 28#endif
diff --git a/CPP/7zip/UI/FileManager/PluginInterface.h b/CPP/7zip/UI/FileManager/PluginInterface.h
index 37654a0..dcb1b4b 100644
--- a/CPP/7zip/UI/FileManager/PluginInterface.h
+++ b/CPP/7zip/UI/FileManager/PluginInterface.h
@@ -1,31 +1,32 @@
1// PluginInterface.h 1// PluginInterface.h
2 2
3#ifndef __PLUGIN_INTERFACE_H 3#ifndef ZIP7_INC_PLUGIN_INTERFACE_H
4#define __PLUGIN_INTERFACE_H 4#define ZIP7_INC_PLUGIN_INTERFACE_H
5 5
6/* 6/*
7#include "../../../Common/Types.h" 7#include "../../../../C/7zTypes.h"
8#include "../../IDecl.h" 8#include "../../IDecl.h"
9 9
10#define PLUGIN_INTERFACE(i, x) DECL_INTERFACE(i, 0x0A, x) 10#define Z7_IFACE_CONSTR_PLUGIN(i, n) \
11 11 Z7_DECL_IFACE_7ZIP(i, 0x0A, n) \
12PLUGIN_INTERFACE(IInitContextMenu, 0x00) 12 { Z7_IFACE_COM7_PURE(i) };
13{ 13
14 STDMETHOD(InitContextMenu)(const wchar_t *folder, const wchar_t * const *names, UInt32 numFiles) PURE; 14#define Z7_IFACEM_IInitContextMenu(x) \
15}; 15 x(InitContextMenu(const wchar_t *folder, const wchar_t * const *names, UInt32 numFiles)) \
16 16
17PLUGIN_INTERFACE(IPluginOptionsCallback, 0x01) 17Z7_IFACE_CONSTR_PLUGIN(IInitContextMenu, 0x00)
18{ 18
19 STDMETHOD(GetProgramFolderPath)(BSTR *value) PURE; 19#define Z7_IFACEM_IPluginOptionsCallback(x) \
20 STDMETHOD(GetProgramPath)(BSTR *value) PURE; 20 x(GetProgramFolderPath(BSTR *value)) \
21 STDMETHOD(GetRegistryCUPath)(BSTR *value) PURE; 21 x(GetProgramPath(BSTR *value)) \
22}; 22 x(GetRegistryCUPath(BSTR *value)) \
23
24PLUGIN_INTERFACE(IPluginOptions, 0x02)
25{
26 STDMETHOD(PluginOptions)(HWND hWnd, IPluginOptionsCallback *callback) PURE;
27 // STDMETHOD(GetFileExtensions)(BSTR *extensions) PURE;
28};
29*/
30 23
24Z7_IFACE_CONSTR_PLUGIN(IPluginOptionsCallback, 0x01)
25
26#define Z7_IFACEM_IPluginOptions(x) \
27 x(PluginOptions(HWND hWnd, IPluginOptionsCallback *callback)) \
28 // x(GetFileExtensions(BSTR *extensions))
29
30Z7_IFACE_CONSTR_PLUGIN(IPluginOptions, 0x02)
31*/
31#endif 32#endif
diff --git a/CPP/7zip/UI/FileManager/PluginLoader.h b/CPP/7zip/UI/FileManager/PluginLoader.h
index fed38d6..d9309f2 100644
--- a/CPP/7zip/UI/FileManager/PluginLoader.h
+++ b/CPP/7zip/UI/FileManager/PluginLoader.h
@@ -1,7 +1,7 @@
1// PluginLoader.h 1// PluginLoader.h
2 2
3#ifndef __PLUGIN_LOADER_H 3#ifndef ZIP7_INC_PLUGIN_LOADER_H
4#define __PLUGIN_LOADER_H 4#define ZIP7_INC_PLUGIN_LOADER_H
5 5
6#include "../../../Windows/DLL.h" 6#include "../../../Windows/DLL.h"
7 7
@@ -12,15 +12,18 @@ class CPluginLibrary: public NWindows::NDLL::CLibrary
12public: 12public:
13 HRESULT CreateManager(REFGUID clsID, IFolderManager **manager) 13 HRESULT CreateManager(REFGUID clsID, IFolderManager **manager)
14 { 14 {
15 Func_CreateObject createObject = (Func_CreateObject)GetProc("CreateObject"); 15 const
16 Func_CreateObject createObject = Z7_GET_PROC_ADDRESS(
17 Func_CreateObject, Get_HMODULE(),
18 "CreateObject");
16 if (!createObject) 19 if (!createObject)
17 return GetLastError(); 20 return GetLastError_noZero_HRESULT();
18 return createObject(&clsID, &IID_IFolderManager, (void **)manager); 21 return createObject(&clsID, &IID_IFolderManager, (void **)manager);
19 } 22 }
20 HRESULT LoadAndCreateManager(CFSTR filePath, REFGUID clsID, IFolderManager **manager) 23 HRESULT LoadAndCreateManager(CFSTR filePath, REFGUID clsID, IFolderManager **manager)
21 { 24 {
22 if (!Load(filePath)) 25 if (!Load(filePath))
23 return GetLastError(); 26 return GetLastError_noZero_HRESULT();
24 return CreateManager(clsID, manager); 27 return CreateManager(clsID, manager);
25 } 28 }
26}; 29};
diff --git a/CPP/7zip/UI/FileManager/ProgramLocation.h b/CPP/7zip/UI/FileManager/ProgramLocation.h
index 6bfb711..0cd9c74 100644
--- a/CPP/7zip/UI/FileManager/ProgramLocation.h
+++ b/CPP/7zip/UI/FileManager/ProgramLocation.h
@@ -1,6 +1,6 @@
1// ProgramLocation.h 1// ProgramLocation.h
2 2
3#ifndef __PROGRAM_LOCATION_H 3#ifndef ZIP7_INC_PROGRAM_LOCATION_H
4#define __PROGRAM_LOCATION_H 4#define ZIP7_INC_PROGRAM_LOCATION_H
5 5
6#endif 6#endif
diff --git a/CPP/7zip/UI/FileManager/ProgressDialog.cpp b/CPP/7zip/UI/FileManager/ProgressDialog.cpp
index b688a90..fc6f559 100644
--- a/CPP/7zip/UI/FileManager/ProgressDialog.cpp
+++ b/CPP/7zip/UI/FileManager/ProgressDialog.cpp
@@ -15,7 +15,7 @@ extern HINSTANCE g_hInstance;
15static const UINT_PTR kTimerID = 3; 15static const UINT_PTR kTimerID = 3;
16static const UINT kTimerElapse = 100; 16static const UINT kTimerElapse = 100;
17 17
18#ifdef LANG 18#ifdef Z7_LANG
19#include "LangUtils.h" 19#include "LangUtils.h"
20#endif 20#endif
21 21
@@ -32,7 +32,7 @@ HRESULT CProgressSync::ProcessStopAndPause()
32 return S_OK; 32 return S_OK;
33} 33}
34 34
35#ifndef _SFX 35#ifndef Z7_SFX
36CProgressDialog::~CProgressDialog() 36CProgressDialog::~CProgressDialog()
37{ 37{
38 AddToTitle(L""); 38 AddToTitle(L"");
@@ -45,15 +45,17 @@ void CProgressDialog::AddToTitle(LPCWSTR s)
45#endif 45#endif
46 46
47 47
48#define UNDEFINED_VAL ((UInt64)(Int64)-1)
49
48bool CProgressDialog::OnInit() 50bool CProgressDialog::OnInit()
49{ 51{
50 _range = (UInt64)(Int64)-1; 52 _range = UNDEFINED_VAL;
51 _prevPercentValue = -1; 53 _prevPercentValue = UNDEFINED_VAL;
52 54
53 _wasCreated = true; 55 _wasCreated = true;
54 _dialogCreatedEvent.Set(); 56 _dialogCreatedEvent.Set();
55 57
56 #ifdef LANG 58 #ifdef Z7_LANG
57 LangSetDlgItems(*this, NULL, 0); 59 LangSetDlgItems(*this, NULL, 0);
58 #endif 60 #endif
59 61
@@ -114,7 +116,7 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
114 if (total == 0) 116 if (total == 0)
115 total = 1; 117 total = 1;
116 118
117 int percentValue = (int)(completed * 100 / total); 119 const UInt64 percentValue = completed * 100 / total;
118 if (percentValue != _prevPercentValue) 120 if (percentValue != _prevPercentValue)
119 { 121 {
120 wchar_t s[64]; 122 wchar_t s[64];
@@ -122,7 +124,7 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
122 UString title = s; 124 UString title = s;
123 title += "% "; 125 title += "% ";
124 SetText(title + _title); 126 SetText(title + _title);
125 #ifndef _SFX 127 #ifndef Z7_SFX
126 AddToTitle(title + MainAddTitle); 128 AddToTitle(title + MainAddTitle);
127 #endif 129 #endif
128 _prevPercentValue = percentValue; 130 _prevPercentValue = percentValue;
@@ -159,7 +161,7 @@ bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
159 return CModalDialog::OnMessage(message, wParam, lParam); 161 return CModalDialog::OnMessage(message, wParam, lParam);
160} 162}
161 163
162bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND) 164bool CProgressDialog::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
163{ 165{
164 switch (buttonID) 166 switch (buttonID)
165 { 167 {
diff --git a/CPP/7zip/UI/FileManager/ProgressDialog.h b/CPP/7zip/UI/FileManager/ProgressDialog.h
index 35c182a..1fe9587 100644
--- a/CPP/7zip/UI/FileManager/ProgressDialog.h
+++ b/CPP/7zip/UI/FileManager/ProgressDialog.h
@@ -1,7 +1,7 @@
1// ProgressDialog.h 1// ProgressDialog.h
2 2
3#ifndef __PROGRESS_DIALOG_H 3#ifndef ZIP7_INC_PROGRESS_DIALOG_H
4#define __PROGRESS_DIALOG_H 4#define ZIP7_INC_PROGRESS_DIALOG_H
5 5
6#include "../../../Windows/Synchronization.h" 6#include "../../../Windows/Synchronization.h"
7#include "../../../Windows/Thread.h" 7#include "../../../Windows/Thread.h"
@@ -85,24 +85,27 @@ private:
85 UInt64 _range; 85 UInt64 _range;
86 NWindows::NControl::CProgressBar m_ProgressBar; 86 NWindows::NControl::CProgressBar m_ProgressBar;
87 87
88 int _prevPercentValue; 88 UInt64 _prevPercentValue;
89 89
90 bool _wasCreated; 90 bool _wasCreated;
91 bool _needClose; 91 bool _needClose;
92 bool _inCancelMessageBox; 92 bool _inCancelMessageBox;
93 bool _externalCloseMessageWasReceived; 93 bool _externalCloseMessageWasReceived;
94 94
95 bool OnTimer(WPARAM timerID, LPARAM callback); 95 virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
96 virtual bool OnTimer(WPARAM timerID, LPARAM callback) Z7_override;
97 virtual bool OnInit() Z7_override;
98 virtual void OnCancel() Z7_override;
99 virtual void OnOK() Z7_override;
100 virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam) Z7_override;
101
96 void SetRange(UInt64 range); 102 void SetRange(UInt64 range);
97 void SetPos(UInt64 pos); 103 void SetPos(UInt64 pos);
98 virtual bool OnInit(); 104
99 virtual void OnCancel();
100 virtual void OnOK();
101 NWindows::NSynchronization::CManualResetEvent _dialogCreatedEvent; 105 NWindows::NSynchronization::CManualResetEvent _dialogCreatedEvent;
102 #ifndef _SFX 106 #ifndef Z7_SFX
103 void AddToTitle(LPCWSTR string); 107 void AddToTitle(LPCWSTR string);
104 #endif 108 #endif
105 bool OnButtonClicked(int buttonID, HWND buttonHWND);
106 109
107 void WaitCreating() { _dialogCreatedEvent.Lock(); } 110 void WaitCreating() { _dialogCreatedEvent.Lock(); }
108 void CheckNeedClose(); 111 void CheckNeedClose();
@@ -111,7 +114,7 @@ public:
111 CProgressSync Sync; 114 CProgressSync Sync;
112 int IconID; 115 int IconID;
113 116
114 #ifndef _SFX 117 #ifndef Z7_SFX
115 HWND MainWindow; 118 HWND MainWindow;
116 UString MainTitle; 119 UString MainTitle;
117 UString MainAddTitle; 120 UString MainAddTitle;
@@ -119,8 +122,8 @@ public:
119 #endif 122 #endif
120 123
121 CProgressDialog(): _timer(0) 124 CProgressDialog(): _timer(0)
122 #ifndef _SFX 125 #ifndef Z7_SFX
123 ,MainWindow(0) 126 ,MainWindow(NULL)
124 #endif 127 #endif
125 { 128 {
126 IconID = -1; 129 IconID = -1;
@@ -133,7 +136,7 @@ public:
133 throw 1334987; 136 throw 1334987;
134 } 137 }
135 138
136 INT_PTR Create(const UString &title, NWindows::CThread &thread, HWND wndParent = 0) 139 INT_PTR Create(const UString &title, NWindows::CThread &thread, HWND wndParent = NULL)
137 { 140 {
138 _title = title; 141 _title = title;
139 INT_PTR res = CModalDialog::Create(IDD_PROGRESS, wndParent); 142 INT_PTR res = CModalDialog::Create(IDD_PROGRESS, wndParent);
@@ -146,8 +149,6 @@ public:
146 kCloseMessage = WM_APP + 1 149 kCloseMessage = WM_APP + 1
147 }; 150 };
148 151
149 virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
150
151 void ProcessWasFinished() 152 void ProcessWasFinished()
152 { 153 {
153 WaitCreating(); 154 WaitCreating();
@@ -155,7 +156,7 @@ public:
155 PostMsg(kCloseMessage); 156 PostMsg(kCloseMessage);
156 else 157 else
157 _needClose = true; 158 _needClose = true;
158 }; 159 }
159}; 160};
160 161
161 162
diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.cpp b/CPP/7zip/UI/FileManager/ProgressDialog2.cpp
index 54273d0..1521d83 100644
--- a/CPP/7zip/UI/FileManager/ProgressDialog2.cpp
+++ b/CPP/7zip/UI/FileManager/ProgressDialog2.cpp
@@ -2,6 +2,10 @@
2 2
3#include "StdAfx.h" 3#include "StdAfx.h"
4 4
5#ifdef Z7_OLD_WIN_SDK
6#include <ShlGuid.h>
7#endif
8
5#include "../../../Common/IntToString.h" 9#include "../../../Common/IntToString.h"
6#include "../../../Common/StringConvert.h" 10#include "../../../Common/StringConvert.h"
7 11
@@ -43,7 +47,7 @@ static const UINT kCreateDelay =
43 47
44static const DWORD kPauseSleepTime = 100; 48static const DWORD kPauseSleepTime = 100;
45 49
46#ifdef LANG 50#ifdef Z7_LANG
47 51
48static const UInt32 kLangIDs[] = 52static const UInt32 kLangIDs[] =
49{ 53{
@@ -67,19 +71,19 @@ static const UInt32 kLangIDs_Colon[] =
67#endif 71#endif
68 72
69 73
70#define UNDEFINED_VAL ((UInt64)(Int64)-1) 74#define UNDEFINED_VAL ((UInt64)(Int64)-1)
71#define INIT_AS_UNDEFINED(v) v = UNDEFINED_VAL; 75#define INIT_AS_UNDEFINED(v) v = UNDEFINED_VAL;
72#define IS_UNDEFINED_VAL(v) ((v) == UNDEFINED_VAL) 76#define IS_UNDEFINED_VAL(v) ((v) == UNDEFINED_VAL)
73#define IS_DEFINED_VAL(v) ((v) != UNDEFINED_VAL) 77#define IS_DEFINED_VAL(v) ((v) != UNDEFINED_VAL)
74 78
75CProgressSync::CProgressSync(): 79CProgressSync::CProgressSync():
76 _stopped(false), _paused(false), 80 _stopped(false), _paused(false),
77 _bytesProgressMode(true), 81 _bytesProgressMode(true),
82 _isDir(false),
78 _totalBytes(UNDEFINED_VAL), _completedBytes(0), 83 _totalBytes(UNDEFINED_VAL), _completedBytes(0),
79 _totalFiles(UNDEFINED_VAL), _curFiles(0), 84 _totalFiles(UNDEFINED_VAL), _curFiles(0),
80 _inSize(UNDEFINED_VAL), 85 _inSize(UNDEFINED_VAL),
81 _outSize(UNDEFINED_VAL), 86 _outSize(UNDEFINED_VAL)
82 _isDir(false)
83 {} 87 {}
84 88
85#define CHECK_STOP if (_stopped) return E_ABORT; if (!_paused) return S_OK; 89#define CHECK_STOP if (_stopped) return E_ABORT; if (!_paused) return S_OK;
@@ -228,7 +232,7 @@ void CProgressSync::AddError_Message_Name(const wchar_t *message, const wchar_t
228 AddError_Message(s); 232 AddError_Message(s);
229} 233}
230 234
231void CProgressSync::AddError_Code_Name(DWORD systemError, const wchar_t *name) 235void CProgressSync::AddError_Code_Name(HRESULT systemError, const wchar_t *name)
232{ 236{
233 UString s = NError::MyFormatMessage(systemError); 237 UString s = NError::MyFormatMessage(systemError);
234 if (systemError == 0) 238 if (systemError == 0)
@@ -262,20 +266,20 @@ CProgressDialog::CProgressDialog():
262 throw 1334987; 266 throw 1334987;
263 if (_createDialogEvent.Create() != S_OK) 267 if (_createDialogEvent.Create() != S_OK)
264 throw 1334987; 268 throw 1334987;
265 #ifdef __ITaskbarList3_INTERFACE_DEFINED__ 269 // #ifdef __ITaskbarList3_INTERFACE_DEFINED__
266 CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, (void**)&_taskbarList); 270 CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, (void**)&_taskbarList);
267 if (_taskbarList) 271 if (_taskbarList)
268 _taskbarList->HrInit(); 272 _taskbarList->HrInit();
269 #endif 273 // #endif
270} 274}
271 275
272#ifndef _SFX 276#ifndef Z7_SFX
273 277
274CProgressDialog::~CProgressDialog() 278CProgressDialog::~CProgressDialog()
275{ 279{
276 #ifdef __ITaskbarList3_INTERFACE_DEFINED__ 280 // #ifdef __ITaskbarList3_INTERFACE_DEFINED__
277 SetTaskbarProgressState(TBPF_NOPROGRESS); 281 SetTaskbarProgressState(TBPF_NOPROGRESS);
278 #endif 282 // #endif
279 AddToTitle(L""); 283 AddToTitle(L"");
280} 284}
281void CProgressDialog::AddToTitle(LPCWSTR s) 285void CProgressDialog::AddToTitle(LPCWSTR s)
@@ -292,7 +296,7 @@ void CProgressDialog::AddToTitle(LPCWSTR s)
292 296
293void CProgressDialog::SetTaskbarProgressState() 297void CProgressDialog::SetTaskbarProgressState()
294{ 298{
295 #ifdef __ITaskbarList3_INTERFACE_DEFINED__ 299 // #ifdef __ITaskbarList3_INTERFACE_DEFINED__
296 if (_taskbarList && _hwndForTaskbar) 300 if (_taskbarList && _hwndForTaskbar)
297 { 301 {
298 TBPFLAG tbpFlags; 302 TBPFLAG tbpFlags;
@@ -302,7 +306,7 @@ void CProgressDialog::SetTaskbarProgressState()
302 tbpFlags = _errorsWereDisplayed ? TBPF_ERROR: TBPF_NORMAL; 306 tbpFlags = _errorsWereDisplayed ? TBPF_ERROR: TBPF_NORMAL;
303 SetTaskbarProgressState(tbpFlags); 307 SetTaskbarProgressState(tbpFlags);
304 } 308 }
305 #endif 309 // #endif
306} 310}
307 311
308static const unsigned kTitleFileNameSizeLimit = 36; 312static const unsigned kTitleFileNameSizeLimit = 36;
@@ -331,23 +335,23 @@ bool CProgressDialog::OnInit()
331 if (!_hwndForTaskbar) 335 if (!_hwndForTaskbar)
332 _hwndForTaskbar = *this; 336 _hwndForTaskbar = *this;
333 337
334 INIT_AS_UNDEFINED(_progressBar_Range); 338 INIT_AS_UNDEFINED(_progressBar_Range)
335 INIT_AS_UNDEFINED(_progressBar_Pos); 339 INIT_AS_UNDEFINED(_progressBar_Pos)
336 340
337 INIT_AS_UNDEFINED(_prevPercentValue); 341 INIT_AS_UNDEFINED(_prevPercentValue)
338 INIT_AS_UNDEFINED(_prevElapsedSec); 342 INIT_AS_UNDEFINED(_prevElapsedSec)
339 INIT_AS_UNDEFINED(_prevRemainingSec); 343 INIT_AS_UNDEFINED(_prevRemainingSec)
340 344
341 INIT_AS_UNDEFINED(_prevSpeed); 345 INIT_AS_UNDEFINED(_prevSpeed)
342 _prevSpeed_MoveBits = 0; 346 _prevSpeed_MoveBits = 0;
343 347
344 _prevTime = ::GetTickCount(); 348 _prevTime = ::GetTickCount();
345 _elapsedTime = 0; 349 _elapsedTime = 0;
346 350
347 INIT_AS_UNDEFINED(_totalBytes_Prev); 351 INIT_AS_UNDEFINED(_totalBytes_Prev)
348 INIT_AS_UNDEFINED(_processed_Prev); 352 INIT_AS_UNDEFINED(_processed_Prev)
349 INIT_AS_UNDEFINED(_packed_Prev); 353 INIT_AS_UNDEFINED(_packed_Prev)
350 INIT_AS_UNDEFINED(_ratio_Prev); 354 INIT_AS_UNDEFINED(_ratio_Prev)
351 355
352 _filesStr_Prev.Empty(); 356 _filesStr_Prev.Empty();
353 _filesTotStr_Prev.Empty(); 357 _filesTotStr_Prev.Empty();
@@ -362,9 +366,9 @@ bool CProgressDialog::OnInit()
362 _wasCreated = true; 366 _wasCreated = true;
363 _dialogCreatedEvent.Set(); 367 _dialogCreatedEvent.Set();
364 368
365 #ifdef LANG 369 #ifdef Z7_LANG
366 LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); 370 LangSetDlgItems(*this, kLangIDs, Z7_ARRAY_SIZE(kLangIDs));
367 LangSetDlgItems_Colon(*this, kLangIDs_Colon, ARRAY_SIZE(kLangIDs_Colon)); 371 LangSetDlgItems_Colon(*this, kLangIDs_Colon, Z7_ARRAY_SIZE(kLangIDs_Colon));
368 #endif 372 #endif
369 373
370 CWindow window(GetItem(IDB_PROGRESS_BACKGROUND)); 374 CWindow window(GetItem(IDB_PROGRESS_BACKGROUND));
@@ -453,12 +457,12 @@ bool CProgressDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
453 457
454 InvalidateRect(NULL); 458 InvalidateRect(NULL);
455 459
456 int xSizeClient = xSize - mx * 2; 460 const int xSizeClient = xSize - mx * 2;
457 461
458 { 462 {
459 int i; 463 unsigned i;
460 for (i = 800; i > 40; i = i * 9 / 10) 464 for (i = 800; i > 40; i = i * 9 / 10)
461 if (Units_To_Pixels_X(i) <= xSizeClient) 465 if (Units_To_Pixels_X((int)i) <= xSizeClient)
462 break; 466 break;
463 _numReduceSymbols = i / 4; 467 _numReduceSymbols = i / 4;
464 } 468 }
@@ -473,7 +477,7 @@ bool CProgressDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
473 int mx2 = mx; 477 int mx2 = mx;
474 for (;; mx2--) 478 for (;; mx2--)
475 { 479 {
476 int bSize2 = bSizeX * 3 + mx2 * 2; 480 const int bSize2 = bSizeX * 3 + mx2 * 2;
477 if (bSize2 <= xSizeClient) 481 if (bSize2 <= xSizeClient)
478 break; 482 break;
479 if (mx2 < 5) 483 if (mx2 < 5)
@@ -488,7 +492,7 @@ bool CProgressDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
488 { 492 {
489 RECT r; 493 RECT r;
490 GetClientRectOfItem(IDL_PROGRESS_MESSAGES, r); 494 GetClientRectOfItem(IDL_PROGRESS_MESSAGES, r);
491 int y = r.top; 495 const int y = r.top;
492 int ySize2 = yPos - my - y; 496 int ySize2 = yPos - my - y;
493 const int kMinYSize = _buttonSizeY + _buttonSizeY * 3 / 4; 497 const int kMinYSize = _buttonSizeY + _buttonSizeY * 3 / 4;
494 int xx = xSize - mx * 2; 498 int xx = xSize - mx * 2;
@@ -519,13 +523,13 @@ bool CProgressDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
519 labelSize = Units_To_Pixels_X(MY_PROGRESS_LABEL_UNITS_MIN); 523 labelSize = Units_To_Pixels_X(MY_PROGRESS_LABEL_UNITS_MIN);
520 valueSize = Units_To_Pixels_X(MY_PROGRESS_VAL_UNITS); 524 valueSize = Units_To_Pixels_X(MY_PROGRESS_VAL_UNITS);
521 padSize = Units_To_Pixels_X(MY_PROGRESS_PAD_UNITS); 525 padSize = Units_To_Pixels_X(MY_PROGRESS_PAD_UNITS);
522 int requiredSize = (labelSize + valueSize) * 2 + padSize; 526 const int requiredSize = (labelSize + valueSize) * 2 + padSize;
523 527
524 int gSize; 528 int gSize;
525 { 529 {
526 if (requiredSize < xSizeClient) 530 if (requiredSize < xSizeClient)
527 { 531 {
528 int incr = (xSizeClient - requiredSize) / 3; 532 const int incr = (xSizeClient - requiredSize) / 3;
529 labelSize += incr; 533 labelSize += incr;
530 } 534 }
531 else 535 else
@@ -540,7 +544,7 @@ bool CProgressDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
540 labelSize = gSize - valueSize; 544 labelSize = gSize - valueSize;
541 545
542 yPos = my; 546 yPos = my;
543 for (unsigned i = 0; i < ARRAY_SIZE(kIDs); i += 2) 547 for (unsigned i = 0; i < Z7_ARRAY_SIZE(kIDs); i += 2)
544 { 548 {
545 int x = mx; 549 int x = mx;
546 const unsigned kNumColumn1Items = 5 * 2; 550 const unsigned kNumColumn1Items = 5 * 2;
@@ -566,7 +570,7 @@ void CProgressDialog::SetProgressRange(UInt64 range)
566 if (range == _progressBar_Range) 570 if (range == _progressBar_Range)
567 return; 571 return;
568 _progressBar_Range = range; 572 _progressBar_Range = range;
569 INIT_AS_UNDEFINED(_progressBar_Pos); 573 INIT_AS_UNDEFINED(_progressBar_Pos)
570 _progressConv.Init(range); 574 _progressConv.Init(range);
571 m_ProgressBar.SetRange32(0, _progressConv.Count(range)); 575 m_ProgressBar.SetRange32(0, _progressConv.Count(range));
572} 576}
@@ -578,10 +582,10 @@ void CProgressDialog::SetProgressPos(UInt64 pos)
578 pos - _progressBar_Pos >= (_progressBar_Range >> 10)) 582 pos - _progressBar_Pos >= (_progressBar_Range >> 10))
579 { 583 {
580 m_ProgressBar.SetPos(_progressConv.Count(pos)); 584 m_ProgressBar.SetPos(_progressConv.Count(pos));
581 #ifdef __ITaskbarList3_INTERFACE_DEFINED__ 585 // #ifdef __ITaskbarList3_INTERFACE_DEFINED__
582 if (_taskbarList && _hwndForTaskbar) 586 if (_taskbarList && _hwndForTaskbar)
583 _taskbarList->SetProgressValue(_hwndForTaskbar, pos, _progressBar_Range); 587 _taskbarList->SetProgressValue(_hwndForTaskbar, pos, _progressBar_Range);
584 #endif 588 // #endif
585 _progressBar_Pos = pos; 589 _progressBar_Pos = pos;
586 } 590 }
587} 591}
@@ -603,10 +607,10 @@ void GetTimeString(UInt64 timeValue, wchar_t *s)
603 else 607 else
604 { 608 {
605 UInt32 hours32 = (UInt32)hours; 609 UInt32 hours32 = (UInt32)hours;
606 UINT_TO_STR_2(hours32); 610 UINT_TO_STR_2(hours32)
607 } 611 }
608 *s++ = ':'; UINT_TO_STR_2(minutes); 612 *s++ = ':'; UINT_TO_STR_2(minutes)
609 *s++ = ':'; UINT_TO_STR_2(seconds); 613 *s++ = ':'; UINT_TO_STR_2(seconds)
610 *s = 0; 614 *s = 0;
611} 615}
612 616
@@ -627,7 +631,7 @@ static void ConvertSizeToString(UInt64 v, wchar_t *s)
627 } 631 }
628} 632}
629 633
630void CProgressDialog::ShowSize(int id, UInt64 val, UInt64 &prev) 634void CProgressDialog::ShowSize(unsigned id, UInt64 val, UInt64 &prev)
631{ 635{
632 if (val == prev) 636 if (val == prev)
633 return; 637 return;
@@ -771,7 +775,7 @@ void CProgressDialog::UpdateStatInfo(bool showAll)
771 { 775 {
772 if (IS_DEFINED_VAL(_prevRemainingSec)) 776 if (IS_DEFINED_VAL(_prevRemainingSec))
773 { 777 {
774 INIT_AS_UNDEFINED(_prevRemainingSec); 778 INIT_AS_UNDEFINED(_prevRemainingSec)
775 SetItemText(IDT_PROGRESS_REMAINING_VAL, L""); 779 SetItemText(IDT_PROGRESS_REMAINING_VAL, L"");
776 } 780 }
777 } 781 }
@@ -790,8 +794,9 @@ void CProgressDialog::UpdateStatInfo(bool showAll)
790 } 794 }
791 } 795 }
792 { 796 {
793 UInt64 elapsedTime = (_elapsedTime == 0) ? 1 : _elapsedTime; 797 const UInt64 elapsedTime = (_elapsedTime == 0) ? 1 : _elapsedTime;
794 UInt64 v = (progressCompleted * 1000) / elapsedTime; 798 // 22.02: progressCompleted can be for number of files
799 UInt64 v = (completed * 1000) / elapsedTime;
795 Byte c = 0; 800 Byte c = 0;
796 unsigned moveBits = 0; 801 unsigned moveBits = 0;
797 if (v >= ((UInt64)10000 << 10)) { moveBits = 20; c = 'M'; } 802 if (v >= ((UInt64)10000 << 10)) { moveBits = 20; c = 'M'; }
@@ -957,7 +962,7 @@ INT_PTR CProgressDialog::Create(const UString &title, NWindows::CThread &thread,
957 CWaitCursor waitCursor; 962 CWaitCursor waitCursor;
958 HANDLE h[] = { thread, _createDialogEvent }; 963 HANDLE h[] = { thread, _createDialogEvent };
959 964
960 DWORD res2 = WaitForMultipleObjects(ARRAY_SIZE(h), h, FALSE, kCreateDelay); 965 const DWORD res2 = WaitForMultipleObjects(Z7_ARRAY_SIZE(h), h, FALSE, kCreateDelay);
961 if (res2 == WAIT_OBJECT_0 && !Sync.ThereIsMessage()) 966 if (res2 == WAIT_OBJECT_0 && !Sync.ThereIsMessage())
962 return 0; 967 return 0;
963 } 968 }
@@ -979,9 +984,9 @@ INT_PTR CProgressDialog::Create(const UString &title, NWindows::CThread &thread,
979bool CProgressDialog::OnExternalCloseMessage() 984bool CProgressDialog::OnExternalCloseMessage()
980{ 985{
981 // it doesn't work if there is MessageBox. 986 // it doesn't work if there is MessageBox.
982 #ifdef __ITaskbarList3_INTERFACE_DEFINED__ 987 // #ifdef __ITaskbarList3_INTERFACE_DEFINED__
983 SetTaskbarProgressState(TBPF_NOPROGRESS); 988 SetTaskbarProgressState(TBPF_NOPROGRESS);
984 #endif 989 // #endif
985 // AddToTitle(L"Finished "); 990 // AddToTitle(L"Finished ");
986 // SetText(L"Finished2 "); 991 // SetText(L"Finished2 ");
987 992
@@ -1088,7 +1093,7 @@ void CProgressDialog::SetTitleText()
1088 } 1093 }
1089 1094
1090 s.Add_Space(); 1095 s.Add_Space();
1091 #ifndef _SFX 1096 #ifndef Z7_SFX
1092 { 1097 {
1093 unsigned len = s.Len(); 1098 unsigned len = s.Len();
1094 s += MainAddTitle; 1099 s += MainAddTitle;
@@ -1150,9 +1155,9 @@ void CProgressDialog::AddMessageDirect(LPCWSTR message, bool needNumber)
1150 if (needNumber) 1155 if (needNumber)
1151 ConvertUInt32ToString(_numMessages + 1, sz); 1156 ConvertUInt32ToString(_numMessages + 1, sz);
1152 const unsigned itemIndex = _messageStrings.Size(); // _messageList.GetItemCount(); 1157 const unsigned itemIndex = _messageStrings.Size(); // _messageList.GetItemCount();
1153 if (_messageList.InsertItem((int)itemIndex, sz) == (int)itemIndex) 1158 if (_messageList.InsertItem(itemIndex, sz) == (int)itemIndex)
1154 { 1159 {
1155 _messageList.SetSubItem((int)itemIndex, 1, message); 1160 _messageList.SetSubItem(itemIndex, 1, message);
1156 _messageStrings.Add(message); 1161 _messageStrings.Add(message);
1157 } 1162 }
1158} 1163}
@@ -1163,12 +1168,12 @@ void CProgressDialog::AddMessage(LPCWSTR message)
1163 bool needNumber = true; 1168 bool needNumber = true;
1164 while (!s.IsEmpty()) 1169 while (!s.IsEmpty())
1165 { 1170 {
1166 int pos = s.Find(L'\n'); 1171 const int pos = s.Find(L'\n');
1167 if (pos < 0) 1172 if (pos < 0)
1168 break; 1173 break;
1169 AddMessageDirect(s.Left(pos), needNumber); 1174 AddMessageDirect(s.Left((unsigned)pos), needNumber);
1170 needNumber = false; 1175 needNumber = false;
1171 s.DeleteFrontal(pos + 1); 1176 s.DeleteFrontal((unsigned)pos + 1);
1172 } 1177 }
1173 AddMessageDirect(s, needNumber); 1178 AddMessageDirect(s, needNumber);
1174 _numMessages++; 1179 _numMessages++;
@@ -1210,7 +1215,7 @@ void CProgressDialog::UpdateMessagesDialog()
1210} 1215}
1211 1216
1212 1217
1213bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND) 1218bool CProgressDialog::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
1214{ 1219{
1215 switch (buttonID) 1220 switch (buttonID)
1216 { 1221 {
@@ -1340,7 +1345,7 @@ static void ListView_GetSelected(NControl::CListView &listView, CUIntVector &vec
1340 index = listView.GetNextSelectedItem(index); 1345 index = listView.GetNextSelectedItem(index);
1341 if (index < 0) 1346 if (index < 0)
1342 break; 1347 break;
1343 vector.Add(index); 1348 vector.Add((unsigned)index);
1344 } 1349 }
1345} 1350}
1346 1351
@@ -1352,7 +1357,7 @@ void CProgressDialog::CopyToClipboard()
1352 UString s; 1357 UString s;
1353 unsigned numIndexes = indexes.Size(); 1358 unsigned numIndexes = indexes.Size();
1354 if (numIndexes == 0) 1359 if (numIndexes == 0)
1355 numIndexes = _messageList.GetItemCount(); 1360 numIndexes = (unsigned)_messageList.GetItemCount();
1356 1361
1357 for (unsigned i = 0; i < numIndexes; i++) 1362 for (unsigned i = 0; i < numIndexes; i++)
1358 { 1363 {
@@ -1391,7 +1396,9 @@ static THREAD_FUNC_DECL MyThreadFunction(void *param)
1391HRESULT CProgressThreadVirt::Create(const UString &title, HWND parentWindow) 1396HRESULT CProgressThreadVirt::Create(const UString &title, HWND parentWindow)
1392{ 1397{
1393 NWindows::CThread thread; 1398 NWindows::CThread thread;
1394 RINOK(thread.Create(MyThreadFunction, this)); 1399 const WRes wres = thread.Create(MyThreadFunction, this);
1400 if (wres != 0)
1401 return HRESULT_FROM_WIN32(wres);
1395 CProgressDialog::Create(title, thread, parentWindow); 1402 CProgressDialog::Create(title, thread, parentWindow);
1396 return S_OK; 1403 return S_OK;
1397} 1404}
@@ -1417,7 +1424,7 @@ void CProgressThreadVirt::Process()
1417 catch(int v) 1424 catch(int v)
1418 { 1425 {
1419 m = "Error #"; 1426 m = "Error #";
1420 m.Add_UInt32(v); 1427 m.Add_UInt32((unsigned)v);
1421 } 1428 }
1422 catch(...) { m = "Error"; } 1429 catch(...) { m = "Error"; }
1423 if (Result != E_ABORT) 1430 if (Result != E_ABORT)
diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.h b/CPP/7zip/UI/FileManager/ProgressDialog2.h
index d8259d6..4ca9be7 100644
--- a/CPP/7zip/UI/FileManager/ProgressDialog2.h
+++ b/CPP/7zip/UI/FileManager/ProgressDialog2.h
@@ -1,7 +1,7 @@
1// ProgressDialog2.h 1// ProgressDialog2.h
2 2
3#ifndef __PROGRESS_DIALOG_2_H 3#ifndef ZIP7_INC_PROGRESS_DIALOG_2_H
4#define __PROGRESS_DIALOG_2_H 4#define ZIP7_INC_PROGRESS_DIALOG_2_H
5 5
6#include "../../../Common/MyCom.h" 6#include "../../../Common/MyCom.h"
7 7
@@ -36,6 +36,7 @@ class CProgressSync
36 36
37public: 37public:
38 bool _bytesProgressMode; 38 bool _bytesProgressMode;
39 bool _isDir;
39 UInt64 _totalBytes; 40 UInt64 _totalBytes;
40 UInt64 _completedBytes; 41 UInt64 _completedBytes;
41 UInt64 _totalFiles; 42 UInt64 _totalFiles;
@@ -46,7 +47,6 @@ public:
46 UString _titleFileName; 47 UString _titleFileName;
47 UString _status; 48 UString _status;
48 UString _filePath; 49 UString _filePath;
49 bool _isDir;
50 50
51 UStringVector Messages; 51 UStringVector Messages;
52 CProgressFinalMessage FinalMessage; 52 CProgressFinalMessage FinalMessage;
@@ -96,7 +96,8 @@ public:
96 96
97 void AddError_Message(const wchar_t *message); 97 void AddError_Message(const wchar_t *message);
98 void AddError_Message_Name(const wchar_t *message, const wchar_t *name); 98 void AddError_Message_Name(const wchar_t *message, const wchar_t *name);
99 void AddError_Code_Name(DWORD systemError, const wchar_t *name); 99 // void AddError_Code_Name(DWORD systemError, const wchar_t *name);
100 void AddError_Code_Name(HRESULT systemError, const wchar_t *name);
100 101
101 bool ThereIsMessage() const { return !Messages.IsEmpty() || FinalMessage.ThereIsMessage(); } 102 bool ThereIsMessage() const { return !Messages.IsEmpty() || FinalMessage.ThereIsMessage(); }
102}; 103};
@@ -151,12 +152,12 @@ class CProgressDialog: public NWindows::NControl::CModalDialog
151 NWindows::NControl::CProgressBar m_ProgressBar; 152 NWindows::NControl::CProgressBar m_ProgressBar;
152 NWindows::NControl::CListView _messageList; 153 NWindows::NControl::CListView _messageList;
153 154
154 int _numMessages; 155 unsigned _numMessages;
155 UStringVector _messageStrings; 156 UStringVector _messageStrings;
156 157
157 #ifdef __ITaskbarList3_INTERFACE_DEFINED__ 158 // #ifdef __ITaskbarList3_INTERFACE_DEFINED__
158 CMyComPtr<ITaskbarList3> _taskbarList; 159 CMyComPtr<ITaskbarList3> _taskbarList;
159 #endif 160 // #endif
160 HWND _hwndForTaskbar; 161 HWND _hwndForTaskbar;
161 162
162 UInt32 _prevTime; 163 UInt32 _prevTime;
@@ -196,29 +197,29 @@ class CProgressDialog: public NWindows::NControl::CModalDialog
196 bool _externalCloseMessageWasReceived; 197 bool _externalCloseMessageWasReceived;
197 198
198 199
199 #ifdef __ITaskbarList3_INTERFACE_DEFINED__ 200 // #ifdef __ITaskbarList3_INTERFACE_DEFINED__
200 void SetTaskbarProgressState(TBPFLAG tbpFlags) 201 void SetTaskbarProgressState(TBPFLAG tbpFlags)
201 { 202 {
202 if (_taskbarList && _hwndForTaskbar) 203 if (_taskbarList && _hwndForTaskbar)
203 _taskbarList->SetProgressState(_hwndForTaskbar, tbpFlags); 204 _taskbarList->SetProgressState(_hwndForTaskbar, tbpFlags);
204 } 205 }
205 #endif 206 // #endif
206 void SetTaskbarProgressState(); 207 void SetTaskbarProgressState();
207 208
208 void UpdateStatInfo(bool showAll); 209 void UpdateStatInfo(bool showAll);
209 bool OnTimer(WPARAM timerID, LPARAM callback);
210 void SetProgressRange(UInt64 range); 210 void SetProgressRange(UInt64 range);
211 void SetProgressPos(UInt64 pos); 211 void SetProgressPos(UInt64 pos);
212 virtual bool OnInit(); 212 virtual bool OnTimer(WPARAM timerID, LPARAM callback) Z7_override;
213 virtual bool OnSize(WPARAM wParam, int xSize, int ySize); 213 virtual bool OnInit() Z7_override;
214 virtual void OnCancel(); 214 virtual bool OnSize(WPARAM wParam, int xSize, int ySize) Z7_override;
215 virtual void OnOK(); 215 virtual void OnCancel() Z7_override;
216 virtual bool OnNotify(UINT /* controlID */, LPNMHDR header); 216 virtual void OnOK() Z7_override;
217 virtual bool OnNotify(UINT /* controlID */, LPNMHDR header) Z7_override;
217 void CopyToClipboard(); 218 void CopyToClipboard();
218 219
219 NWindows::NSynchronization::CManualResetEvent _createDialogEvent; 220 NWindows::NSynchronization::CManualResetEvent _createDialogEvent;
220 NWindows::NSynchronization::CManualResetEvent _dialogCreatedEvent; 221 NWindows::NSynchronization::CManualResetEvent _dialogCreatedEvent;
221 #ifndef _SFX 222 #ifndef Z7_SFX
222 void AddToTitle(LPCWSTR string); 223 void AddToTitle(LPCWSTR string);
223 #endif 224 #endif
224 225
@@ -226,11 +227,11 @@ class CProgressDialog: public NWindows::NControl::CModalDialog
226 void SetPriorityText(); 227 void SetPriorityText();
227 void OnPauseButton(); 228 void OnPauseButton();
228 void OnPriorityButton(); 229 void OnPriorityButton();
229 bool OnButtonClicked(int buttonID, HWND buttonHWND); 230 bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
230 bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam); 231 bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam) Z7_override;
231 232
232 void SetTitleText(); 233 void SetTitleText();
233 void ShowSize(int id, UInt64 val, UInt64 &prev); 234 void ShowSize(unsigned id, UInt64 val, UInt64 &prev);
234 235
235 void UpdateMessagesDialog(); 236 void UpdateMessagesDialog();
236 237
@@ -252,10 +253,10 @@ public:
252 int IconID; 253 int IconID;
253 254
254 HWND MainWindow; 255 HWND MainWindow;
255 #ifndef _SFX 256 #ifndef Z7_SFX
256 UString MainTitle; 257 UString MainTitle;
257 UString MainAddTitle; 258 UString MainAddTitle;
258 ~CProgressDialog(); 259 ~CProgressDialog() Z7_DESTRUCTOR_override;
259 #endif 260 #endif
260 261
261 CProgressDialog(); 262 CProgressDialog();
@@ -265,7 +266,7 @@ public:
265 _dialogCreatedEvent.Lock(); 266 _dialogCreatedEvent.Lock();
266 } 267 }
267 268
268 INT_PTR Create(const UString &title, NWindows::CThread &thread, HWND wndParent = 0); 269 INT_PTR Create(const UString &title, NWindows::CThread &thread, HWND wndParent = NULL);
269 270
270 271
271 /* how it works: 272 /* how it works:
@@ -306,7 +307,7 @@ public:
306 void Process(); 307 void Process();
307 void AddErrorPath(const FString &path) { ErrorPaths.Add(path); } 308 void AddErrorPath(const FString &path) { ErrorPaths.Add(path); }
308 309
309 HRESULT Create(const UString &title, HWND parentWindow = 0); 310 HRESULT Create(const UString &title, HWND parentWindow = NULL);
310 CProgressThreadVirt(): Result(E_FAIL), ThreadFinishedOK(false) {} 311 CProgressThreadVirt(): Result(E_FAIL), ThreadFinishedOK(false) {}
311 312
312 CProgressMessageBoxPair &GetMessagePair(bool isError) { return isError ? FinalMessage.ErrorMessage : FinalMessage.OkMessage; } 313 CProgressMessageBoxPair &GetMessagePair(bool isError) { return isError ? FinalMessage.ErrorMessage : FinalMessage.OkMessage; }
diff --git a/CPP/7zip/UI/FileManager/PropertyName.h b/CPP/7zip/UI/FileManager/PropertyName.h
index 4f0d6dc..fa6e5c5 100644
--- a/CPP/7zip/UI/FileManager/PropertyName.h
+++ b/CPP/7zip/UI/FileManager/PropertyName.h
@@ -1,7 +1,7 @@
1// PropertyName.h 1// PropertyName.h
2 2
3#ifndef __PROPERTY_NAME_H 3#ifndef ZIP7_INC_PROPERTY_NAME_H
4#define __PROPERTY_NAME_H 4#define ZIP7_INC_PROPERTY_NAME_H
5 5
6#include "../../../Common/MyString.h" 6#include "../../../Common/MyString.h"
7 7
diff --git a/CPP/7zip/UI/FileManager/PropertyName.rc b/CPP/7zip/UI/FileManager/PropertyName.rc
index e16c526..618875b 100644
--- a/CPP/7zip/UI/FileManager/PropertyName.rc
+++ b/CPP/7zip/UI/FileManager/PropertyName.rc
@@ -104,4 +104,6 @@ BEGIN
104 IDS_PROP_GROUP_ID "Group ID" 104 IDS_PROP_GROUP_ID "Group ID"
105 IDS_PROP_DEVICE_MAJOR "Device Major" 105 IDS_PROP_DEVICE_MAJOR "Device Major"
106 IDS_PROP_DEVICE_MINOR "Device Minor" 106 IDS_PROP_DEVICE_MINOR "Device Minor"
107 IDS_PROP_DEV_MAJOR "Dev Major"
108 IDS_PROP_DEV_MINOR "Dev Minor"
107END 109END
diff --git a/CPP/7zip/UI/FileManager/PropertyNameRes.h b/CPP/7zip/UI/FileManager/PropertyNameRes.h
index e3d08db..913887e 100644
--- a/CPP/7zip/UI/FileManager/PropertyNameRes.h
+++ b/CPP/7zip/UI/FileManager/PropertyNameRes.h
@@ -100,3 +100,5 @@
100#define IDS_PROP_GROUP_ID 1100 100#define IDS_PROP_GROUP_ID 1100
101#define IDS_PROP_DEVICE_MAJOR 1101 101#define IDS_PROP_DEVICE_MAJOR 1101
102#define IDS_PROP_DEVICE_MINOR 1102 102#define IDS_PROP_DEVICE_MINOR 1102
103#define IDS_PROP_DEV_MAJOR 1103
104#define IDS_PROP_DEV_MINOR 1104
diff --git a/CPP/7zip/UI/FileManager/RegistryAssociations.cpp b/CPP/7zip/UI/FileManager/RegistryAssociations.cpp
index e48dbb4..16e4675 100644
--- a/CPP/7zip/UI/FileManager/RegistryAssociations.cpp
+++ b/CPP/7zip/UI/FileManager/RegistryAssociations.cpp
@@ -65,18 +65,18 @@ bool CShellExtInfo::ReadFromRegistry(HKEY hkey, const CSysString &ext)
65 UString value; 65 UString value;
66 if (iconKey.QueryValue(NULL, value) == ERROR_SUCCESS) 66 if (iconKey.QueryValue(NULL, value) == ERROR_SUCCESS)
67 { 67 {
68 int pos = value.ReverseFind(L','); 68 const int pos = value.ReverseFind(L',');
69 IconPath = value; 69 IconPath = value;
70 if (pos >= 0) 70 if (pos >= 0)
71 { 71 {
72 const wchar_t *end; 72 const wchar_t *end;
73 Int32 index = ConvertStringToInt32((const wchar_t *)value + pos + 1, &end); 73 const Int32 index = ConvertStringToInt32((const wchar_t *)value + pos + 1, &end);
74 if (*end == 0) 74 if (*end == 0)
75 { 75 {
76 // 9.31: if there is no icon index, we use -1. Is it OK? 76 // 9.31: if there is no icon index, we use -1. Is it OK?
77 if (pos != (int)value.Len() - 1) 77 if (pos != (int)value.Len() - 1)
78 IconIndex = (int)index; 78 IconIndex = (int)index;
79 IconPath.SetFrom(value, pos); 79 IconPath.SetFrom(value, (unsigned)pos);
80 } 80 }
81 } 81 }
82 } 82 }
diff --git a/CPP/7zip/UI/FileManager/RegistryAssociations.h b/CPP/7zip/UI/FileManager/RegistryAssociations.h
index 975c9d5..3d7b63d 100644
--- a/CPP/7zip/UI/FileManager/RegistryAssociations.h
+++ b/CPP/7zip/UI/FileManager/RegistryAssociations.h
@@ -1,7 +1,7 @@
1// RegistryAssociations.h 1// RegistryAssociations.h
2 2
3#ifndef __REGISTRY_ASSOCIATIONS_H 3#ifndef ZIP7_INC_REGISTRY_ASSOCIATIONS_H
4#define __REGISTRY_ASSOCIATIONS_H 4#define ZIP7_INC_REGISTRY_ASSOCIATIONS_H
5 5
6#include "../../../Common/MyString.h" 6#include "../../../Common/MyString.h"
7 7
diff --git a/CPP/7zip/UI/FileManager/RegistryPlugins.cpp b/CPP/7zip/UI/FileManager/RegistryPlugins.cpp
index 76a5787..87e5fa1 100644
--- a/CPP/7zip/UI/FileManager/RegistryPlugins.cpp
+++ b/CPP/7zip/UI/FileManager/RegistryPlugins.cpp
@@ -2,138 +2,144 @@
2 2
3#include "StdAfx.h" 3#include "StdAfx.h"
4 4
5/*
5#include "../../../Windows/DLL.h" 6#include "../../../Windows/DLL.h"
6#include "../../../Windows/FileFind.h" 7#include "../../../Windows/FileFind.h"
7#include "../../../Windows/PropVariant.h" 8#include "../../../Windows/PropVariant.h"
8 9
9#include "IFolder.h" 10#include "IFolder.h"
11*/
10#include "RegistryPlugins.h" 12#include "RegistryPlugins.h"
11 13
12using namespace NWindows; 14// using namespace NWindows;
13using namespace NFile; 15// using namespace NFile;
14 16
15/* 17/*
16static LPCTSTR const kLMBasePath = TEXT("Software\\7-Zip\\FM"); 18typedef UINT32 (WINAPI * Func_GetPluginProperty)(PROPID propID, PROPVARIANT *value);
17 19
18static LPCTSTR const kPluginsKeyName = TEXT("Plugins"); 20static bool ReadPluginInfo(CPluginInfo &plugin, bool needCheckDll)
19static LPCTSTR const kPluginsOpenClassIDValue = TEXT("CLSID");
20static LPCTSTR const kPluginsOptionsClassIDValue = TEXT("Options");
21static LPCTSTR const kPluginsTypeValue = TEXT("Type");
22
23static CSysString GetFileFolderPluginsKeyName()
24{
25 return CSysString(kLMBasePath) + CSysString(TEXT('\\')) +
26 CSysString(kPluginsKeyName);
27}
28
29*/
30
31typedef UINT32 (WINAPI * GetPluginPropertyFunc)(PROPID propID, PROPVARIANT *value);
32
33static bool ReadPluginInfo(CPluginInfo &pluginInfo, bool needCheckDll)
34{ 21{
35 if (needCheckDll) 22 if (needCheckDll)
36 { 23 {
37 NDLL::CLibrary lib; 24 NDLL::CLibrary lib;
38 if (!lib.LoadEx(pluginInfo.FilePath, LOAD_LIBRARY_AS_DATAFILE)) 25 if (!lib.LoadEx(plugin.FilePath, LOAD_LIBRARY_AS_DATAFILE))
39 return false; 26 return false;
40 } 27 }
41 NDLL::CLibrary lib; 28 NDLL::CLibrary lib;
42 if (!lib.Load(pluginInfo.FilePath)) 29 if (!lib.Load(plugin.FilePath))
43 return false; 30 return false;
44 GetPluginPropertyFunc getPluginProperty = (GetPluginPropertyFunc)lib.GetProc("GetPluginProperty"); 31 const
45 if (getPluginProperty == NULL) 32 Func_GetPluginProperty
33 f_GetPluginProperty = ZIP7_GET_PROC_ADDRESS(
34 Func_GetPluginProperty, lib.Get_HMODULE(),
35 "GetPluginProperty");
36 if (!f_GetPluginProperty)
46 return false; 37 return false;
47 38
48 NCOM::CPropVariant prop; 39 NCOM::CPropVariant prop;
49 if (getPluginProperty(NPlugin::kName, &prop) != S_OK) 40 if (f_GetPluginProperty(NPlugin::kType, &prop) != S_OK)
41 return false;
42 if (prop.vt == VT_EMPTY)
43 plugin.Type = kPluginTypeFF;
44 else if (prop.vt == VT_UI4)
45 plugin.Type = (EPluginType)prop.ulVal;
46 else
47 return false;
48 prop.Clear();
49
50 if (f_GetPluginProperty(NPlugin::kName, &prop) != S_OK)
50 return false; 51 return false;
51 if (prop.vt != VT_BSTR) 52 if (prop.vt != VT_BSTR)
52 return false; 53 return false;
53 pluginInfo.Name = prop.bstrVal; 54 plugin.Name = prop.bstrVal;
54 prop.Clear(); 55 prop.Clear();
55 56
56 if (getPluginProperty(NPlugin::kClassID, &prop) != S_OK) 57 if (f_GetPluginProperty(NPlugin::kClassID, &prop) != S_OK)
57 return false; 58 return false;
58 if (prop.vt == VT_EMPTY) 59 if (prop.vt == VT_EMPTY)
59 pluginInfo.ClassIDDefined = false; 60 plugin.ClassID_Defined = false;
60 else if (prop.vt != VT_BSTR) 61 else if (prop.vt != VT_BSTR)
61 return false; 62 return false;
62 else 63 else
63 { 64 {
64 pluginInfo.ClassIDDefined = true; 65 plugin.ClassID_Defined = true;
65 pluginInfo.ClassID = *(const GUID *)(const void *)prop.bstrVal; 66 plugin.ClassID = *(const GUID *)(const void *)prop.bstrVal;
66 } 67 }
67 prop.Clear(); 68 prop.Clear();
69 return true;
70*/
68 71
69 if (getPluginProperty(NPlugin::kOptionsClassID, &prop) != S_OK) 72/*
73{
74 if (f_GetPluginProperty(NPlugin::kOptionsClassID, &prop) != S_OK)
70 return false; 75 return false;
71 if (prop.vt == VT_EMPTY) 76 if (prop.vt == VT_EMPTY)
72 pluginInfo.OptionsClassIDDefined = false; 77 plugin.OptionsClassID_Defined = false;
73 else if (prop.vt != VT_BSTR) 78 else if (prop.vt != VT_BSTR)
74 return false; 79 return false;
75 else 80 else
76 { 81 {
77 pluginInfo.OptionsClassIDDefined = true; 82 plugin.OptionsClassID_Defined = true;
78 pluginInfo.OptionsClassID = *(const GUID *)(const void *)prop.bstrVal; 83 plugin.OptionsClassID = *(const GUID *)(const void *)prop.bstrVal;
79 } 84 }
80 prop.Clear();
81
82 if (getPluginProperty(NPlugin::kType, &prop) != S_OK)
83 return false;
84 if (prop.vt == VT_EMPTY)
85 pluginInfo.Type = kPluginTypeFF;
86 else if (prop.vt == VT_UI4)
87 pluginInfo.Type = (EPluginType)prop.ulVal;
88 else
89 return false;
90 return true;
91} 85}
86*/
92 87
93void ReadPluginInfoList(CObjectVector<CPluginInfo> &plugins) 88 /*
94{ 89 {
95 plugins.Clear(); 90 // very old 7-zip used agent plugin in "7-zip.dll"
91 // but then agent code was moved to 7zfm.
92 // so now we don't need to load "7-zip.dll" here
93 CPluginInfo plugin;
94 plugin.FilePath = baseFolderPrefix + FTEXT("7-zip.dll");
95 if (::ReadPluginInfo(plugin, false))
96 if (plugin.Type == kPluginTypeFF)
97 plugins.Add(plugin);
98 }
99 */
100 /*
101 FString folderPath = NDLL::GetModuleDirPrefix();
102 folderPath += "Plugins" STRING_PATH_SEPARATOR;
103 NFind::CEnumerator enumerator;
104 enumerator.SetDirPrefix(folderPath);
105 NFind::CFileInfo fi;
106 while (enumerator.Next(fi))
107 {
108 if (fi.IsDir())
109 continue;
110 CPluginInfo plugin;
111 plugin.FilePath = folderPath + fi.Name;
112 if (::ReadPluginInfo(plugin, true))
113 if (plugin.Type == kPluginTypeFF)
114 plugins.Add(plugin);
115 }
116 */
96 117
97 FString baseFolderPrefix = NDLL::GetModuleDirPrefix(); 118 /*
98 {
99 CPluginInfo pluginInfo;
100 pluginInfo.FilePath = baseFolderPrefix + FTEXT("7-zip.dll");
101 if (::ReadPluginInfo(pluginInfo, false))
102 plugins.Add(pluginInfo);
103 }
104 FString folderPath = baseFolderPrefix;
105 folderPath += "Plugins" STRING_PATH_SEPARATOR;
106 NFind::CEnumerator enumerator;
107 enumerator.SetDirPrefix(folderPath);
108 NFind::CFileInfo fileInfo;
109 while (enumerator.Next(fileInfo))
110 {
111 if (fileInfo.IsDir())
112 continue;
113 CPluginInfo pluginInfo;
114 pluginInfo.FilePath = folderPath + fileInfo.Name;
115 if (::ReadPluginInfo(pluginInfo, true))
116 plugins.Add(pluginInfo);
117 }
118}
119
120void ReadFileFolderPluginInfoList(CObjectVector<CPluginInfo> &plugins)
121{
122 ReadPluginInfoList(plugins); 119 ReadPluginInfoList(plugins);
123 for (unsigned i = 0; i < plugins.Size();) 120 for (unsigned i = 0; i < plugins.Size();)
124 if (plugins[i].Type != kPluginTypeFF) 121 if (plugins[i].Type != kPluginTypeFF)
125 plugins.Delete(i); 122 plugins.Delete(i);
126 else 123 else
127 i++; 124 i++;
125 */
126
127/*
128void ReadFileFolderPluginInfoList(CObjectVector<CPluginInfo> &plugins)
129{
130 plugins.Clear();
131 {
132 }
133
128 { 134 {
129 CPluginInfo p; 135 CPluginInfo &plugin = plugins.AddNew();
130 // p.FilePath.Empty(); 136 // p.FilePath.Empty();
131 p.Type = kPluginTypeFF; 137 plugin.Type = kPluginTypeFF;
132 p.Name = "7-Zip"; 138 plugin.Name = "7-Zip";
133 // p.ClassID = CLSID_CAgentArchiveHandler; 139 // plugin.ClassID = CLSID_CAgentArchiveHandler;
134 p.ClassIDDefined = true; 140 // plugin.ClassID_Defined = true;
135 // p.OptionsClassID; 141 // plugin.ClassID_Defined = false;
136 p.OptionsClassIDDefined = false; 142 // plugin.OptionsClassID_Defined = false;
137 plugins.Add(p);
138 } 143 }
139} 144}
145*/
diff --git a/CPP/7zip/UI/FileManager/RegistryPlugins.h b/CPP/7zip/UI/FileManager/RegistryPlugins.h
index dfa6de5..1cb765a 100644
--- a/CPP/7zip/UI/FileManager/RegistryPlugins.h
+++ b/CPP/7zip/UI/FileManager/RegistryPlugins.h
@@ -1,10 +1,11 @@
1// RegistryPlugins.h 1// RegistryPlugins.h
2 2
3#ifndef __REGISTRY_PLUGINS_H 3#ifndef ZIP7_INC_REGISTRY_PLUGINS_H
4#define __REGISTRY_PLUGINS_H 4#define ZIP7_INC_REGISTRY_PLUGINS_H
5 5
6#include "../../../Common/MyString.h" 6#include "../../../Common/MyString.h"
7 7
8/*
8enum EPluginType 9enum EPluginType
9{ 10{
10 kPluginTypeFF = 0 11 kPluginTypeFF = 0
@@ -12,21 +13,17 @@ enum EPluginType
12 13
13struct CPluginInfo 14struct CPluginInfo
14{ 15{
15 FString FilePath;
16 EPluginType Type; 16 EPluginType Type;
17 UString Name; 17 // bool ClassID_Defined;
18 CLSID ClassID; 18 // bool OptionsClassID_Defined;
19 CLSID OptionsClassID; 19 // FString FilePath;
20 bool ClassIDDefined; 20 // UString Name;
21 bool OptionsClassIDDefined; 21 // CLSID ClassID;
22 22 // CLSID OptionsClassID;
23 // CSysString Extension;
24 // CSysString AddExtension;
25 // bool UpdateEnabled;
26 // bool KeepName;
27}; 23};
28 24
29void ReadPluginInfoList(CObjectVector<CPluginInfo> &plugins); 25// void ReadPluginInfoList(CObjectVector<CPluginInfo> &plugins);
30void ReadFileFolderPluginInfoList(CObjectVector<CPluginInfo> &plugins); 26// void ReadFileFolderPluginInfoList(CObjectVector<CPluginInfo> &plugins);
27*/
31 28
32#endif 29#endif
diff --git a/CPP/7zip/UI/FileManager/RegistryUtils.cpp b/CPP/7zip/UI/FileManager/RegistryUtils.cpp
index a2fc201..7e61998 100644
--- a/CPP/7zip/UI/FileManager/RegistryUtils.cpp
+++ b/CPP/7zip/UI/FileManager/RegistryUtils.cpp
@@ -137,6 +137,11 @@ void CFmSettings::Load()
137{ 137{
138 ShowDots = false; 138 ShowDots = false;
139 ShowRealFileIcons = false; 139 ShowRealFileIcons = false;
140 /* if (FullRow == false), we can use mouse click on another columns
141 to select group of files. We need to implement additional
142 way to select files in any column as in Explorer.
143 Then we can enable (FullRow == true) default mode. */
144 // FullRow = true;
140 FullRow = false; 145 FullRow = false;
141 ShowGrid = false; 146 ShowGrid = false;
142 SingleClick = false; 147 SingleClick = false;
diff --git a/CPP/7zip/UI/FileManager/RegistryUtils.h b/CPP/7zip/UI/FileManager/RegistryUtils.h
index b85d670..8b4cdf0 100644
--- a/CPP/7zip/UI/FileManager/RegistryUtils.h
+++ b/CPP/7zip/UI/FileManager/RegistryUtils.h
@@ -1,7 +1,7 @@
1// RegistryUtils.h 1// RegistryUtils.h
2 2
3#ifndef __REGISTRY_UTILS_H 3#ifndef ZIP7_INC_REGISTRY_UTILS_H
4#define __REGISTRY_UTILS_H 4#define ZIP7_INC_REGISTRY_UTILS_H
5 5
6#include "../../../Common/MyTypes.h" 6#include "../../../Common/MyTypes.h"
7#include "../../../Common/MyString.h" 7#include "../../../Common/MyString.h"
diff --git a/CPP/7zip/UI/FileManager/RootFolder.cpp b/CPP/7zip/UI/FileManager/RootFolder.cpp
index 84844c7..34dd638 100644
--- a/CPP/7zip/UI/FileManager/RootFolder.cpp
+++ b/CPP/7zip/UI/FileManager/RootFolder.cpp
@@ -4,7 +4,11 @@
4 4
5#include "../../../Common/MyWindows.h" 5#include "../../../Common/MyWindows.h"
6 6
7#if defined(__MINGW32__) || defined(__MINGW64__)
8#include <shlobj.h>
9#else
7#include <ShlObj.h> 10#include <ShlObj.h>
11#endif
8 12
9#include "../../../Common/StringConvert.h" 13#include "../../../Common/StringConvert.h"
10 14
@@ -96,19 +100,19 @@ void CRootFolder::Init()
96 #endif 100 #endif
97} 101}
98 102
99STDMETHODIMP CRootFolder::LoadItems() 103Z7_COM7F_IMF(CRootFolder::LoadItems())
100{ 104{
101 Init(); 105 Init();
102 return S_OK; 106 return S_OK;
103} 107}
104 108
105STDMETHODIMP CRootFolder::GetNumberOfItems(UInt32 *numItems) 109Z7_COM7F_IMF(CRootFolder::GetNumberOfItems(UInt32 *numItems))
106{ 110{
107 *numItems = kNumRootFolderItems; 111 *numItems = kNumRootFolderItems;
108 return S_OK; 112 return S_OK;
109} 113}
110 114
111STDMETHODIMP CRootFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value) 115Z7_COM7F_IMF(CRootFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value))
112{ 116{
113 NCOM::CPropVariant prop; 117 NCOM::CPropVariant prop;
114 switch (propID) 118 switch (propID)
@@ -120,28 +124,31 @@ STDMETHODIMP CRootFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIA
120 return S_OK; 124 return S_OK;
121} 125}
122 126
123typedef BOOL (WINAPI *SHGetSpecialFolderPathWp)(HWND hwnd, LPWSTR pszPath, int csidl, BOOL fCreate); 127typedef BOOL (WINAPI *Func_SHGetSpecialFolderPathW)(HWND hwnd, LPWSTR pszPath, int csidl, BOOL fCreate);
124typedef BOOL (WINAPI *SHGetSpecialFolderPathAp)(HWND hwnd, LPSTR pszPath, int csidl, BOOL fCreate); 128typedef BOOL (WINAPI *Func_SHGetSpecialFolderPathA)(HWND hwnd, LPSTR pszPath, int csidl, BOOL fCreate);
125 129
126static UString GetMyDocsPath() 130static UString GetMyDocsPath()
127{ 131{
128 UString us; 132 UString us;
129 WCHAR s[MAX_PATH + 1]; 133 WCHAR s[MAX_PATH + 1];
130 SHGetSpecialFolderPathWp getW = (SHGetSpecialFolderPathWp) 134#ifdef UNDER_CE
131 #ifdef UNDER_CE 135 #define shell_name TEXT("coredll.dll")
132 My_GetProcAddress(GetModuleHandle(TEXT("coredll.dll")), "SHGetSpecialFolderPath"); 136#else
133 #else 137 #define shell_name TEXT("shell32.dll")
134 My_GetProcAddress(GetModuleHandle(TEXT("shell32.dll")), "SHGetSpecialFolderPathW"); 138#endif
135 #endif 139 Func_SHGetSpecialFolderPathW getW = Z7_GET_PROC_ADDRESS(
136 if (getW && getW(0, s, CSIDL_PERSONAL, FALSE)) 140 Func_SHGetSpecialFolderPathW, GetModuleHandle(shell_name),
141 "SHGetSpecialFolderPathW");
142 if (getW && getW(NULL, s, CSIDL_PERSONAL, FALSE))
137 us = s; 143 us = s;
138 #ifndef _UNICODE 144 #ifndef _UNICODE
139 else 145 else
140 { 146 {
141 SHGetSpecialFolderPathAp getA = (SHGetSpecialFolderPathAp) 147 Func_SHGetSpecialFolderPathA getA = Z7_GET_PROC_ADDRESS(
142 (void *)::GetProcAddress(::GetModuleHandleA("shell32.dll"), "SHGetSpecialFolderPathA"); 148 Func_SHGetSpecialFolderPathA, ::GetModuleHandleA("shell32.dll"),
149 "SHGetSpecialFolderPathA");
143 CHAR s2[MAX_PATH + 1]; 150 CHAR s2[MAX_PATH + 1];
144 if (getA && getA(0, s2, CSIDL_PERSONAL, FALSE)) 151 if (getA && getA(NULL, s2, CSIDL_PERSONAL, FALSE))
145 us = GetUnicodeString(s2); 152 us = GetUnicodeString(s2);
146 } 153 }
147 #endif 154 #endif
@@ -149,7 +156,7 @@ static UString GetMyDocsPath()
149 return us; 156 return us;
150} 157}
151 158
152STDMETHODIMP CRootFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder) 159Z7_COM7F_IMF(CRootFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder))
153{ 160{
154 *resultFolder = NULL; 161 *resultFolder = NULL;
155 CMyComPtr<IFolderFolder> subFolder; 162 CMyComPtr<IFolderFolder> subFolder;
@@ -165,7 +172,7 @@ STDMETHODIMP CRootFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolde
165 { 172 {
166 CNetFolder *netFolderSpec = new CNetFolder; 173 CNetFolder *netFolderSpec = new CNetFolder;
167 subFolder = netFolderSpec; 174 subFolder = netFolderSpec;
168 netFolderSpec->Init(0, 0, _names[ROOT_INDEX_NETWORK] + WCHAR_PATH_SEPARATOR); 175 netFolderSpec->Init(NULL, NULL, _names[ROOT_INDEX_NETWORK] + WCHAR_PATH_SEPARATOR);
169 } 176 }
170 else if (index == ROOT_INDEX_DOCUMENTS) 177 else if (index == ROOT_INDEX_DOCUMENTS)
171 { 178 {
@@ -174,7 +181,7 @@ STDMETHODIMP CRootFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolde
174 { 181 {
175 NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder; 182 NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder;
176 subFolder = fsFolderSpec; 183 subFolder = fsFolderSpec;
177 RINOK(fsFolderSpec->Init(us2fs(s))); 184 RINOK(fsFolderSpec->Init(us2fs(s)))
178 } 185 }
179 } 186 }
180 #else 187 #else
@@ -202,9 +209,9 @@ static bool AreEqualNames(const UString &path, const wchar_t *name)
202 return path.IsPrefixedBy(name); 209 return path.IsPrefixedBy(name);
203} 210}
204 211
205STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder) 212Z7_COM7F_IMF(CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder))
206{ 213{
207 *resultFolder = 0; 214 *resultFolder = NULL;
208 UString name2 = name; 215 UString name2 = name;
209 name2.Trim(); 216 name2.Trim();
210 217
@@ -259,7 +266,8 @@ STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resu
259 subFolder = folderSpec; 266 subFolder = folderSpec;
260 folderSpec->Init(false, true); 267 folderSpec->Init(false, true);
261 } 268 }
262 else if (name2.Back() == ':') 269 else if (name2.Back() == ':'
270 && (name2.Len() != 2 || !NFile::NName::IsDrivePath2(name2)))
263 { 271 {
264 NAltStreamsFolder::CAltStreamsFolder *folderSpec = new NAltStreamsFolder::CAltStreamsFolder; 272 NAltStreamsFolder::CAltStreamsFolder *folderSpec = new NAltStreamsFolder::CAltStreamsFolder;
265 subFolder = folderSpec; 273 subFolder = folderSpec;
@@ -291,15 +299,15 @@ STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resu
291 return S_OK; 299 return S_OK;
292} 300}
293 301
294STDMETHODIMP CRootFolder::BindToParentFolder(IFolderFolder **resultFolder) 302Z7_COM7F_IMF(CRootFolder::BindToParentFolder(IFolderFolder **resultFolder))
295{ 303{
296 *resultFolder = 0; 304 *resultFolder = NULL;
297 return S_OK; 305 return S_OK;
298} 306}
299 307
300IMP_IFolderFolder_Props(CRootFolder) 308IMP_IFolderFolder_Props(CRootFolder)
301 309
302STDMETHODIMP CRootFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value) 310Z7_COM7F_IMF(CRootFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value))
303{ 311{
304 NCOM::CPropVariant prop; 312 NCOM::CPropVariant prop;
305 switch (propID) 313 switch (propID)
@@ -311,7 +319,7 @@ STDMETHODIMP CRootFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
311 return S_OK; 319 return S_OK;
312} 320}
313 321
314STDMETHODIMP CRootFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex) 322Z7_COM7F_IMF(CRootFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex))
315{ 323{
316 *iconIndex = _iconIndices[index]; 324 *iconIndex = _iconIndices[index];
317 return S_OK; 325 return S_OK;
diff --git a/CPP/7zip/UI/FileManager/RootFolder.h b/CPP/7zip/UI/FileManager/RootFolder.h
index e253783..3f0a31b 100644
--- a/CPP/7zip/UI/FileManager/RootFolder.h
+++ b/CPP/7zip/UI/FileManager/RootFolder.h
@@ -1,26 +1,23 @@
1// RootFolder.h 1// RootFolder.h
2 2
3#ifndef __ROOT_FOLDER_H 3#ifndef ZIP7_INC_ROOT_FOLDER_H
4#define __ROOT_FOLDER_H 4#define ZIP7_INC_ROOT_FOLDER_H
5 5
6#include "../../../Common/MyCom.h"
6#include "../../../Common/MyString.h" 7#include "../../../Common/MyString.h"
7 8
8#include "IFolder.h" 9#include "IFolder.h"
9 10
10const unsigned kNumRootFolderItems_Max = 4; 11const unsigned kNumRootFolderItems_Max = 4;
11 12
12class CRootFolder: 13Z7_CLASS_IMP_NOQIB_2(
13 public IFolderFolder, 14 CRootFolder
14 public IFolderGetSystemIconIndex, 15 , IFolderFolder
15 public CMyUnknownImp 16 , IFolderGetSystemIconIndex
16{ 17)
17 UString _names[kNumRootFolderItems_Max]; 18 UString _names[kNumRootFolderItems_Max];
18 int _iconIndices[kNumRootFolderItems_Max]; 19 int _iconIndices[kNumRootFolderItems_Max];
19
20public: 20public:
21 MY_UNKNOWN_IMP1(IFolderGetSystemIconIndex)
22 INTERFACE_FolderFolder(;)
23 STDMETHOD(GetSystemIconIndex)(UInt32 index, Int32 *iconIndex);
24 void Init(); 21 void Init();
25}; 22};
26 23
diff --git a/CPP/7zip/UI/FileManager/SettingsPage.cpp b/CPP/7zip/UI/FileManager/SettingsPage.cpp
index 2868721..784b8c7 100644
--- a/CPP/7zip/UI/FileManager/SettingsPage.cpp
+++ b/CPP/7zip/UI/FileManager/SettingsPage.cpp
@@ -20,6 +20,7 @@
20 20
21using namespace NWindows; 21using namespace NWindows;
22 22
23#ifdef Z7_LANG
23static const UInt32 kLangIDs[] = 24static const UInt32 kLangIDs[] =
24{ 25{
25 IDX_SETTINGS_SHOW_DOTS, 26 IDX_SETTINGS_SHOW_DOTS,
@@ -32,6 +33,7 @@ static const UInt32 kLangIDs[] =
32 IDX_SETTINGS_LARGE_PAGES 33 IDX_SETTINGS_LARGE_PAGES
33 // , IDT_COMPRESS_MEMORY 34 // , IDT_COMPRESS_MEMORY
34}; 35};
36#endif
35 37
36#define kSettingsTopic "FM/options.htm#settings" 38#define kSettingsTopic "FM/options.htm#settings"
37 39
@@ -112,7 +114,9 @@ bool CSettingsPage::OnInit()
112 _memCombo.Attach(GetItem(IDC_SETTINGS_MEM)); 114 _memCombo.Attach(GetItem(IDC_SETTINGS_MEM));
113 */ 115 */
114 116
115 LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); 117#ifdef Z7_LANG
118 LangSetDlgItems(*this, kLangIDs, Z7_ARRAY_SIZE(kLangIDs));
119#endif
116 120
117 CFmSettings st; 121 CFmSettings st;
118 st.Load(); 122 st.Load();
@@ -225,7 +229,7 @@ LONG CSettingsPage::OnApply()
225 { 229 {
226 if (IsLargePageSupported()) 230 if (IsLargePageSupported())
227 { 231 {
228 bool enable = IsButtonCheckedBool(IDX_SETTINGS_LARGE_PAGES); 232 const bool enable = IsButtonCheckedBool(IDX_SETTINGS_LARGE_PAGES);
229 NSecurity::EnablePrivilege_LockMemory(enable); 233 NSecurity::EnablePrivilege_LockMemory(enable);
230 SaveLockMemoryEnable(enable); 234 SaveLockMemoryEnable(enable);
231 } 235 }
@@ -301,7 +305,7 @@ void CSettingsPage::OnNotifyHelp()
301} 305}
302 306
303/* 307/*
304bool CSettingsPage::OnCommand(int code, int itemID, LPARAM param) 308bool CSettingsPage::OnCommand(unsigned code, unsigned itemID, LPARAM param)
305{ 309{
306 if (code == CBN_SELCHANGE) 310 if (code == CBN_SELCHANGE)
307 { 311 {
@@ -319,7 +323,7 @@ bool CSettingsPage::OnCommand(int code, int itemID, LPARAM param)
319} 323}
320*/ 324*/
321 325
322bool CSettingsPage::OnButtonClicked(int buttonID, HWND buttonHWND) 326bool CSettingsPage::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
323{ 327{
324 switch (buttonID) 328 switch (buttonID)
325 { 329 {
diff --git a/CPP/7zip/UI/FileManager/SettingsPage.h b/CPP/7zip/UI/FileManager/SettingsPage.h
index f3f57a4..91b9828 100644
--- a/CPP/7zip/UI/FileManager/SettingsPage.h
+++ b/CPP/7zip/UI/FileManager/SettingsPage.h
@@ -1,7 +1,7 @@
1// SettingsPage.h 1// SettingsPage.h
2 2
3#ifndef __SETTINGS_PAGE_H 3#ifndef ZIP7_INC_SETTINGS_PAGE_H
4#define __SETTINGS_PAGE_H 4#define ZIP7_INC_SETTINGS_PAGE_H
5 5
6#include "../../../Windows/Control/PropertyPage.h" 6#include "../../../Windows/Control/PropertyPage.h"
7#include "../../../Windows/Control/ComboBox.h" 7#include "../../../Windows/Control/ComboBox.h"
@@ -22,11 +22,11 @@ class CSettingsPage: public NWindows::NControl::CPropertyPage
22 */ 22 */
23 23
24 // void EnableSubItems(); 24 // void EnableSubItems();
25 // bool OnCommand(int code, int itemID, LPARAM param); 25 // bool OnCommand(unsigned code, unsigned itemID, LPARAM param) Z7_override;
26 bool OnButtonClicked(int buttonID, HWND buttonHWND); 26 virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
27 virtual bool OnInit(); 27 virtual bool OnInit() Z7_override;
28 virtual void OnNotifyHelp(); 28 virtual void OnNotifyHelp() Z7_override;
29 virtual LONG OnApply(); 29 virtual LONG OnApply() Z7_override;
30public: 30public:
31}; 31};
32 32
diff --git a/CPP/7zip/UI/FileManager/SplitDialog.cpp b/CPP/7zip/UI/FileManager/SplitDialog.cpp
index 0c9fdd1..21d812c 100644
--- a/CPP/7zip/UI/FileManager/SplitDialog.cpp
+++ b/CPP/7zip/UI/FileManager/SplitDialog.cpp
@@ -4,9 +4,7 @@
4 4
5#include "../../../Windows/FileName.h" 5#include "../../../Windows/FileName.h"
6 6
7#ifdef LANG
8#include "LangUtils.h" 7#include "LangUtils.h"
9#endif
10 8
11#include "BrowseDialog.h" 9#include "BrowseDialog.h"
12#include "CopyDialogRes.h" 10#include "CopyDialogRes.h"
@@ -16,7 +14,7 @@
16 14
17using namespace NWindows; 15using namespace NWindows;
18 16
19#ifdef LANG 17#ifdef Z7_LANG
20static const UInt32 kLangIDs[] = 18static const UInt32 kLangIDs[] =
21{ 19{
22 IDT_SPLIT_PATH, 20 IDT_SPLIT_PATH,
@@ -27,9 +25,9 @@ static const UInt32 kLangIDs[] =
27 25
28bool CSplitDialog::OnInit() 26bool CSplitDialog::OnInit()
29{ 27{
30 #ifdef LANG 28 #ifdef Z7_LANG
31 LangSetWindowText(*this, IDD_SPLIT); 29 LangSetWindowText(*this, IDD_SPLIT);
32 LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); 30 LangSetDlgItems(*this, kLangIDs, Z7_ARRAY_SIZE(kLangIDs));
33 #endif 31 #endif
34 _pathCombo.Attach(GetItem(IDC_SPLIT_PATH)); 32 _pathCombo.Attach(GetItem(IDC_SPLIT_PATH));
35 _volumeCombo.Attach(GetItem(IDC_SPLIT_VOLUME)); 33 _volumeCombo.Attach(GetItem(IDC_SPLIT_VOLUME));
@@ -75,7 +73,7 @@ bool CSplitDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
75 return false; 73 return false;
76} 74}
77 75
78bool CSplitDialog::OnButtonClicked(int buttonID, HWND buttonHWND) 76bool CSplitDialog::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
79{ 77{
80 switch (buttonID) 78 switch (buttonID)
81 { 79 {
@@ -91,7 +89,7 @@ void CSplitDialog::OnButtonSetPath()
91 UString currentPath; 89 UString currentPath;
92 _pathCombo.GetText(currentPath); 90 _pathCombo.GetText(currentPath);
93 // UString title = "Specify a location for output folder"; 91 // UString title = "Specify a location for output folder";
94 UString title = LangString(IDS_SET_FOLDER); 92 const UString title = LangString(IDS_SET_FOLDER);
95 93
96 UString resultPath; 94 UString resultPath;
97 if (!MyBrowseForFolder(*this, title, currentPath, resultPath)) 95 if (!MyBrowseForFolder(*this, title, currentPath, resultPath))
diff --git a/CPP/7zip/UI/FileManager/SplitDialog.h b/CPP/7zip/UI/FileManager/SplitDialog.h
index 00aae65..f897136 100644
--- a/CPP/7zip/UI/FileManager/SplitDialog.h
+++ b/CPP/7zip/UI/FileManager/SplitDialog.h
@@ -1,7 +1,7 @@
1// SplitDialog.h 1// SplitDialog.h
2 2
3#ifndef __SPLIT_DIALOG_H 3#ifndef ZIP7_INC_SPLIT_DIALOG_H
4#define __SPLIT_DIALOG_H 4#define ZIP7_INC_SPLIT_DIALOG_H
5 5
6#include "../../../Windows/Control/Dialog.h" 6#include "../../../Windows/Control/Dialog.h"
7#include "../../../Windows/Control/ComboBox.h" 7#include "../../../Windows/Control/ComboBox.h"
@@ -12,16 +12,16 @@ class CSplitDialog: public NWindows::NControl::CModalDialog
12{ 12{
13 NWindows::NControl::CComboBox _pathCombo; 13 NWindows::NControl::CComboBox _pathCombo;
14 NWindows::NControl::CComboBox _volumeCombo; 14 NWindows::NControl::CComboBox _volumeCombo;
15 virtual void OnOK(); 15 virtual void OnOK() Z7_override;
16 virtual bool OnInit(); 16 virtual bool OnInit() Z7_override;
17 virtual bool OnSize(WPARAM wParam, int xSize, int ySize); 17 virtual bool OnSize(WPARAM wParam, int xSize, int ySize) Z7_override;
18 virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); 18 virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
19 void OnButtonSetPath(); 19 void OnButtonSetPath();
20public: 20public:
21 UString FilePath; 21 UString FilePath;
22 UString Path; 22 UString Path;
23 CRecordVector<UInt64> VolumeSizes; 23 CRecordVector<UInt64> VolumeSizes;
24 INT_PTR Create(HWND parentWindow = 0) 24 INT_PTR Create(HWND parentWindow = NULL)
25 { return CModalDialog::Create(IDD_SPLIT, parentWindow); } 25 { return CModalDialog::Create(IDD_SPLIT, parentWindow); }
26}; 26};
27 27
diff --git a/CPP/7zip/UI/FileManager/SplitUtils.cpp b/CPP/7zip/UI/FileManager/SplitUtils.cpp
index 4b6235b..1982afb 100644
--- a/CPP/7zip/UI/FileManager/SplitUtils.cpp
+++ b/CPP/7zip/UI/FileManager/SplitUtils.cpp
@@ -74,7 +74,7 @@ static const char * const k_Sizes[] =
74 74
75void AddVolumeItems(NWindows::NControl::CComboBox &combo) 75void AddVolumeItems(NWindows::NControl::CComboBox &combo)
76{ 76{
77 for (unsigned i = 0; i < ARRAY_SIZE(k_Sizes); i++) 77 for (unsigned i = 0; i < Z7_ARRAY_SIZE(k_Sizes); i++)
78 combo.AddString(CSysString(k_Sizes[i])); 78 combo.AddString(CSysString(k_Sizes[i]));
79} 79}
80 80
diff --git a/CPP/7zip/UI/FileManager/SplitUtils.h b/CPP/7zip/UI/FileManager/SplitUtils.h
index 641dfe6..d1d44e4 100644
--- a/CPP/7zip/UI/FileManager/SplitUtils.h
+++ b/CPP/7zip/UI/FileManager/SplitUtils.h
@@ -1,7 +1,7 @@
1// SplitUtils.h 1// SplitUtils.h
2 2
3#ifndef __SPLIT_UTILS_H 3#ifndef ZIP7_INC_SPLIT_UTILS_H
4#define __SPLIT_UTILS_H 4#define ZIP7_INC_SPLIT_UTILS_H
5 5
6#include "../../../Common/MyTypes.h" 6#include "../../../Common/MyTypes.h"
7#include "../../../Common/MyString.h" 7#include "../../../Common/MyString.h"
diff --git a/CPP/7zip/UI/FileManager/StdAfx.h b/CPP/7zip/UI/FileManager/StdAfx.h
index 0e6d446..789cc6e 100644
--- a/CPP/7zip/UI/FileManager/StdAfx.h
+++ b/CPP/7zip/UI/FileManager/StdAfx.h
@@ -1,21 +1,83 @@
1// stdafx.h 1// StdAfx.h
2 2
3#ifndef __STDAFX_H 3#ifndef ZIP7_INC_STDAFX_H
4#define __STDAFX_H 4#define ZIP7_INC_STDAFX_H
5 5
6/* we used 0x0400 for Windows NT supporting (MENUITEMINFOW) 6#if defined(_MSC_VER) && _MSC_VER >= 1800
7 But now menu problem is fixed. So it's OK to use 0x0500 (Windows 2000) */ 7#pragma warning(disable : 4464) // relative include path contains '..'
8#endif
9
10#include "../../../../C/Compiler.h"
8 11
12Z7_DIAGNOSCTIC_IGNORE_BEGIN_RESERVED_MACRO_IDENTIFIER
13#ifndef _WIN32_WINNT
9// #define _WIN32_WINNT 0x0400 14// #define _WIN32_WINNT 0x0400
10#define _WIN32_WINNT 0x0500 15#define _WIN32_WINNT 0x0500
16// #define _WIN32_WINNT 0x0600
17// #define _WIN32_WINNT 0x0A00
18#endif
19#ifndef WINVER
11#define WINVER _WIN32_WINNT 20#define WINVER _WIN32_WINNT
21#endif
22// #define _WIN32_IE 0x400 // for debug
23Z7_DIAGNOSCTIC_IGNORE_END_RESERVED_MACRO_IDENTIFIER
12 24
13#include "../../../Common/Common.h" 25#include "../../../Common/Common.h"
26#include "../../../Common/MyWindows.h"
27
28#endif
14 29
15// #include "../../../Common/MyWindows.h" 30/*
31WINVER and _WIN32_WINNT
16 32
17// #include <CommCtrl.h> 33MSVC6 / 2003sdk:
18// #include <ShlObj.h> 34{
19// #include <Shlwapi.h> 35 <windows.h> doesn't set _WIN32_WINNT
36 if WINVER is not set <windows.h> sets WINVER to value:
37 0x0400 : MSVC6
38 0x0501 : Windows Server 2003 PSDK / 2003 R2 PSDK
39}
20 40
41SDK for Win7 (and later)
42{
43 <windows.h> sets _WIN32_WINNT if it's not set.
44 <windows.h> sets WINVER if it's not set.
45<windows.h> includes <sdkddkver.h> that does:
46#if !defined(_WIN32_WINNT) && !defined(_CHICAGO_)
47 #define _WIN32_WINNT 0x0601 // in win7 sdk
48 #define _WIN32_WINNT 0x0A00 // in win10 sdk
21#endif 49#endif
50#ifndef WINVER
51 #ifdef _WIN32_WINNT
52 #define WINVER _WIN32_WINNT
53 else
54 #define WINVER 0x0601 // in win7 sdk
55 #define WINVER 0x0A00 // in win10 sdk
56 endif
57#endif
58}
59
60Some GUI structures defined by windows will be larger,
61If (_WIN32_WINNT) value is larger.
62
63Also if we send sizeof(win_gui_struct) to some windows function,
64and we compile that code with big (_WIN32_WINNT) value,
65the window function in old Windows can fail, if that old Windows
66doesn't understand new big version of (win_gui_struct) compiled
67with big (_WIN32_WINNT) value.
68
69So it's better to define smallest (_WIN32_WINNT) value here.
70In 7-Zip FM we use some functions that require (_WIN32_WINNT == 0x0500).
71So it's simpler to define (_WIN32_WINNT == 0x0500) here.
72If we define (_WIN32_WINNT == 0x0400) here, we need some manual
73declarations for functions and macros that require (0x0500) functions.
74Also libs must contain these (0x0500+) functions.
75
76Some code in 7-zip FM uses also CommCtrl.h structures
77that depend from (_WIN32_IE) value. But default
78(_WIN32_IE) value from <windows.h> probably is OK for us.
79So we don't set _WIN32_IE here.
80default _WIN32_IE value set by <windows.h>:
81 0x501 2003sdk
82 0xa00 win10 sdk
83*/
diff --git a/CPP/7zip/UI/FileManager/StringUtils.cpp b/CPP/7zip/UI/FileManager/StringUtils.cpp
index 0478399..4641d15 100644
--- a/CPP/7zip/UI/FileManager/StringUtils.cpp
+++ b/CPP/7zip/UI/FileManager/StringUtils.cpp
@@ -24,35 +24,9 @@ void SplitStringToTwoStrings(const UString &src, UString &dest1, UString &dest2)
24 } 24 }
25} 25}
26 26
27void SplitString(const UString &srcString, UStringVector &destStrings)
28{
29 destStrings.Clear();
30 unsigned len = srcString.Len();
31 if (len == 0)
32 return;
33 UString s;
34 for (unsigned i = 0; i < len; i++)
35 {
36 wchar_t c = srcString[i];
37 if (c == ' ')
38 {
39 if (!s.IsEmpty())
40 {
41 destStrings.Add(s);
42 s.Empty();
43 }
44 }
45 else
46 s += c;
47 }
48 if (!s.IsEmpty())
49 destStrings.Add(s);
50}
51
52/* 27/*
53UString JoinStrings(const UStringVector &srcStrings) 28UString JoinStrings(const UStringVector &srcStrings)
54{ 29{
55
56 UString s; 30 UString s;
57 FOR_VECTOR (i, srcStrings) 31 FOR_VECTOR (i, srcStrings)
58 { 32 {
diff --git a/CPP/7zip/UI/FileManager/StringUtils.h b/CPP/7zip/UI/FileManager/StringUtils.h
index fc070de..37aad3a 100644
--- a/CPP/7zip/UI/FileManager/StringUtils.h
+++ b/CPP/7zip/UI/FileManager/StringUtils.h
@@ -1,13 +1,11 @@
1// StringUtils.h 1// StringUtils.h
2 2
3#ifndef __STRING_UTILS_H 3#ifndef ZIP7_INC_STRING_UTILS_H
4#define __STRING_UTILS_H 4#define ZIP7_INC_STRING_UTILS_H
5 5
6#include "../../../Common/MyString.h" 6#include "../../../Common/MyString.h"
7 7
8void SplitStringToTwoStrings(const UString &src, UString &dest1, UString &dest2); 8void SplitStringToTwoStrings(const UString &src, UString &dest1, UString &dest2);
9 9// UString JoinStrings(const UStringVector &srcStrings);
10void SplitString(const UString &srcString, UStringVector &destStrings);
11UString JoinStrings(const UStringVector &srcStrings);
12 10
13#endif 11#endif
diff --git a/CPP/7zip/UI/FileManager/SysIconUtils.cpp b/CPP/7zip/UI/FileManager/SysIconUtils.cpp
index d8e0f8b..1c7cab0 100644
--- a/CPP/7zip/UI/FileManager/SysIconUtils.cpp
+++ b/CPP/7zip/UI/FileManager/SysIconUtils.cpp
@@ -10,10 +10,11 @@
10 10
11#include "SysIconUtils.h" 11#include "SysIconUtils.h"
12 12
13#if defined(__MINGW32__) || defined(__MINGW64__)
14#include <shlobj.h>
15#else
13#include <ShlObj.h> 16#include <ShlObj.h>
14 17#endif
15#define MY_CAST_FUNC (void(*)())
16// #define MY_CAST_FUNC
17 18
18#ifndef _UNICODE 19#ifndef _UNICODE
19extern bool g_IsNT; 20extern bool g_IsNT;
@@ -21,49 +22,55 @@ extern bool g_IsNT;
21 22
22int GetIconIndexForCSIDL(int csidl) 23int GetIconIndexForCSIDL(int csidl)
23{ 24{
24 LPITEMIDLIST pidl = 0; 25 LPITEMIDLIST pidl = NULL;
25 SHGetSpecialFolderLocation(NULL, csidl, &pidl); 26 SHGetSpecialFolderLocation(NULL, csidl, &pidl);
26 if (pidl) 27 if (pidl)
27 { 28 {
28 SHFILEINFO shellInfo; 29 SHFILEINFO shellInfo;
29 SHGetFileInfo((LPCTSTR)(const void *)(pidl), FILE_ATTRIBUTE_NORMAL, 30 shellInfo.iIcon = 0;
30 &shellInfo, sizeof(shellInfo), 31 const DWORD_PTR res = SHGetFileInfo((LPCTSTR)(const void *)(pidl), FILE_ATTRIBUTE_NORMAL,
31 SHGFI_PIDL | SHGFI_SYSICONINDEX); 32 &shellInfo, sizeof(shellInfo),
32 IMalloc *pMalloc; 33 SHGFI_PIDL | SHGFI_SYSICONINDEX);
34 /*
35 IMalloc *pMalloc;
33 SHGetMalloc(&pMalloc); 36 SHGetMalloc(&pMalloc);
34 if (pMalloc) 37 if (pMalloc)
35 { 38 {
36 pMalloc->Free(pidl); 39 pMalloc->Free(pidl);
37 pMalloc->Release(); 40 pMalloc->Release();
38 } 41 }
39 return shellInfo.iIcon; 42 */
43 // we use OLE2.dll function here
44 CoTaskMemFree(pidl);
45 if (res)
46 return shellInfo.iIcon;
40 } 47 }
41 return 0; 48 return 0;
42} 49}
43 50
44#ifndef _UNICODE 51#ifndef _UNICODE
45typedef int (WINAPI * Func_SHGetFileInfoW)(LPCWSTR pszPath, DWORD attrib, SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags); 52typedef DWORD_PTR (WINAPI * Func_SHGetFileInfoW)(LPCWSTR pszPath, DWORD attrib, SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags);
46 53
47static struct CSHGetFileInfoInit 54static struct C_SHGetFileInfo_Init
48{ 55{
49 Func_SHGetFileInfoW shGetFileInfoW; 56 Func_SHGetFileInfoW f_SHGetFileInfoW;
50 CSHGetFileInfoInit() 57 C_SHGetFileInfo_Init()
51 { 58 {
52 shGetFileInfoW = (Func_SHGetFileInfoW) 59 f_SHGetFileInfoW = Z7_GET_PROC_ADDRESS(
53 MY_CAST_FUNC 60 Func_SHGetFileInfoW, ::GetModuleHandleW(L"shell32.dll"),
54 ::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "SHGetFileInfoW"); 61 "SHGetFileInfoW");
55 } 62 }
56} g_SHGetFileInfoInit; 63} g_SHGetFileInfo_Init;
57#endif 64#endif
58 65
59static DWORD_PTR MySHGetFileInfoW(LPCWSTR pszPath, DWORD attrib, SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags) 66static DWORD_PTR My_SHGetFileInfoW(LPCWSTR pszPath, DWORD attrib, SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags)
60{ 67{
61 #ifdef _UNICODE 68 #ifdef _UNICODE
62 return SHGetFileInfo 69 return SHGetFileInfo
63 #else 70 #else
64 if (g_SHGetFileInfoInit.shGetFileInfoW == 0) 71 if (!g_SHGetFileInfo_Init.f_SHGetFileInfoW)
65 return 0; 72 return 0;
66 return g_SHGetFileInfoInit.shGetFileInfoW 73 return g_SHGetFileInfo_Init.f_SHGetFileInfoW
67 #endif 74 #endif
68 (pszPath, attrib, psfi, cbFileInfo, uFlags); 75 (pszPath, attrib, psfi, cbFileInfo, uFlags);
69} 76}
@@ -74,7 +81,7 @@ DWORD_PTR GetRealIconIndex(CFSTR path, DWORD attrib, int &iconIndex)
74 if (!g_IsNT) 81 if (!g_IsNT)
75 { 82 {
76 SHFILEINFO shellInfo; 83 SHFILEINFO shellInfo;
77 DWORD_PTR res = ::SHGetFileInfo(fs2fas(path), FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo, 84 const DWORD_PTR res = ::SHGetFileInfo(fs2fas(path), FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo,
78 sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX); 85 sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX);
79 iconIndex = shellInfo.iIcon; 86 iconIndex = shellInfo.iIcon;
80 return res; 87 return res;
@@ -83,7 +90,7 @@ DWORD_PTR GetRealIconIndex(CFSTR path, DWORD attrib, int &iconIndex)
83 #endif 90 #endif
84 { 91 {
85 SHFILEINFOW shellInfo; 92 SHFILEINFOW shellInfo;
86 DWORD_PTR res = ::MySHGetFileInfoW(fs2us(path), FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo, 93 const DWORD_PTR res = ::My_SHGetFileInfoW(fs2us(path), FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo,
87 sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX); 94 sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX);
88 iconIndex = shellInfo.iIcon; 95 iconIndex = shellInfo.iIcon;
89 return res; 96 return res;
@@ -110,7 +117,7 @@ DWORD_PTR GetRealIconIndex(const UString &fileName, DWORD attrib, int &iconIndex
110 { 117 {
111 SHFILEINFOW shellInfo; 118 SHFILEINFOW shellInfo;
112 shellInfo.szTypeName[0] = 0; 119 shellInfo.szTypeName[0] = 0;
113 DWORD_PTR res = ::MySHGetFileInfoW(fileName, FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo, 120 DWORD_PTR res = ::My_SHGetFileInfoW(fileName, FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo,
114 sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | SHGFI_TYPENAME); 121 sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | SHGFI_TYPENAME);
115 if (typeName) 122 if (typeName)
116 *typeName = shellInfo.szTypeName; 123 *typeName = shellInfo.szTypeName;
@@ -120,15 +127,15 @@ DWORD_PTR GetRealIconIndex(const UString &fileName, DWORD attrib, int &iconIndex
120} 127}
121*/ 128*/
122 129
123static int FindInSorted_Attrib(const CRecordVector<CAttribIconPair> &vect, DWORD attrib, int &insertPos) 130static int FindInSorted_Attrib(const CRecordVector<CAttribIconPair> &vect, DWORD attrib, unsigned &insertPos)
124{ 131{
125 unsigned left = 0, right = vect.Size(); 132 unsigned left = 0, right = vect.Size();
126 while (left != right) 133 while (left != right)
127 { 134 {
128 unsigned mid = (left + right) / 2; 135 const unsigned mid = (left + right) / 2;
129 DWORD midAttrib = vect[mid].Attrib; 136 const DWORD midAttrib = vect[mid].Attrib;
130 if (attrib == midAttrib) 137 if (attrib == midAttrib)
131 return mid; 138 return (int)mid;
132 if (attrib < midAttrib) 139 if (attrib < midAttrib)
133 right = mid; 140 right = mid;
134 else 141 else
@@ -138,15 +145,15 @@ static int FindInSorted_Attrib(const CRecordVector<CAttribIconPair> &vect, DWORD
138 return -1; 145 return -1;
139} 146}
140 147
141static int FindInSorted_Ext(const CObjectVector<CExtIconPair> &vect, const wchar_t *ext, int &insertPos) 148static int FindInSorted_Ext(const CObjectVector<CExtIconPair> &vect, const wchar_t *ext, unsigned &insertPos)
142{ 149{
143 unsigned left = 0, right = vect.Size(); 150 unsigned left = 0, right = vect.Size();
144 while (left != right) 151 while (left != right)
145 { 152 {
146 unsigned mid = (left + right) / 2; 153 const unsigned mid = (left + right) / 2;
147 int compare = MyStringCompareNoCase(ext, vect[mid].Ext); 154 const int compare = MyStringCompareNoCase(ext, vect[mid].Ext);
148 if (compare == 0) 155 if (compare == 0)
149 return mid; 156 return (int)mid;
150 if (compare < 0) 157 if (compare < 0)
151 right = mid; 158 right = mid;
152 else 159 else
@@ -162,11 +169,11 @@ int CExtToIconMap::GetIconIndex(DWORD attrib, const wchar_t *fileName /*, UStrin
162 unsigned i; 169 unsigned i;
163 for (i = 0;; i++) 170 for (i = 0;; i++)
164 { 171 {
165 wchar_t c = fileName[i]; 172 const wchar_t c = fileName[i];
166 if (c == 0) 173 if (c == 0)
167 break; 174 break;
168 if (c == '.') 175 if (c == '.')
169 dotPos = i; 176 dotPos = (int)i;
170 } 177 }
171 178
172 /* 179 /*
@@ -181,12 +188,12 @@ int CExtToIconMap::GetIconIndex(DWORD attrib, const wchar_t *fileName /*, UStrin
181 188
182 if ((attrib & FILE_ATTRIBUTE_DIRECTORY) != 0 || dotPos < 0) 189 if ((attrib & FILE_ATTRIBUTE_DIRECTORY) != 0 || dotPos < 0)
183 { 190 {
184 int insertPos = 0; 191 unsigned insertPos = 0;
185 int index = FindInSorted_Attrib(_attribMap, attrib, insertPos); 192 const int index = FindInSorted_Attrib(_attribMap, attrib, insertPos);
186 if (index >= 0) 193 if (index >= 0)
187 { 194 {
188 // if (typeName) *typeName = _attribMap[index].TypeName; 195 // if (typeName) *typeName = _attribMap[index].TypeName;
189 return _attribMap[index].IconIndex; 196 return _attribMap[(unsigned)index].IconIndex;
190 } 197 }
191 CAttribIconPair pair; 198 CAttribIconPair pair;
192 GetRealIconIndex( 199 GetRealIconIndex(
@@ -211,8 +218,8 @@ int CExtToIconMap::GetIconIndex(DWORD attrib, const wchar_t *fileName /*, UStrin
211 } 218 }
212 219
213 const wchar_t *ext = fileName + dotPos + 1; 220 const wchar_t *ext = fileName + dotPos + 1;
214 int insertPos = 0; 221 unsigned insertPos = 0;
215 int index = FindInSorted_Ext(_extMap, ext, insertPos); 222 const int index = FindInSorted_Ext(_extMap, ext, insertPos);
216 if (index >= 0) 223 if (index >= 0)
217 { 224 {
218 const CExtIconPair &pa = _extMap[index]; 225 const CExtIconPair &pa = _extMap[index];
@@ -222,7 +229,7 @@ int CExtToIconMap::GetIconIndex(DWORD attrib, const wchar_t *fileName /*, UStrin
222 229
223 for (i = 0;; i++) 230 for (i = 0;; i++)
224 { 231 {
225 wchar_t c = ext[i]; 232 const wchar_t c = ext[i];
226 if (c == 0) 233 if (c == 0)
227 break; 234 break;
228 if (c < L'0' || c > L'9') 235 if (c < L'0' || c > L'9')
@@ -257,3 +264,15 @@ int CExtToIconMap::GetIconIndex(DWORD attrib, const UString &fileName)
257 return GetIconIndex(attrib, fileName, NULL); 264 return GetIconIndex(attrib, fileName, NULL);
258} 265}
259*/ 266*/
267
268HIMAGELIST GetSysImageList(bool smallIcons)
269{
270 SHFILEINFO shellInfo;
271 return (HIMAGELIST)SHGetFileInfo(TEXT(""),
272 FILE_ATTRIBUTE_NORMAL |
273 FILE_ATTRIBUTE_DIRECTORY,
274 &shellInfo, sizeof(shellInfo),
275 SHGFI_USEFILEATTRIBUTES |
276 SHGFI_SYSICONINDEX |
277 (smallIcons ? SHGFI_SMALLICON : SHGFI_ICON));
278}
diff --git a/CPP/7zip/UI/FileManager/SysIconUtils.h b/CPP/7zip/UI/FileManager/SysIconUtils.h
index fde16e4..1d34ef6 100644
--- a/CPP/7zip/UI/FileManager/SysIconUtils.h
+++ b/CPP/7zip/UI/FileManager/SysIconUtils.h
@@ -1,7 +1,7 @@
1// SysIconUtils.h 1// SysIconUtils.h
2 2
3#ifndef __SYS_ICON_UTILS_H 3#ifndef ZIP7_INC_SYS_ICON_UTILS_H
4#define __SYS_ICON_UTILS_H 4#define ZIP7_INC_SYS_ICON_UTILS_H
5 5
6#include "../../../Common/MyWindows.h" 6#include "../../../Common/MyWindows.h"
7 7
@@ -50,13 +50,6 @@ public:
50DWORD_PTR GetRealIconIndex(CFSTR path, DWORD attrib, int &iconIndex); 50DWORD_PTR GetRealIconIndex(CFSTR path, DWORD attrib, int &iconIndex);
51int GetIconIndexForCSIDL(int csidl); 51int GetIconIndexForCSIDL(int csidl);
52 52
53inline HIMAGELIST GetSysImageList(bool smallIcons) 53HIMAGELIST GetSysImageList(bool smallIcons);
54{
55 SHFILEINFO shellInfo;
56 return (HIMAGELIST)SHGetFileInfo(TEXT(""),
57 FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY,
58 &shellInfo, sizeof(shellInfo),
59 SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | (smallIcons ? SHGFI_SMALLICON : SHGFI_ICON));
60}
61 54
62#endif 55#endif
diff --git a/CPP/7zip/UI/FileManager/SystemPage.cpp b/CPP/7zip/UI/FileManager/SystemPage.cpp
index a95999f..09d8a72 100644
--- a/CPP/7zip/UI/FileManager/SystemPage.cpp
+++ b/CPP/7zip/UI/FileManager/SystemPage.cpp
@@ -4,7 +4,11 @@
4 4
5#include "../../../Common/MyWindows.h" 5#include "../../../Common/MyWindows.h"
6 6
7#if defined(__MINGW32__) || defined(__MINGW64__)
8#include <shlobj.h>
9#else
7#include <ShlObj.h> 10#include <ShlObj.h>
11#endif
8 12
9#include "../../../Common/Defs.h" 13#include "../../../Common/Defs.h"
10#include "../../../Common/StringConvert.h" 14#include "../../../Common/StringConvert.h"
@@ -25,10 +29,12 @@ using namespace NWindows;
25extern bool g_IsNT; 29extern bool g_IsNT;
26#endif 30#endif
27 31
32#ifdef Z7_LANG
28static const UInt32 kLangIDs[] = 33static const UInt32 kLangIDs[] =
29{ 34{
30 IDT_SYSTEM_ASSOCIATE 35 IDT_SYSTEM_ASSOCIATE
31}; 36};
37#endif
32 38
33#define kSystemTopic "FM/options.htm#system" 39#define kSystemTopic "FM/options.htm#system"
34 40
@@ -44,7 +50,7 @@ CSysString CModifiedExtInfo::GetString() const
44 else 50 else
45 return ProgramKey; 51 return ProgramKey;
46 return CSysString (s); 52 return CSysString (s);
47}; 53}
48 54
49 55
50int CSystemPage::AddIcon(const UString &iconPath, int iconIndex) 56int CSystemPage::AddIcon(const UString &iconPath, int iconIndex)
@@ -62,19 +68,19 @@ int CSystemPage::AddIcon(const UString &iconPath, int iconIndex)
62 #else 68 #else
63 // we expand path from REG_EXPAND_SZ registry item. 69 // we expand path from REG_EXPAND_SZ registry item.
64 UString path; 70 UString path;
65 DWORD size = MAX_PATH + 10; 71 const DWORD size = MAX_PATH + 10;
66 DWORD needLen = ::ExpandEnvironmentStringsW(iconPath, path.GetBuf(size + 2), size); 72 const DWORD needLen = ::ExpandEnvironmentStringsW(iconPath, path.GetBuf(size + 2), size);
67 path.ReleaseBuf_CalcLen(size); 73 path.ReleaseBuf_CalcLen(size);
68 if (needLen == 0 || needLen >= size) 74 if (needLen == 0 || needLen >= size)
69 path = iconPath; 75 path = iconPath;
70 int num = ExtractIconExW(path, iconIndex, NULL, &hicon, 1); 76 const UINT num = ExtractIconExW(path, iconIndex, NULL, &hicon, 1);
71 if (num != 1 || !hicon) 77 if (num != 1 || !hicon)
72 #endif 78 #endif
73 return -1; 79 return -1;
74 80
75 _imageList.AddIcon(hicon); 81 _imageList.AddIcon(hicon);
76 DestroyIcon(hicon); 82 DestroyIcon(hicon);
77 return _numIcons++; 83 return (int)(_numIcons++);
78} 84}
79 85
80 86
@@ -84,7 +90,7 @@ void CSystemPage::RefreshListItem(unsigned group, unsigned listIndex)
84 _listView.SetSubItem(listIndex, group + 1, assoc.Pair[group].GetString()); 90 _listView.SetSubItem(listIndex, group + 1, assoc.Pair[group].GetString());
85 LVITEMW newItem; 91 LVITEMW newItem;
86 memset(&newItem, 0, sizeof(newItem)); 92 memset(&newItem, 0, sizeof(newItem));
87 newItem.iItem = listIndex; 93 newItem.iItem = (int)listIndex;
88 newItem.mask = LVIF_IMAGE; 94 newItem.mask = LVIF_IMAGE;
89 newItem.iImage = assoc.GetIconIndex(); 95 newItem.iImage = assoc.GetIconIndex();
90 _listView.SetItem(&newItem); 96 _listView.SetItem(&newItem);
@@ -151,7 +157,9 @@ bool CSystemPage::OnInit()
151{ 157{
152 _needSave = false; 158 _needSave = false;
153 159
154 LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); 160#ifdef Z7_LANG
161 LangSetDlgItems(*this, kLangIDs, Z7_ARRAY_SIZE(kLangIDs));
162#endif
155 163
156 _listView.Attach(GetItem(IDL_SYSTEM_ASSOCIATE)); 164 _listView.Attach(GetItem(IDL_SYSTEM_ASSOCIATE));
157 _listView.SetUnicodeFormat(); 165 _listView.SetUnicodeFormat();
@@ -221,9 +229,9 @@ bool CSystemPage::OnInit()
221 const CExtPlugins &extInfo = _extDB.Exts[i]; 229 const CExtPlugins &extInfo = _extDB.Exts[i];
222 230
223 LVITEMW item; 231 LVITEMW item;
224 item.iItem = i; 232 item.iItem = (int)i;
225 item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; 233 item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
226 item.lParam = i; 234 item.lParam = (LPARAM)i;
227 item.iSubItem = 0; 235 item.iSubItem = 0;
228 // ListView always uses internal iImage that is 0 by default? 236 // ListView always uses internal iImage that is 0 by default?
229 // so we always use LVIF_IMAGE. 237 // so we always use LVIF_IMAGE.
@@ -245,9 +253,9 @@ bool CSystemPage::OnInit()
245 texts[g] = mi.GetString(); 253 texts[g] = mi.GetString();
246 } 254 }
247 item.iImage = assoc.GetIconIndex(); 255 item.iImage = assoc.GetIconIndex();
248 int itemIndex = _listView.InsertItem(&item); 256 const int itemIndex = _listView.InsertItem(&item);
249 for (g = 0; g < NUM_EXT_GROUPS; g++) 257 for (g = 0; g < NUM_EXT_GROUPS; g++)
250 _listView.SetSubItem(itemIndex, 1 + g, texts[g]); 258 _listView.SetSubItem((unsigned)itemIndex, 1 + g, texts[g]);
251 _items.Add(assoc); 259 _items.Add(assoc);
252 } 260 }
253 261
@@ -334,7 +342,7 @@ void CSystemPage::OnNotifyHelp()
334} 342}
335 343
336 344
337bool CSystemPage::OnButtonClicked(int buttonID, HWND buttonHWND) 345bool CSystemPage::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
338{ 346{
339 switch (buttonID) 347 switch (buttonID)
340 { 348 {
@@ -379,7 +387,7 @@ bool CSystemPage::OnNotify(UINT controlID, LPNMHDR lParam)
379 if (item->iSubItem >= 1 && item->iSubItem <= 2) 387 if (item->iSubItem >= 1 && item->iSubItem <= 2)
380 { 388 {
381 CUIntVector indices; 389 CUIntVector indices;
382 indices.Add(item->iItem); 390 indices.Add((unsigned)item->iItem);
383 ChangeState(item->iSubItem < 2 ? 0 : 1, indices); 391 ChangeState(item->iSubItem < 2 ? 0 : 1, indices);
384 } 392 }
385 } 393 }
@@ -414,7 +422,7 @@ void CSystemPage::ChangeState(unsigned group)
414 422
415 int itemIndex = -1; 423 int itemIndex = -1;
416 while ((itemIndex = _listView.GetNextSelectedItem(itemIndex)) != -1) 424 while ((itemIndex = _listView.GetNextSelectedItem(itemIndex)) != -1)
417 indices.Add(itemIndex); 425 indices.Add((unsigned)itemIndex);
418 426
419 if (indices.IsEmpty()) 427 if (indices.IsEmpty())
420 FOR_VECTOR (i, _items) 428 FOR_VECTOR (i, _items)
diff --git a/CPP/7zip/UI/FileManager/SystemPage.h b/CPP/7zip/UI/FileManager/SystemPage.h
index 765214c..6f2ed0c 100644
--- a/CPP/7zip/UI/FileManager/SystemPage.h
+++ b/CPP/7zip/UI/FileManager/SystemPage.h
@@ -1,7 +1,7 @@
1// SystemPage.h 1// SystemPage.h
2 2
3#ifndef __SYSTEM_PAGE_H 3#ifndef ZIP7_INC_SYSTEM_PAGE_H
4#define __SYSTEM_PAGE_H 4#define ZIP7_INC_SYSTEM_PAGE_H
5 5
6#include "../../../Windows/Control/ImageList.h" 6#include "../../../Windows/Control/ImageList.h"
7#include "../../../Windows/Control/ListView.h" 7#include "../../../Windows/Control/ListView.h"
@@ -49,7 +49,7 @@ struct CModifiedExtInfo: public NRegistryAssoc::CShellExtInfo
49 } 49 }
50 } 50 }
51 OldState = State; 51 OldState = State;
52 }; 52 }
53}; 53};
54 54
55struct CAssoc 55struct CAssoc
@@ -116,11 +116,11 @@ public:
116 116
117 CSystemPage(): WasChanged(false) {} 117 CSystemPage(): WasChanged(false) {}
118 118
119 virtual bool OnInit(); 119 virtual bool OnInit() Z7_override;
120 virtual void OnNotifyHelp(); 120 virtual void OnNotifyHelp() Z7_override;
121 virtual bool OnNotify(UINT controlID, LPNMHDR lParam); 121 virtual bool OnNotify(UINT controlID, LPNMHDR lParam) Z7_override;
122 virtual LONG OnApply(); 122 virtual LONG OnApply() Z7_override;
123 virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); 123 virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
124}; 124};
125 125
126#endif 126#endif
diff --git a/CPP/7zip/UI/FileManager/TextPairs.cpp b/CPP/7zip/UI/FileManager/TextPairs.cpp
index 4edf025..1ac7098 100644
--- a/CPP/7zip/UI/FileManager/TextPairs.cpp
+++ b/CPP/7zip/UI/FileManager/TextPairs.cpp
@@ -100,9 +100,9 @@ static int ComparePairItems(const CTextPair &p1, const CTextPair &p2)
100static int ComparePairItems(void *const *a1, void *const *a2, void * /* param */) 100static int ComparePairItems(void *const *a1, void *const *a2, void * /* param */)
101 { return ComparePairItems(**(const CTextPair *const *)a1, **(const CTextPair *const *)a2); } 101 { return ComparePairItems(**(const CTextPair *const *)a1, **(const CTextPair *const *)a2); }
102 102
103void CPairsStorage::Sort() { Pairs.Sort(ComparePairItems, 0); } 103void CPairsStorage::Sort() { Pairs.Sort(ComparePairItems, NULL); }
104 104
105int CPairsStorage::FindID(const UString &id, int &insertPos) const 105int CPairsStorage::FindID(const UString &id, unsigned &insertPos) const
106{ 106{
107 unsigned left = 0, right = Pairs.Size(); 107 unsigned left = 0, right = Pairs.Size();
108 while (left != right) 108 while (left != right)
@@ -112,7 +112,7 @@ int CPairsStorage::FindID(const UString &id, int &insertPos) const
112 if (compResult == 0) 112 if (compResult == 0)
113 { 113 {
114 insertPos = mid; // to disable GCC warning 114 insertPos = mid; // to disable GCC warning
115 return mid; 115 return (int)mid;
116 } 116 }
117 if (compResult < 0) 117 if (compResult < 0)
118 right = mid; 118 right = mid;
@@ -125,13 +125,13 @@ int CPairsStorage::FindID(const UString &id, int &insertPos) const
125 125
126int CPairsStorage::FindID(const UString &id) const 126int CPairsStorage::FindID(const UString &id) const
127{ 127{
128 int pos; 128 unsigned pos;
129 return FindID(id, pos); 129 return FindID(id, pos);
130} 130}
131 131
132void CPairsStorage::AddPair(const CTextPair &pair) 132void CPairsStorage::AddPair(const CTextPair &pair)
133{ 133{
134 int insertPos; 134 unsigned insertPos;
135 const int pos = FindID(pair.ID, insertPos); 135 const int pos = FindID(pair.ID, insertPos);
136 if (pos >= 0) 136 if (pos >= 0)
137 Pairs[pos] = pair; 137 Pairs[pos] = pair;
@@ -143,7 +143,7 @@ void CPairsStorage::DeletePair(const UString &id)
143{ 143{
144 const int pos = FindID(id); 144 const int pos = FindID(id);
145 if (pos >= 0) 145 if (pos >= 0)
146 Pairs.Delete(pos); 146 Pairs.Delete((unsigned)pos);
147} 147}
148 148
149bool CPairsStorage::GetValue(const UString &id, UString &value) const 149bool CPairsStorage::GetValue(const UString &id, UString &value) const
@@ -185,7 +185,7 @@ void CPairsStorage::SaveToString(UString &text) const
185 text += pair.ID; 185 text += pair.ID;
186 if (multiWord) 186 if (multiWord)
187 text += '\"'; 187 text += '\"';
188 text += ' '; 188 text.Add_Space();
189 text += pair.Value; 189 text += pair.Value;
190 text += '\x0D'; 190 text += '\x0D';
191 text.Add_LF(); 191 text.Add_LF();
diff --git a/CPP/7zip/UI/FileManager/TextPairs.h b/CPP/7zip/UI/FileManager/TextPairs.h
index 0a71d04..d18233d 100644
--- a/CPP/7zip/UI/FileManager/TextPairs.h
+++ b/CPP/7zip/UI/FileManager/TextPairs.h
@@ -1,7 +1,7 @@
1// TextPairs.h 1// TextPairs.h
2 2
3#ifndef __FM_TEXT_PAIRS_H 3#ifndef ZIP7_INC_FM_TEXT_PAIRS_H
4#define __FM_TEXT_PAIRS_H 4#define ZIP7_INC_FM_TEXT_PAIRS_H
5 5
6#include "../../../Common/MyString.h" 6#include "../../../Common/MyString.h"
7 7
@@ -15,7 +15,7 @@ class CPairsStorage
15{ 15{
16 CObjectVector<CTextPair> Pairs; 16 CObjectVector<CTextPair> Pairs;
17 17
18 int FindID(const UString &id, int &insertPos) const; 18 int FindID(const UString &id, unsigned &insertPos) const;
19 int FindID(const UString &id) const; 19 int FindID(const UString &id) const;
20 void Sort(); 20 void Sort();
21public: 21public:
diff --git a/CPP/7zip/UI/FileManager/UpdateCallback100.cpp b/CPP/7zip/UI/FileManager/UpdateCallback100.cpp
index 67e70fb..71ad710 100644
--- a/CPP/7zip/UI/FileManager/UpdateCallback100.cpp
+++ b/CPP/7zip/UI/FileManager/UpdateCallback100.cpp
@@ -9,50 +9,50 @@
9#include "LangUtils.h" 9#include "LangUtils.h"
10#include "UpdateCallback100.h" 10#include "UpdateCallback100.h"
11 11
12STDMETHODIMP CUpdateCallback100Imp::ScanProgress(UInt64 /* numFolders */, UInt64 numFiles, UInt64 totalSize, const wchar_t *path, Int32 /* isDir */) 12Z7_COM7F_IMF(CUpdateCallback100Imp::ScanProgress(UInt64 /* numFolders */, UInt64 numFiles, UInt64 totalSize, const wchar_t *path, Int32 /* isDir */))
13{ 13{
14 return ProgressDialog->Sync.ScanProgress(numFiles, totalSize, us2fs(path)); 14 return ProgressDialog->Sync.ScanProgress(numFiles, totalSize, us2fs(path));
15} 15}
16 16
17STDMETHODIMP CUpdateCallback100Imp::ScanError(const wchar_t *path, HRESULT errorCode) 17Z7_COM7F_IMF(CUpdateCallback100Imp::ScanError(const wchar_t *path, HRESULT errorCode))
18{ 18{
19 ProgressDialog->Sync.AddError_Code_Name(errorCode, path); 19 ProgressDialog->Sync.AddError_Code_Name(errorCode, path);
20 return S_OK; 20 return S_OK;
21} 21}
22 22
23STDMETHODIMP CUpdateCallback100Imp::SetNumFiles(UInt64 numFiles) 23Z7_COM7F_IMF(CUpdateCallback100Imp::SetNumFiles(UInt64 numFiles))
24{ 24{
25 return ProgressDialog->Sync.Set_NumFilesTotal(numFiles); 25 return ProgressDialog->Sync.Set_NumFilesTotal(numFiles);
26} 26}
27 27
28STDMETHODIMP CUpdateCallback100Imp::SetTotal(UInt64 size) 28Z7_COM7F_IMF(CUpdateCallback100Imp::SetTotal(UInt64 size))
29{ 29{
30 ProgressDialog->Sync.Set_NumBytesTotal(size); 30 ProgressDialog->Sync.Set_NumBytesTotal(size);
31 return S_OK; 31 return S_OK;
32} 32}
33 33
34STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 *completed) 34Z7_COM7F_IMF(CUpdateCallback100Imp::SetCompleted(const UInt64 *completed))
35{ 35{
36 return ProgressDialog->Sync.Set_NumBytesCur(completed); 36 return ProgressDialog->Sync.Set_NumBytesCur(completed);
37} 37}
38 38
39STDMETHODIMP CUpdateCallback100Imp::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) 39Z7_COM7F_IMF(CUpdateCallback100Imp::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize))
40{ 40{
41 ProgressDialog->Sync.Set_Ratio(inSize, outSize); 41 ProgressDialog->Sync.Set_Ratio(inSize, outSize);
42 return S_OK; 42 return S_OK;
43} 43}
44 44
45STDMETHODIMP CUpdateCallback100Imp::CompressOperation(const wchar_t *name) 45Z7_COM7F_IMF(CUpdateCallback100Imp::CompressOperation(const wchar_t *name))
46{ 46{
47 return SetOperation_Base(NUpdateNotifyOp::kAdd, name, false); 47 return SetOperation_Base(NUpdateNotifyOp::kAdd, name, false);
48} 48}
49 49
50STDMETHODIMP CUpdateCallback100Imp::DeleteOperation(const wchar_t *name) 50Z7_COM7F_IMF(CUpdateCallback100Imp::DeleteOperation(const wchar_t *name))
51{ 51{
52 return SetOperation_Base(NUpdateNotifyOp::kDelete, name, false); 52 return SetOperation_Base(NUpdateNotifyOp::kDelete, name, false);
53} 53}
54 54
55STDMETHODIMP CUpdateCallback100Imp::OperationResult(Int32 /* operationResult */) 55Z7_COM7F_IMF(CUpdateCallback100Imp::OperationResult(Int32 /* operationResult */))
56{ 56{
57 ProgressDialog->Sync.Set_NumFilesCur(++NumFiles); 57 ProgressDialog->Sync.Set_NumFilesCur(++NumFiles);
58 return S_OK; 58 return S_OK;
@@ -60,7 +60,7 @@ STDMETHODIMP CUpdateCallback100Imp::OperationResult(Int32 /* operationResult */)
60 60
61void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, const wchar_t *fileName, UString &s); 61void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, const wchar_t *fileName, UString &s);
62 62
63HRESULT CUpdateCallback100Imp::ReportExtractResult(Int32 opRes, Int32 isEncrypted, const wchar_t *name) 63Z7_COM7F_IMF(CUpdateCallback100Imp::ReportExtractResult(Int32 opRes, Int32 isEncrypted, const wchar_t *name))
64{ 64{
65 if (opRes != NArchive::NExtract::NOperationResult::kOK) 65 if (opRes != NArchive::NExtract::NOperationResult::kOK)
66 { 66 {
@@ -71,30 +71,30 @@ HRESULT CUpdateCallback100Imp::ReportExtractResult(Int32 opRes, Int32 isEncrypte
71 return S_OK; 71 return S_OK;
72} 72}
73 73
74HRESULT CUpdateCallback100Imp::ReportUpdateOperation(UInt32 notifyOp, const wchar_t *name, Int32 isDir) 74Z7_COM7F_IMF(CUpdateCallback100Imp::ReportUpdateOperation(UInt32 notifyOp, const wchar_t *name, Int32 isDir))
75{ 75{
76 return SetOperation_Base(notifyOp, name, IntToBool(isDir)); 76 return SetOperation_Base(notifyOp, name, IntToBool(isDir));
77} 77}
78 78
79STDMETHODIMP CUpdateCallback100Imp::UpdateErrorMessage(const wchar_t *message) 79Z7_COM7F_IMF(CUpdateCallback100Imp::UpdateErrorMessage(const wchar_t *message))
80{ 80{
81 ProgressDialog->Sync.AddError_Message(message); 81 ProgressDialog->Sync.AddError_Message(message);
82 return S_OK; 82 return S_OK;
83} 83}
84 84
85HRESULT CUpdateCallback100Imp::OpenFileError(const wchar_t *path, HRESULT errorCode) 85Z7_COM7F_IMF(CUpdateCallback100Imp::OpenFileError(const wchar_t *path, HRESULT errorCode))
86{ 86{
87 ProgressDialog->Sync.AddError_Code_Name(errorCode, path); 87 ProgressDialog->Sync.AddError_Code_Name(errorCode, path);
88 return S_OK; 88 return S_OK;
89} 89}
90 90
91STDMETHODIMP CUpdateCallback100Imp::ReadingFileError(const wchar_t *path, HRESULT errorCode) 91Z7_COM7F_IMF(CUpdateCallback100Imp::ReadingFileError(const wchar_t *path, HRESULT errorCode))
92{ 92{
93 ProgressDialog->Sync.AddError_Code_Name(errorCode, path); 93 ProgressDialog->Sync.AddError_Code_Name(errorCode, path);
94 return S_OK; 94 return S_OK;
95} 95}
96 96
97STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password) 97Z7_COM7F_IMF(CUpdateCallback100Imp::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password))
98{ 98{
99 *password = NULL; 99 *password = NULL;
100 *passwordIsDefined = BoolToInt(PasswordIsDefined); 100 *passwordIsDefined = BoolToInt(PasswordIsDefined);
@@ -103,17 +103,17 @@ STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword2(Int32 *passwordIsDefi
103 return StringToBstr(Password, password); 103 return StringToBstr(Password, password);
104} 104}
105 105
106STDMETHODIMP CUpdateCallback100Imp::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */) 106Z7_COM7F_IMF(CUpdateCallback100Imp::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */))
107{ 107{
108 return S_OK; 108 return S_OK;
109} 109}
110 110
111STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */) 111Z7_COM7F_IMF(CUpdateCallback100Imp::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */))
112{ 112{
113 return ProgressDialog->Sync.CheckStop(); 113 return ProgressDialog->Sync.CheckStop();
114} 114}
115 115
116STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword(BSTR *password) 116Z7_COM7F_IMF(CUpdateCallback100Imp::CryptoGetTextPassword(BSTR *password))
117{ 117{
118 *password = NULL; 118 *password = NULL;
119 if (!PasswordIsDefined) 119 if (!PasswordIsDefined)
diff --git a/CPP/7zip/UI/FileManager/UpdateCallback100.h b/CPP/7zip/UI/FileManager/UpdateCallback100.h
index 7cbc11e..5d56dfb 100644
--- a/CPP/7zip/UI/FileManager/UpdateCallback100.h
+++ b/CPP/7zip/UI/FileManager/UpdateCallback100.h
@@ -1,7 +1,7 @@
1// UpdateCallback100.h 1// UpdateCallback100.h
2 2
3#ifndef __UPDATE_CALLBACK100_H 3#ifndef ZIP7_INC_UPDATE_CALLBACK100_H
4#define __UPDATE_CALLBACK100_H 4#define ZIP7_INC_UPDATE_CALLBACK100_H
5 5
6#include "../../../Common/MyCom.h" 6#include "../../../Common/MyCom.h"
7 7
@@ -13,7 +13,7 @@
13 13
14#include "ProgressDialog2.h" 14#include "ProgressDialog2.h"
15 15
16class CUpdateCallback100Imp: 16class CUpdateCallback100Imp Z7_final:
17 public IFolderArchiveUpdateCallback, 17 public IFolderArchiveUpdateCallback,
18 public IFolderArchiveUpdateCallback2, 18 public IFolderArchiveUpdateCallback2,
19 public IFolderScanProgress, 19 public IFolderScanProgress,
@@ -24,11 +24,7 @@ class CUpdateCallback100Imp:
24 public CUpdateCallbackGUI2, 24 public CUpdateCallbackGUI2,
25 public CMyUnknownImp 25 public CMyUnknownImp
26{ 26{
27public: 27 Z7_COM_UNKNOWN_IMP_7(
28
29 // CUpdateCallback100Imp() {}
30
31 MY_UNKNOWN_IMP7(
32 IFolderArchiveUpdateCallback, 28 IFolderArchiveUpdateCallback,
33 IFolderArchiveUpdateCallback2, 29 IFolderArchiveUpdateCallback2,
34 IFolderScanProgress, 30 IFolderScanProgress,
@@ -37,16 +33,14 @@ public:
37 IArchiveOpenCallback, 33 IArchiveOpenCallback,
38 ICompressProgressInfo) 34 ICompressProgressInfo)
39 35
40 INTERFACE_IProgress(;) 36 Z7_IFACE_COM7_IMP(IProgress)
41 INTERFACE_IArchiveOpenCallback(;) 37 Z7_IFACE_COM7_IMP(IFolderArchiveUpdateCallback)
42 INTERFACE_IFolderArchiveUpdateCallback(;) 38 Z7_IFACE_COM7_IMP(IFolderArchiveUpdateCallback2)
43 INTERFACE_IFolderArchiveUpdateCallback2(;) 39 Z7_IFACE_COM7_IMP(IFolderScanProgress)
44 INTERFACE_IFolderScanProgress(;) 40 Z7_IFACE_COM7_IMP(ICryptoGetTextPassword2)
45 41 Z7_IFACE_COM7_IMP(ICryptoGetTextPassword)
46 STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize); 42 Z7_IFACE_COM7_IMP(IArchiveOpenCallback)
47 43 Z7_IFACE_COM7_IMP(ICompressProgressInfo)
48 STDMETHOD(CryptoGetTextPassword)(BSTR *password);
49 STDMETHOD(CryptoGetTextPassword2)(Int32 *passwordIsDefined, BSTR *password);
50}; 44};
51 45
52#endif 46#endif
diff --git a/CPP/7zip/UI/FileManager/VerCtrl.cpp b/CPP/7zip/UI/FileManager/VerCtrl.cpp
index 4bb034f..0c894b8 100644
--- a/CPP/7zip/UI/FileManager/VerCtrl.cpp
+++ b/CPP/7zip/UI/FileManager/VerCtrl.cpp
@@ -149,7 +149,7 @@ void CApp::VerCtrl(unsigned id)
149 } 149 }
150 150
151 CRecordVector<UInt32> indices; 151 CRecordVector<UInt32> indices;
152 panel.GetSelectedItemsIndices(indices); 152 panel.Get_ItemIndices_Selected(indices);
153 153
154 if (indices.Size() != 1) 154 if (indices.Size() != 1)
155 { 155 {
@@ -223,7 +223,7 @@ void CApp::VerCtrl(unsigned id)
223 if (!ParseNumberString(fi.Name, val)) 223 if (!ParseNumberString(fi.Name, val))
224 continue; 224 continue;
225 if ((Int32)val > maxVal) 225 if ((Int32)val > maxVal)
226 maxVal = val; 226 maxVal = (Int32)val;
227 } 227 }
228 228
229 UInt32 next = (UInt32)maxVal + 1; 229 UInt32 next = (UInt32)maxVal + 1;
@@ -320,7 +320,7 @@ void CApp::VerCtrl(unsigned id)
320 const UInt64 k_Ntfs_prec = 10000000; 320 const UInt64 k_Ntfs_prec = 10000000;
321 UInt64 timeStamp = timeStampOriginal; 321 UInt64 timeStamp = timeStampOriginal;
322 const UInt32 k_precs[] = { 60 * 60, 60, 2, 1 }; 322 const UInt32 k_precs[] = { 60 * 60, 60, 2, 1 };
323 for (unsigned i = 0; i < ARRAY_SIZE(k_precs); i++) 323 for (unsigned i = 0; i < Z7_ARRAY_SIZE(k_precs); i++)
324 { 324 {
325 timeStamp = timeStampOriginal; 325 timeStamp = timeStampOriginal;
326 const UInt64 prec = k_Ntfs_prec * k_precs[i]; 326 const UInt64 prec = k_Ntfs_prec * k_precs[i];
diff --git a/CPP/7zip/UI/FileManager/ViewSettings.cpp b/CPP/7zip/UI/FileManager/ViewSettings.cpp
index 0f87711..3d64602 100644
--- a/CPP/7zip/UI/FileManager/ViewSettings.cpp
+++ b/CPP/7zip/UI/FileManager/ViewSettings.cpp
@@ -36,7 +36,8 @@ static NSynchronization::CCriticalSection g_CS;
36#define Set32(p, v) SetUi32(((Byte *)p), v) 36#define Set32(p, v) SetUi32(((Byte *)p), v)
37#define SetBool(p, v) Set32(p, ((v) ? 1 : 0)) 37#define SetBool(p, v) Set32(p, ((v) ? 1 : 0))
38 38
39#define Get32(p, dest) dest = GetUi32((const Byte *)p) 39#define Get32(p, dest) dest = GetUi32((const Byte *)p);
40#define Get32_LONG(p, dest) dest = (LONG)GetUi32((const Byte *)p);
40#define GetBool(p, dest) dest = (GetUi32(p) != 0); 41#define GetBool(p, dest) dest = (GetUi32(p) != 0);
41 42
42/* 43/*
@@ -57,16 +58,16 @@ void CListViewInfo::Save(const UString &id) const
57 const UInt32 dataSize = kListViewHeaderSize + kColumnInfoSize * Columns.Size(); 58 const UInt32 dataSize = kListViewHeaderSize + kColumnInfoSize * Columns.Size();
58 CByteArr buf(dataSize); 59 CByteArr buf(dataSize);
59 60
60 Set32(buf, kListViewVersion); 61 Set32(buf, kListViewVersion)
61 Set32(buf + 4, SortID); 62 Set32(buf + 4, SortID)
62 SetBool(buf + 8, Ascending); 63 SetBool(buf + 8, Ascending)
63 FOR_VECTOR (i, Columns) 64 FOR_VECTOR (i, Columns)
64 { 65 {
65 const CColumnInfo &column = Columns[i]; 66 const CColumnInfo &column = Columns[i];
66 Byte *p = buf + kListViewHeaderSize + i * kColumnInfoSize; 67 Byte *p = buf + kListViewHeaderSize + i * kColumnInfoSize;
67 Set32(p, column.PropID); 68 Set32(p, column.PropID)
68 SetBool(p + 4, column.IsVisible); 69 SetBool(p + 4, column.IsVisible)
69 Set32(p + 8, column.Width); 70 Set32(p + 8, column.Width)
70 } 71 }
71 { 72 {
72 NSynchronization::CCriticalSectionLock lock(g_CS); 73 NSynchronization::CCriticalSectionLock lock(g_CS);
@@ -92,11 +93,11 @@ void CListViewInfo::Read(const UString &id)
92 if (size < kListViewHeaderSize) 93 if (size < kListViewHeaderSize)
93 return; 94 return;
94 UInt32 version; 95 UInt32 version;
95 Get32(buf, version); 96 Get32(buf, version)
96 if (version != kListViewVersion) 97 if (version != kListViewVersion)
97 return; 98 return;
98 Get32(buf + 4, SortID); 99 Get32(buf + 4, SortID)
99 GetBool(buf + 8, Ascending); 100 GetBool(buf + 8, Ascending)
100 101
101 IsLoaded = true; 102 IsLoaded = true;
102 103
@@ -109,9 +110,9 @@ void CListViewInfo::Read(const UString &id)
109 { 110 {
110 CColumnInfo column; 111 CColumnInfo column;
111 const Byte *p = buf + kListViewHeaderSize + i * kColumnInfoSize; 112 const Byte *p = buf + kListViewHeaderSize + i * kColumnInfoSize;
112 Get32(p, column.PropID); 113 Get32(p, column.PropID)
113 GetBool(p + 4, column.IsVisible); 114 GetBool(p + 4, column.IsVisible)
114 Get32(p + 8, column.Width); 115 Get32(p + 8, column.Width)
115 Columns.AddInReserved(column); 116 Columns.AddInReserved(column);
116 } 117 }
117} 118}
@@ -142,18 +143,18 @@ void CWindowInfo::Save() const
142 key.Create(HKEY_CURRENT_USER, kCUBasePath); 143 key.Create(HKEY_CURRENT_USER, kCUBasePath);
143 { 144 {
144 Byte buf[kWindowPositionHeaderSize]; 145 Byte buf[kWindowPositionHeaderSize];
145 Set32(buf, rect.left); 146 Set32(buf, (UInt32)rect.left)
146 Set32(buf + 4, rect.top); 147 Set32(buf + 4, (UInt32)rect.top)
147 Set32(buf + 8, rect.right); 148 Set32(buf + 8, (UInt32)rect.right)
148 Set32(buf + 12, rect.bottom); 149 Set32(buf + 12, (UInt32)rect.bottom)
149 SetBool(buf + 16, maximized); 150 SetBool(buf + 16, maximized)
150 key.SetValue(kPositionValueName, buf, kWindowPositionHeaderSize); 151 key.SetValue(kPositionValueName, buf, kWindowPositionHeaderSize);
151 } 152 }
152 { 153 {
153 Byte buf[kPanelsInfoHeaderSize]; 154 Byte buf[kPanelsInfoHeaderSize];
154 Set32(buf, numPanels); 155 Set32(buf, numPanels)
155 Set32(buf + 4, currentPanel); 156 Set32(buf + 4, currentPanel)
156 Set32(buf + 8, splitterPos); 157 Set32(buf + 8, splitterPos)
157 key.SetValue(kPanelsInfoValueName, buf, kPanelsInfoHeaderSize); 158 key.SetValue(kPanelsInfoValueName, buf, kPanelsInfoHeaderSize);
158 } 159 }
159} 160}
@@ -175,18 +176,18 @@ void CWindowInfo::Read(bool &windowPosDefined, bool &panelInfoDefined)
175 CByteBuffer buf; 176 CByteBuffer buf;
176 if (QueryBuf(key, kPositionValueName, buf, kWindowPositionHeaderSize)) 177 if (QueryBuf(key, kPositionValueName, buf, kWindowPositionHeaderSize))
177 { 178 {
178 Get32(buf, rect.left); 179 Get32_LONG(buf, rect.left)
179 Get32(buf + 4, rect.top); 180 Get32_LONG(buf + 4, rect.top)
180 Get32(buf + 8, rect.right); 181 Get32_LONG(buf + 8, rect.right)
181 Get32(buf + 12, rect.bottom); 182 Get32_LONG(buf + 12, rect.bottom)
182 GetBool(buf + 16, maximized); 183 GetBool(buf + 16, maximized)
183 windowPosDefined = true; 184 windowPosDefined = true;
184 } 185 }
185 if (QueryBuf(key, kPanelsInfoValueName, buf, kPanelsInfoHeaderSize)) 186 if (QueryBuf(key, kPanelsInfoValueName, buf, kPanelsInfoHeaderSize))
186 { 187 {
187 Get32(buf, numPanels); 188 Get32(buf, numPanels)
188 Get32(buf + 4, currentPanel); 189 Get32(buf + 4, currentPanel)
189 Get32(buf + 8, splitterPos); 190 Get32(buf + 8, splitterPos)
190 panelInfoDefined = true; 191 panelInfoDefined = true;
191 } 192 }
192 return; 193 return;
diff --git a/CPP/7zip/UI/FileManager/ViewSettings.h b/CPP/7zip/UI/FileManager/ViewSettings.h
index aeb6897..02af0a1 100644
--- a/CPP/7zip/UI/FileManager/ViewSettings.h
+++ b/CPP/7zip/UI/FileManager/ViewSettings.h
@@ -1,7 +1,7 @@
1// ViewSettings.h 1// ViewSettings.h
2 2
3#ifndef __VIEW_SETTINGS_H 3#ifndef ZIP7_INC_VIEW_SETTINGS_H
4#define __VIEW_SETTINGS_H 4#define ZIP7_INC_VIEW_SETTINGS_H
5 5
6#include "../../../Common/MyTypes.h" 6#include "../../../Common/MyTypes.h"
7#include "../../../Common/MyString.h" 7#include "../../../Common/MyString.h"
diff --git a/CPP/7zip/UI/FileManager/makefile b/CPP/7zip/UI/FileManager/makefile
index dd2a2f2..df08c98 100644
--- a/CPP/7zip/UI/FileManager/makefile
+++ b/CPP/7zip/UI/FileManager/makefile
@@ -1,6 +1,6 @@
1PROG = 7zFM.exe 1PROG = 7zFM.exe
2CFLAGS = $(CFLAGS) \ 2CFLAGS = $(CFLAGS) \
3 -DEXTERNAL_CODECS \ 3 -DZ7_EXTERNAL_CODECS \
4 4
5!include "FM.mak" 5!include "FM.mak"
6 6
@@ -85,6 +85,7 @@ UI_COMMON_OBJS = \
85 85
86EXPLORER_OBJS = \ 86EXPLORER_OBJS = \
87 $O\ContextMenu.obj \ 87 $O\ContextMenu.obj \
88 $O\MyMessages.obj \
88 $O\RegistryContextMenu.obj \ 89 $O\RegistryContextMenu.obj \
89 90
90GUI_OBJS = \ 91GUI_OBJS = \
diff --git a/CPP/7zip/UI/FileManager/resource.h b/CPP/7zip/UI/FileManager/resource.h
index 98cb4fd..9d605c6 100644
--- a/CPP/7zip/UI/FileManager/resource.h
+++ b/CPP/7zip/UI/FileManager/resource.h
@@ -26,6 +26,14 @@
26#define IDM_SHA1 104 26#define IDM_SHA1 104
27#define IDM_SHA256 105 27#define IDM_SHA256 105
28 28
29
30#define IDM_FILE 500
31#define IDM_EDIT 501
32#define IDM_VIEW 502
33#define IDM_FAVORITES 503
34#define IDM_TOOLS 504
35#define IDM_HELP 505
36
29#define IDM_OPEN 540 37#define IDM_OPEN 540
30#define IDM_OPEN_INSIDE 541 38#define IDM_OPEN_INSIDE 541
31#define IDM_OPEN_OUTSIDE 542 39#define IDM_OPEN_OUTSIDE 542
@@ -90,8 +98,10 @@
90#define IDM_VIEW_TOOLBARS_LARGE_BUTTONS 752 98#define IDM_VIEW_TOOLBARS_LARGE_BUTTONS 752
91#define IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT 753 99#define IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT 753
92 100
101#define IDM_VIEW_TIME_POPUP 760
93#define IDM_VIEW_TIME 761 102#define IDM_VIEW_TIME 761
94 103
104#define IDM_ADD_TO_FAVORITES 800
95#define IDS_BOOKMARK 801 105#define IDS_BOOKMARK 801
96 106
97#define IDM_OPTIONS 900 107#define IDM_OPTIONS 900
diff --git a/CPP/7zip/UI/FileManager/resource.rc b/CPP/7zip/UI/FileManager/resource.rc
index fc2c840..002265a 100644
--- a/CPP/7zip/UI/FileManager/resource.rc
+++ b/CPP/7zip/UI/FileManager/resource.rc
@@ -12,10 +12,27 @@ BEGIN
12// VK_F7, IDM_CREATE_FOLDER, VIRTKEY, NOINVERT 12// VK_F7, IDM_CREATE_FOLDER, VIRTKEY, NOINVERT
13END 13END
14 14
15// for MENUEX:
16// /*
17#define MY_MENUITEM_SEPARATOR MENUITEM "", 0, MFT_SEPARATOR
18#define MY_MFT_MENUBREAK MFT_MENUBREAK
19#define MY_MFT_MENUBARBREAK MFT_MENUBARBREAK
20#define MY_MFS_CHECKED MFT_STRING, MFS_CHECKED
21#define MY_MENUITEM_ID(x) , x
22// */
15 23
16IDM_MENU MENU 24// for MENU:
25/*
26#define MY_MENUITEM_SEPARATOR MENUITEM SEPARATOR
27#define MY_MFT_MENUBREAK MENUBREAK
28#define MY_MFT_MENUBARBREAK MENUBARBREAK
29#define MY_MFS_CHECKED CHECKED
30#define MY_MENUITEM_ID(x)
31*/
32
33IDM_MENU MENUEX
17BEGIN 34BEGIN
18 POPUP "&File" 35 POPUP "&File" MY_MENUITEM_ID(IDM_FILE)
19 BEGIN 36 BEGIN
20 MENUITEM "&Open\tEnter", IDM_OPEN 37 MENUITEM "&Open\tEnter", IDM_OPEN
21 MENUITEM "Open &Inside\tCtrl+PgDn", IDM_OPEN_INSIDE 38 MENUITEM "Open &Inside\tCtrl+PgDn", IDM_OPEN_INSIDE
@@ -24,19 +41,19 @@ BEGIN
24 MENUITEM "Open O&utside\tShift+Enter", IDM_OPEN_OUTSIDE 41 MENUITEM "Open O&utside\tShift+Enter", IDM_OPEN_OUTSIDE
25 MENUITEM "&View\tF3", IDM_FILE_VIEW 42 MENUITEM "&View\tF3", IDM_FILE_VIEW
26 MENUITEM "&Edit\tF4", IDM_FILE_EDIT 43 MENUITEM "&Edit\tF4", IDM_FILE_EDIT
27 MENUITEM SEPARATOR 44 MY_MENUITEM_SEPARATOR
28 MENUITEM "Rena&me\tF2", IDM_RENAME 45 MENUITEM "Rena&me\tF2", IDM_RENAME
29 MENUITEM "&Copy To...\tF5", IDM_COPY_TO 46 MENUITEM "&Copy To...\tF5", IDM_COPY_TO
30 MENUITEM "&Move To...\tF6", IDM_MOVE_TO 47 MENUITEM "&Move To...\tF6", IDM_MOVE_TO
31 MENUITEM "&Delete\tDel", IDM_DELETE 48 MENUITEM "&Delete\tDel", IDM_DELETE
32 MENUITEM SEPARATOR 49 MY_MENUITEM_SEPARATOR
33 MENUITEM "&Split file...", IDM_SPLIT 50 MENUITEM "&Split file...", IDM_SPLIT
34 MENUITEM "Com&bine files...", IDM_COMBINE 51 MENUITEM "Com&bine files...", IDM_COMBINE
35 MENUITEM SEPARATOR 52 MY_MENUITEM_SEPARATOR
36 MENUITEM "P&roperties\tAlt+Enter", IDM_PROPERTIES 53 MENUITEM "P&roperties\tAlt+Enter", IDM_PROPERTIES
37 MENUITEM "Comme&nt...\tCtrl+Z", IDM_COMMENT 54 MENUITEM "Comme&nt...\tCtrl+Z", IDM_COMMENT
38 // MENUITEM "Calculate checksum", IDM_CRC 55 // MENUITEM "Calculate checksum", IDM_CRC
39 POPUP "CRC" 56 POPUP "CRC" MY_MENUITEM_ID(0)
40 BEGIN 57 BEGIN
41 MENUITEM "CRC-32", IDM_CRC32 58 MENUITEM "CRC-32", IDM_CRC32
42 MENUITEM "CRC-64", IDM_CRC64 59 MENUITEM "CRC-64", IDM_CRC64
@@ -45,55 +62,56 @@ BEGIN
45 MENUITEM "*", IDM_HASH_ALL 62 MENUITEM "*", IDM_HASH_ALL
46 END 63 END
47 MENUITEM "Di&ff", IDM_DIFF 64 MENUITEM "Di&ff", IDM_DIFF
48 MENUITEM SEPARATOR 65 MY_MENUITEM_SEPARATOR
49 MENUITEM "Create Folder\tF7", IDM_CREATE_FOLDER 66 MENUITEM "Create Folder\tF7", IDM_CREATE_FOLDER
50 MENUITEM "Create File\tCtrl+N", IDM_CREATE_FILE 67 MENUITEM "Create File\tCtrl+N", IDM_CREATE_FILE
51 MENUITEM SEPARATOR 68 MY_MENUITEM_SEPARATOR
52 MENUITEM "&Link...", IDM_LINK 69 MENUITEM "&Link...", IDM_LINK
53 MENUITEM "&Alternate streams", IDM_ALT_STREAMS 70 MENUITEM "&Alternate streams", IDM_ALT_STREAMS
54 MENUITEM SEPARATOR 71 MY_MENUITEM_SEPARATOR
55 MENUITEM "E&xit\tAlt+F4", IDCLOSE 72 MENUITEM "E&xit\tAlt+F4", IDCLOSE
56 END 73 END
57 POPUP "&Edit" 74 POPUP "&Edit" MY_MENUITEM_ID(IDM_EDIT)
58 BEGIN 75 BEGIN
59 // MENUITEM "Cu&t\tCtrl+X", IDM_EDIT_CUT, GRAYED 76 // MENUITEM "Cu&t\tCtrl+X", IDM_EDIT_CUT, GRAYED
60 // MENUITEM "&Copy\tCtrl+C", IDM_EDIT_COPY, GRAYED 77 // MENUITEM "&Copy\tCtrl+C", IDM_EDIT_COPY, GRAYED
61 // MENUITEM "&Paste\tCtrl+V", IDM_EDIT_PASTE, GRAYED 78 // MENUITEM "&Paste\tCtrl+V", IDM_EDIT_PASTE, GRAYED
62 // MENUITEM SEPARATOR 79 // MY_MENUITEM_SEPARATOR
63 MENUITEM "Select &All\tShift+[Grey +]", IDM_SELECT_ALL 80 MENUITEM "Select &All\tShift+[Grey +]", IDM_SELECT_ALL
64 MENUITEM "Deselect All\tShift+[Grey -]", IDM_DESELECT_ALL 81 MENUITEM "Deselect All\tShift+[Grey -]", IDM_DESELECT_ALL
65 MENUITEM "&Invert Selection\tGrey *", IDM_INVERT_SELECTION 82 MENUITEM "&Invert Selection\tGrey *", IDM_INVERT_SELECTION
66 MENUITEM "Select...\tGrey +", IDM_SELECT 83 MENUITEM "Select...\tGrey +", IDM_SELECT
67 MENUITEM "Deselect...\tGrey -", IDM_DESELECT 84 MENUITEM "Deselect...\tGrey -", IDM_DESELECT
85 MENUITEM "", 0, MY_MFT_MENUBARBREAK
68 MENUITEM "Select by Type\tAlt+[Grey+]", IDM_SELECT_BY_TYPE 86 MENUITEM "Select by Type\tAlt+[Grey+]", IDM_SELECT_BY_TYPE
69 MENUITEM "Deselect by Type\tAlt+[Grey -]", IDM_DESELECT_BY_TYPE 87 MENUITEM "Deselect by Type\tAlt+[Grey -]", IDM_DESELECT_BY_TYPE
70 END 88 END
71 POPUP "&View" 89 POPUP "&View" MY_MENUITEM_ID(IDM_VIEW)
72 BEGIN 90 BEGIN
73 MENUITEM "Lar&ge Icons\tCtrl+1", IDM_VIEW_LARGE_ICONS 91 MENUITEM "Lar&ge Icons\tCtrl+1", IDM_VIEW_LARGE_ICONS
74 MENUITEM "S&mall Icons\tCtrl+2", IDM_VIEW_SMALL_ICONS 92 MENUITEM "S&mall Icons\tCtrl+2", IDM_VIEW_SMALL_ICONS
75 MENUITEM "&List\tCtrl+3", IDM_VIEW_LIST 93 MENUITEM "&List\tCtrl+3", IDM_VIEW_LIST
76 MENUITEM "&Details\tCtrl+4", IDM_VIEW_DETAILS, CHECKED 94 MENUITEM "&Details\tCtrl+4", IDM_VIEW_DETAILS, MY_MFS_CHECKED
77 MENUITEM SEPARATOR 95 MY_MENUITEM_SEPARATOR
78 MENUITEM "Name\tCtrl+F3", IDM_VIEW_ARANGE_BY_NAME 96 MENUITEM "Name\tCtrl+F3", IDM_VIEW_ARANGE_BY_NAME
79 MENUITEM "Type\tCtrl+F4", IDM_VIEW_ARANGE_BY_TYPE 97 MENUITEM "Type\tCtrl+F4", IDM_VIEW_ARANGE_BY_TYPE
80 MENUITEM "Date\tCtrl+F5", IDM_VIEW_ARANGE_BY_DATE 98 MENUITEM "Date\tCtrl+F5", IDM_VIEW_ARANGE_BY_DATE
81 MENUITEM "Size\tCtrl+F6", IDM_VIEW_ARANGE_BY_SIZE 99 MENUITEM "Size\tCtrl+F6", IDM_VIEW_ARANGE_BY_SIZE
82 MENUITEM "Unsorted\tCtrl+F7", IDM_VIEW_ARANGE_NO_SORT 100 MENUITEM "Unsorted\tCtrl+F7", IDM_VIEW_ARANGE_NO_SORT
83 MENUITEM SEPARATOR 101 MY_MENUITEM_SEPARATOR
84 MENUITEM "Flat View", IDM_VIEW_FLAT_VIEW 102 MENUITEM "Flat View", IDM_VIEW_FLAT_VIEW
85 MENUITEM "&2 Panels\tF9", IDM_VIEW_TWO_PANELS 103 MENUITEM "&2 Panels\tF9", IDM_VIEW_TWO_PANELS
86 104
87 POPUP "2017" 105 POPUP "2017" MY_MENUITEM_ID(IDM_VIEW_TIME_POPUP)
88 BEGIN 106 BEGIN
89 MENUITEM "Time", IDM_VIEW_TIME 107 MENUITEM "Time", IDM_VIEW_TIME
90 END 108 END
91 109
92 POPUP "Toolbars" 110 POPUP "Toolbars" MY_MENUITEM_ID(IDM_VIEW_TOOLBARS)
93 BEGIN 111 BEGIN
94 MENUITEM "Archive Toolbar", IDM_VIEW_ARCHIVE_TOOLBAR 112 MENUITEM "Archive Toolbar", IDM_VIEW_ARCHIVE_TOOLBAR
95 MENUITEM "Standard Toolbar", IDM_VIEW_STANDARD_TOOLBAR 113 MENUITEM "Standard Toolbar", IDM_VIEW_STANDARD_TOOLBAR
96 MENUITEM SEPARATOR 114 MY_MENUITEM_SEPARATOR
97 MENUITEM "Large Buttons", IDM_VIEW_TOOLBARS_LARGE_BUTTONS 115 MENUITEM "Large Buttons", IDM_VIEW_TOOLBARS_LARGE_BUTTONS
98 MENUITEM "Show Buttons Text", IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT 116 MENUITEM "Show Buttons Text", IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT
99 END 117 END
@@ -107,29 +125,29 @@ BEGIN
107 // MENUITEM "Show deleted files", IDM_VIEW_SHOW_DELETED 125 // MENUITEM "Show deleted files", IDM_VIEW_SHOW_DELETED
108 126
109 END 127 END
110 POPUP "F&avorites" 128 POPUP "F&avorites" MY_MENUITEM_ID(IDM_FAVORITES)
111 BEGIN 129 BEGIN
112 POPUP "&Add folder to Favorites as" 130 POPUP "&Add folder to Favorites as" MY_MENUITEM_ID(IDM_ADD_TO_FAVORITES)
113 BEGIN 131 BEGIN
114 MENUITEM SEPARATOR 132 MY_MENUITEM_SEPARATOR
115 END 133 END
116 MENUITEM SEPARATOR 134 MY_MENUITEM_SEPARATOR
117 END 135 END
118 POPUP "&Tools" 136 POPUP "&Tools" MY_MENUITEM_ID(IDM_TOOLS)
119 BEGIN 137 BEGIN
120 MENUITEM "&Options...", IDM_OPTIONS 138 MENUITEM "&Options...", IDM_OPTIONS
121 MENUITEM SEPARATOR 139 MY_MENUITEM_SEPARATOR
122 MENUITEM "&Benchmark", IDM_BENCHMARK 140 MENUITEM "&Benchmark", IDM_BENCHMARK
123 #ifdef UNDER_CE 141 #ifdef UNDER_CE
124 MENUITEM "Benchmark 2", IDM_BENCHMARK2 142 MENUITEM "Benchmark 2", IDM_BENCHMARK2
125 #endif 143 #endif
126 #ifndef UNDER_CE 144 #ifndef UNDER_CE
127 END 145 END
128 POPUP "&Help" 146 POPUP "&Help" MY_MENUITEM_ID(IDM_HELP)
129 BEGIN 147 BEGIN
130 MENUITEM "&Contents...\tF1", IDM_HELP_CONTENTS 148 MENUITEM "&Contents...\tF1", IDM_HELP_CONTENTS
131 #endif 149 #endif
132 MENUITEM SEPARATOR 150 MY_MENUITEM_SEPARATOR
133 MENUITEM "&About 7-Zip...", IDM_ABOUT 151 MENUITEM "&About 7-Zip...", IDM_ABOUT
134 END 152 END
135END 153END
@@ -172,7 +190,7 @@ BEGIN
172 IDS_VIRUS "The file looks like a virus (the file name contains long spaces in name)." 190 IDS_VIRUS "The file looks like a virus (the file name contains long spaces in name)."
173 IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER "The operation cannot be called from a folder that has a long path." 191 IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER "The operation cannot be called from a folder that has a long path."
174 IDS_SELECT_ONE_FILE "You must select one file" 192 IDS_SELECT_ONE_FILE "You must select one file"
175 IDS_SELECT_FILES "You must select one or more files" 193 // IDS_SELECT_FILES "You must select one or more files"
176 IDS_TOO_MANY_ITEMS "Too many items" 194 IDS_TOO_MANY_ITEMS "Too many items"
177 195
178 IDS_COPY "Copy" 196 IDS_COPY "Copy"