From e648b8b8db9e09b110a221c1f170c77e25c49008 Mon Sep 17 00:00:00 2001 From: shunf4 Date: Sat, 20 Apr 2024 21:13:00 +0800 Subject: [PATCH] when the archive has only one folder as its direct child, do not add filename to path by default on extraction; if not, add filename to path --- CPP/7zip/UI/FileManager/App.cpp | 11 +++++++++-- CPP/7zip/UI/FileManager/CopyDialog.cpp | 5 +++++ CPP/7zip/UI/FileManager/CopyDialog.h | 5 ++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CPP/7zip/UI/FileManager/App.cpp b/CPP/7zip/UI/FileManager/App.cpp index 3508143f..8eb78860 100644 --- a/CPP/7zip/UI/FileManager/App.cpp +++ b/CPP/7zip/UI/FileManager/App.cpp @@ -496,23 +496,30 @@ static void AddPropValueToSum(IFolderFolder *folder, int index, PROPID propID, U sum = (UInt64)(Int64)-1; } -UString CPanel::GetItemsInfoString(const CRecordVector &indices) +UString CPanel::GetItemsInfoString(const CRecordVector &indices, int *soleDir) { UString info; UInt64 numDirs, numFiles, filesSize, foldersSize; numDirs = numFiles = filesSize = foldersSize = 0; unsigned i; + *soleDir = 0; for (i = 0; i < indices.Size(); i++) { int index = indices[i]; if (IsItem_Folder(index)) { + if (i == 0) { + *soleDir = 1; + } else { + *soleDir = 0; + } AddPropValueToSum(_folder, index, kpidSize, foldersSize); numDirs++; } else { + *soleDir = 0; AddPropValueToSum(_folder, index, kpidSize, filesSize); numFiles++; } @@ -629,7 +636,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) copyDialog.Value = destPath; LangString(move ? IDS_MOVE : IDS_COPY, copyDialog.Title); LangString(move ? IDS_MOVE_TO : IDS_COPY_TO, copyDialog.Static); - copyDialog.Info = srcPanel.GetItemsInfoString(indices); + copyDialog.Info = srcPanel.GetItemsInfoString(indices, ©Dialog.soleDir); copyDialog.m_currentFolderPrefix = srcPanel._currentFolderPrefix; if (copyDialog.Create(srcPanel.GetParent()) != IDOK) diff --git a/CPP/7zip/UI/FileManager/CopyDialog.cpp b/CPP/7zip/UI/FileManager/CopyDialog.cpp index 527a3511..28fff48d 100644 --- a/CPP/7zip/UI/FileManager/CopyDialog.cpp +++ b/CPP/7zip/UI/FileManager/CopyDialog.cpp @@ -109,6 +109,9 @@ bool CCopyDialog::OnInit() } } } + if (soleDir == 0) { + OnButtonAddFileName(); + } return CModalDialog::OnInit(); } @@ -267,6 +270,8 @@ void CCopyDialog::OnButtonAddFileName() currentPath += m_strRealFileName; _path.SetText(currentPath); + } else { + _path.SetText(currentPath.Mid(0, n)); } _path.SetFocus(); } diff --git a/CPP/7zip/UI/FileManager/CopyDialog.h b/CPP/7zip/UI/FileManager/CopyDialog.h index 054f5bc0..e6214d63 100644 --- a/CPP/7zip/UI/FileManager/CopyDialog.h +++ b/CPP/7zip/UI/FileManager/CopyDialog.h @@ -30,7 +30,8 @@ protected: SIZE m_sizeMinWindow; public: - CCopyDialog(): m_bOpenOutputFolder(false), m_bDeleteSourceFile(false), m_bClose7Zip (false) { m_sizeMinWindow.cx = 0; m_sizeMinWindow.cy = 0; } + // soleDir=2: undecided + CCopyDialog(): soleDir(2), m_bOpenOutputFolder(false), m_bDeleteSourceFile(false), m_bClose7Zip (false) { m_sizeMinWindow.cx = 0; m_sizeMinWindow.cy = 0; } UString Title; UString Static; @@ -38,6 +39,8 @@ public: UString Info; UStringVector Strings; + int soleDir; + bool m_bOpenOutputFolder; bool m_bDeleteSourceFile; bool m_bClose7Zip;