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

This commit is contained in:
shunf4
2024-04-20 21:13:00 +08:00
parent 4b7e9f0800
commit 9d218e2681
3 changed files with 18 additions and 3 deletions

View File

@@ -496,23 +496,30 @@ static void AddPropValueToSum(IFolderFolder *folder, UInt32 index, PROPID propID
sum = (UInt64)(Int64)-1; sum = (UInt64)(Int64)-1;
} }
UString CPanel::GetItemsInfoString(const CRecordVector<UInt32> &indices) UString CPanel::GetItemsInfoString(const CRecordVector<UInt32> &indices, int *soleDir)
{ {
UString info; UString info;
UInt64 numDirs, numFiles, filesSize, foldersSize; UInt64 numDirs, numFiles, filesSize, foldersSize;
numDirs = numFiles = filesSize = foldersSize = 0; numDirs = numFiles = filesSize = foldersSize = 0;
unsigned i; unsigned i;
*soleDir = 0;
for (i = 0; i < indices.Size(); i++) for (i = 0; i < indices.Size(); i++)
{ {
const UInt32 index = indices[i]; const UInt32 index = indices[i];
if (IsItem_Folder(index)) if (IsItem_Folder(index))
{ {
if (i == 0) {
*soleDir = 1;
} else {
*soleDir = 0;
}
AddPropValueToSum(_folder, index, kpidSize, foldersSize); AddPropValueToSum(_folder, index, kpidSize, foldersSize);
numDirs++; numDirs++;
} }
else else
{ {
*soleDir = 0;
AddPropValueToSum(_folder, index, kpidSize, filesSize); AddPropValueToSum(_folder, index, kpidSize, filesSize);
numFiles++; numFiles++;
} }
@@ -629,7 +636,7 @@ void CApp::OnCopy(bool move, bool copyToSame, unsigned srcPanelIndex)
copyDialog.Value = destPath; copyDialog.Value = destPath;
LangString(move ? IDS_MOVE : IDS_COPY, copyDialog.Title); LangString(move ? IDS_MOVE : IDS_COPY, copyDialog.Title);
LangString(move ? IDS_MOVE_TO : IDS_COPY_TO, copyDialog.Static); LangString(move ? IDS_MOVE_TO : IDS_COPY_TO, copyDialog.Static);
copyDialog.Info = srcPanel.GetItemsInfoString(indices); copyDialog.Info = srcPanel.GetItemsInfoString(indices, &copyDialog.soleDir);
copyDialog.m_currentFolderPrefix = srcPanel._currentFolderPrefix; copyDialog.m_currentFolderPrefix = srcPanel._currentFolderPrefix;
if (copyDialog.Create(srcPanel.GetParent()) != IDOK) if (copyDialog.Create(srcPanel.GetParent()) != IDOK)

View File

@@ -107,6 +107,9 @@ bool CCopyDialog::OnInit()
} }
} }
} }
if (soleDir == 0) {
OnButtonAddFileName();
}
return CModalDialog::OnInit(); return CModalDialog::OnInit();
} }
@@ -265,6 +268,8 @@ void CCopyDialog::OnButtonAddFileName()
currentPath += m_strRealFileName; currentPath += m_strRealFileName;
_path.SetText(currentPath); _path.SetText(currentPath);
} else {
_path.SetText(currentPath.Mid(0, n));
} }
_path.SetFocus(); _path.SetFocus();
} }

View File

@@ -30,7 +30,8 @@ protected:
SIZE m_sizeMinWindow; SIZE m_sizeMinWindow;
public: 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 Title;
UString Static; UString Static;
@@ -38,6 +39,8 @@ public:
UString Info; UString Info;
UStringVector Strings; UStringVector Strings;
int soleDir;
bool m_bOpenOutputFolder; bool m_bOpenOutputFolder;
bool m_bDeleteSourceFile; bool m_bDeleteSourceFile;
bool m_bClose7Zip; bool m_bClose7Zip;