This commit is contained in:
glachancecmaisonneuve
2019-04-04 02:12:44 -04:00
parent a6e2c7e401
commit aec3e4502e
30 changed files with 1082 additions and 60 deletions

View File

@@ -39,6 +39,7 @@ extern DWORD g_ComCtl32Version;
extern HINSTANCE g_hInstance;
#define kTempDirPrefix FTEXT("7zE")
extern bool g_bProcessError;
void CPanelCallbackImp::OnTab()
{
@@ -282,6 +283,9 @@ void CApp::SaveToolbarChanges()
}
void MyLoadMenu();
HRESULT CApp::Create(HWND hwnd, const UString &mainPath, const UString &arcFormat, int xSizes[2], bool needOpenArc, bool &archiveIsOpened, bool &encrypted)
{
_window.Attach(hwnd);
@@ -544,6 +548,12 @@ UString CPanel::GetItemsInfoString(const CRecordVector<UInt32> &indices)
bool IsCorrectFsName(const UString &name);
static bool IsDirectory(LPCWSTR lpszPathFile)
{
DWORD dwAttr;
dwAttr = GetFileAttributesW(lpszPathFile);
return (dwAttr != (DWORD)-1) && ((dwAttr & FILE_ATTRIBUTE_DIRECTORY) != 0);
}
/* Returns true, if path is path that can be used as path for File System functions
@@ -580,6 +590,9 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
CRecordVector<UInt32> indices;
UString destPath;
bool openOutputFolder;
bool deleteSourceFile;
bool close7Zip;
bool useDestPanel = false;
{
@@ -618,10 +631,15 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
LangString(move ? IDS_MOVE : IDS_COPY, copyDialog.Title);
LangString(move ? IDS_MOVE_TO : IDS_COPY_TO, copyDialog.Static);
copyDialog.Info = srcPanel.GetItemsInfoString(indices);
copyDialog.m_currentFolderPrefix = srcPanel._currentFolderPrefix;
if (copyDialog.Create(srcPanel.GetParent()) != IDOK)
return;
openOutputFolder = copyDialog.m_bOpenOutputFolder;
deleteSourceFile = copyDialog.m_bDeleteSourceFile;
close7Zip = copyDialog.m_bClose7Zip;
destPath = copyDialog.Value;
}
@@ -715,7 +733,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
UString name = destPath.Ptr(pos + 1);
if (name.Find(L':') >= 0)
{
srcPanel.MessageBox_Error_UnsupportOperation();
srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED);
return;
}
#endif
@@ -753,6 +771,8 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
SaveCopyHistory(copyFolders);
}
g_bProcessError = false;
bool useSrcPanel = !useDestPanel || !srcPanel.Is_IO_FS_Folder();
bool useTemp = useSrcPanel && useDestPanel;
@@ -848,6 +868,62 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
disableNotify1.Restore();
disableNotify2.Restore();
srcPanel.SetFocusToList();
if (!g_bProcessError && result == S_OK)
{
if (openOutputFolder && IsDirectory(destPath))
{
StartApplicationDontWait(destPath, destPath, (HWND)_window);
}
if (deleteSourceFile)
{
DWORD dwAttr;
UString srcFilePath(srcPanel._currentFolderPrefix);
srcPanel.OpenParentFolder();
while (!srcFilePath.IsEmpty())
{
if (srcFilePath.Back() == '\\')
{
srcFilePath.DeleteBack();
}
dwAttr = GetFileAttributesW(srcFilePath);
if (dwAttr == INVALID_FILE_ATTRIBUTES)
{
int n = srcFilePath.ReverseFind(L'\\');
if (n != -1)
{
srcPanel.OpenParentFolder();
srcFilePath.ReleaseBuf_SetEnd(n);
}
else
{
break;
}
}
else if (dwAttr & FILE_ATTRIBUTE_ARCHIVE)
{
if (dwAttr & FILE_ATTRIBUTE_READONLY)
{
dwAttr &= (~FILE_ATTRIBUTE_READONLY);
SetFileAttributesW(srcFilePath, dwAttr);
}
::DeleteFileW(srcFilePath);
break;
}
else //if (dwAttr & FILE_ATTRIBUTE_DIRECTORY)
{
break;
}
} // while
}
if (close7Zip)
{
PostMessage (_window, WM_CLOSE, 0, 0);
}
}
}
void CApp::OnSetSameFolder(int srcPanelIndex)
@@ -887,7 +963,7 @@ void CApp::OnSetSubFolder(int srcPanelIndex)
destPanel.BindToPath(parentPrefix, UString(), archiveIsOpened, encrypted);
destPanel.RefreshListCtrl();
return;
}
}
}
else
{