Skip to content

Commit fd0b834

Browse files
committed
[ZIPFLDR] Various usability improvements
- Take the user-entered folder into account - Hide size / ratio for folders CORE-14543 CORE-14542
1 parent 2c90194 commit fd0b834

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

dll/shellext/zipfldr/CZipExtract.cpp

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ class CZipExtract :
1212
{
1313
CStringW m_Filename;
1414
CStringW m_Directory;
15+
bool m_DirectoryChanged;
1516
unzFile uf;
1617
public:
1718
CZipExtract(PCWSTR Filename)
18-
:uf(NULL)
19+
:m_DirectoryChanged(false)
20+
,uf(NULL)
1921
{
2022
m_Filename = Filename;
2123
m_Directory = m_Filename;
@@ -158,6 +160,7 @@ class CZipExtract :
158160
int OnSetActive()
159161
{
160162
SetDlgItemTextW(IDC_DIRECTORY, m_pExtract->m_Directory);
163+
m_pExtract->m_DirectoryChanged = false;
161164
::EnableWindow(GetDlgItem(IDC_PASSWORD), FALSE); /* Not supported for now */
162165
GetParent().CenterWindow(::GetDesktopWindow());
163166
return 0;
@@ -169,6 +172,9 @@ class CZipExtract :
169172
::EnableWindow(GetDlgItem(IDC_DIRECTORY), FALSE);
170173
::EnableWindow(GetDlgItem(IDC_PASSWORD), FALSE);
171174

175+
if (m_pExtract->m_DirectoryChanged)
176+
UpdateDirectory();
177+
172178
if (!m_pExtract->Extract(m_hWnd, GetDlgItem(IDC_PROGRESS)))
173179
{
174180
/* Extraction failed, do not go to the next page */
@@ -211,6 +217,9 @@ class CZipExtract :
211217
CStringW title(MAKEINTRESOURCEW(IDS_WIZ_BROWSE_TITLE));
212218
bi.lpszTitle = title;
213219

220+
if (m_pExtract->m_DirectoryChanged)
221+
UpdateDirectory();
222+
214223
browse_info info = { m_hWnd, m_pExtract->m_Directory.GetString() };
215224
bi.lParam = (LPARAM)&info;
216225

@@ -222,21 +231,35 @@ class CZipExtract :
222231
{
223232
m_pExtract->m_Directory = tmpPath;
224233
SetDlgItemTextW(IDC_DIRECTORY, m_pExtract->m_Directory);
234+
m_pExtract->m_DirectoryChanged = false;
225235
}
226236
return 0;
227237
}
228238

239+
LRESULT OnEnChangeDirectory(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
240+
{
241+
m_pExtract->m_DirectoryChanged = true;
242+
return 0;
243+
}
244+
229245
LRESULT OnPassword(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
230246
{
231247
return 0;
232248
}
233249

250+
void UpdateDirectory()
251+
{
252+
GetDlgItemText(IDC_DIRECTORY, m_pExtract->m_Directory);
253+
m_pExtract->m_DirectoryChanged = false;
254+
}
255+
234256
public:
235257
enum { IDD = IDD_PROPPAGEDESTINATION };
236258

237259
BEGIN_MSG_MAP(CCompleteSettingsPage)
238260
COMMAND_ID_HANDLER(IDC_BROWSE, OnBrowse)
239261
COMMAND_ID_HANDLER(IDC_PASSWORD, OnPassword)
262+
COMMAND_HANDLER(IDC_DIRECTORY, EN_CHANGE, OnEnChangeDirectory)
240263
CHAIN_MSG_MAP(CPropertyPageImpl<CExtractSettingsPage>)
241264
END_MSG_MAP()
242265
};
@@ -319,13 +342,15 @@ class CZipExtract :
319342
if (err != UNZ_OK)
320343
{
321344
DPRINT1("ERROR, unzGetGlobalInfo64: 0x%x\n", err);
345+
Close();
322346
return false;
323347
}
324348

325349
CZipEnumerator zipEnum;
326350
if (!zipEnum.initialize(this))
327351
{
328352
DPRINT1("ERROR, zipEnum.initialize\n");
353+
Close();
329354
return false;
330355
}
331356

@@ -351,6 +376,7 @@ class CZipExtract :
351376
HRESULT hr = SHPathPrepareForWriteA(hDlg, NULL, FullPath, dwFlags);
352377
if (FAILED_UNEXPECTEDLY(hr))
353378
{
379+
Close();
354380
return false;
355381
}
356382
CurrentFile++;
@@ -363,6 +389,7 @@ class CZipExtract :
363389
if (err != UNZ_OK)
364390
{
365391
DPRINT1("ERROR, unzOpenCurrentFilePassword: 0x%x\n", err);
392+
Close();
366393
return false;
367394
}
368395

@@ -386,6 +413,8 @@ class CZipExtract :
386413
case CConfirmReplace::No:
387414
break;
388415
case CConfirmReplace::Cancel:
416+
unzCloseCurrentFile(uf);
417+
Close();
389418
return false;
390419
}
391420
}
@@ -408,6 +437,7 @@ class CZipExtract :
408437
{
409438
unzCloseCurrentFile(uf);
410439
DPRINT1("ERROR, CreateFileA: 0x%x (%s)\n", dwErr, bOverwriteAll ? "Y" : "N");
440+
Close();
411441
return false;
412442
}
413443
}
@@ -454,6 +484,7 @@ class CZipExtract :
454484
{
455485
unzCloseCurrentFile(uf);
456486
DPRINT1("ERROR, unzReadCurrentFile2: 0x%x\n", err);
487+
Close();
457488
return false;
458489
}
459490
else

dll/shellext/zipfldr/CZipFolder.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ class CZipFolder :
172172
case 2: /* Compressed size */
173173
case 4: /* Size */
174174
{
175+
if (isDir)
176+
return SHSetStrRet(&psd->str, L"");
177+
175178
ULONG64 Size = iColumn == 2 ? zipEntry->CompressedSize : zipEntry->UncompressedSize;
176179
if (!StrFormatByteSizeW(Size, Buffer, _countof(Buffer)))
177180
return E_FAIL;
@@ -183,8 +186,11 @@ class CZipFolder :
183186
return SHSetStrRet(&psd->str, _AtlBaseModule.GetResourceInstance(), zipEntry->Password ? IDS_YES : IDS_NO);
184187
case 5: /* Ratio */
185188
{
189+
if (isDir)
190+
return SHSetStrRet(&psd->str, L"");
191+
186192
int ratio = 0;
187-
if (zipEntry->UncompressedSize && !isDir)
193+
if (zipEntry->UncompressedSize)
188194
ratio = 100 - (int)((zipEntry->CompressedSize*100)/zipEntry->UncompressedSize);
189195
StringCchPrintfW(Buffer, _countof(Buffer), L"%d%%", ratio);
190196
return SHSetStrRet(&psd->str, Buffer);

dll/shellext/zipfldr/zippidl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ LPITEMIDLIST _ILCreate(ZipPidlType Type, LPCSTR lpString, unz_file_info64& info)
1414
if (!pidl)
1515
return NULL;
1616

17+
ZeroMemory(pidl, cbData + sizeof(WORD));
18+
1719
pidl->cb = cbData;
1820
pidl->MagicType = 'z';
1921
pidl->ZipType = Type;

0 commit comments

Comments
 (0)