https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fd0b834a0a11f0ffd622a…
commit fd0b834a0a11f0ffd622ad59fb29a7bf5e33e43e
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Sat Apr 21 12:50:05 2018 +0200
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Apr 22 17:38:44 2018 +0200
[ZIPFLDR] Various usability improvements
- Take the user-entered folder into account
- Hide size / ratio for folders
CORE-14543
CORE-14542
---
dll/shellext/zipfldr/CZipExtract.cpp | 33 ++++++++++++++++++++++++++++++++-
dll/shellext/zipfldr/CZipFolder.hpp | 8 +++++++-
dll/shellext/zipfldr/zippidl.cpp | 2 ++
3 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/dll/shellext/zipfldr/CZipExtract.cpp b/dll/shellext/zipfldr/CZipExtract.cpp
index 0b5465a52c..258f9b34a1 100644
--- a/dll/shellext/zipfldr/CZipExtract.cpp
+++ b/dll/shellext/zipfldr/CZipExtract.cpp
@@ -12,10 +12,12 @@ class CZipExtract :
{
CStringW m_Filename;
CStringW m_Directory;
+ bool m_DirectoryChanged;
unzFile uf;
public:
CZipExtract(PCWSTR Filename)
- :uf(NULL)
+ :m_DirectoryChanged(false)
+ ,uf(NULL)
{
m_Filename = Filename;
m_Directory = m_Filename;
@@ -158,6 +160,7 @@ public:
int OnSetActive()
{
SetDlgItemTextW(IDC_DIRECTORY, m_pExtract->m_Directory);
+ m_pExtract->m_DirectoryChanged = false;
::EnableWindow(GetDlgItem(IDC_PASSWORD), FALSE); /* Not supported for now
*/
GetParent().CenterWindow(::GetDesktopWindow());
return 0;
@@ -169,6 +172,9 @@ public:
::EnableWindow(GetDlgItem(IDC_DIRECTORY), FALSE);
::EnableWindow(GetDlgItem(IDC_PASSWORD), FALSE);
+ if (m_pExtract->m_DirectoryChanged)
+ UpdateDirectory();
+
if (!m_pExtract->Extract(m_hWnd, GetDlgItem(IDC_PROGRESS)))
{
/* Extraction failed, do not go to the next page */
@@ -211,6 +217,9 @@ public:
CStringW title(MAKEINTRESOURCEW(IDS_WIZ_BROWSE_TITLE));
bi.lpszTitle = title;
+ if (m_pExtract->m_DirectoryChanged)
+ UpdateDirectory();
+
browse_info info = { m_hWnd, m_pExtract->m_Directory.GetString() };
bi.lParam = (LPARAM)&info;
@@ -222,21 +231,35 @@ public:
{
m_pExtract->m_Directory = tmpPath;
SetDlgItemTextW(IDC_DIRECTORY, m_pExtract->m_Directory);
+ m_pExtract->m_DirectoryChanged = false;
}
return 0;
}
+ LRESULT OnEnChangeDirectory(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL&
bHandled)
+ {
+ m_pExtract->m_DirectoryChanged = true;
+ return 0;
+ }
+
LRESULT OnPassword(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
return 0;
}
+ void UpdateDirectory()
+ {
+ GetDlgItemText(IDC_DIRECTORY, m_pExtract->m_Directory);
+ m_pExtract->m_DirectoryChanged = false;
+ }
+
public:
enum { IDD = IDD_PROPPAGEDESTINATION };
BEGIN_MSG_MAP(CCompleteSettingsPage)
COMMAND_ID_HANDLER(IDC_BROWSE, OnBrowse)
COMMAND_ID_HANDLER(IDC_PASSWORD, OnPassword)
+ COMMAND_HANDLER(IDC_DIRECTORY, EN_CHANGE, OnEnChangeDirectory)
CHAIN_MSG_MAP(CPropertyPageImpl<CExtractSettingsPage>)
END_MSG_MAP()
};
@@ -319,6 +342,7 @@ public:
if (err != UNZ_OK)
{
DPRINT1("ERROR, unzGetGlobalInfo64: 0x%x\n", err);
+ Close();
return false;
}
@@ -326,6 +350,7 @@ public:
if (!zipEnum.initialize(this))
{
DPRINT1("ERROR, zipEnum.initialize\n");
+ Close();
return false;
}
@@ -351,6 +376,7 @@ public:
HRESULT hr = SHPathPrepareForWriteA(hDlg, NULL, FullPath, dwFlags);
if (FAILED_UNEXPECTEDLY(hr))
{
+ Close();
return false;
}
CurrentFile++;
@@ -363,6 +389,7 @@ public:
if (err != UNZ_OK)
{
DPRINT1("ERROR, unzOpenCurrentFilePassword: 0x%x\n", err);
+ Close();
return false;
}
@@ -386,6 +413,8 @@ public:
case CConfirmReplace::No:
break;
case CConfirmReplace::Cancel:
+ unzCloseCurrentFile(uf);
+ Close();
return false;
}
}
@@ -408,6 +437,7 @@ public:
{
unzCloseCurrentFile(uf);
DPRINT1("ERROR, CreateFileA: 0x%x (%s)\n", dwErr,
bOverwriteAll ? "Y" : "N");
+ Close();
return false;
}
}
@@ -454,6 +484,7 @@ public:
{
unzCloseCurrentFile(uf);
DPRINT1("ERROR, unzReadCurrentFile2: 0x%x\n", err);
+ Close();
return false;
}
else
diff --git a/dll/shellext/zipfldr/CZipFolder.hpp b/dll/shellext/zipfldr/CZipFolder.hpp
index fa98673ff2..2b7010c4fa 100644
--- a/dll/shellext/zipfldr/CZipFolder.hpp
+++ b/dll/shellext/zipfldr/CZipFolder.hpp
@@ -172,6 +172,9 @@ public:
case 2: /* Compressed size */
case 4: /* Size */
{
+ if (isDir)
+ return SHSetStrRet(&psd->str, L"");
+
ULONG64 Size = iColumn == 2 ? zipEntry->CompressedSize :
zipEntry->UncompressedSize;
if (!StrFormatByteSizeW(Size, Buffer, _countof(Buffer)))
return E_FAIL;
@@ -183,8 +186,11 @@ public:
return SHSetStrRet(&psd->str, _AtlBaseModule.GetResourceInstance(),
zipEntry->Password ? IDS_YES : IDS_NO);
case 5: /* Ratio */
{
+ if (isDir)
+ return SHSetStrRet(&psd->str, L"");
+
int ratio = 0;
- if (zipEntry->UncompressedSize && !isDir)
+ if (zipEntry->UncompressedSize)
ratio = 100 -
(int)((zipEntry->CompressedSize*100)/zipEntry->UncompressedSize);
StringCchPrintfW(Buffer, _countof(Buffer), L"%d%%", ratio);
return SHSetStrRet(&psd->str, Buffer);
diff --git a/dll/shellext/zipfldr/zippidl.cpp b/dll/shellext/zipfldr/zippidl.cpp
index 1e1eb9f57f..79b23c3b00 100644
--- a/dll/shellext/zipfldr/zippidl.cpp
+++ b/dll/shellext/zipfldr/zippidl.cpp
@@ -14,6 +14,8 @@ LPITEMIDLIST _ILCreate(ZipPidlType Type, LPCSTR lpString,
unz_file_info64& info)
if (!pidl)
return NULL;
+ ZeroMemory(pidl, cbData + sizeof(WORD));
+
pidl->cb = cbData;
pidl->MagicType = 'z';
pidl->ZipType = Type;