Skip to content

Commit

Permalink
copy history excludes appended filename path segment; always check op…
Browse files Browse the repository at this point in the history
…en output folder, unless manually changing registry
  • Loading branch information
shunf4 committed Sep 2, 2024
1 parent fb962a8 commit dee3259
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
4 changes: 3 additions & 1 deletion CPP/7zip/UI/FileManager/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ void CApp::OnCopy(bool move, bool copyToSame, unsigned srcPanelIndex)

CRecordVector<UInt32> indices;
UString destPath;
UString destPathBeforeAppendingFilename;
bool openOutputFolder;
bool deleteSourceFile;
bool close7Zip;
Expand Down Expand Up @@ -663,6 +664,7 @@ void CApp::OnCopy(bool move, bool copyToSame, unsigned srcPanelIndex)
close7Zip = copyDialog.m_bClose7Zip;

destPath = copyDialog.Value;
destPathBeforeAppendingFilename = copyDialog.isActuallyAppendingFilename ? copyDialog.ValueBeforeAppendingFilename : destPath;
}

{
Expand Down Expand Up @@ -787,7 +789,7 @@ void CApp::OnCopy(bool move, bool copyToSame, unsigned srcPanelIndex)
if (!destIsFsPath)
useDestPanel = true;

AddUniqueStringToHeadOfList(copyFolders, destPath);
AddUniqueStringToHeadOfList(copyFolders, destPathBeforeAppendingFilename);
while (copyFolders.Size() > 20)
copyFolders.DeleteBack();
SaveCopyHistory(copyFolders);
Expand Down
5 changes: 5 additions & 0 deletions CPP/7zip/UI/FileManager/CopyDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ bool CCopyDialog::OnInit()
m_sizeMinWindow.cy = (RECT_SIZE_Y(rc))*4/5;
/////////////////////////////////////////////////////////
m_strRealFileName.Empty();
ValueBeforeAppendingFilename.Empty();
if (IsDirectory(m_currentFolderPrefix))
{
EnableItem(IDC_COPY_ADD_FILE_NAME, false);
Expand Down Expand Up @@ -264,12 +265,16 @@ void CCopyDialog::OnButtonAddFileName()
}
if (strLastDir != m_strRealFileName)
{
ValueBeforeAppendingFilename = currentPath;
currentPath += L'\\';
currentPath += m_strRealFileName;

_path.SetText(currentPath);

isActuallyAppendingFilename = true;
} else {
_path.SetText(currentPath.Mid(0, n));
isActuallyAppendingFilename = false;
}
_path.SetFocus();
}
Expand Down
6 changes: 5 additions & 1 deletion CPP/7zip/UI/FileManager/CopyDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CCopyDialog: public NWindows::NControl::CModalDialog

public:
// soleDir=2: undecided
CCopyDialog(): soleDir(2), m_bOpenOutputFolder(false), m_bDeleteSourceFile(false), m_bClose7Zip (false) { m_sizeMinWindow.cx = 0; m_sizeMinWindow.cy = 0; }
CCopyDialog(): soleDir(2), m_bOpenOutputFolder(false), m_bDeleteSourceFile(false), m_bClose7Zip (false), isActuallyAppendingFilename(false) { m_sizeMinWindow.cx = 0; m_sizeMinWindow.cy = 0; }

UString Title;
UString Static;
Expand All @@ -48,6 +48,10 @@ class CCopyDialog: public NWindows::NControl::CModalDialog
UString m_currentFolderPrefix;
UString m_strRealFileName;

UString ValueBeforeAppendingFilename;

bool isActuallyAppendingFilename;

INT_PTR Create(HWND parentWindow = NULL) { return CModalDialog::Create(IDD_COPY, parentWindow); }

bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
Expand Down
11 changes: 6 additions & 5 deletions CPP/7zip/UI/FileManager/ViewSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,19 +317,20 @@ void AddUniqueStringToHeadOfList(UStringVector &list, const UString &s)

void SaveOptOpenOutputFolder(bool bOpen)
{
CKey key;
key.Create(HKEY_CURRENT_USER, kCUBasePath);
key.SetValue(kOpenOutputFolderValueName, bOpen);
// CKey key;
// key.Create(HKEY_CURRENT_USER, kCUBasePath);
// key.SetValue(kOpenOutputFolderValueName, bOpen);
(void)(bOpen);
}

bool ReadOptOpenOutputFolder()
{
CKey key;
if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS)
return false;
return true;
bool bOpen;
if (key.QueryValue(kOpenOutputFolderValueName, bOpen) != ERROR_SUCCESS)
return false;
return true;
return bOpen;
}

Expand Down

0 comments on commit dee3259

Please sign in to comment.