mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-11 14:07:13 -06:00
Update to 7-Zip Version 21.02
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
|
||||
#include "../../MyVersion.h"
|
||||
|
||||
#include "../Common/LoadCodecs.h"
|
||||
|
||||
#include "AboutDialog.h"
|
||||
#include "PropertyNameRes.h"
|
||||
|
||||
@@ -24,8 +26,20 @@ static const UInt32 kLangIDs[] =
|
||||
#define LLL_(quote) L##quote
|
||||
#define LLL(quote) LLL_(quote)
|
||||
|
||||
extern CCodecs *g_CodecsObj;
|
||||
|
||||
bool CAboutDialog::OnInit()
|
||||
{
|
||||
#ifdef EXTERNAL_CODECS
|
||||
if (g_CodecsObj)
|
||||
{
|
||||
UString s;
|
||||
g_CodecsObj->GetCodecsErrorMessage(s);
|
||||
if (!s.IsEmpty())
|
||||
MessageBoxW(GetParent(), s, L"7-Zip", MB_ICONERROR);
|
||||
}
|
||||
#endif
|
||||
|
||||
LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs));
|
||||
SetItemText(IDT_ABOUT_VERSION, UString("7-Zip " MY_VERSION_CPU));
|
||||
SetItemText(IDT_ABOUT_DATE, LLL(MY_DATE));
|
||||
|
||||
@@ -19,7 +19,7 @@ CAPTION "About 7-Zip"
|
||||
DEFPUSHBUTTON "OK", IDOK, bx3-10, by, bxs, bys
|
||||
PUSHBUTTON "www.7-zip.org", IDB_ABOUT_HOMEPAGE, bx2-10, by, bxs, bys
|
||||
PUSHBUTTON "7-Zip ZS Hompeage", IDB_ABOUT_HOMEPAGE2, bx1-10, by, bxs+10, bys
|
||||
ICON IDI_LOGO, -1, m, m, 32, 32, SS_REALSIZEIMAGE,
|
||||
ICON IDI_LOGO, -1, m, m, 32, 32, SS_REALSIZEIMAGE
|
||||
LTEXT "", IDT_ABOUT_VERSION, m, 54, xc, 8
|
||||
LTEXT "", IDT_ABOUT_DATE, m, 67, xc, 8
|
||||
LTEXT MY_COPYRIGHT_CR, -1, m, 80, xc, 8
|
||||
|
||||
@@ -86,7 +86,7 @@ HRESULT CAltStreamsFolder::Init(const FString &path /* , IFolderFolder *parentFo
|
||||
{
|
||||
CFileInfo fi;
|
||||
if (!fi.Find(_pathBaseFile))
|
||||
return GetLastError();
|
||||
return GetLastError_noZero_HRESULT();
|
||||
}
|
||||
|
||||
unsigned prefixSize = GetFsParentPrefixSize(_pathBaseFile);
|
||||
@@ -612,7 +612,7 @@ static HRESULT CopyStream(
|
||||
FString destPath = destPathSpec;
|
||||
if (CompareFileNames(destPath, srcPath) == 0)
|
||||
{
|
||||
RINOK(SendMessageError(callback, "can not copy file onto itself", destPath));
|
||||
RINOK(SendMessageError(callback, "Cannot copy file onto itself", destPath));
|
||||
return E_ABORT;
|
||||
}
|
||||
|
||||
@@ -716,7 +716,7 @@ STDMETHODIMP CAltStreamsFolder::CopyTo(Int32 moveMode, const UInt32 *indices, UI
|
||||
if (destPath.IsEmpty() /* && !ExtractToStreamCallback */)
|
||||
return E_INVALIDARG;
|
||||
|
||||
bool isAltDest = NName::IsAltPathPrefix(destPath);;
|
||||
bool isAltDest = NName::IsAltPathPrefix(destPath);
|
||||
bool isDirectPath = (!isAltDest && !IsPathSepar(destPath.Back()));
|
||||
|
||||
if (isDirectPath)
|
||||
@@ -764,7 +764,7 @@ STDMETHODIMP CAltStreamsFolder::CopyFrom(Int32 /* moveMode */, const wchar_t * /
|
||||
|
||||
if (CompareFileNames(fromFolderPath, fs2us(_pathPrefix)) == 0)
|
||||
{
|
||||
RINOK(SendMessageError(callback, "can not copy file onto itself", _pathPrefix));
|
||||
RINOK(SendMessageError(callback, "Cannot copy file onto itself", _pathPrefix));
|
||||
return E_ABORT;
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ void CApp::SetListSettings()
|
||||
|
||||
HRESULT CApp::CreateOnePanel(int panelIndex, const UString &mainPath, const UString &arcFormat,
|
||||
bool needOpenArc,
|
||||
bool &archiveIsOpened, bool &encrypted)
|
||||
COpenResult &openRes)
|
||||
{
|
||||
if (Panels[panelIndex].PanelCreated)
|
||||
return S_OK;
|
||||
@@ -138,7 +138,7 @@ HRESULT CApp::CreateOnePanel(int panelIndex, const UString &mainPath, const UStr
|
||||
return Panels[panelIndex].Create(_window, _window,
|
||||
id, path, arcFormat, &m_PanelCallbackImp[panelIndex], &AppState,
|
||||
needOpenArc,
|
||||
archiveIsOpened, encrypted);
|
||||
openRes);
|
||||
}
|
||||
|
||||
|
||||
@@ -282,7 +282,7 @@ void CApp::SaveToolbarChanges()
|
||||
}
|
||||
|
||||
|
||||
HRESULT CApp::Create(HWND hwnd, const UString &mainPath, const UString &arcFormat, int xSizes[2], bool needOpenArc, bool &archiveIsOpened, bool &encrypted)
|
||||
HRESULT CApp::Create(HWND hwnd, const UString &mainPath, const UString &arcFormat, int xSizes[2], bool needOpenArc, COpenResult &openRes)
|
||||
{
|
||||
_window.Attach(hwnd);
|
||||
|
||||
@@ -334,21 +334,19 @@ HRESULT CApp::Create(HWND hwnd, const UString &mainPath, const UString &arcForma
|
||||
{
|
||||
if (NumPanels == 1)
|
||||
Panels[panelIndex]._xSize = xSizes[0] + xSizes[1];
|
||||
bool archiveIsOpened2 = false;
|
||||
bool encrypted2 = false;
|
||||
|
||||
COpenResult openRes2;
|
||||
UString path;
|
||||
if (isMainPanel)
|
||||
path = mainPath;
|
||||
|
||||
RINOK(CreateOnePanel(panelIndex, path, arcFormat,
|
||||
isMainPanel && needOpenArc,
|
||||
archiveIsOpened2, encrypted2));
|
||||
*(isMainPanel ? &openRes : &openRes2)));
|
||||
|
||||
if (isMainPanel)
|
||||
{
|
||||
archiveIsOpened = archiveIsOpened2;
|
||||
encrypted = encrypted2;
|
||||
if (needOpenArc && !archiveIsOpened2)
|
||||
if (needOpenArc && !openRes.ArchiveIsOpened)
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
@@ -365,10 +363,10 @@ HRESULT CApp::SwitchOnOffOnePanel()
|
||||
if (NumPanels == 1)
|
||||
{
|
||||
NumPanels++;
|
||||
bool archiveIsOpened, encrypted;
|
||||
COpenResult openRes;
|
||||
RINOK(CreateOnePanel(1 - LastFocusedPanel, UString(), UString(),
|
||||
false, // needOpenArc
|
||||
archiveIsOpened, encrypted));
|
||||
openRes));
|
||||
Panels[1 - LastFocusedPanel].Enable(true);
|
||||
Panels[1 - LastFocusedPanel].Show(SW_SHOWNORMAL);
|
||||
}
|
||||
@@ -414,13 +412,13 @@ void CApp::Release()
|
||||
|
||||
// reduces path to part that exists on disk (or root prefix of path)
|
||||
// output path is normalized (with WCHAR_PATH_SEPARATOR)
|
||||
static void ReducePathToRealFileSystemPath(UString &path)
|
||||
static void Reduce_Path_To_RealFileSystemPath(UString &path)
|
||||
{
|
||||
unsigned prefixSize = GetRootPrefixSize(path);
|
||||
|
||||
while (!path.IsEmpty())
|
||||
{
|
||||
if (NFind::DoesDirExist(us2fs(path)))
|
||||
if (NFind::DoesDirExist_FollowLink(us2fs(path)))
|
||||
{
|
||||
NName::NormalizeDirPathPrefix(path);
|
||||
break;
|
||||
@@ -431,10 +429,10 @@ static void ReducePathToRealFileSystemPath(UString &path)
|
||||
path.Empty();
|
||||
break;
|
||||
}
|
||||
path.DeleteFrom(pos + 1);
|
||||
path.DeleteFrom((unsigned)(pos + 1));
|
||||
if ((unsigned)pos + 1 == prefixSize)
|
||||
break;
|
||||
path.DeleteFrom(pos);
|
||||
path.DeleteFrom((unsigned)pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,7 +441,7 @@ static void ReducePathToRealFileSystemPath(UString &path)
|
||||
static bool CheckFolderPath(const UString &path)
|
||||
{
|
||||
UString pathReduced = path;
|
||||
ReducePathToRealFileSystemPath(pathReduced);
|
||||
Reduce_Path_To_RealFileSystemPath(pathReduced);
|
||||
return (pathReduced == path);
|
||||
}
|
||||
*/
|
||||
@@ -463,6 +461,7 @@ static void AddValuePair1(UString &s, UINT resourceID, UInt64 size)
|
||||
s.Add_LF();
|
||||
}
|
||||
|
||||
void AddValuePair2(UString &s, UINT resourceID, UInt64 num, UInt64 size);
|
||||
void AddValuePair2(UString &s, UINT resourceID, UInt64 num, UInt64 size)
|
||||
{
|
||||
if (num == 0)
|
||||
@@ -601,7 +600,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
|
||||
return;
|
||||
destPath = destPanel.GetFsPath();
|
||||
if (NumPanels == 1)
|
||||
ReducePathToRealFileSystemPath(destPath);
|
||||
Reduce_Path_To_RealFileSystemPath(destPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -660,7 +659,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
|
||||
{
|
||||
if (NumPanels == 1 || CompareFileNames(destPath, srcPanel.GetFsPath()) == 0)
|
||||
{
|
||||
srcPanel.MessageBox_Error(L"Can not copy files onto itself");
|
||||
srcPanel.MessageBox_Error(L"Cannot copy files onto itself");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -882,9 +881,11 @@ void CApp::OnSetSubFolder(int srcPanelIndex)
|
||||
return;
|
||||
if (!newFolder)
|
||||
{
|
||||
const UString parentPrefix = srcPanel.GetParentDirPrefix();
|
||||
bool archiveIsOpened, encrypted;
|
||||
destPanel.BindToPath(parentPrefix, UString(), archiveIsOpened, encrypted);
|
||||
{
|
||||
const UString parentPrefix = srcPanel.GetParentDirPrefix();
|
||||
COpenResult openRes;
|
||||
destPanel.BindToPath(parentPrefix, UString(), openRes);
|
||||
}
|
||||
destPanel.RefreshListCtrl();
|
||||
return;
|
||||
}
|
||||
@@ -936,7 +937,7 @@ void CApp::OnNotify(int /* ctrlID */, LPNMHDR pnmh)
|
||||
g_ToolTipBuffer.Empty();
|
||||
SetButtonText((int)info->hdr.idFrom, g_ToolTipBuffer);
|
||||
g_ToolTipBufferSys = GetSystemString(g_ToolTipBuffer);
|
||||
info->lpszText = (LPTSTR)(LPCTSTR)g_ToolTipBufferSys;
|
||||
info->lpszText = g_ToolTipBufferSys.Ptr_non_const();
|
||||
return;
|
||||
}
|
||||
#ifndef _UNICODE
|
||||
@@ -946,7 +947,7 @@ void CApp::OnNotify(int /* ctrlID */, LPNMHDR pnmh)
|
||||
info->hinst = 0;
|
||||
g_ToolTipBuffer.Empty();
|
||||
SetButtonText((int)info->hdr.idFrom, g_ToolTipBuffer);
|
||||
info->lpszText = (LPWSTR)(LPCWSTR)g_ToolTipBuffer;
|
||||
info->lpszText = g_ToolTipBuffer.Ptr_non_const();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -971,7 +972,7 @@ void CApp::RefreshTitlePanel(unsigned panelIndex, bool always)
|
||||
RefreshTitle(always);
|
||||
}
|
||||
|
||||
void AddUniqueStringToHead(UStringVector &list, const UString &s)
|
||||
static void AddUniqueStringToHead(UStringVector &list, const UString &s)
|
||||
{
|
||||
for (unsigned i = 0; i < list.Size();)
|
||||
if (s.IsEqualTo_NoCase(list[i]))
|
||||
|
||||
@@ -89,22 +89,24 @@ public:
|
||||
STDMETHOD(Drop)(IDataObject * dataObject, DWORD keyState, POINTL pt, DWORD *effect);
|
||||
|
||||
CDropTarget():
|
||||
TargetPanelIndex(-1),
|
||||
SrcPanelIndex(-1),
|
||||
m_IsAppTarget(false),
|
||||
m_Panel(0),
|
||||
App(0),
|
||||
m_PanelDropIsAllowed(false),
|
||||
m_DropIsAllowed(false),
|
||||
m_SelectionIndex(-1),
|
||||
m_DropIsAllowed(false),
|
||||
m_PanelDropIsAllowed(false),
|
||||
m_SubFolderIndex(-1),
|
||||
m_SetPathIsOK(false) {}
|
||||
m_Panel(NULL),
|
||||
m_IsAppTarget(false),
|
||||
m_SetPathIsOK(false),
|
||||
App(NULL),
|
||||
SrcPanelIndex(-1),
|
||||
TargetPanelIndex(-1)
|
||||
{}
|
||||
|
||||
CApp *App;
|
||||
int SrcPanelIndex; // index of D&D source_panel
|
||||
int TargetPanelIndex; // what panel to use as target_panel of Application
|
||||
};
|
||||
|
||||
|
||||
class CApp
|
||||
{
|
||||
public:
|
||||
@@ -173,8 +175,8 @@ public:
|
||||
void OnSetSameFolder(int srcPanelIndex);
|
||||
void OnSetSubFolder(int srcPanelIndex);
|
||||
|
||||
HRESULT CreateOnePanel(int panelIndex, const UString &mainPath, const UString &arcFormat, bool needOpenArc, bool &archiveIsOpened, bool &encrypted);
|
||||
HRESULT Create(HWND hwnd, const UString &mainPath, const UString &arcFormat, int xSizes[2], bool needOpenArc, bool &archiveIsOpened, bool &encrypted);
|
||||
HRESULT CreateOnePanel(int panelIndex, const UString &mainPath, const UString &arcFormat, bool needOpenArc, COpenResult &openRes);
|
||||
HRESULT Create(HWND hwnd, const UString &mainPath, const UString &arcFormat, int xSizes[2], bool needOpenArc, COpenResult &openRes);
|
||||
void Read();
|
||||
void Save();
|
||||
void Release();
|
||||
@@ -196,7 +198,12 @@ public:
|
||||
void Delete(bool toRecycleBin) { GetFocusedPanel().DeleteItems(toRecycleBin); }
|
||||
HRESULT CalculateCrc2(const UString &methodName);
|
||||
void CalculateCrc(const char *methodName);
|
||||
|
||||
void DiffFiles(const UString &path1, const UString &path2);
|
||||
void DiffFiles();
|
||||
|
||||
void VerCtrl(unsigned id);
|
||||
|
||||
void Split();
|
||||
void Combine();
|
||||
void Properties() { GetFocusedPanel().Properties(); }
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "../../../Common/MyWindows.h"
|
||||
|
||||
#include <commctrl.h>
|
||||
#include <CommCtrl.h>
|
||||
|
||||
#ifndef UNDER_CE
|
||||
#include "../../../Windows/CommonDialog.h"
|
||||
@@ -139,7 +139,7 @@ public:
|
||||
UStringVector Filters;
|
||||
UString FilterDescription;
|
||||
|
||||
CBrowseDialog(): FolderMode(false), _showDots(false), ShowAllFiles(true) {}
|
||||
CBrowseDialog(): _showDots(false), FolderMode(false), ShowAllFiles(true) {}
|
||||
void SetFilter(const UString &s);
|
||||
INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_BROWSE, parent); }
|
||||
int CompareItems(LPARAM lParam1, LPARAM lParam2);
|
||||
@@ -235,7 +235,7 @@ bool CBrowseDialog::OnInit()
|
||||
column.fmt = LVCFMT_RIGHT;
|
||||
column.cx = 100;
|
||||
const UString s = LangString(IDS_PROP_SIZE);
|
||||
column.pszText = (wchar_t *)(const wchar_t *)s;
|
||||
column.pszText = s.Ptr_non_const();
|
||||
_list.InsertColumn(2, &column);
|
||||
}
|
||||
|
||||
@@ -476,7 +476,7 @@ bool CBrowseDialog::GetParentPath(const UString &path, UString &parentPrefix, US
|
||||
return false;
|
||||
int pos = s.ReverseFind_PathSepar();
|
||||
parentPrefix.SetFrom(s, pos + 1);
|
||||
name = s.Ptr(pos + 1);
|
||||
name = s.Ptr((unsigned)(pos + 1));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -604,7 +604,7 @@ HRESULT CBrowseDialog::Reload(const UString &pathPrefix, const UString &selected
|
||||
int subItem = 0;
|
||||
item.iSubItem = subItem++;
|
||||
item.lParam = kParentIndex;
|
||||
item.pszText = (wchar_t *)(const wchar_t *)itemName;
|
||||
item.pszText = itemName.Ptr_non_const();
|
||||
item.iImage = _extToIconMap.GetIconIndex(FILE_ATTRIBUTE_DIRECTORY, DirPrefix);
|
||||
if (item.iImage < 0)
|
||||
item.iImage = 0;
|
||||
@@ -626,7 +626,7 @@ HRESULT CBrowseDialog::Reload(const UString &pathPrefix, const UString &selected
|
||||
int subItem = 0;
|
||||
item.iSubItem = subItem++;
|
||||
item.lParam = i;
|
||||
item.pszText = (wchar_t *)(const wchar_t *)name;
|
||||
item.pszText = name.Ptr_non_const();
|
||||
|
||||
const UString fullPath = DirPrefix + name;
|
||||
#ifndef UNDER_CE
|
||||
@@ -953,7 +953,7 @@ bool CorrectFsPath(const UString &relBase, const UString &path2, UString &result
|
||||
if (path.Back() == WCHAR_PATH_SEPARATOR)
|
||||
{
|
||||
path.DeleteBack();
|
||||
result.Insert(0, WCHAR_PATH_SEPARATOR);;
|
||||
result.Insert(0, WCHAR_PATH_SEPARATOR);
|
||||
}
|
||||
int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR) + 1;
|
||||
UString cur = path.Ptr(pos);
|
||||
|
||||
@@ -58,7 +58,7 @@ CEnumFormatEtc::~CEnumFormatEtc()
|
||||
for (ULONG i = 0; i < m_NumFormats; i++)
|
||||
if (m_Formats[i].ptd)
|
||||
CoTaskMemFree(m_Formats[i].ptd);
|
||||
delete[]m_Formats;
|
||||
delete []m_Formats;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#ifndef __ENUMFORMATETC_H
|
||||
#define __ENUMFORMATETC_H
|
||||
|
||||
#include <windows.h>
|
||||
#include "../../../Common/MyWindows.h"
|
||||
|
||||
HRESULT CreateEnumFormatEtc(UINT numFormats, const FORMATETC *formats, IEnumFORMATETC **enumFormat);
|
||||
|
||||
|
||||
@@ -262,6 +262,7 @@ STDMETHODIMP CExtractCallbackImp::ShowMessage(const wchar_t *s)
|
||||
|
||||
#endif
|
||||
|
||||
void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, const wchar_t *fileName, UString &s);
|
||||
void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, const wchar_t *fileName, UString &s)
|
||||
{
|
||||
s.Empty();
|
||||
@@ -449,6 +450,7 @@ static void AddNewLineString(UString &s, const UString &m)
|
||||
s.Add_LF();
|
||||
}
|
||||
|
||||
UString GetOpenArcErrorMessage(UInt32 errorFlags);
|
||||
UString GetOpenArcErrorMessage(UInt32 errorFlags)
|
||||
{
|
||||
UString s;
|
||||
@@ -523,6 +525,7 @@ static UString GetBracedType(const wchar_t *type)
|
||||
return s;
|
||||
}
|
||||
|
||||
void OpenResult_GUI(UString &s, const CCodecs *codecs, const CArchiveLink &arcLink, const wchar_t *name, HRESULT result);
|
||||
void OpenResult_GUI(UString &s, const CCodecs *codecs, const CArchiveLink &arcLink, const wchar_t *name, HRESULT result)
|
||||
{
|
||||
FOR_VECTOR (level, arcLink.Arcs)
|
||||
@@ -632,7 +635,9 @@ HRESULT CExtractCallbackImp::ExtractResult(HRESULT result)
|
||||
if (result == S_OK)
|
||||
return result;
|
||||
NumArchiveErrors++;
|
||||
if (result == E_ABORT || result == ERROR_DISK_FULL)
|
||||
if (result == E_ABORT
|
||||
|| result == HRESULT_FROM_WIN32(ERROR_DISK_FULL)
|
||||
)
|
||||
return result;
|
||||
|
||||
Add_ArchiveName_Error();
|
||||
@@ -702,7 +707,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
|
||||
{
|
||||
if (!destFileInfo.IsDir())
|
||||
{
|
||||
RINOK(MessageError("can not replace file with folder with same name", destPathSys));
|
||||
RINOK(MessageError("Cannot replace file with folder with same name", destPathSys));
|
||||
return E_ABORT;
|
||||
}
|
||||
*writeAnswer = BoolToInt(false);
|
||||
@@ -711,7 +716,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
|
||||
|
||||
if (destFileInfo.IsDir())
|
||||
{
|
||||
RINOK(MessageError("can not replace folder with file with same name", destPathSys));
|
||||
RINOK(MessageError("Cannot replace folder with file with same name", destPathSys));
|
||||
*writeAnswer = BoolToInt(false);
|
||||
return S_OK;
|
||||
}
|
||||
@@ -725,7 +730,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
|
||||
Int32 overwriteResult;
|
||||
UString destPathSpec = destPath;
|
||||
int slashPos = destPathSpec.ReverseFind_PathSepar();
|
||||
destPathSpec.DeleteFrom(slashPos + 1);
|
||||
destPathSpec.DeleteFrom((unsigned)(slashPos + 1));
|
||||
destPathSpec += fs2us(destFileInfo.Name);
|
||||
|
||||
RINOK(AskOverwrite(
|
||||
@@ -746,25 +751,28 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
|
||||
default:
|
||||
return E_FAIL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (OverwriteMode == NExtract::NOverwriteMode::kRename)
|
||||
{
|
||||
if (!AutoRenamePath(destPathSys))
|
||||
{
|
||||
RINOK(MessageError("can not create name for file", destPathSys));
|
||||
RINOK(MessageError("Cannot create name for file", destPathSys));
|
||||
return E_ABORT;
|
||||
}
|
||||
destPathResultTemp = fs2us(destPathSys);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (NFind::DoesFileExist(destPathSys))
|
||||
if (NFind::DoesFileExist_Raw(destPathSys))
|
||||
if (!NDir::DeleteFileAlways(destPathSys))
|
||||
if (GetLastError() != ERROR_FILE_NOT_FOUND)
|
||||
{
|
||||
RINOK(MessageError("can not delete output file", destPathSys));
|
||||
RINOK(MessageError("Cannot delete output file", destPathSys));
|
||||
return E_ABORT;
|
||||
}
|
||||
}
|
||||
@@ -950,9 +958,8 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult7(Int32 opRes, Int32 encrypt
|
||||
}
|
||||
|
||||
|
||||
static const size_t k_SizeT_MAX = (size_t)((size_t)0 - 1);
|
||||
|
||||
static const UInt32 kBlockSize = ((UInt32)1 << 31);
|
||||
// static const UInt32 kBlockSize = ((UInt32)1 << 31);
|
||||
|
||||
STDMETHODIMP CVirtFileSystem::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
@@ -977,8 +984,9 @@ STDMETHODIMP CVirtFileSystem::Write(const void *data, UInt32 size, UInt32 *proce
|
||||
if (b < a)
|
||||
b = a;
|
||||
useMem = false;
|
||||
if (b <= k_SizeT_MAX && b <= MaxTotalAllocSize)
|
||||
useMem = file.Data.ReAlloc_KeepData((size_t)b, (size_t)file.Size);
|
||||
const size_t b_sizet = (size_t)b;
|
||||
if (b == b_sizet && b <= MaxTotalAllocSize)
|
||||
useMem = file.Data.ReAlloc_KeepData(b_sizet, (size_t)file.Size);
|
||||
}
|
||||
if (useMem)
|
||||
{
|
||||
|
||||
@@ -289,21 +289,19 @@ public:
|
||||
bool MultiArcMode;
|
||||
|
||||
CExtractCallbackImp():
|
||||
#ifndef _SFX
|
||||
_hashCalc(NULL),
|
||||
#endif
|
||||
ProcessAltStreams(true),
|
||||
StreamMode(false),
|
||||
OverwriteMode(NExtract::NOverwriteMode::kAsk),
|
||||
#ifndef _NO_CRYPTO
|
||||
PasswordIsDefined(false),
|
||||
PasswordWasAsked(false),
|
||||
#endif
|
||||
OverwriteMode(NExtract::NOverwriteMode::kAsk),
|
||||
StreamMode(false),
|
||||
ProcessAltStreams(true),
|
||||
|
||||
_totalFilesDefined(false),
|
||||
_totalBytesDefined(false),
|
||||
MultiArcMode(false)
|
||||
|
||||
#ifndef _SFX
|
||||
, _hashCalc(NULL)
|
||||
#endif
|
||||
{}
|
||||
|
||||
~CExtractCallbackImp();
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "../../../Common/MyWindows.h"
|
||||
|
||||
#include <shlwapi.h>
|
||||
#include <Shlwapi.h>
|
||||
|
||||
#include "../../../../C/Alloc.h"
|
||||
#ifdef _WIN32
|
||||
@@ -40,19 +40,24 @@ using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NFind;
|
||||
|
||||
#define MAX_LOADSTRING 100
|
||||
|
||||
#define MENU_HEIGHT 26
|
||||
// #define MAX_LOADSTRING 100
|
||||
|
||||
extern
|
||||
bool g_RAM_Size_Defined;
|
||||
bool g_LargePagesMode = false;
|
||||
bool g_OpenArchive = false;
|
||||
bool g_RAM_Size_Defined;
|
||||
|
||||
static bool g_LargePagesMode = false;
|
||||
// static bool g_OpenArchive = false;
|
||||
|
||||
static bool g_Maximized = false;
|
||||
|
||||
extern
|
||||
UInt64 g_RAM_Size;
|
||||
UInt64 g_RAM_Size;
|
||||
|
||||
#ifdef _WIN32
|
||||
extern
|
||||
HINSTANCE g_hInstance;
|
||||
HINSTANCE g_hInstance;
|
||||
#endif
|
||||
|
||||
@@ -66,6 +71,8 @@ void FreeGlobalCodecs();
|
||||
|
||||
#ifndef UNDER_CE
|
||||
|
||||
extern
|
||||
DWORD g_ComCtl32Version;
|
||||
DWORD g_ComCtl32Version;
|
||||
|
||||
static DWORD GetDllVersion(LPCTSTR dllName)
|
||||
@@ -74,7 +81,7 @@ static DWORD GetDllVersion(LPCTSTR dllName)
|
||||
HINSTANCE hinstDll = LoadLibrary(dllName);
|
||||
if (hinstDll)
|
||||
{
|
||||
DLLGETVERSIONPROC pDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hinstDll, "DllGetVersion");
|
||||
DLLGETVERSIONPROC pDllGetVersion = (DLLGETVERSIONPROC)(void *)GetProcAddress(hinstDll, "DllGetVersion");
|
||||
if (pDllGetVersion)
|
||||
{
|
||||
DLLVERSIONINFO dvi;
|
||||
@@ -93,19 +100,19 @@ static DWORD GetDllVersion(LPCTSTR dllName)
|
||||
|
||||
bool g_IsSmallScreen = false;
|
||||
|
||||
extern
|
||||
bool g_LVN_ITEMACTIVATE_Support;
|
||||
bool g_LVN_ITEMACTIVATE_Support = true;
|
||||
// LVN_ITEMACTIVATE replaces both NM_DBLCLK & NM_RETURN
|
||||
// Windows 2000
|
||||
// NT/98 + IE 3 (g_ComCtl32Version >= 4.70)
|
||||
|
||||
|
||||
const int kNumDefaultPanels = 1;
|
||||
static const int kNumDefaultPanels = 1;
|
||||
static const int kSplitterWidth = 4;
|
||||
static const int kSplitterRateMax = 1 << 16;
|
||||
static const int kPanelSizeMin = 120;
|
||||
|
||||
const int kSplitterWidth = 4;
|
||||
int kSplitterRateMax = 1 << 16;
|
||||
int kPanelSizeMin = 120;
|
||||
|
||||
// bool OnMenuCommand(HWND hWnd, int id);
|
||||
|
||||
class CSplitterPos
|
||||
{
|
||||
@@ -343,7 +350,7 @@ typedef BOOL (WINAPI *Func_IsWow64Process)(HANDLE, PBOOL);
|
||||
static void Set_Wow64()
|
||||
{
|
||||
g_Is_Wow64 = false;
|
||||
Func_IsWow64Process fnIsWow64Process = (Func_IsWow64Process)GetProcAddress(
|
||||
Func_IsWow64Process fnIsWow64Process = (Func_IsWow64Process)(void *)GetProcAddress(
|
||||
GetModuleHandleA("kernel32.dll"), "IsWow64Process");
|
||||
if (fnIsWow64Process)
|
||||
{
|
||||
@@ -356,6 +363,7 @@ static void Set_Wow64()
|
||||
#endif
|
||||
|
||||
|
||||
bool IsLargePageSupported();
|
||||
bool IsLargePageSupported()
|
||||
{
|
||||
#ifdef _WIN64
|
||||
@@ -383,7 +391,7 @@ static void SetMemoryLock()
|
||||
if (!IsLargePageSupported())
|
||||
return;
|
||||
// if (ReadLockMemoryAdd())
|
||||
NSecurity::AddLockMemoryPrivilege();
|
||||
NSecurity::AddLockMemoryPrivilege();
|
||||
|
||||
if (ReadLockMemoryEnable())
|
||||
if (NSecurity::Get_LargePages_RiskLevel() == 0)
|
||||
@@ -393,6 +401,8 @@ static void SetMemoryLock()
|
||||
}
|
||||
}
|
||||
|
||||
extern
|
||||
bool g_SymLink_Supported;
|
||||
bool g_SymLink_Supported = false;
|
||||
|
||||
static void Set_SymLink_Supported()
|
||||
@@ -443,7 +453,9 @@ static void ErrorMessage(const char *s)
|
||||
}
|
||||
|
||||
|
||||
#if defined(_UNICODE) && !defined(_WIN64) && !defined(UNDER_CE)
|
||||
#define NT_CHECK_FAIL_ACTION ErrorMessage("Unsupported Windows version"); return 1;
|
||||
#endif
|
||||
|
||||
static int WINAPI WinMain2(int nCmdShow)
|
||||
{
|
||||
@@ -756,12 +768,12 @@ static void ExecuteCommand(UINT commandID)
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
int wmId, wmEvent;
|
||||
switch (message)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
wmId = LOWORD(wParam);
|
||||
wmEvent = HIWORD(wParam);
|
||||
{
|
||||
unsigned wmId = LOWORD(wParam);
|
||||
unsigned wmEvent = HIWORD(wParam);
|
||||
if ((HWND) lParam != NULL && wmEvent != 0)
|
||||
break;
|
||||
if (wmId >= kMenuCmdID_Toolbar_Start && wmId < kMenuCmdID_Toolbar_End)
|
||||
@@ -772,6 +784,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
if (OnMenuCommand(hWnd, wmId))
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
case WM_INITMENUPOPUP:
|
||||
OnMenuActivating(hWnd, HMENU(wParam), LOWORD(lParam));
|
||||
break;
|
||||
@@ -837,9 +850,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
g_App.CreateDragTarget();
|
||||
|
||||
bool archiveIsOpened;
|
||||
bool encrypted;
|
||||
bool needOpenFile = false;
|
||||
COpenResult openRes;
|
||||
bool needOpenArc = false;
|
||||
|
||||
UString fullPath = g_MainPath;
|
||||
if (!fullPath.IsEmpty() /* && g_OpenArchive */)
|
||||
@@ -850,29 +862,34 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
if (NFile::NName::GetFullPath(us2fs(fullPath), fullPathF))
|
||||
fullPath = fs2us(fullPathF);
|
||||
}
|
||||
if (NFile::NFind::DoesFileExist(us2fs(fullPath)))
|
||||
needOpenFile = true;
|
||||
if (NFile::NFind::DoesFileExist_FollowLink(us2fs(fullPath)))
|
||||
needOpenArc = true;
|
||||
}
|
||||
|
||||
HRESULT res = g_App.Create(hWnd, fullPath, g_ArcFormat, xSizes,
|
||||
needOpenFile,
|
||||
archiveIsOpened, encrypted);
|
||||
needOpenArc,
|
||||
openRes);
|
||||
|
||||
if (res == E_ABORT)
|
||||
return -1;
|
||||
|
||||
if (needOpenFile && !archiveIsOpened || res != S_OK)
|
||||
if ((needOpenArc && !openRes.ArchiveIsOpened) || res != S_OK)
|
||||
{
|
||||
UString m ("Error");
|
||||
if (res == S_FALSE || res == S_OK)
|
||||
{
|
||||
m = MyFormatNew(encrypted ?
|
||||
m = MyFormatNew(openRes.Encrypted ?
|
||||
IDS_CANT_OPEN_ENCRYPTED_ARCHIVE :
|
||||
IDS_CANT_OPEN_ARCHIVE,
|
||||
fullPath);
|
||||
}
|
||||
else if (res != S_OK)
|
||||
m = HResultToMessage(res);
|
||||
if (!openRes.ErrorMessage.IsEmpty())
|
||||
{
|
||||
m.Add_LF();
|
||||
m += openRes.ErrorMessage;
|
||||
}
|
||||
ErrorMessage(m);
|
||||
return -1;
|
||||
}
|
||||
@@ -954,7 +971,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
g_Panel[1]._listView.MoveWindow(xSize - xWidth, 0, xWidth, ySize);
|
||||
*/
|
||||
return 0;
|
||||
break;
|
||||
// break;
|
||||
}
|
||||
|
||||
case WM_SETFOCUS:
|
||||
|
||||
@@ -55,7 +55,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib Mpr.lib htmlhelp.lib Urlmon.lib /nologo /subsystem:windows /machine:I386 /out:"C:\Program Files\7-ZIP\7zFM.exe" /opt:NOWIN98
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib Mpr.lib htmlhelp.lib Urlmon.lib /nologo /subsystem:windows /machine:I386 /out:"C:\Util\7zFM.exe" /opt:NOWIN98
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "FM - Win32 Debug"
|
||||
@@ -82,7 +82,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib Mpr.lib htmlhelp.lib Urlmon.lib /nologo /subsystem:windows /debug /machine:I386 /out:"C:\Program Files\7-ZIP\7zFM.exe" /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib Mpr.lib htmlhelp.lib Urlmon.lib /nologo /subsystem:windows /debug /machine:I386 /out:"C:\Util\7zFM.exe" /pdbtype:sept
|
||||
|
||||
!ELSEIF "$(CFG)" == "FM - Win32 ReleaseU"
|
||||
|
||||
@@ -109,7 +109,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib Mpr.lib htmlhelp.lib Urlmon.lib /nologo /subsystem:windows /machine:I386 /out:"C:\Program Files\7-ZIP\7zFM.exe" /opt:NOWIN98
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib Mpr.lib htmlhelp.lib Urlmon.lib /nologo /subsystem:windows /machine:I386 /out:"C:\Util\7zFM.exe" /opt:NOWIN98
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "FM - Win32 DebugU"
|
||||
@@ -137,7 +137,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib Mpr.lib htmlhelp.lib Urlmon.lib /nologo /subsystem:windows /debug /machine:I386 /out:"C:\Program Files\7-ZIP\7zFM.exe" /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib Mpr.lib htmlhelp.lib Urlmon.lib /nologo /subsystem:windows /debug /machine:I386 /out:"C:\Util\7zFM.exe" /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
@@ -393,6 +393,10 @@ SOURCE=.\PanelSort.cpp
|
||||
|
||||
SOURCE=.\PanelSplitFile.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\VerCtrl.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Dialog"
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ LIBS = $(LIBS) ceshell.lib Commctrl.lib
|
||||
!ELSE
|
||||
LIBS = $(LIBS) comctl32.lib htmlhelp.lib comdlg32.lib Mpr.lib Gdi32.lib
|
||||
CFLAGS = $(CFLAGS) -DWIN_LONG_PATH -DSUPPORT_DEVICE_FILE
|
||||
LFLAGS = $(LFLAGS) /DELAYLOAD:mpr.dll
|
||||
LIBS = $(LIBS) delayimp.lib
|
||||
LFLAGS = $(LFLAGS) /DELAYLOAD:mpr.dll
|
||||
LIBS = $(LIBS) delayimp.lib
|
||||
!ENDIF
|
||||
|
||||
FM_OBJS = \
|
||||
@@ -70,6 +70,7 @@ FM_OBJS = \
|
||||
$O\SettingsPage.obj \
|
||||
$O\SplitDialog.obj \
|
||||
$O\SystemPage.obj \
|
||||
$O\VerCtrl.obj \
|
||||
|
||||
!IFNDEF UNDER_CE
|
||||
|
||||
|
||||
@@ -115,15 +115,15 @@ HRESULT CFsFolderStat::Enumerate()
|
||||
const unsigned len = Path.Len();
|
||||
CEnumerator enumerator;
|
||||
enumerator.SetDirPrefix(Path);
|
||||
CFileInfo fi;
|
||||
CDirEntry fi;
|
||||
while (enumerator.Next(fi))
|
||||
{
|
||||
if (fi.IsDir())
|
||||
{
|
||||
NumFolders++;
|
||||
Path.DeleteFrom(len);
|
||||
Path += fi.Name;
|
||||
RINOK(Enumerate());
|
||||
NumFolders++;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -136,6 +136,7 @@ HRESULT CFsFolderStat::Enumerate()
|
||||
|
||||
#ifndef UNDER_CE
|
||||
|
||||
bool MyGetCompressedFileSizeW(CFSTR path, UInt64 &size);
|
||||
bool MyGetCompressedFileSizeW(CFSTR path, UInt64 &size)
|
||||
{
|
||||
DWORD highPart;
|
||||
@@ -171,7 +172,7 @@ bool MyGetCompressedFileSizeW(CFSTR path, UInt64 &size)
|
||||
|
||||
HRESULT CFSFolder::LoadSubItems(int dirItem, const FString &relPrefix)
|
||||
{
|
||||
unsigned startIndex = Folders.Size();
|
||||
const unsigned startIndex = Folders.Size();
|
||||
{
|
||||
CEnumerator enumerator;
|
||||
enumerator.SetDirPrefix(_path + relPrefix);
|
||||
@@ -261,7 +262,7 @@ HRESULT CFSFolder::LoadSubItems(int dirItem, const FString &relPrefix)
|
||||
if (!_flatMode)
|
||||
return S_OK;
|
||||
|
||||
unsigned endIndex = Folders.Size();
|
||||
const unsigned endIndex = Folders.Size();
|
||||
for (unsigned i = startIndex; i < endIndex; i++)
|
||||
LoadSubItems(i, Folders[i]);
|
||||
return S_OK;
|
||||
@@ -293,8 +294,9 @@ bool CFSFolder::LoadComments()
|
||||
return false;
|
||||
AString s;
|
||||
char *p = s.GetBuf((unsigned)(size_t)len);
|
||||
UInt32 processedSize;
|
||||
file.Read(p, (UInt32)len, processedSize);
|
||||
size_t processedSize;
|
||||
if (!file.ReadFull(p, (unsigned)(size_t)len, processedSize))
|
||||
return false;
|
||||
s.ReleaseBuf_CalcLen((unsigned)(size_t)len);
|
||||
if (processedSize != len)
|
||||
return false;
|
||||
@@ -506,7 +508,7 @@ STDMETHODIMP CFSFolder::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
|
||||
{
|
||||
int pos = comment.Find((wchar_t)4);
|
||||
if (pos >= 0)
|
||||
comment.DeleteFrom(pos);
|
||||
comment.DeleteFrom((unsigned)pos);
|
||||
prop = comment;
|
||||
}
|
||||
break;
|
||||
@@ -784,7 +786,7 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
|
||||
return E_FAIL;
|
||||
FString parentPath = _path.Left(pos);
|
||||
pos = parentPath.ReverseFind_PathSepar();
|
||||
parentPath.DeleteFrom(pos + 1);
|
||||
parentPath.DeleteFrom((unsigned)(pos + 1));
|
||||
|
||||
if (NName::IsDrivePath_SuperAllowed(parentPath))
|
||||
{
|
||||
|
||||
@@ -203,7 +203,7 @@ struct CCopyStateIO
|
||||
int ErrorFileIndex;
|
||||
UString ErrorMessage;
|
||||
|
||||
CCopyStateIO(): DeleteSrcFile(false), TotalSize(0), StartPos(0) {}
|
||||
CCopyStateIO(): TotalSize(0), StartPos(0), DeleteSrcFile(false) {}
|
||||
|
||||
HRESULT MyCopyFile(CFSTR inPath, CFSTR outPath, DWORD attrib = INVALID_FILE_ATTRIBUTES);
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "../../../Common/MyWindows.h"
|
||||
|
||||
#include <Winbase.h>
|
||||
#include <WinBase.h>
|
||||
|
||||
#include "../../../Common/Defs.h"
|
||||
#include "../../../Common/StringConvert.h"
|
||||
@@ -397,8 +397,8 @@ static HRESULT CopyFile_Ask(
|
||||
{
|
||||
RINOK(SendMessageError(state.Callback,
|
||||
state.MoveMode ?
|
||||
"can not move file onto itself" :
|
||||
"can not copy file onto itself"
|
||||
"Cannot move file onto itself" :
|
||||
"Cannot copy file onto itself"
|
||||
, destPath));
|
||||
return E_ABORT;
|
||||
}
|
||||
@@ -497,8 +497,8 @@ static HRESULT CopyFolder(
|
||||
{
|
||||
RINOK(SendMessageError(state.Callback,
|
||||
state.MoveMode ?
|
||||
"can not copy folder onto itself" :
|
||||
"can not move folder onto itself"
|
||||
"Cannot copy folder onto itself" :
|
||||
"Cannot move folder onto itself"
|
||||
, destPath));
|
||||
return E_ABORT;
|
||||
}
|
||||
@@ -513,7 +513,7 @@ static HRESULT CopyFolder(
|
||||
|
||||
if (!CreateComplexDir(destPath))
|
||||
{
|
||||
RINOK(SendMessageError(state.Callback, "can not create folder", destPath));
|
||||
RINOK(SendMessageError(state.Callback, "Cannot create folder", destPath));
|
||||
return E_ABORT;
|
||||
}
|
||||
|
||||
@@ -547,7 +547,7 @@ static HRESULT CopyFolder(
|
||||
{
|
||||
if (!RemoveDir(srcPath))
|
||||
{
|
||||
RINOK(SendMessageError(state.Callback, "can not remove folder", srcPath));
|
||||
RINOK(SendMessageError(state.Callback, "Cannot remove folder", srcPath));
|
||||
return E_ABORT;
|
||||
}
|
||||
}
|
||||
@@ -566,7 +566,7 @@ STDMETHODIMP CFSFolder::CopyTo(Int32 moveMode, const UInt32 *indices, UInt32 num
|
||||
if (destPath.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
|
||||
bool isAltDest = NName::IsAltPathPrefix(destPath);;
|
||||
bool isAltDest = NName::IsAltPathPrefix(destPath);
|
||||
bool isDirectPath = (!isAltDest && !IsPathSepar(destPath.Back()));
|
||||
|
||||
if (isDirectPath)
|
||||
|
||||
@@ -8,10 +8,14 @@
|
||||
#include "../../../Windows/Thread.h"
|
||||
|
||||
#include "../Agent/Agent.h"
|
||||
#include "../GUI/ExtractRes.h"
|
||||
|
||||
#include "FileFolderPluginOpen.h"
|
||||
#include "FormatUtils.h"
|
||||
#include "LangUtils.h"
|
||||
#include "OpenCallback.h"
|
||||
#include "PluginLoader.h"
|
||||
#include "PropertyName.h"
|
||||
#include "RegistryPlugins.h"
|
||||
|
||||
using namespace NWindows;
|
||||
@@ -69,18 +73,165 @@ static void SplitNameToPureNameAndExtension(const FString &fullName,
|
||||
{
|
||||
pureName.SetFrom(fullName, index);
|
||||
extensionDelimiter = '.';
|
||||
extension = fullName.Ptr(index + 1);
|
||||
extension = fullName.Ptr((unsigned)index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT OpenFileFolderPlugin(
|
||||
IInStream *inStream,
|
||||
const FString &path,
|
||||
const UString &arcFormat,
|
||||
HMODULE *module,
|
||||
IFolderFolder **resultFolder,
|
||||
HWND parentWindow,
|
||||
bool &encrypted, UString &password)
|
||||
|
||||
struct CArcLevelInfo
|
||||
{
|
||||
UString Error;
|
||||
UString Path;
|
||||
UString Type;
|
||||
UString ErrorType;
|
||||
UString ErrorFlags;
|
||||
};
|
||||
|
||||
|
||||
struct CArcLevelsInfo
|
||||
{
|
||||
CObjectVector<CArcLevelInfo> Levels; // LastLevel Is NON-OPEN
|
||||
};
|
||||
|
||||
|
||||
UString GetOpenArcErrorMessage(UInt32 errorFlags);
|
||||
|
||||
|
||||
static void GetFolderLevels(CMyComPtr<IFolderFolder> &folder, CArcLevelsInfo &levels)
|
||||
{
|
||||
levels.Levels.Clear();
|
||||
|
||||
CMyComPtr<IGetFolderArcProps> getFolderArcProps;
|
||||
folder.QueryInterface(IID_IGetFolderArcProps, &getFolderArcProps);
|
||||
|
||||
if (!getFolderArcProps)
|
||||
return;
|
||||
CMyComPtr<IFolderArcProps> arcProps;
|
||||
getFolderArcProps->GetFolderArcProps(&arcProps);
|
||||
if (!arcProps)
|
||||
return;
|
||||
|
||||
UInt32 numLevels;
|
||||
if (arcProps->GetArcNumLevels(&numLevels) != S_OK)
|
||||
numLevels = 0;
|
||||
|
||||
for (UInt32 level = 0; level <= numLevels; level++)
|
||||
{
|
||||
const PROPID propIDs[] = { kpidError, kpidPath, kpidType, kpidErrorType };
|
||||
|
||||
CArcLevelInfo lev;
|
||||
|
||||
for (Int32 i = 0; i < 4; i++)
|
||||
{
|
||||
CMyComBSTR name;
|
||||
NCOM::CPropVariant prop;
|
||||
if (arcProps->GetArcProp(level, propIDs[i], &prop) != S_OK)
|
||||
continue;
|
||||
if (prop.vt != VT_EMPTY)
|
||||
{
|
||||
UString *s = NULL;
|
||||
switch (propIDs[i])
|
||||
{
|
||||
case kpidError: s = &lev.Error; break;
|
||||
case kpidPath: s = &lev.Path; break;
|
||||
case kpidType: s = &lev.Type; break;
|
||||
case kpidErrorType: s = &lev.ErrorType; break;
|
||||
}
|
||||
*s = (prop.vt == VT_BSTR) ? prop.bstrVal : L"?";
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
NCOM::CPropVariant prop;
|
||||
if (arcProps->GetArcProp(level, kpidErrorFlags, &prop) == S_OK)
|
||||
{
|
||||
UInt32 flags = GetOpenArcErrorFlags(prop);
|
||||
if (flags != 0)
|
||||
lev.ErrorFlags = GetOpenArcErrorMessage(flags);
|
||||
}
|
||||
}
|
||||
|
||||
levels.Levels.Add(lev);
|
||||
}
|
||||
}
|
||||
|
||||
static UString GetBracedType(const wchar_t *type)
|
||||
{
|
||||
UString s ('[');
|
||||
s += type;
|
||||
s += ']';
|
||||
return s;
|
||||
}
|
||||
|
||||
static void GetFolderError(CMyComPtr<IFolderFolder> &folder, UString &open_Errors, UString &nonOpen_Errors)
|
||||
{
|
||||
CArcLevelsInfo levs;
|
||||
GetFolderLevels(folder, levs);
|
||||
open_Errors.Empty();
|
||||
nonOpen_Errors.Empty();
|
||||
|
||||
FOR_VECTOR (i, levs.Levels)
|
||||
{
|
||||
bool isNonOpenLevel = (i == 0);
|
||||
const CArcLevelInfo &lev = levs.Levels[levs.Levels.Size() - 1 - i];
|
||||
|
||||
UString m;
|
||||
|
||||
if (!lev.ErrorType.IsEmpty())
|
||||
{
|
||||
m = MyFormatNew(IDS_CANT_OPEN_AS_TYPE, GetBracedType(lev.ErrorType));
|
||||
if (!isNonOpenLevel)
|
||||
{
|
||||
m.Add_LF();
|
||||
m += MyFormatNew(IDS_IS_OPEN_AS_TYPE, GetBracedType(lev.Type));
|
||||
}
|
||||
}
|
||||
|
||||
if (!lev.Error.IsEmpty())
|
||||
{
|
||||
if (!m.IsEmpty())
|
||||
m.Add_LF();
|
||||
m += GetBracedType(lev.Type);
|
||||
m += " : ";
|
||||
m += GetNameOfProperty(kpidError, L"Error");
|
||||
m += " : ";
|
||||
m += lev.Error;
|
||||
}
|
||||
|
||||
if (!lev.ErrorFlags.IsEmpty())
|
||||
{
|
||||
if (!m.IsEmpty())
|
||||
m.Add_LF();
|
||||
m += GetNameOfProperty(kpidErrorFlags, L"Errors");
|
||||
m += ": ";
|
||||
m += lev.ErrorFlags;
|
||||
}
|
||||
|
||||
if (!m.IsEmpty())
|
||||
{
|
||||
if (isNonOpenLevel)
|
||||
{
|
||||
UString &s = nonOpen_Errors;
|
||||
s += lev.Path;
|
||||
s.Add_LF();
|
||||
s += m;
|
||||
}
|
||||
else
|
||||
{
|
||||
UString &s = open_Errors;
|
||||
if (!s.IsEmpty())
|
||||
s += "--------------------\n";
|
||||
s += lev.Path;
|
||||
s.Add_LF();
|
||||
s += m;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
HRESULT CFfpOpen::OpenFileFolderPlugin(IInStream *inStream,
|
||||
const FString &path, const UString &arcFormat, HWND parentWindow)
|
||||
{
|
||||
CObjectVector<CPluginInfo> plugins;
|
||||
ReadFileFolderPluginInfoList(plugins);
|
||||
@@ -92,8 +243,8 @@ HRESULT OpenFileFolderPlugin(
|
||||
FString fileName;
|
||||
if (slashPos >= 0)
|
||||
{
|
||||
dirPrefix.SetFrom(path, slashPos + 1);
|
||||
fileName = path.Ptr(slashPos + 1);
|
||||
dirPrefix.SetFrom(path, (unsigned)(slashPos + 1));
|
||||
fileName = path.Ptr((unsigned)(slashPos + 1));
|
||||
}
|
||||
else
|
||||
fileName = path;
|
||||
@@ -120,6 +271,8 @@ HRESULT OpenFileFolderPlugin(
|
||||
}
|
||||
*/
|
||||
|
||||
ErrorMessage.Empty();
|
||||
|
||||
FOR_VECTOR (i, plugins)
|
||||
{
|
||||
const CPluginInfo &plugin = plugins[i];
|
||||
@@ -136,24 +289,29 @@ HRESULT OpenFileFolderPlugin(
|
||||
|
||||
t.OpenCallbackSpec = new COpenArchiveCallback;
|
||||
t.OpenCallback = t.OpenCallbackSpec;
|
||||
t.OpenCallbackSpec->PasswordIsDefined = encrypted;
|
||||
t.OpenCallbackSpec->Password = password;
|
||||
t.OpenCallbackSpec->PasswordIsDefined = Encrypted;
|
||||
t.OpenCallbackSpec->Password = Password;
|
||||
t.OpenCallbackSpec->ParentWindow = parentWindow;
|
||||
|
||||
if (inStream)
|
||||
t.OpenCallbackSpec->SetSubArchiveName(fs2us(fileName));
|
||||
else
|
||||
t.OpenCallbackSpec->LoadFileInfo(dirPrefix, fileName);
|
||||
{
|
||||
RINOK(t.OpenCallbackSpec->LoadFileInfo2(dirPrefix, fileName));
|
||||
}
|
||||
|
||||
t.InStream = inStream;
|
||||
t.Path = fs2us(path);
|
||||
t.ArcFormat = arcFormat;
|
||||
|
||||
UString progressTitle = LangString(IDS_OPENNING);
|
||||
t.OpenCallbackSpec->ProgressDialog.MainWindow = parentWindow;
|
||||
t.OpenCallbackSpec->ProgressDialog.MainTitle = "7-Zip"; // LangString(IDS_APP_TITLE);
|
||||
t.OpenCallbackSpec->ProgressDialog.MainAddTitle = progressTitle + L' ';
|
||||
t.OpenCallbackSpec->ProgressDialog.WaitMode = true;
|
||||
const UString progressTitle = LangString(IDS_OPENNING);
|
||||
{
|
||||
CProgressDialog &pd = t.OpenCallbackSpec->ProgressDialog;
|
||||
pd.MainWindow = parentWindow;
|
||||
pd.MainTitle = "7-Zip"; // LangString(IDS_APP_TITLE);
|
||||
pd.MainAddTitle = progressTitle + L' ';
|
||||
pd.WaitMode = true;
|
||||
}
|
||||
|
||||
{
|
||||
NWindows::CThread thread;
|
||||
@@ -161,23 +319,39 @@ HRESULT OpenFileFolderPlugin(
|
||||
t.OpenCallbackSpec->StartProgressDialog(progressTitle, thread);
|
||||
}
|
||||
|
||||
if (t.Result == E_ABORT)
|
||||
if (t.Result != S_FALSE && t.Result != S_OK)
|
||||
return t.Result;
|
||||
|
||||
encrypted = t.OpenCallbackSpec->PasswordIsDefined;
|
||||
if (t.Folder)
|
||||
{
|
||||
UString open_Errors, nonOpen_Errors;
|
||||
GetFolderError(t.Folder, open_Errors, nonOpen_Errors);
|
||||
if (!nonOpen_Errors.IsEmpty())
|
||||
{
|
||||
ErrorMessage = nonOpen_Errors;
|
||||
// if (t.Result != S_OK) return t.Result;
|
||||
/* if there are good open leves, and non0open level,
|
||||
we could force error as critical error and return error here
|
||||
but it's better to allow to open such rachives */
|
||||
// return S_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// if (openCallbackSpec->PasswordWasAsked)
|
||||
{
|
||||
Encrypted = t.OpenCallbackSpec->PasswordIsDefined;
|
||||
Password = t.OpenCallbackSpec->Password;
|
||||
}
|
||||
|
||||
if (t.Result == S_OK)
|
||||
{
|
||||
// if (openCallbackSpec->PasswordWasAsked)
|
||||
{
|
||||
password = t.OpenCallbackSpec->Password;
|
||||
}
|
||||
*module = library.Detach();
|
||||
*resultFolder = t.Folder.Detach();
|
||||
return S_OK;
|
||||
Library.Attach(library.Detach());
|
||||
// Folder.Attach(t.Folder.Detach());
|
||||
Folder = t.Folder;
|
||||
}
|
||||
|
||||
if (t.Result != S_FALSE)
|
||||
return t.Result;
|
||||
return t.Result;
|
||||
}
|
||||
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,25 @@
|
||||
#ifndef __FILE_FOLDER_PLUGIN_OPEN_H
|
||||
#define __FILE_FOLDER_PLUGIN_OPEN_H
|
||||
|
||||
HRESULT OpenFileFolderPlugin(IInStream *inStream, const FString &path, const UString &arcFormat,
|
||||
HMODULE *module, IFolderFolder **resultFolder, HWND parentWindow, bool &encrypted, UString &password);
|
||||
#include "../../../Windows/DLL.h"
|
||||
|
||||
struct CFfpOpen
|
||||
{
|
||||
CLASS_NO_COPY(CFfpOpen)
|
||||
public:
|
||||
// out:
|
||||
bool Encrypted;
|
||||
UString Password;
|
||||
|
||||
NWindows::NDLL::CLibrary Library;
|
||||
CMyComPtr<IFolderFolder> Folder;
|
||||
UString ErrorMessage;
|
||||
|
||||
CFfpOpen(): Encrypted (false) {}
|
||||
|
||||
HRESULT OpenFileFolderPlugin(IInStream *inStream,
|
||||
const FString &path, const UString &arcFormat, HWND parentWindow);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "HelpUtils.h"
|
||||
|
||||
#if defined(UNDER_CE) || !defined(_WIN32)
|
||||
#if defined(UNDER_CE) || !defined(_WIN32) /* || !defined(_MSC_VER) */
|
||||
|
||||
void ShowHelpWindow(LPCSTR)
|
||||
{
|
||||
|
||||
@@ -23,6 +23,7 @@ static CLang g_Lang;
|
||||
static bool g_Loaded = false;
|
||||
static NSynchronization::CCriticalSection g_CriticalSection;
|
||||
|
||||
bool LangOpen(CLang &lang, CFSTR fileName);
|
||||
bool LangOpen(CLang &lang, CFSTR fileName)
|
||||
{
|
||||
return lang.Open(fileName, "7-Zip");
|
||||
@@ -145,7 +146,7 @@ static const char * const kLangs =
|
||||
"it.ja.ko.nl.no.=nb.=nn.pl.pt.-br.rm.ro.ru.sr.=hr.-spl.-spc.sk.sq.sv.th.tr."
|
||||
"ur.id.uk.be.sl.et.lv.lt.tg.fa.vi.hy.az.eu.hsb.mk."
|
||||
"st.ts.tn.ve.xh.zu.af.ka.fo.hi.mt.se.ga.yi.ms.kk."
|
||||
"ky.sw.tk.uz.tt.bn.pa.-in.gu.or.ta.te.kn.ml.as.mr.sa."
|
||||
"ky.sw.tk.uz.-latn.-cyrl.tt.bn.pa.-in.gu.or.ta.te.kn.ml.as.mr.sa."
|
||||
"mn.=mn.=mng.bo.cy.kh.lo.my.gl.kok..sd.syr.si..iu.am.tzm."
|
||||
"ks.ne.fy.ps.tl.dv..ff.ha..yo.qu.st.ba.lb.kl."
|
||||
"ig.kr.om.ti.gn..la.so.ii..arn..moh..br.."
|
||||
|
||||
@@ -36,46 +36,50 @@ static const UInt32 kLangIDs[] =
|
||||
IDR_LINK_TYPE_HARD,
|
||||
IDR_LINK_TYPE_SYM_FILE,
|
||||
IDR_LINK_TYPE_SYM_DIR,
|
||||
IDR_LINK_TYPE_JUNCTION
|
||||
IDR_LINK_TYPE_JUNCTION,
|
||||
IDR_LINK_TYPE_WSL
|
||||
};
|
||||
#endif
|
||||
|
||||
static bool GetSymLink(CFSTR path, CReparseAttr &attr)
|
||||
{
|
||||
NIO::CInFile file;
|
||||
if (!file.Open(path,
|
||||
FILE_SHARE_READ,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS))
|
||||
return false;
|
||||
|
||||
const unsigned kBufSize = MAXIMUM_REPARSE_DATA_BUFFER_SIZE;
|
||||
CByteArr buf(kBufSize);
|
||||
DWORD returnedSize;
|
||||
if (!file.DeviceIoControlOut(my_FSCTL_GET_REPARSE_POINT, buf, kBufSize, &returnedSize))
|
||||
static bool GetSymLink(CFSTR path, CReparseAttr &attr, UString &errorMessage)
|
||||
{
|
||||
CByteBuffer buf;
|
||||
if (!NIO::GetReparseData(path, buf, NULL))
|
||||
return false;
|
||||
|
||||
DWORD errorCode = 0;
|
||||
if (!attr.Parse(buf, returnedSize, errorCode))
|
||||
if (!attr.Parse(buf, buf.Size()))
|
||||
{
|
||||
SetLastError(attr.ErrorCode);
|
||||
return false;
|
||||
}
|
||||
|
||||
CByteBuffer data2;
|
||||
if (!FillLinkData(data2, attr.GetPath(), attr.IsSymLink()))
|
||||
if (!FillLinkData(data2, attr.GetPath(),
|
||||
!attr.IsMountPoint(), attr.IsSymLink_WSL()))
|
||||
{
|
||||
errorMessage = "Cannot reproduce reparse point";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (data2.Size() != returnedSize ||
|
||||
memcmp(data2, buf, returnedSize) != 0)
|
||||
if (data2.Size() != buf.Size() ||
|
||||
memcmp(data2, buf, buf.Size()) != 0)
|
||||
{
|
||||
errorMessage = "mismatch for reproduced reparse point";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static const int k_LinkType_Buttons[] =
|
||||
{
|
||||
IDR_LINK_TYPE_HARD,
|
||||
IDR_LINK_TYPE_SYM_FILE,
|
||||
IDR_LINK_TYPE_SYM_DIR,
|
||||
IDR_LINK_TYPE_JUNCTION
|
||||
IDR_LINK_TYPE_JUNCTION,
|
||||
IDR_LINK_TYPE_WSL
|
||||
};
|
||||
|
||||
void CLinkDialog::Set_LinkType_Radio(int idb)
|
||||
@@ -104,16 +108,33 @@ bool CLinkDialog::OnInit()
|
||||
if (fi.HasReparsePoint())
|
||||
{
|
||||
CReparseAttr attr;
|
||||
bool res = GetSymLink(us2fs(FilePath), attr);
|
||||
UString error;
|
||||
bool res = GetSymLink(us2fs(FilePath), attr, error);
|
||||
if (!res && error.IsEmpty())
|
||||
{
|
||||
DWORD lastError = GetLastError();
|
||||
if (lastError != 0)
|
||||
error = NError::MyFormatMessage(lastError);
|
||||
}
|
||||
|
||||
UString s = attr.PrintName;
|
||||
UString s = attr.GetPath();
|
||||
if (!attr.IsSymLink_WSL())
|
||||
if (!attr.IsOkNamePair())
|
||||
{
|
||||
s += " : ";
|
||||
s += attr.SubsName;
|
||||
s += attr.PrintName;
|
||||
}
|
||||
|
||||
if (!res)
|
||||
{
|
||||
s.Insert(0, L"ERROR: ");
|
||||
if (!error.IsEmpty())
|
||||
{
|
||||
s += " : ";
|
||||
s += error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SetItemText(IDT_LINK_PATH_TO_CUR, s);
|
||||
|
||||
@@ -121,11 +142,13 @@ bool CLinkDialog::OnInit()
|
||||
_pathFromCombo.SetText(FilePath);
|
||||
_pathToCombo.SetText(destPath);
|
||||
|
||||
if (res)
|
||||
// if (res)
|
||||
{
|
||||
if (attr.IsMountPoint())
|
||||
linkType = IDR_LINK_TYPE_JUNCTION;
|
||||
if (attr.IsSymLink())
|
||||
else if (attr.IsSymLink_WSL())
|
||||
linkType = IDR_LINK_TYPE_WSL;
|
||||
else if (attr.IsSymLink_Win())
|
||||
{
|
||||
linkType =
|
||||
fi.IsDir() ?
|
||||
@@ -140,6 +163,7 @@ bool CLinkDialog::OnInit()
|
||||
}
|
||||
else
|
||||
{
|
||||
// no ReparsePoint
|
||||
_pathFromCombo.SetText(AnotherPath);
|
||||
_pathToCombo.SetText(FilePath);
|
||||
if (fi.IsDir())
|
||||
@@ -258,15 +282,18 @@ void CLinkDialog::OnButton_Link()
|
||||
}
|
||||
|
||||
NFind::CFileInfo info1, info2;
|
||||
bool finded1 = info1.Find(us2fs(from));
|
||||
bool finded2 = info2.Find(us2fs(to));
|
||||
const bool finded1 = info1.Find(us2fs(from));
|
||||
const bool finded2 = info2.Find(us2fs(to));
|
||||
|
||||
bool isDirLink = (
|
||||
const bool isDirLink = (
|
||||
idb == IDR_LINK_TYPE_SYM_DIR ||
|
||||
idb == IDR_LINK_TYPE_JUNCTION);
|
||||
|
||||
if (finded1 && info1.IsDir() != isDirLink ||
|
||||
finded2 && info2.IsDir() != isDirLink)
|
||||
const bool isWSL = (idb == IDR_LINK_TYPE_WSL);
|
||||
|
||||
if (!isWSL)
|
||||
if ((finded1 && info1.IsDir() != isDirLink) ||
|
||||
(finded2 && info2.IsDir() != isDirLink))
|
||||
{
|
||||
ShowError(L"Incorrect link type");
|
||||
return;
|
||||
@@ -282,25 +309,41 @@ void CLinkDialog::OnButton_Link()
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isSymLink = (idb != IDR_LINK_TYPE_JUNCTION);
|
||||
if (finded1 && !info1.IsDir() && !info1.HasReparsePoint() && info1.Size != 0)
|
||||
{
|
||||
UString s ("WARNING: reparse point will hide the data of existing file");
|
||||
s.Add_LF();
|
||||
s += from;
|
||||
ShowError(s);
|
||||
return;
|
||||
}
|
||||
|
||||
const bool isSymLink = (idb != IDR_LINK_TYPE_JUNCTION);
|
||||
|
||||
CByteBuffer data;
|
||||
if (!FillLinkData(data, to, isSymLink))
|
||||
if (!FillLinkData(data, to, isSymLink, isWSL))
|
||||
{
|
||||
ShowError(L"Incorrect link");
|
||||
return;
|
||||
}
|
||||
|
||||
CReparseAttr attr;
|
||||
DWORD errorCode = 0;
|
||||
if (!attr.Parse(data, data.Size(), errorCode))
|
||||
if (!attr.Parse(data, data.Size()))
|
||||
{
|
||||
ShowError(L"Internal conversion error");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!NIO::SetReparseData(us2fs(from), isDirLink, data, (DWORD)data.Size()))
|
||||
|
||||
bool res;
|
||||
if (to.IsEmpty())
|
||||
{
|
||||
// res = NIO::SetReparseData(us2fs(from), isDirLink, NULL, 0);
|
||||
res = NIO::DeleteReparseData(us2fs(from));
|
||||
}
|
||||
else
|
||||
res = NIO::SetReparseData(us2fs(from), isDirLink, data, (DWORD)data.Size());
|
||||
|
||||
if (!res)
|
||||
{
|
||||
ShowLastErrorMessage();
|
||||
return;
|
||||
@@ -350,5 +393,7 @@ void CApp::Link()
|
||||
if (dlg.Create(srcPanel.GetParent()) != IDOK)
|
||||
return;
|
||||
|
||||
// fix it: we should refresh panel with changed link
|
||||
|
||||
RefreshTitleAlways();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "../../GuiCommon.rc"
|
||||
|
||||
#define xc 288
|
||||
#define yc 200
|
||||
#define yc 214
|
||||
|
||||
#undef xRadioSize
|
||||
#define xRadioSize xc - m - 2
|
||||
@@ -20,7 +20,7 @@ BEGIN
|
||||
|
||||
LTEXT "", IDT_LINK_PATH_TO_CUR, m, 78, xc, 8
|
||||
|
||||
GROUPBOX "Link Type", IDG_LINK_TYPE, m, 104, xc, 76
|
||||
GROUPBOX "Link Type", IDG_LINK_TYPE, m, 104, xc, 90
|
||||
|
||||
CONTROL "Hard Link", IDR_LINK_TYPE_HARD, "Button", BS_AUTORADIOBUTTON | WS_GROUP,
|
||||
m + m, 120, xRadioSize, 10
|
||||
@@ -30,6 +30,8 @@ BEGIN
|
||||
m + m, 148, xRadioSize, 10
|
||||
CONTROL "Directory Junction", IDR_LINK_TYPE_JUNCTION, "Button", BS_AUTORADIOBUTTON,
|
||||
m + m, 162, xRadioSize, 10
|
||||
CONTROL "WSL", IDR_LINK_TYPE_WSL, "Button", BS_AUTORADIOBUTTON,
|
||||
m + m, 176, xRadioSize, 10
|
||||
|
||||
DEFPUSHBUTTON "Link", IDB_LINK_LINK, bx2, by, bxs, bys
|
||||
PUSHBUTTON "Cancel", IDCANCEL, bx1, by, bxs, bys
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#define IDR_LINK_TYPE_SYM_FILE 7712
|
||||
#define IDR_LINK_TYPE_SYM_DIR 7713
|
||||
#define IDR_LINK_TYPE_JUNCTION 7714
|
||||
#define IDR_LINK_TYPE_WSL 7715
|
||||
|
||||
|
||||
#define IDC_LINK_PATH_FROM 100
|
||||
|
||||
@@ -152,7 +152,7 @@ bool CMenuPage::OnInit()
|
||||
);
|
||||
|
||||
|
||||
if (!NFile::NFind::DoesFileExist(path))
|
||||
if (!NFile::NFind::DoesFileExist_Raw(path))
|
||||
{
|
||||
path.Empty();
|
||||
EnableItem(dll.ctrl, false);
|
||||
|
||||
@@ -124,7 +124,7 @@ static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex)
|
||||
CMenu menu;
|
||||
menu.Attach(menuLoc);
|
||||
|
||||
for (int i = 0;; i++)
|
||||
for (unsigned i = 0;; i++)
|
||||
{
|
||||
CMenuItem item;
|
||||
item.fMask = Get_fMask_for_String() | MIIM_SUBMENU | MIIM_ID;
|
||||
@@ -214,7 +214,7 @@ static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex)
|
||||
|
||||
static CMenu g_FileMenu;
|
||||
|
||||
struct CFileMenuDestroyer
|
||||
static struct CFileMenuDestroyer
|
||||
{
|
||||
~CFileMenuDestroyer() { if ((HMENU)g_FileMenu != 0) g_FileMenu.Destroy(); }
|
||||
} g_FileMenuDestroyer;
|
||||
@@ -461,6 +461,22 @@ void OnMenuUnActivating(HWND hWnd, HMENU hMenu, int id)
|
||||
}
|
||||
*/
|
||||
|
||||
static const unsigned g_Zvc_IDs[] =
|
||||
{
|
||||
IDM_VER_EDIT,
|
||||
IDM_VER_COMMIT,
|
||||
IDM_VER_REVERT,
|
||||
IDM_VER_DIFF
|
||||
};
|
||||
|
||||
static const char * const g_Zvc_Strings[] =
|
||||
{
|
||||
"Ver Edit (&1)"
|
||||
, "Ver Commit"
|
||||
, "Ver Revert"
|
||||
, "Ver Diff (&0)"
|
||||
};
|
||||
|
||||
void CFileMenu::Load(HMENU hMenu, unsigned startPos)
|
||||
{
|
||||
CMenu destMenu;
|
||||
@@ -468,7 +484,7 @@ void CFileMenu::Load(HMENU hMenu, unsigned startPos)
|
||||
|
||||
UString diffPath;
|
||||
ReadRegDiff(diffPath);
|
||||
|
||||
|
||||
unsigned numRealItems = startPos;
|
||||
|
||||
for (unsigned i = 0;; i++)
|
||||
@@ -544,11 +560,47 @@ void CFileMenu::Load(HMENU hMenu, unsigned startPos)
|
||||
numRealItems = startPos;
|
||||
}
|
||||
}
|
||||
|
||||
UString vercPath;
|
||||
if (!diffPath.IsEmpty() && isFsFolder && allAreFiles && numItems == 1)
|
||||
ReadReg_VerCtrlPath(vercPath);
|
||||
|
||||
if (!vercPath.IsEmpty())
|
||||
{
|
||||
NFile::NFind::CFileInfo fi;
|
||||
if (fi.Find(FilePath) && fi.Size < ((UInt32)1 << 31) && !fi.IsDir())
|
||||
{
|
||||
for (unsigned k = 0; k < ARRAY_SIZE(g_Zvc_IDs); k++)
|
||||
{
|
||||
const unsigned id = g_Zvc_IDs[k];
|
||||
if (fi.IsReadOnly())
|
||||
{
|
||||
if (id == IDM_VER_COMMIT ||
|
||||
id == IDM_VER_REVERT ||
|
||||
id == IDM_VER_DIFF)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (id == IDM_VER_EDIT)
|
||||
continue;
|
||||
}
|
||||
|
||||
CMenuItem item;
|
||||
UString s (g_Zvc_Strings[k]);
|
||||
if (destMenu.AppendItem(MF_STRING, id, s))
|
||||
{
|
||||
startPos++;
|
||||
numRealItems = startPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
destMenu.RemoveAllItemsFrom(numRealItems);
|
||||
}
|
||||
|
||||
bool ExecuteFileCommand(int id)
|
||||
bool ExecuteFileCommand(unsigned id)
|
||||
{
|
||||
if (id >= kMenuCmdID_Plugin_Start)
|
||||
{
|
||||
@@ -591,6 +643,13 @@ bool ExecuteFileCommand(int id)
|
||||
case IDM_BLAKE3: g_App.CalculateCrc("BLAKE3"); break;
|
||||
|
||||
case IDM_DIFF: g_App.DiffFiles(); break;
|
||||
|
||||
case IDM_VER_EDIT:
|
||||
case IDM_VER_COMMIT:
|
||||
case IDM_VER_REVERT:
|
||||
case IDM_VER_DIFF:
|
||||
g_App.VerCtrl(id); break;
|
||||
|
||||
case IDM_SPLIT: g_App.Split(); break;
|
||||
case IDM_COMBINE: g_App.Combine(); break;
|
||||
case IDM_PROPERTIES: g_App.Properties(); break;
|
||||
@@ -613,7 +672,7 @@ static void MyBenchmark(bool totalMode)
|
||||
Benchmark(totalMode);
|
||||
}
|
||||
|
||||
bool OnMenuCommand(HWND hWnd, int id)
|
||||
bool OnMenuCommand(HWND hWnd, unsigned id)
|
||||
{
|
||||
if (ExecuteFileCommand(id))
|
||||
return true;
|
||||
|
||||
@@ -7,7 +7,7 @@ void OnMenuActivating(HWND hWnd, HMENU hMenu, int position);
|
||||
// void OnMenuUnActivating(HWND hWnd, HMENU hMenu, int id);
|
||||
// void OnMenuUnActivating(HWND hWnd);
|
||||
|
||||
bool OnMenuCommand(HWND hWnd, int id);
|
||||
bool OnMenuCommand(HWND hWnd, unsigned id);
|
||||
void MyLoadMenu();
|
||||
|
||||
struct CFileMenu
|
||||
@@ -19,6 +19,8 @@ struct CFileMenu
|
||||
bool isAltStreamsSupported;
|
||||
int numItems;
|
||||
|
||||
UString FilePath;
|
||||
|
||||
CFileMenu():
|
||||
programMenu(false),
|
||||
readOnly(false),
|
||||
@@ -31,6 +33,6 @@ struct CFileMenu
|
||||
void Load(HMENU hMenu, unsigned startPos);
|
||||
};
|
||||
|
||||
bool ExecuteFileCommand(int id);
|
||||
bool ExecuteFileCommand(unsigned id);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -92,7 +92,7 @@ STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name, IInStream **in
|
||||
FString fullPath;
|
||||
if (!NFile::NName::GetFullPath(_folderPrefix, us2fs(name), fullPath))
|
||||
return S_FALSE;
|
||||
if (!_fileInfo.Find(fullPath))
|
||||
if (!_fileInfo.Find_FollowLink(fullPath))
|
||||
return S_FALSE;
|
||||
if (_fileInfo.IsDir())
|
||||
return S_FALSE;
|
||||
|
||||
@@ -74,12 +74,17 @@ public:
|
||||
_subArchiveMode = false;
|
||||
}
|
||||
*/
|
||||
void LoadFileInfo(const FString &folderPrefix, const FString &fileName)
|
||||
|
||||
HRESULT LoadFileInfo2(const FString &folderPrefix, const FString &fileName)
|
||||
{
|
||||
_folderPrefix = folderPrefix;
|
||||
if (!_fileInfo.Find(_folderPrefix + fileName))
|
||||
throw 1;
|
||||
if (!_fileInfo.Find_FollowLink(_folderPrefix + fileName))
|
||||
{
|
||||
return GetLastError_noZero_HRESULT();
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void ShowMessage(const UInt64 *completed);
|
||||
|
||||
INT_PTR StartProgressDialog(const UString &title, NWindows::CThread &thread)
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
void OptionsDialog(HWND hwndOwner, HINSTANCE hInstance);
|
||||
void OptionsDialog(HWND hwndOwner, HINSTANCE /* hInstance */)
|
||||
{
|
||||
CSystemPage systemPage;
|
||||
|
||||
@@ -57,8 +57,8 @@ void COverwriteDialog::SetFileInfoControl(int textID, int iconID,
|
||||
|
||||
const UString &fileName = fileInfo.Name;
|
||||
int slashPos = fileName.ReverseFind_PathSepar();
|
||||
UString s1 = fileName.Left(slashPos + 1);
|
||||
UString s2 = fileName.Ptr(slashPos + 1);
|
||||
UString s1 = fileName.Left((unsigned)(slashPos + 1));
|
||||
UString s2 = fileName.Ptr((unsigned)(slashPos + 1));
|
||||
|
||||
ReduceString(s1);
|
||||
ReduceString(s2);
|
||||
@@ -103,6 +103,22 @@ bool COverwriteDialog::OnInit()
|
||||
SetFileInfoControl(IDT_OVERWRITE_OLD_FILE_SIZE_TIME, IDI_OVERWRITE_OLD_FILE, OldFileInfo);
|
||||
SetFileInfoControl(IDT_OVERWRITE_NEW_FILE_SIZE_TIME, IDI_OVERWRITE_NEW_FILE, NewFileInfo);
|
||||
NormalizePosition();
|
||||
|
||||
if (!ShowExtraButtons)
|
||||
{
|
||||
HideItem(IDB_YES_TO_ALL);
|
||||
HideItem(IDB_NO_TO_ALL);
|
||||
HideItem(IDB_AUTO_RENAME);
|
||||
}
|
||||
|
||||
if (DefaultButton_is_NO)
|
||||
{
|
||||
PostMsg(DM_SETDEFID, IDNO);
|
||||
HWND h = GetItem(IDNO);
|
||||
PostMsg(WM_NEXTDLGCTL, (WPARAM)h, TRUE);
|
||||
// ::SetFocus(h);
|
||||
}
|
||||
|
||||
return CModalDialog::OnInit();
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace NOverwriteDialog
|
||||
|
||||
void SetTime(const FILETIME *t)
|
||||
{
|
||||
if (t == 0)
|
||||
if (!t)
|
||||
TimeIsDefined = false;
|
||||
else
|
||||
{
|
||||
@@ -28,15 +28,19 @@ namespace NOverwriteDialog
|
||||
Time = *t;
|
||||
}
|
||||
}
|
||||
|
||||
void SetSize(UInt64 size)
|
||||
{
|
||||
SizeIsDefined = true;
|
||||
Size = size;
|
||||
}
|
||||
|
||||
void SetSize(const UInt64 *size)
|
||||
{
|
||||
if (size == 0)
|
||||
if (!size)
|
||||
SizeIsDefined = false;
|
||||
else
|
||||
{
|
||||
SizeIsDefined = true;
|
||||
Size = *size;
|
||||
}
|
||||
SetSize(*size);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -51,6 +55,12 @@ class COverwriteDialog: public NWindows::NControl::CModalDialog
|
||||
void ReduceString(UString &s);
|
||||
|
||||
public:
|
||||
bool ShowExtraButtons;
|
||||
bool DefaultButton_is_NO;
|
||||
|
||||
|
||||
COverwriteDialog(): ShowExtraButtons(true), DefaultButton_is_NO(false) {}
|
||||
|
||||
INT_PTR Create(HWND parent = 0)
|
||||
{
|
||||
BIG_DIALOG_SIZE(280, 200);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <Windowsx.h>
|
||||
#include <WindowsX.h>
|
||||
// #include <stdio.h>
|
||||
|
||||
#include "../../../Common/IntToString.h"
|
||||
@@ -62,7 +62,7 @@ CPanel::~CPanel()
|
||||
CloseOpenFolders();
|
||||
}
|
||||
|
||||
HWND CPanel::GetParent()
|
||||
HWND CPanel::GetParent() const
|
||||
{
|
||||
HWND h = CWindow2::GetParent();
|
||||
return (h == 0) ? _mainWindow : h;
|
||||
@@ -76,7 +76,7 @@ HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
|
||||
const UString &arcFormat,
|
||||
CPanelCallback *panelCallback, CAppState *appState,
|
||||
bool needOpenArc,
|
||||
bool &archiveIsOpened, bool &encrypted)
|
||||
COpenResult &openRes)
|
||||
{
|
||||
_mainWindow = mainWindow;
|
||||
_processTimer = true;
|
||||
@@ -100,9 +100,9 @@ HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
|
||||
cfp = fs2us(cfpF);
|
||||
}
|
||||
|
||||
RINOK(BindToPath(cfp, arcFormat, archiveIsOpened, encrypted));
|
||||
RINOK(BindToPath(cfp, arcFormat, openRes));
|
||||
|
||||
if (needOpenArc && !archiveIsOpened)
|
||||
if (needOpenArc && !openRes.ArchiveIsOpened)
|
||||
return S_OK;
|
||||
|
||||
if (!CreateEx(0, kClassName, 0, WS_CHILD | WS_VISIBLE,
|
||||
@@ -114,8 +114,11 @@ HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// extern UInt32 g_NumMessages;
|
||||
|
||||
LRESULT CPanel::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// g_NumMessages++;
|
||||
switch (message)
|
||||
{
|
||||
case kShiftSelectMessage:
|
||||
@@ -309,7 +312,7 @@ LRESULT CMyComboBoxEdit::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
bool shift = IsKeyDown(VK_SHIFT);
|
||||
if (!alt && !ctrl && !shift)
|
||||
{
|
||||
g_App.SwitchOnOffOnePanel();;
|
||||
g_App.SwitchOnOffOnePanel();
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
@@ -340,7 +343,7 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
|
||||
_ascending = true;
|
||||
_lastFocusedIsList = true;
|
||||
|
||||
DWORD style = WS_CHILD | WS_VISIBLE; // | WS_BORDER ; // | LVS_SHAREIMAGELISTS; // | LVS_SHOWSELALWAYS;;
|
||||
DWORD style = WS_CHILD | WS_VISIBLE; // | WS_BORDER ; // | LVS_SHAREIMAGELISTS; // | LVS_SHOWSELALWAYS;
|
||||
|
||||
style |= LVS_SHAREIMAGELISTS;
|
||||
// style |= LVS_AUTOARRANGE;
|
||||
@@ -396,7 +399,7 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
|
||||
TBBUTTON tbb [ ] =
|
||||
{
|
||||
// {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
|
||||
{VIEW_PARENTFOLDER, kParentFolderID, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
|
||||
{VIEW_PARENTFOLDER, kParentFolderID, TBSTATE_ENABLED, BTNS_BUTTON, { 0, 0 }, 0, 0 },
|
||||
// {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
|
||||
// {VIEW_NEWFOLDER, kCreateFolderID, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
|
||||
};
|
||||
@@ -667,9 +670,14 @@ bool CPanel::OnNotify(UINT /* controlID */, LPNMHDR header, LRESULT &result)
|
||||
return OnNotifyReBar(header, result);
|
||||
else if (header->hwndFrom == _listView)
|
||||
return OnNotifyList(header, result);
|
||||
else if (::GetParent(header->hwndFrom) == _listView &&
|
||||
header->code == NM_RCLICK)
|
||||
return OnRightClick((MY_NMLISTVIEW_NMITEMACTIVATE *)header, result);
|
||||
else if (::GetParent(header->hwndFrom) == _listView)
|
||||
{
|
||||
// NMHDR:code is UINT
|
||||
// NM_RCLICK is unsigned in windows sdk
|
||||
// NM_RCLICK is int in MinGW
|
||||
if (header->code == (UINT)NM_RCLICK)
|
||||
return OnRightClick((MY_NMLISTVIEW_NMITEMACTIVATE *)header, result);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -903,8 +911,8 @@ static UString GetSubFolderNameForExtract2(const UString &arcPath)
|
||||
UString name = arcPath;
|
||||
if (slashPos >= 0)
|
||||
{
|
||||
s = arcPath.Left(slashPos + 1);
|
||||
name = arcPath.Ptr(slashPos + 1);
|
||||
s = arcPath.Left((unsigned)(slashPos + 1));
|
||||
name = arcPath.Ptr((unsigned)(slashPos + 1));
|
||||
}
|
||||
s += GetSubFolderNameForExtract(name);
|
||||
return s;
|
||||
@@ -967,7 +975,8 @@ static void AddValuePair(UINT resourceID, UInt64 value, UString &s)
|
||||
s += sz;
|
||||
s.Add_LF();
|
||||
}
|
||||
*/
|
||||
|
||||
// now we don't need CThreadTest, since now we call CopyTo for "test command
|
||||
|
||||
class CThreadTest: public CProgressThreadVirt
|
||||
{
|
||||
@@ -979,9 +988,6 @@ public:
|
||||
CMyComPtr<IArchiveFolder> ArchiveFolder;
|
||||
};
|
||||
|
||||
// actually now we don't need CThreadTest, since now we call CopyTo for "test command
|
||||
|
||||
/*
|
||||
HRESULT CThreadTest::ProcessVirt()
|
||||
{
|
||||
RINOK(ArchiveFolder->Extract(&Indices[0], Indices.Size(),
|
||||
@@ -1005,9 +1011,7 @@ HRESULT CThreadTest::ProcessVirt()
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
static void AddSizePair(UInt32 langID, UInt64 value, UString &s)
|
||||
{
|
||||
char sz[32];
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
const int kParentFolderID = 100;
|
||||
|
||||
const int kParentIndex = -1;
|
||||
const UInt32 kParentIndex_UInt32 = (UInt32)(Int32)kParentIndex;
|
||||
|
||||
#if !defined(_WIN32) || defined(UNDER_CE)
|
||||
#define ROOT_FS_FOLDER L"\\"
|
||||
@@ -225,7 +226,7 @@ struct CSelectedState
|
||||
UString FocusedName;
|
||||
UStringVector SelectedNames;
|
||||
|
||||
CSelectedState(): FocusedItem(-1), FocusedName_Defined(false), SelectFocused(true) {}
|
||||
CSelectedState(): FocusedItem(-1), SelectFocused(true), FocusedName_Defined(false) {}
|
||||
};
|
||||
|
||||
#ifdef UNDER_CE
|
||||
@@ -263,6 +264,23 @@ struct CCopyToOptions
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct COpenResult
|
||||
{
|
||||
// bool needOpenArc;
|
||||
// out:
|
||||
bool ArchiveIsOpened;
|
||||
bool Encrypted;
|
||||
UString ErrorMessage;
|
||||
|
||||
COpenResult():
|
||||
// needOpenArc(false),
|
||||
ArchiveIsOpened(false), Encrypted(false) {}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class CPanel: public NWindows::NControl::CWindow2
|
||||
{
|
||||
CExtToIconMap _extToIconMap;
|
||||
@@ -403,7 +421,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
HWND GetParent();
|
||||
HWND GetParent() const;
|
||||
|
||||
UInt32 GetRealIndex(const LVITEMW &item) const
|
||||
{
|
||||
@@ -483,7 +501,7 @@ public:
|
||||
// PanelFolderChange.cpp
|
||||
|
||||
void SetToRootFolder();
|
||||
HRESULT BindToPath(const UString &fullPath, const UString &arcFormat, bool &archiveIsOpened, bool &encrypted); // can be prefix
|
||||
HRESULT BindToPath(const UString &fullPath, const UString &arcFormat, COpenResult &openRes); // can be prefix
|
||||
HRESULT BindToPathAndRefresh(const UString &path);
|
||||
void OpenDrivesFolder();
|
||||
|
||||
@@ -507,7 +525,8 @@ public:
|
||||
CPanelCallback *panelCallback,
|
||||
CAppState *appState,
|
||||
bool needOpenArc,
|
||||
bool &archiveIsOpened, bool &encrypted);
|
||||
COpenResult &openRes);
|
||||
|
||||
void SetFocusToList();
|
||||
void SetFocusToLastRememberedItem();
|
||||
|
||||
@@ -515,32 +534,35 @@ public:
|
||||
void SaveListViewInfo();
|
||||
|
||||
CPanel() :
|
||||
// _virtualMode(flase),
|
||||
_thereAre_ListView_Items(false),
|
||||
_exStyle(0),
|
||||
_showDots(false),
|
||||
_showRealFileIcons(false),
|
||||
_needSaveInfo(false),
|
||||
_startGroupSelect(0),
|
||||
_selectionIsDefined(false),
|
||||
// _virtualMode(flase),
|
||||
_enableItemChangeNotify(true),
|
||||
_mySelectMode(false),
|
||||
_timestampLevel(kTimestampPrintLevel_MIN),
|
||||
|
||||
_thereAreDeletedItems(false),
|
||||
_markDeletedItems(true),
|
||||
PanelCreated(false),
|
||||
|
||||
_ListViewMode(3),
|
||||
_xSize(300),
|
||||
|
||||
_flatMode(false),
|
||||
_flatModeForDisk(false),
|
||||
_flatModeForArc(false),
|
||||
PanelCreated(false),
|
||||
_thereAre_ListView_Items(false),
|
||||
|
||||
// _showNtfsStrems_Mode(false),
|
||||
// _showNtfsStrems_ModeForDisk(false),
|
||||
// _showNtfsStrems_ModeForArc(false),
|
||||
|
||||
_xSize(300),
|
||||
_mySelectMode(false),
|
||||
_thereAreDeletedItems(false),
|
||||
_markDeletedItems(true),
|
||||
_enableItemChangeNotify(true),
|
||||
_dontShowMode(false),
|
||||
|
||||
_timestampLevel(kTimestampPrintLevel_MIN)
|
||||
_needSaveInfo(false),
|
||||
_startGroupSelect(0),
|
||||
_selectionIsDefined(false)
|
||||
{}
|
||||
|
||||
void SetExtendedStyle()
|
||||
@@ -590,8 +612,8 @@ public:
|
||||
CMyComPtr<IContextMenu> &systemContextMenu,
|
||||
bool programMenu);
|
||||
void CreateFileMenu(HMENU menu);
|
||||
bool InvokePluginCommand(int id);
|
||||
bool InvokePluginCommand(int id, IContextMenu *sevenZipContextMenu,
|
||||
bool InvokePluginCommand(unsigned id);
|
||||
bool InvokePluginCommand(unsigned id, IContextMenu *sevenZipContextMenu,
|
||||
IContextMenu *systemContextMenu);
|
||||
|
||||
void InvokeSystemCommand(const char *command);
|
||||
@@ -737,9 +759,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// bool _passwordIsDefined;
|
||||
// UString _password;
|
||||
|
||||
void InvalidateList() { _listView.InvalidateRect(NULL, true); }
|
||||
|
||||
HRESULT RefreshListCtrl();
|
||||
@@ -773,17 +792,21 @@ public:
|
||||
const CTempFileInfo &tempFileInfo,
|
||||
const UString &virtualFilePath,
|
||||
const UString &arcFormat,
|
||||
bool &encrypted);
|
||||
COpenResult &openRes);
|
||||
|
||||
HRESULT OpenAsArc_Msg(IInStream *inStream,
|
||||
const CTempFileInfo &tempFileInfo,
|
||||
const UString &virtualFilePath,
|
||||
const UString &arcFormat,
|
||||
bool &encrypted,
|
||||
bool showErrorMessage);
|
||||
const UString &arcFormat
|
||||
// , bool showErrorMessage
|
||||
);
|
||||
|
||||
HRESULT OpenAsArc_Name(const UString &relPath, const UString &arcFormat, bool &encrypted, bool showErrorMessage);
|
||||
HRESULT OpenAsArc_Index(int index, const wchar_t *type /* = NULL */, bool showErrorMessage);
|
||||
HRESULT OpenAsArc_Name(const UString &relPath, const UString &arcFormat
|
||||
// , bool showErrorMessage
|
||||
);
|
||||
HRESULT OpenAsArc_Index(int index, const wchar_t *type /* = NULL */
|
||||
// , bool showErrorMessage
|
||||
);
|
||||
|
||||
void OpenItemInArchive(int index, bool tryInternal, bool tryExternal,
|
||||
bool editMode, bool useEditor, const wchar_t *type = NULL);
|
||||
|
||||
@@ -31,14 +31,14 @@ public:
|
||||
CHashBundle Hash;
|
||||
// UString FirstFilePath;
|
||||
|
||||
HRESULT Result;
|
||||
// HRESULT Result2;
|
||||
|
||||
void ShowFinalResults(HWND hwnd);
|
||||
|
||||
CPanelCopyThread():
|
||||
Result(E_FAIL),
|
||||
ResultsWereShown(false),
|
||||
NeedShowRes(false)
|
||||
// , Result2(E_FAIL)
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -68,6 +68,8 @@ HRESULT CPanelCopyThread::ProcessVirt()
|
||||
}
|
||||
*/
|
||||
|
||||
HRESULT result2;
|
||||
|
||||
if (options->testMode)
|
||||
{
|
||||
CMyComPtr<IArchiveFolder> archiveFolder;
|
||||
@@ -79,21 +81,21 @@ HRESULT CPanelCopyThread::ProcessVirt()
|
||||
NExtract::NPathMode::EEnum pathMode =
|
||||
NExtract::NPathMode::kCurPaths;
|
||||
// NExtract::NPathMode::kFullPathnames;
|
||||
Result = archiveFolder->Extract(&Indices.Front(), Indices.Size(),
|
||||
result2 = archiveFolder->Extract(&Indices.Front(), Indices.Size(),
|
||||
BoolToInt(options->includeAltStreams),
|
||||
BoolToInt(options->replaceAltStreamChars),
|
||||
pathMode, NExtract::NOverwriteMode::kAsk,
|
||||
options->folder, BoolToInt(true), extractCallback2);
|
||||
}
|
||||
else
|
||||
Result = FolderOperations->CopyTo(
|
||||
result2 = FolderOperations->CopyTo(
|
||||
BoolToInt(options->moveMode),
|
||||
&Indices.Front(), Indices.Size(),
|
||||
BoolToInt(options->includeAltStreams),
|
||||
BoolToInt(options->replaceAltStreamChars),
|
||||
options->folder, ExtractCallback);
|
||||
|
||||
if (Result == S_OK && !ExtractCallbackSpec->ThereAreMessageErrors)
|
||||
if (result2 == S_OK && !ExtractCallbackSpec->ThereAreMessageErrors)
|
||||
{
|
||||
if (!options->hashMethods.IsEmpty())
|
||||
NeedShowRes = true;
|
||||
@@ -104,7 +106,7 @@ HRESULT CPanelCopyThread::ProcessVirt()
|
||||
}
|
||||
}
|
||||
|
||||
return Result;
|
||||
return result2;
|
||||
}
|
||||
|
||||
|
||||
@@ -232,6 +234,8 @@ HRESULT CPanel::CopyTo(CCopyToOptions &options, const CRecordVector<UInt32> &ind
|
||||
|
||||
if (messages)
|
||||
*messages = extracter.Sync.Messages;
|
||||
|
||||
// res = extracter.Result2;
|
||||
res = extracter.Result;
|
||||
|
||||
if (res == S_OK && extracter.ExtractCallbackSpec->IsOK())
|
||||
@@ -327,9 +331,11 @@ HRESULT CPanel::CopyFrom(bool moveMode, const UString &folderPrefix, const UStri
|
||||
for (i = 0; i < updater.FileNames.Size(); i++)
|
||||
updater.FileNamePointers.AddInReserved(updater.FileNames[i]);
|
||||
|
||||
NWindows::CThread thread;
|
||||
RINOK(thread.Create(CThreadUpdate::MyThreadFunction, &updater));
|
||||
updater.ProgressDialog.Create(title, thread, GetParent());
|
||||
{
|
||||
NWindows::CThread thread;
|
||||
RINOK(thread.Create(CThreadUpdate::MyThreadFunction, &updater));
|
||||
updater.ProgressDialog.Create(title, thread, GetParent());
|
||||
}
|
||||
|
||||
if (messages)
|
||||
*messages = updater.ProgressDialog.Sync.Messages;
|
||||
|
||||
@@ -383,7 +383,7 @@ HRESULT CApp::CalculateCrc2(const UString &methodName)
|
||||
{
|
||||
int pos = basePrefix2.ReverseFind_PathSepar();
|
||||
if (pos >= 0)
|
||||
basePrefix2.DeleteFrom(pos + 1);
|
||||
basePrefix2.DeleteFrom((unsigned)(pos + 1));
|
||||
}
|
||||
|
||||
t.Enumerator.BasePrefix = us2fs(basePrefix);
|
||||
|
||||
@@ -190,7 +190,7 @@ public:
|
||||
HRESULT Result;
|
||||
UStringVector Messages;
|
||||
|
||||
CDropSource(): NeedPostCopy(false), Panel(0), Result(S_OK), m_Effect(DROPEFFECT_NONE) {}
|
||||
CDropSource(): m_Effect(DROPEFFECT_NONE), Panel(NULL), NeedPostCopy(false), Result(S_OK) {}
|
||||
};
|
||||
|
||||
STDMETHODIMP CDropSource::QueryContinueDrag(BOOL escapePressed, DWORD keyState)
|
||||
@@ -300,7 +300,7 @@ static bool CopyNamesToHGlobal(NMemory::CGlobal &hgDrop, const UStringVector &na
|
||||
dropFiles->pt.y = 0;
|
||||
dropFiles->pFiles = sizeof(DROPFILES);
|
||||
dropFiles->fWide = TRUE;
|
||||
WCHAR *p = (WCHAR *)((BYTE *)dropFiles + sizeof(DROPFILES));
|
||||
WCHAR *p = (WCHAR *) (void *) ((BYTE *)dropFiles + sizeof(DROPFILES));
|
||||
for (i = 0; i < names.Size(); i++)
|
||||
{
|
||||
const UString &s = names[i];
|
||||
|
||||
@@ -73,15 +73,15 @@ static bool DoesNameContainWildcard_SkipRoot(const UString &path)
|
||||
return DoesNameContainWildcard(path.Ptr(NName::GetRootPrefixSize(path)));
|
||||
}
|
||||
|
||||
HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bool &archiveIsOpened, bool &encrypted)
|
||||
HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, COpenResult &openRes)
|
||||
{
|
||||
UString path = fullPath;
|
||||
#ifdef _WIN32
|
||||
path.Replace(L'/', WCHAR_PATH_SEPARATOR);
|
||||
#endif
|
||||
|
||||
archiveIsOpened = false;
|
||||
encrypted = false;
|
||||
openRes.ArchiveIsOpened = false;
|
||||
openRes.Encrypted = false;
|
||||
|
||||
CDisableTimerProcessing disableTimerProcessing(*this);
|
||||
CDisableNotify disableNotify(*this);
|
||||
@@ -169,7 +169,7 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo
|
||||
pos++;
|
||||
#endif
|
||||
|
||||
sysPath.DeleteFrom(pos);
|
||||
sysPath.DeleteFrom((unsigned)pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo
|
||||
tfi.RelPath = fs2us(fileName);
|
||||
tfi.FolderPath = dirPrefix;
|
||||
tfi.FilePath = us2fs(sysPath);
|
||||
res = OpenAsArc(NULL, tfi, sysPath, arcFormat, encrypted);
|
||||
res = OpenAsArc(NULL, tfi, sysPath, arcFormat, openRes);
|
||||
}
|
||||
|
||||
if (res == S_FALSE)
|
||||
@@ -226,7 +226,7 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo
|
||||
else
|
||||
{
|
||||
RINOK(res);
|
||||
archiveIsOpened = true;
|
||||
openRes.ArchiveIsOpened = true;
|
||||
_parentFolders.Back().ParentFolderPath = fs2us(dirPrefix);
|
||||
path.DeleteFrontal(sysPath.Len());
|
||||
if (!path.IsEmpty() && IS_PATH_SEPAR(path[0]))
|
||||
@@ -252,7 +252,7 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo
|
||||
unsigned skipLen = s.Len();
|
||||
if (slashPos >= 0)
|
||||
{
|
||||
s.DeleteFrom(slashPos);
|
||||
s.DeleteFrom((unsigned)slashPos);
|
||||
skipLen = slashPos + 1;
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo
|
||||
if (pos >= 0)
|
||||
{
|
||||
UString baseName = s;
|
||||
baseName.DeleteFrom(pos);
|
||||
baseName.DeleteFrom((unsigned)pos);
|
||||
if (_folderAltStreams->BindToAltStreams(baseName, &newFolder) == S_OK && newFolder)
|
||||
curPos += pos + 1;
|
||||
}
|
||||
@@ -286,7 +286,7 @@ HRESULT CPanel::BindToPathAndRefresh(const UString &path)
|
||||
{
|
||||
CDisableTimerProcessing disableTimerProcessing(*this);
|
||||
CDisableNotify disableNotify(*this);
|
||||
bool archiveIsOpened, encrypted;
|
||||
COpenResult openRes;
|
||||
UString s = path;
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -297,7 +297,7 @@ HRESULT CPanel::BindToPathAndRefresh(const UString &path)
|
||||
}
|
||||
#endif
|
||||
|
||||
HRESULT res = BindToPath(s, UString(), archiveIsOpened, encrypted);
|
||||
HRESULT res = BindToPath(s, UString(), openRes);
|
||||
RefreshListCtrl();
|
||||
return res;
|
||||
}
|
||||
@@ -484,7 +484,7 @@ void CPanel::AddComboBoxItem(const UString &name, int iconIndex, int indent, boo
|
||||
item.mask |= (CBEIF_IMAGE | CBEIF_SELECTEDIMAGE);
|
||||
item.iItem = -1;
|
||||
item.iIndent = indent;
|
||||
item.pszText = (LPWSTR)(LPCWSTR)name;
|
||||
item.pszText = name.Ptr_non_const();
|
||||
_headerComboBox.InsertItem(&item);
|
||||
|
||||
#endif
|
||||
@@ -559,7 +559,6 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result)
|
||||
|
||||
case CBN_SELENDOK:
|
||||
{
|
||||
code = code;
|
||||
int index = _headerComboBox.GetCurSel();
|
||||
if (index >= 0)
|
||||
{
|
||||
@@ -664,7 +663,7 @@ UString CPanel::GetParentDirPrefix() const
|
||||
{
|
||||
int pos = s.ReverseFind_PathSepar();
|
||||
if (pos >= 0)
|
||||
s.DeleteFrom(pos + 1);
|
||||
s.DeleteFrom((unsigned)(pos + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -700,7 +699,7 @@ void CPanel::OpenParentFolder()
|
||||
if (pos >= 0)
|
||||
{
|
||||
parentFolderPrefix = focusedName;
|
||||
parentFolderPrefix.DeleteFrom(pos + 1);
|
||||
parentFolderPrefix.DeleteFrom((unsigned)(pos + 1));
|
||||
focusedName.DeleteFrontal(pos + 1);
|
||||
}
|
||||
}
|
||||
@@ -734,9 +733,8 @@ void CPanel::OpenParentFolder()
|
||||
if (needSetFolder)
|
||||
{
|
||||
{
|
||||
bool archiveIsOpened;
|
||||
bool encrypted;
|
||||
BindToPath(parentFolderPrefix, UString(), archiveIsOpened, encrypted);
|
||||
COpenResult openRes;
|
||||
BindToPath(parentFolderPrefix, UString(), openRes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -822,7 +820,12 @@ void CPanel::OpenFolder(int index)
|
||||
return;
|
||||
}
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
_folder->BindToFolder(index, &newFolder);
|
||||
HRESULT res = _folder->BindToFolder(index, &newFolder);
|
||||
if (res != 0)
|
||||
{
|
||||
MessageBox_Error_HRESULT(res);
|
||||
return;
|
||||
}
|
||||
if (!newFolder)
|
||||
return;
|
||||
SetNewFolder(newFolder);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "../../../Common/MyWindows.h"
|
||||
|
||||
#include <tlhelp32.h>
|
||||
#include <TlHelp32.h>
|
||||
|
||||
#include "../../../Common/IntToString.h"
|
||||
|
||||
@@ -222,14 +222,14 @@ static void My_GetProcessFileName(HANDLE hProcess, UString &path)
|
||||
|
||||
const char *func_name = "GetProcessImageFileNameW";
|
||||
Func_GetProcessImageFileNameW my_func = (Func_GetProcessImageFileNameW)
|
||||
::GetProcAddress(::GetModuleHandleA("kernel32.dll"), func_name);
|
||||
(void *)::GetProcAddress(::GetModuleHandleA("kernel32.dll"), func_name);
|
||||
|
||||
if (!my_func)
|
||||
{
|
||||
if (!g_Psapi_dll_module)
|
||||
g_Psapi_dll_module = LoadLibraryW(L"Psapi.dll");
|
||||
if (g_Psapi_dll_module)
|
||||
my_func = (Func_GetProcessImageFileNameW)::GetProcAddress(g_Psapi_dll_module, func_name);
|
||||
my_func = (Func_GetProcessImageFileNameW)(void *)::GetProcAddress(g_Psapi_dll_module, func_name);
|
||||
}
|
||||
|
||||
if (my_func)
|
||||
@@ -319,7 +319,7 @@ public:
|
||||
{
|
||||
#ifndef UNDER_CE
|
||||
|
||||
Func_GetProcessId func = (Func_GetProcessId)::GetProcAddress(::GetModuleHandleA("kernel32.dll"), "GetProcessId");
|
||||
Func_GetProcessId func = (Func_GetProcessId)(void *)::GetProcAddress(::GetModuleHandleA("kernel32.dll"), "GetProcessId");
|
||||
if (func)
|
||||
{
|
||||
DWORD id = func(h);
|
||||
@@ -349,7 +349,7 @@ public:
|
||||
GetSnapshot(sps);
|
||||
|
||||
const int separ = Path.ReverseFind_PathSepar();
|
||||
const UString mainName = Path.Ptr(separ + 1);
|
||||
const UString mainName = Path.Ptr((unsigned)(separ + 1));
|
||||
if (mainName.IsEmpty())
|
||||
needFindProcessByPath = false;
|
||||
|
||||
@@ -444,14 +444,16 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void GetFolderError(CMyComPtr<IFolderFolder> &folder, UString &s);
|
||||
|
||||
|
||||
HRESULT CPanel::OpenAsArc(IInStream *inStream,
|
||||
const CTempFileInfo &tempFileInfo,
|
||||
const UString &virtualFilePath,
|
||||
const UString &arcFormat,
|
||||
bool &encrypted)
|
||||
COpenResult &openRes)
|
||||
{
|
||||
encrypted = false;
|
||||
openRes.Encrypted = false;
|
||||
CFolderLink folderLink;
|
||||
(CTempFileInfo &)folderLink = tempFileInfo;
|
||||
|
||||
@@ -468,21 +470,18 @@ HRESULT CPanel::OpenAsArc(IInStream *inStream,
|
||||
|
||||
folderLink.VirtualPath = virtualFilePath;
|
||||
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
|
||||
// _passwordIsDefined = false;
|
||||
// _password.Empty();
|
||||
|
||||
NDLL::CLibrary library;
|
||||
|
||||
UString password;
|
||||
RINOK(OpenFileFolderPlugin(inStream,
|
||||
CFfpOpen ffp;
|
||||
HRESULT res = ffp.OpenFileFolderPlugin(inStream,
|
||||
folderLink.FilePath.IsEmpty() ? us2fs(virtualFilePath) : folderLink.FilePath,
|
||||
arcFormat,
|
||||
&library, &newFolder, GetParent(), encrypted, password));
|
||||
arcFormat, GetParent());
|
||||
|
||||
openRes.Encrypted = ffp.Encrypted;
|
||||
openRes.ErrorMessage = ffp.ErrorMessage;
|
||||
|
||||
RINOK(res);
|
||||
|
||||
folderLink.Password = password;
|
||||
folderLink.UsePassword = encrypted;
|
||||
folderLink.Password = ffp.Password;
|
||||
folderLink.UsePassword = ffp.Encrypted;
|
||||
|
||||
if (_folder)
|
||||
folderLink.ParentFolderPath = GetFolderPath(_folder);
|
||||
@@ -497,75 +496,24 @@ HRESULT CPanel::OpenAsArc(IInStream *inStream,
|
||||
|
||||
ReleaseFolder();
|
||||
_library.Free();
|
||||
SetNewFolder(newFolder);
|
||||
_library.Attach(library.Detach());
|
||||
SetNewFolder(ffp.Folder);
|
||||
_library.Attach(ffp.Library.Detach());
|
||||
|
||||
_flatMode = _flatModeForArc;
|
||||
|
||||
CMyComPtr<IGetFolderArcProps> getFolderArcProps;
|
||||
_folder.QueryInterface(IID_IGetFolderArcProps, &getFolderArcProps);
|
||||
_thereAreDeletedItems = false;
|
||||
|
||||
if (getFolderArcProps)
|
||||
{
|
||||
CMyComPtr<IFolderArcProps> arcProps;
|
||||
getFolderArcProps->GetFolderArcProps(&arcProps);
|
||||
if (arcProps)
|
||||
{
|
||||
/*
|
||||
UString s;
|
||||
UInt32 numLevels;
|
||||
if (arcProps->GetArcNumLevels(&numLevels) != S_OK)
|
||||
numLevels = 0;
|
||||
for (UInt32 level2 = 0; level2 <= numLevels; level2++)
|
||||
{
|
||||
UInt32 level = numLevels - level2;
|
||||
PROPID propIDs[] = { kpidError, kpidPath, kpidType, kpidErrorType } ;
|
||||
UString values[4];
|
||||
for (Int32 i = 0; i < 4; i++)
|
||||
{
|
||||
CMyComBSTR name;
|
||||
NCOM::CPropVariant prop;
|
||||
if (arcProps->GetArcProp(level, propIDs[i], &prop) != S_OK)
|
||||
continue;
|
||||
if (prop.vt != VT_EMPTY)
|
||||
values[i] = (prop.vt == VT_BSTR) ? prop.bstrVal : L"?";
|
||||
}
|
||||
UString s2;
|
||||
if (!values[3].IsEmpty())
|
||||
{
|
||||
s2 = "Can not open the file as [" + values[3] + "] archive";
|
||||
if (level2 != 0)
|
||||
s2 += "\nThe file is open as [" + values[2] + "] archive";
|
||||
}
|
||||
if (!values[0].IsEmpty())
|
||||
{
|
||||
if (!s2.IsEmpty())
|
||||
s2.Add_LF();
|
||||
s2 += "[";
|
||||
s2 += values[2];
|
||||
s2 += "] Error: ";
|
||||
s2 += values[0];
|
||||
}
|
||||
if (!s2.IsEmpty())
|
||||
{
|
||||
if (!s.IsEmpty())
|
||||
s += "--------------------\n";
|
||||
s += values[1];
|
||||
s.Add_LF();
|
||||
s += s2;
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
if (!s.IsEmpty())
|
||||
MessageBox_Warning(s);
|
||||
else
|
||||
*/
|
||||
// after MessageBox_Warning it throws exception in nested archives in Debug Mode. why ?.
|
||||
// MessageBox_Warning(L"test error");
|
||||
}
|
||||
}
|
||||
if (!openRes.ErrorMessage.IsEmpty())
|
||||
MessageBox_Error(openRes.ErrorMessage);
|
||||
/*
|
||||
UString s;
|
||||
GetFolderError(_folder, s);
|
||||
if (!s.IsEmpty())
|
||||
MessageBox_Error(s);
|
||||
*/
|
||||
// we don't show error here by some reasons:
|
||||
// after MessageBox_Warning it throws exception in nested archives in Debug Mode. why ?.
|
||||
// MessageBox_Warning(L"test error");
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
@@ -574,25 +522,28 @@ HRESULT CPanel::OpenAsArc(IInStream *inStream,
|
||||
HRESULT CPanel::OpenAsArc_Msg(IInStream *inStream,
|
||||
const CTempFileInfo &tempFileInfo,
|
||||
const UString &virtualFilePath,
|
||||
const UString &arcFormat,
|
||||
bool &encrypted,
|
||||
bool showErrorMessage)
|
||||
const UString &arcFormat
|
||||
// , bool &encrypted
|
||||
// , bool showErrorMessage
|
||||
)
|
||||
{
|
||||
HRESULT res = OpenAsArc(inStream, tempFileInfo, virtualFilePath, arcFormat, encrypted);
|
||||
COpenResult opRes;
|
||||
|
||||
HRESULT res = OpenAsArc(inStream, tempFileInfo, virtualFilePath, arcFormat, opRes);
|
||||
|
||||
if (res == S_OK)
|
||||
return res;
|
||||
if (res == E_ABORT)
|
||||
return res;
|
||||
|
||||
if (showErrorMessage)
|
||||
if (encrypted || res != S_FALSE) // 17.01 : we show message also for (res != S_FALSE)
|
||||
// if (showErrorMessage)
|
||||
if (opRes.Encrypted || res != S_FALSE) // 17.01 : we show message also for (res != S_FALSE)
|
||||
{
|
||||
UString message;
|
||||
if (res == S_FALSE)
|
||||
{
|
||||
message = MyFormatNew(
|
||||
encrypted ?
|
||||
opRes.Encrypted ?
|
||||
IDS_CANT_OPEN_ENCRYPTED_ARCHIVE :
|
||||
IDS_CANT_OPEN_ARCHIVE,
|
||||
virtualFilePath);
|
||||
@@ -606,23 +557,28 @@ HRESULT CPanel::OpenAsArc_Msg(IInStream *inStream,
|
||||
}
|
||||
|
||||
|
||||
HRESULT CPanel::OpenAsArc_Name(const UString &relPath, const UString &arcFormat, bool &encrypted, bool showErrorMessage)
|
||||
HRESULT CPanel::OpenAsArc_Name(const UString &relPath, const UString &arcFormat
|
||||
// , bool &encrypted,
|
||||
// , bool showErrorMessage
|
||||
)
|
||||
{
|
||||
CTempFileInfo tfi;
|
||||
tfi.RelPath = relPath;
|
||||
tfi.FolderPath = us2fs(GetFsPath());
|
||||
const UString fullPath = GetFsPath() + relPath;
|
||||
tfi.FilePath = us2fs(fullPath);
|
||||
return OpenAsArc_Msg(NULL, tfi, fullPath, arcFormat, encrypted, showErrorMessage);
|
||||
return OpenAsArc_Msg(NULL, tfi, fullPath, arcFormat /* , encrypted, showErrorMessage */);
|
||||
}
|
||||
|
||||
|
||||
HRESULT CPanel::OpenAsArc_Index(int index, const wchar_t *type, bool showErrorMessage)
|
||||
HRESULT CPanel::OpenAsArc_Index(int index, const wchar_t *type
|
||||
// , bool showErrorMessage
|
||||
)
|
||||
{
|
||||
CDisableTimerProcessing disableTimerProcessing1(*this);
|
||||
CDisableNotify disableNotify(*this);
|
||||
bool encrypted;
|
||||
HRESULT res = OpenAsArc_Name(GetItemRelPath2(index), type ? type : L"", encrypted, showErrorMessage);
|
||||
|
||||
HRESULT res = OpenAsArc_Name(GetItemRelPath2(index), type ? type : L"" /* , encrypted, showErrorMessage */);
|
||||
if (res != S_OK)
|
||||
{
|
||||
RefreshTitle(true); // in case of error we must refresh changed title of 7zFM
|
||||
@@ -677,16 +633,24 @@ static const char * const kStartExtensions =
|
||||
" msi doc dot xls ppt pps wps wpt wks xlr wdb vsd pub"
|
||||
|
||||
" docx docm dotx dotm xlsx xlsm xltx xltm xlsb xps"
|
||||
" xlam pptx pptm potx potm ppam ppsx ppsm xsn"
|
||||
" xlam pptx pptm potx potm ppam ppsx ppsm vsdx xsn"
|
||||
" mpp"
|
||||
" msg"
|
||||
" dwf"
|
||||
|
||||
" flv swf"
|
||||
|
||||
" epub"
|
||||
" odt ods"
|
||||
" wb3"
|
||||
" pdf"
|
||||
" ps"
|
||||
" txt"
|
||||
" xml xsd xsl xslt hxk hxc htm html xhtml xht mht mhtml htw asp aspx css cgi jsp shtml"
|
||||
" h hpp hxx c cpp cxx m mm go swift"
|
||||
" awk sed hta js json php php3 php4 php5 phptml pl pm py pyo rb tcl ts vbs"
|
||||
" asm"
|
||||
" mak clw csproj vcproj sln dsp dsw"
|
||||
" ";
|
||||
|
||||
static bool FindExt(const char *p, const UString &name)
|
||||
@@ -724,6 +688,7 @@ static bool DoItemAlwaysStart(const UString &name)
|
||||
UString GetQuotedString(const UString &s);
|
||||
|
||||
|
||||
void SplitCmdLineSmart(const UString &cmd, UString &prg, UString ¶ms);
|
||||
void SplitCmdLineSmart(const UString &cmd, UString &prg, UString ¶ms)
|
||||
{
|
||||
params.Empty();
|
||||
@@ -734,11 +699,11 @@ void SplitCmdLineSmart(const UString &cmd, UString &prg, UString ¶ms)
|
||||
int pos = prg.Find(L'"', 1);
|
||||
if (pos >= 0)
|
||||
{
|
||||
if ((unsigned)pos + 1 == prg.Len() || prg[pos + 1] == ' ')
|
||||
if ((unsigned)(pos + 1) == prg.Len() || prg[pos + 1] == ' ')
|
||||
{
|
||||
params = prg.Ptr(pos + 1);
|
||||
params = prg.Ptr((unsigned)(pos + 1));
|
||||
params.Trim();
|
||||
prg.DeleteFrom(pos);
|
||||
prg.DeleteFrom((unsigned)pos);
|
||||
prg.DeleteFrontal(1);
|
||||
}
|
||||
}
|
||||
@@ -841,6 +806,11 @@ void CApp::DiffFiles()
|
||||
else
|
||||
return;
|
||||
|
||||
DiffFiles(path1, path2);
|
||||
}
|
||||
|
||||
void CApp::DiffFiles(const UString &path1, const UString &path2)
|
||||
{
|
||||
UString command;
|
||||
ReadRegDiff(command);
|
||||
if (command.IsEmpty())
|
||||
@@ -894,7 +864,7 @@ static HRESULT StartApplication(const UString &dir, const UString &path, HWND wi
|
||||
execInfo.nShow = SW_SHOWNORMAL;
|
||||
execInfo.hProcess = 0;
|
||||
ShellExecuteExWP shellExecuteExW = (ShellExecuteExWP)
|
||||
::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "ShellExecuteExW");
|
||||
(void *)::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "ShellExecuteExW");
|
||||
if (!shellExecuteExW)
|
||||
return 0;
|
||||
shellExecuteExW(&execInfo);
|
||||
@@ -985,7 +955,7 @@ void CPanel::OpenFolderExternal(int index)
|
||||
int pos = prefix.ReverseFind_PathSepar();
|
||||
if (pos < 0)
|
||||
return;
|
||||
prefix.DeleteFrom(pos + 1);
|
||||
prefix.DeleteFrom((unsigned)(pos + 1));
|
||||
path = prefix;
|
||||
}
|
||||
else
|
||||
@@ -1102,7 +1072,9 @@ void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal, const wchar
|
||||
if (tryInternal)
|
||||
if (!tryExternal || !DoItemAlwaysStart(name))
|
||||
{
|
||||
HRESULT res = OpenAsArc_Index(index, type, true);
|
||||
HRESULT res = OpenAsArc_Index(index, type
|
||||
// , true
|
||||
);
|
||||
disableNotify.Restore(); // we must restore to allow text notification update
|
||||
InvalidateList();
|
||||
if (res == S_OK || res == E_ABORT)
|
||||
@@ -1299,7 +1271,7 @@ static THREAD_FUNC_DECL MyThreadFunction(void *param)
|
||||
{
|
||||
handles.Add(g_ExitEventLauncher._exitEvent);
|
||||
|
||||
DWORD waitResult = ::WaitForMultipleObjects(handles.Size(), &handles.Front(), FALSE, INFINITE);
|
||||
DWORD waitResult = WaitForMultiObj_Any_Infinite(handles.Size(), &handles.Front());
|
||||
|
||||
waitResult -= WAIT_OBJECT_0;
|
||||
|
||||
@@ -1451,8 +1423,8 @@ static void ReadZoneFile(CFSTR fileName, CByteBuffer &buf)
|
||||
if (fileSize == 0 || fileSize >= ((UInt32)1 << 20))
|
||||
return;
|
||||
buf.Alloc((size_t)fileSize);
|
||||
UInt32 processed;
|
||||
if (file.Read(buf, (UInt32)fileSize, processed) && processed == fileSize)
|
||||
size_t processed;
|
||||
if (file.ReadFull(buf, (size_t)fileSize, processed) && processed == fileSize)
|
||||
return;
|
||||
buf.Free();
|
||||
}
|
||||
@@ -1644,8 +1616,9 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
|
||||
subSeqStream.QueryInterface(IID_IInStream, &subStream);
|
||||
if (subStream)
|
||||
{
|
||||
bool encrypted;
|
||||
HRESULT res = OpenAsArc_Msg(subStream, tempFileInfo, fullVirtPath, type ? type : L"", encrypted, true);
|
||||
HRESULT res = OpenAsArc_Msg(subStream, tempFileInfo, fullVirtPath, type ? type : L""
|
||||
// , true // showErrorMessage
|
||||
);
|
||||
if (res == S_OK)
|
||||
{
|
||||
tempDirectory.DisableDeleting();
|
||||
@@ -1757,9 +1730,12 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
|
||||
CBufInStream *bufInStreamSpec = new CBufInStream;
|
||||
CMyComPtr<IInStream> bufInStream = bufInStreamSpec;
|
||||
bufInStreamSpec->Init(file.Data, streamSize, virtFileSystem);
|
||||
bool encrypted;
|
||||
|
||||
HRESULT res = OpenAsArc_Msg(bufInStream, tempFileInfo, fullVirtPath, type ? type : L"", encrypted, true);
|
||||
HRESULT res = OpenAsArc_Msg(bufInStream, tempFileInfo, fullVirtPath, type ? type : L""
|
||||
// , encrypted
|
||||
// , true // showErrorMessage
|
||||
);
|
||||
|
||||
if (res == S_OK)
|
||||
{
|
||||
tempDirectory.DisableDeleting();
|
||||
@@ -1782,7 +1758,7 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
|
||||
#if defined(_WIN32) && !defined(UNDER_CE)
|
||||
if (zoneBuf.Size() != 0)
|
||||
{
|
||||
if (NFind::DoesFileExist(tempFilePath))
|
||||
if (NFind::DoesFileExist_Raw(tempFilePath))
|
||||
{
|
||||
WriteZoneFile(tempFilePath + k_ZoneId_StreamName, zoneBuf);
|
||||
}
|
||||
@@ -1792,8 +1768,10 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
|
||||
|
||||
if (tryAsArchive)
|
||||
{
|
||||
bool encrypted;
|
||||
HRESULT res = OpenAsArc_Msg(NULL, tempFileInfo, fullVirtPath, type ? type : L"", encrypted, true);
|
||||
HRESULT res = OpenAsArc_Msg(NULL, tempFileInfo, fullVirtPath, type ? type : L""
|
||||
// , encrypted
|
||||
// , true // showErrorMessage
|
||||
);
|
||||
if (res == S_OK)
|
||||
{
|
||||
tempDirectory.DisableDeleting();
|
||||
|
||||
@@ -87,7 +87,7 @@ static int GetColumnAlign(PROPID propID, VARTYPE varType)
|
||||
|
||||
static int ItemProperty_Compare_NameFirst(void *const *a1, void *const *a2, void * /* param */)
|
||||
{
|
||||
return (*(*((const CPropColumn **)a1))).Compare_NameFirst(*(*((const CPropColumn **)a2)));
|
||||
return (*(*((const CPropColumn *const *)a1))).Compare_NameFirst(*(*((const CPropColumn *const *)a2)));
|
||||
}
|
||||
|
||||
HRESULT CPanel::InitColumns()
|
||||
@@ -154,6 +154,21 @@ HRESULT CPanel::InitColumns()
|
||||
prop.IsRawProp = false;
|
||||
_columns.Add(prop);
|
||||
}
|
||||
|
||||
/*
|
||||
{
|
||||
// debug column
|
||||
CPropColumn prop;
|
||||
prop.Type = VT_BSTR;
|
||||
prop.ID = 2000;
|
||||
prop.Name = "Debug";
|
||||
prop.Order = -1;
|
||||
prop.IsVisible = true;
|
||||
prop.Width = 300;
|
||||
prop.IsRawProp = false;
|
||||
_columns.Add(prop);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
if (_folderRawProps)
|
||||
@@ -174,7 +189,7 @@ HRESULT CPanel::InitColumns()
|
||||
prop.Name = GetNameOfProperty(propID, name);
|
||||
prop.Order = -1;
|
||||
prop.IsVisible = GetColumnVisible(propID, isFsFolder);
|
||||
prop.Width = GetColumnWidth(propID, VT_BSTR);;
|
||||
prop.Width = GetColumnWidth(propID, VT_BSTR);
|
||||
prop.IsRawProp = true;
|
||||
_columns.Add(prop);
|
||||
}
|
||||
@@ -250,7 +265,7 @@ HRESULT CPanel::InitColumns()
|
||||
/* There are restrictions in ListView control:
|
||||
1) main column (kpidName) must have (LV_COLUMNW::iSubItem = 0)
|
||||
So we need special sorting for columns.
|
||||
2) when we add new column, LV_COLUMNW::iOrder can not be larger than already inserted columns)
|
||||
2) when we add new column, LV_COLUMNW::iOrder cannot be larger than already inserted columns)
|
||||
So we set column order after all columns are added.
|
||||
*/
|
||||
newColumns.Sort(ItemProperty_Compare_NameFirst, NULL);
|
||||
@@ -435,11 +450,27 @@ void CPanel::SetFocusedSelectedItem(int index, bool select)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
extern UInt32 g_NumGroups;
|
||||
extern DWORD g_start_tick;
|
||||
extern DWORD g_prev_tick;
|
||||
extern DWORD g_Num_SetItemText;
|
||||
extern UInt32 g_NumMessages;
|
||||
*/
|
||||
|
||||
HRESULT CPanel::RefreshListCtrl(const CSelectedState &state)
|
||||
{
|
||||
if (!_folder)
|
||||
return S_OK;
|
||||
|
||||
/*
|
||||
g_start_tick = GetTickCount();
|
||||
g_Num_SetItemText = 0;
|
||||
g_NumMessages = 0;
|
||||
*/
|
||||
|
||||
_dontShowMode = false;
|
||||
LoadFullPathAndShow();
|
||||
// OutputDebugStringA("=======\n");
|
||||
@@ -545,6 +576,8 @@ HRESULT CPanel::RefreshListCtrl(const CSelectedState &state)
|
||||
|
||||
Print_OnNotify("===== Before Load");
|
||||
|
||||
// #define USE_EMBED_ITEM
|
||||
|
||||
if (showDots)
|
||||
{
|
||||
UString itemName ("..");
|
||||
@@ -555,8 +588,11 @@ HRESULT CPanel::RefreshListCtrl(const CSelectedState &state)
|
||||
int subItem = 0;
|
||||
item.iSubItem = subItem++;
|
||||
item.lParam = kParentIndex;
|
||||
// item.pszText = const_cast<wchar_t *>((const wchar_t *)itemName);
|
||||
#ifdef USE_EMBED_ITEM
|
||||
item.pszText = const_cast<wchar_t *>((const wchar_t *)itemName);
|
||||
#else
|
||||
item.pszText = LPSTR_TEXTCALLBACKW;
|
||||
#endif
|
||||
UInt32 attrib = FILE_ATTRIBUTE_DIRECTORY;
|
||||
item.iImage = _extToIconMap.GetIconIndex(attrib, itemName);
|
||||
if (item.iImage < 0)
|
||||
@@ -591,10 +627,8 @@ HRESULT CPanel::RefreshListCtrl(const CSelectedState &state)
|
||||
if (state.FocusedName_Defined || !state.SelectedNames.IsEmpty())
|
||||
{
|
||||
relPath.Empty();
|
||||
|
||||
// relPath += GetItemPrefix(i);
|
||||
// change it (_flatMode)
|
||||
if (i != kParentIndex && _flatMode)
|
||||
if (_flatMode)
|
||||
{
|
||||
const wchar_t *prefix = NULL;
|
||||
if (_folderGetItemName)
|
||||
@@ -672,8 +706,11 @@ HRESULT CPanel::RefreshListCtrl(const CSelectedState &state)
|
||||
else
|
||||
*/
|
||||
{
|
||||
// item.pszText = const_cast<wchar_t *>((const wchar_t *)name);
|
||||
#ifdef USE_EMBED_ITEM
|
||||
item.pszText = const_cast<wchar_t *>((const wchar_t *)name);
|
||||
#else
|
||||
item.pszText = LPSTR_TEXTCALLBACKW;
|
||||
#endif
|
||||
/* LPSTR_TEXTCALLBACKW works, but in some cases there are problems,
|
||||
since we block notify handler.
|
||||
LPSTR_TEXTCALLBACKW can be 2-3 times faster for loading in this loop. */
|
||||
|
||||
@@ -29,7 +29,7 @@ static const CVKeyPropIDPair g_VKeyPropIDPairs[] =
|
||||
|
||||
static int FindVKeyPropIDPair(WORD vKey)
|
||||
{
|
||||
for (int i = 0; i < ARRAY_SIZE(g_VKeyPropIDPairs); i++)
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(g_VKeyPropIDPairs); i++)
|
||||
if (g_VKeyPropIDPairs[i].VKey == vKey)
|
||||
return i;
|
||||
return -1;
|
||||
|
||||
@@ -84,6 +84,7 @@ static void ConvertSizeToString(UInt64 val, wchar_t *s) throw()
|
||||
*s = 0;
|
||||
}
|
||||
|
||||
UString ConvertSizeToString(UInt64 value);
|
||||
UString ConvertSizeToString(UInt64 value)
|
||||
{
|
||||
wchar_t s[32];
|
||||
@@ -110,6 +111,7 @@ static void HexToString(char *dest, const Byte *data, UInt32 size)
|
||||
}
|
||||
*/
|
||||
|
||||
bool IsSizeProp(UINT propID) throw();
|
||||
bool IsSizeProp(UINT propID) throw()
|
||||
{
|
||||
switch (propID)
|
||||
@@ -141,12 +143,39 @@ bool IsSizeProp(UINT propID) throw()
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
#include <stdio.h>
|
||||
|
||||
UInt64 GetCpuTicks()
|
||||
{
|
||||
#ifdef _WIN64
|
||||
return __rdtsc();
|
||||
#else
|
||||
UInt32 lowVal, highVal;
|
||||
__asm RDTSC;
|
||||
__asm mov lowVal, EAX;
|
||||
__asm mov highVal, EDX;
|
||||
return ((UInt64)highVal << 32) | lowVal;
|
||||
#endif
|
||||
}
|
||||
|
||||
UInt32 g_NumGroups;
|
||||
UInt64 g_start_tick;
|
||||
UInt64 g_prev_tick;
|
||||
DWORD g_Num_SetItemText;
|
||||
UInt32 g_NumMessages;
|
||||
*/
|
||||
|
||||
LRESULT CPanel::SetItemText(LVITEMW &item)
|
||||
{
|
||||
if (_dontShowMode)
|
||||
return 0;
|
||||
UInt32 realIndex = GetRealIndex(item);
|
||||
|
||||
// g_Num_SetItemText++;
|
||||
|
||||
/*
|
||||
if ((item.mask & LVIF_IMAGE) != 0)
|
||||
{
|
||||
@@ -190,7 +219,7 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
|
||||
const CPropColumn &property = _visibleColumns[item.iSubItem];
|
||||
PROPID propID = property.ID;
|
||||
|
||||
if (realIndex == kParentIndex)
|
||||
if (realIndex == kParentIndex_UInt32)
|
||||
{
|
||||
if (propID == kpidName)
|
||||
{
|
||||
@@ -204,7 +233,52 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// List-view in report-view in Windows 10 is slow (50+ ms) for page change.
|
||||
// that code shows the time of page reload for items
|
||||
// if you know how to improve the speed of list view refresh, notify 7-Zip developer
|
||||
|
||||
// if (propID == 2000)
|
||||
// if (propID == kpidName)
|
||||
{
|
||||
// debug column;
|
||||
// DWORD dw = GetCpuTicks();
|
||||
UInt64 dw = GetCpuTicks();
|
||||
UInt64 deltaLast = dw - g_prev_tick;
|
||||
#define conv_ticks(t) ((unsigned)((t) / 100000))
|
||||
if (deltaLast > 1000u * 1000 * 1000)
|
||||
{
|
||||
UInt64 deltaFull = g_prev_tick - g_start_tick;
|
||||
char s[128];
|
||||
sprintf(s, "%d", conv_ticks(deltaFull));
|
||||
OutputDebugStringA(s);
|
||||
g_start_tick = dw;
|
||||
g_NumGroups++;
|
||||
}
|
||||
g_prev_tick = dw;
|
||||
UString u;
|
||||
char s[128];
|
||||
UInt64 deltaFull = dw - g_start_tick;
|
||||
// for (int i = 0; i < 100000; i++)
|
||||
sprintf(s, "%d %d %d-%d ", g_NumMessages, g_Num_SetItemText, g_NumGroups, conv_ticks(deltaFull));
|
||||
// sprintf(s, "%d-%d ", g_NumGroups, conv_ticks(deltaFull));
|
||||
u = s;
|
||||
lstrcpyW(text, u.Ptr());
|
||||
text += u.Len();
|
||||
|
||||
// dw = GetCpuTicks();
|
||||
// deltaFull = dw - g_prev_tick;
|
||||
// sprintf(s, "-%d ", conv_ticks(deltaFull));
|
||||
// u = s;
|
||||
// lstrcpyW(text, u.Ptr());
|
||||
// text += u.Len();
|
||||
|
||||
if (propID != kpidName)
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
if (property.IsRawProp)
|
||||
{
|
||||
const void *data;
|
||||
@@ -525,9 +599,15 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result)
|
||||
//is the sub-item information being requested?
|
||||
|
||||
if ((dispInfo->item.mask & LVIF_TEXT) != 0 ||
|
||||
(dispInfo->item.mask & LVIF_IMAGE) != 0)
|
||||
(dispInfo->item.mask & LVIF_IMAGE) != 0)
|
||||
SetItemText(dispInfo->item);
|
||||
return false;
|
||||
{
|
||||
// 20.03:
|
||||
result = 0;
|
||||
return true;
|
||||
// old 7-Zip:
|
||||
// return false;
|
||||
}
|
||||
}
|
||||
case LVN_KEYDOWN:
|
||||
{
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
extern
|
||||
LONG g_DllRefCount;
|
||||
LONG g_DllRefCount = 0;
|
||||
|
||||
static const UINT kSevenZipStartMenuID = kMenuCmdID_Plugin_Start;
|
||||
@@ -99,18 +101,25 @@ static void AddPropertyString(PROPID propID, const wchar_t *nameBSTR,
|
||||
if (flags != 0)
|
||||
val = GetOpenArcErrorMessage(flags);
|
||||
}
|
||||
|
||||
if (val.IsEmpty())
|
||||
if ((prop.vt == VT_UI8 || prop.vt == VT_UI4 || prop.vt == VT_UI2) && IsSizeProp(propID))
|
||||
{
|
||||
UInt64 v = 0;
|
||||
ConvertPropVariantToUInt64(prop, v);
|
||||
val = ConvertSizeToString(v);
|
||||
if ((prop.vt == VT_UI8 || prop.vt == VT_UI4 || prop.vt == VT_UI2) && IsSizeProp(propID))
|
||||
{
|
||||
UInt64 v = 0;
|
||||
ConvertPropVariantToUInt64(prop, v);
|
||||
val = ConvertSizeToString(v);
|
||||
}
|
||||
else
|
||||
ConvertPropertyToString2(val, prop, propID);
|
||||
}
|
||||
else
|
||||
ConvertPropertyToString2(val, prop, propID);
|
||||
|
||||
if (!val.IsEmpty())
|
||||
{
|
||||
if (propID == kpidErrorType)
|
||||
{
|
||||
AddPropertyPair(L"Open WARNING:", L"Cannot open the file as expected archive type", dialog);
|
||||
}
|
||||
AddPropertyPair(GetNameOfProperty(propID, nameBSTR), val, dialog);
|
||||
}
|
||||
}
|
||||
@@ -247,7 +256,7 @@ void CPanel::Properties()
|
||||
{
|
||||
numDirs++;
|
||||
numDirs += GetItem_UInt64Prop(index, kpidNumSubDirs);
|
||||
numFiles += GetItem_UInt64Prop(index, kpidNumSubFiles);;
|
||||
numFiles += GetItem_UInt64Prop(index, kpidNumSubFiles);
|
||||
}
|
||||
else
|
||||
numFiles++;
|
||||
@@ -343,7 +352,7 @@ void CPanel::Properties()
|
||||
}
|
||||
}
|
||||
|
||||
if (level2 != numLevels - 1)
|
||||
if (level2 < numLevels - 1)
|
||||
{
|
||||
UInt32 level = numLevels - 1 - level2;
|
||||
UInt32 numProps;
|
||||
@@ -365,6 +374,28 @@ void CPanel::Properties()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// we ERROR message for NonOpen level
|
||||
bool needSep = true;
|
||||
const int kNumSpecProps = ARRAY_SIZE(kSpecProps);
|
||||
for (Int32 i = -(int)kNumSpecProps; i < 0; i++)
|
||||
{
|
||||
CMyComBSTR name;
|
||||
PROPID propID = kSpecProps[i + kNumSpecProps];
|
||||
NCOM::CPropVariant prop;
|
||||
if (getProps->GetArcProp(numLevels, propID, &prop) != S_OK)
|
||||
continue;
|
||||
if (needSep)
|
||||
{
|
||||
AddSeparator(message);
|
||||
AddSeparator(message);
|
||||
needSep = false;
|
||||
}
|
||||
AddPropertyString(propID, name, prop, message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,7 +491,7 @@ HRESULT CPanel::CreateShellContextMenu(
|
||||
|
||||
// if (folderPath.IsEmpty()), then ParseDisplayName returns pidls of "My Computer"
|
||||
RINOK(desktopFolder->ParseDisplayName(
|
||||
GetParent(), NULL, (wchar_t *)(const wchar_t *)folderPath,
|
||||
GetParent(), NULL, folderPath.Ptr_non_const(),
|
||||
&eaten, &pidls.parent, NULL));
|
||||
|
||||
/*
|
||||
@@ -516,14 +547,14 @@ HRESULT CPanel::CreateShellContextMenu(
|
||||
LPITEMIDLIST pidl;
|
||||
const UString fileName = GetItemRelPath2(operatedIndices[i]);
|
||||
RINOK(parentFolder->ParseDisplayName(GetParent(), 0,
|
||||
(wchar_t *)(const wchar_t *)fileName, &eaten, &pidl, 0));
|
||||
fileName.Ptr_non_const(), &eaten, &pidl, 0));
|
||||
pidls.items.AddInReserved(pidl);
|
||||
}
|
||||
|
||||
// Get IContextMenu for items
|
||||
|
||||
RINOK(parentFolder->GetUIObjectOf(GetParent(), pidls.items.Size(),
|
||||
(LPCITEMIDLIST *)&pidls.items.Front(), IID_IContextMenu, 0, (void**)&systemContextMenu));
|
||||
(LPCITEMIDLIST *)(void *)&pidls.items.Front(), IID_IContextMenu, 0, (void**)&systemContextMenu));
|
||||
|
||||
if (!systemContextMenu)
|
||||
{
|
||||
@@ -533,6 +564,99 @@ HRESULT CPanel::CreateShellContextMenu(
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// #define SHOW_DEBUG_FM_CTX_MENU
|
||||
|
||||
#ifdef SHOW_DEBUG_FM_CTX_MENU
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
// #include Common/IntToString.h"
|
||||
|
||||
static void PrintHex(UString &s, UInt32 v)
|
||||
{
|
||||
char sz[32];
|
||||
ConvertUInt32ToHex(v, sz);
|
||||
s += sz;
|
||||
}
|
||||
|
||||
static void PrintContextStr(UString &s, IContextMenu *ctxm, unsigned i, unsigned id, const char *name)
|
||||
{
|
||||
s += " | ";
|
||||
name = name;
|
||||
// s += name;
|
||||
// s += ": ";
|
||||
|
||||
UString s1;
|
||||
{
|
||||
char buf[256];
|
||||
buf[0] = 0;
|
||||
HRESULT res = ctxm->GetCommandString(i, id,
|
||||
NULL, buf, ARRAY_SIZE(buf) - 1);
|
||||
if (res != S_OK)
|
||||
{
|
||||
PrintHex(s1, res);
|
||||
s1.Add_Space();
|
||||
}
|
||||
s1 += GetUnicodeString(buf);
|
||||
}
|
||||
|
||||
UString s2;
|
||||
{
|
||||
wchar_t buf2[256];
|
||||
buf2[0] = 0;
|
||||
HRESULT res = ctxm->GetCommandString(i, id | GCS_UNICODE,
|
||||
NULL, (char *)buf2, ARRAY_SIZE(buf2) - 1);
|
||||
if (res != S_OK)
|
||||
{
|
||||
PrintHex(s2, res);
|
||||
s2.Add_Space();
|
||||
}
|
||||
s2 += buf2;
|
||||
}
|
||||
|
||||
s += s1;
|
||||
if (s2.Compare(s1) != 0)
|
||||
{
|
||||
s += " Unicode: ";
|
||||
s += s2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void PrintAllContextItems(IContextMenu *ctxm, unsigned num)
|
||||
{
|
||||
for (unsigned i = 0; i < num; i++)
|
||||
{
|
||||
UString s;
|
||||
s.Add_UInt32(i);
|
||||
s += ": ";
|
||||
|
||||
/*
|
||||
UString valid;
|
||||
{
|
||||
char name[256];
|
||||
HRESULT res = ctxm->GetCommandString(i, GCS_VALIDATEA,
|
||||
NULL, name, ARRAY_SIZE(name) - 1);
|
||||
|
||||
if (res == S_OK)
|
||||
{
|
||||
// valid = "valid";
|
||||
}
|
||||
else if (res == S_FALSE)
|
||||
valid = "non-valid";
|
||||
else
|
||||
PrintHex(valid, res);
|
||||
}
|
||||
s += valid;
|
||||
*/
|
||||
|
||||
PrintContextStr(s, ctxm, i, GCS_VALIDATEA, "valid");
|
||||
PrintContextStr(s, ctxm, i, GCS_VERBA, "v");
|
||||
PrintContextStr(s, ctxm, i, GCS_HELPTEXTA, "h");
|
||||
OutputDebugStringW(s);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void CPanel::CreateSystemMenu(HMENU menuSpec,
|
||||
const CRecordVector<UInt32> &operatedIndices,
|
||||
@@ -542,14 +666,16 @@ void CPanel::CreateSystemMenu(HMENU menuSpec,
|
||||
|
||||
CreateShellContextMenu(operatedIndices, systemContextMenu);
|
||||
|
||||
if (systemContextMenu == 0)
|
||||
if (!systemContextMenu)
|
||||
return;
|
||||
|
||||
/*
|
||||
// Set up a CMINVOKECOMMANDINFO structure.
|
||||
CMINVOKECOMMANDINFO ci;
|
||||
ZeroMemory(&ci, sizeof(ci));
|
||||
ci.cbSize = sizeof(CMINVOKECOMMANDINFO);
|
||||
ci.hwnd = GetParent();
|
||||
*/
|
||||
|
||||
/*
|
||||
if (Sender == GoBtn)
|
||||
@@ -578,7 +704,7 @@ void CPanel::CreateSystemMenu(HMENU menuSpec,
|
||||
{
|
||||
// HMENU hMenu = CreatePopupMenu();
|
||||
CMenu popupMenu;
|
||||
// CMenuDestroyer menuDestroyer(popupMenu);
|
||||
CMenuDestroyer menuDestroyer(popupMenu);
|
||||
if (!popupMenu.CreatePopup())
|
||||
throw 210503;
|
||||
|
||||
@@ -592,17 +718,21 @@ void CPanel::CreateSystemMenu(HMENU menuSpec,
|
||||
// commented out but you can uncommnent this
|
||||
// line to show the extended context menu.
|
||||
// Flags |= 0x00000080;
|
||||
systemContextMenu->QueryContextMenu(hMenu, 0, kSystemStartMenuID, 0x7FFF, Flags);
|
||||
|
||||
HRESULT res = systemContextMenu->QueryContextMenu(hMenu, 0, kSystemStartMenuID, 0x7FFF, Flags);
|
||||
|
||||
if (SUCCEEDED(res))
|
||||
{
|
||||
#ifdef SHOW_DEBUG_FM_CTX_MENU
|
||||
PrintAllContextItems(systemContextMenu, (unsigned)res);
|
||||
#endif
|
||||
|
||||
CMenu menu;
|
||||
menu.Attach(menuSpec);
|
||||
CMenuItem menuItem;
|
||||
menuItem.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_ID;
|
||||
menuItem.fType = MFT_STRING;
|
||||
menuItem.hSubMenu = popupMenu.Detach();
|
||||
// menuDestroyer.Disable();
|
||||
menuDestroyer.Disable();
|
||||
LangString(IDS_SYSTEM, menuItem.StringValue);
|
||||
menu.InsertItem(0, true, menuItem);
|
||||
}
|
||||
@@ -648,8 +778,6 @@ void CPanel::CreateSevenZipMenu(HMENU menuSpec,
|
||||
// CMenuDestroyer menuDestroyer(menu);
|
||||
// menu.CreatePopup();
|
||||
|
||||
bool sevenZipMenuCreated = false;
|
||||
|
||||
CZipContextMenu *contextMenuSpec = new CZipContextMenu;
|
||||
CMyComPtr<IContextMenu> contextMenu = contextMenuSpec;
|
||||
// if (contextMenu.CoCreateInstance(CLSID_CZipContextMenu, IID_IContextMenu) == S_OK)
|
||||
@@ -674,9 +802,24 @@ void CPanel::CreateSevenZipMenu(HMENU menuSpec,
|
||||
{
|
||||
HRESULT res = contextMenu->QueryContextMenu(menu, 0, kSevenZipStartMenuID,
|
||||
kSystemStartMenuID - 1, 0);
|
||||
sevenZipMenuCreated = (HRESULT_SEVERITY(res) == SEVERITY_SUCCESS);
|
||||
bool sevenZipMenuCreated = SUCCEEDED(res);
|
||||
if (sevenZipMenuCreated)
|
||||
sevenZipContextMenu = contextMenu;
|
||||
{
|
||||
// if (res != 0)
|
||||
{
|
||||
// some "non-good" implementation of QueryContextMenu() could add some items to menu, but it return 0.
|
||||
// so we still allow these items
|
||||
sevenZipContextMenu = contextMenu;
|
||||
#ifdef SHOW_DEBUG_FM_CTX_MENU
|
||||
PrintAllContextItems(contextMenu, (unsigned)res);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// MessageBox_Error_HRESULT_Caption(res, L"QueryContextMenu");
|
||||
}
|
||||
|
||||
// int code = HRESULT_CODE(res);
|
||||
// int nextItemID = code;
|
||||
}
|
||||
@@ -795,6 +938,9 @@ void CPanel::CreateFileMenu(HMENU menuSpec,
|
||||
|
||||
fm.isAltStreamsSupported = false;
|
||||
|
||||
if (fm.numItems == 1)
|
||||
fm.FilePath = GetItemFullPath(operatedIndices[0]);
|
||||
|
||||
if (_folderAltStreams)
|
||||
{
|
||||
if (operatedIndices.Size() <= 1)
|
||||
@@ -818,7 +964,7 @@ void CPanel::CreateFileMenu(HMENU menuSpec,
|
||||
fm.Load(menu, menu.GetItemCount());
|
||||
}
|
||||
|
||||
bool CPanel::InvokePluginCommand(int id)
|
||||
bool CPanel::InvokePluginCommand(unsigned id)
|
||||
{
|
||||
return InvokePluginCommand(id, _sevenZipContextMenu, _systemContextMenu);
|
||||
}
|
||||
@@ -827,15 +973,15 @@ bool CPanel::InvokePluginCommand(int id)
|
||||
#define use_CMINVOKECOMMANDINFOEX
|
||||
#endif
|
||||
|
||||
bool CPanel::InvokePluginCommand(int id,
|
||||
bool CPanel::InvokePluginCommand(unsigned id,
|
||||
IContextMenu *sevenZipContextMenu, IContextMenu *systemContextMenu)
|
||||
{
|
||||
UInt32 offset;
|
||||
bool isSystemMenu = (id >= kSystemStartMenuID);
|
||||
if (isSystemMenu)
|
||||
offset = id - kSystemStartMenuID;
|
||||
offset = id - kSystemStartMenuID;
|
||||
else
|
||||
offset = id - kSevenZipStartMenuID;
|
||||
offset = id - kSevenZipStartMenuID;
|
||||
|
||||
#ifdef use_CMINVOKECOMMANDINFOEX
|
||||
CMINVOKECOMMANDINFOEX
|
||||
@@ -856,16 +1002,29 @@ bool CPanel::InvokePluginCommand(int id,
|
||||
commandInfo.hwnd = GetParent();
|
||||
commandInfo.lpVerb = (LPCSTR)(MAKEINTRESOURCE(offset));
|
||||
commandInfo.lpParameters = NULL;
|
||||
const CSysString currentFolderSys (GetSystemString(_currentFolderPrefix));
|
||||
commandInfo.lpDirectory = (LPCSTR)(LPCTSTR)(currentFolderSys);
|
||||
// 19.01: fixed CSysString to AString
|
||||
// MSDN suggest to send NULL: lpDirectory: This member is always NULL for menu items inserted by a Shell extension.
|
||||
const AString currentFolderA (GetAnsiString(_currentFolderPrefix));
|
||||
commandInfo.lpDirectory = (LPCSTR)(currentFolderA);
|
||||
commandInfo.nShow = SW_SHOW;
|
||||
|
||||
#ifdef use_CMINVOKECOMMANDINFOEX
|
||||
|
||||
commandInfo.lpParametersW = NULL;
|
||||
commandInfo.lpTitle = "";
|
||||
commandInfo.lpVerbW = (LPCWSTR)(MAKEINTRESOURCEW(offset));
|
||||
UString currentFolderUnicode = _currentFolderPrefix;
|
||||
|
||||
/*
|
||||
system ContextMenu handler supports ContextMenu subhandlers.
|
||||
so InvokeCommand() converts (command_offset) from global number to subhandler number.
|
||||
XP-64 / win10:
|
||||
system ContextMenu converts (command_offset) in lpVerb only,
|
||||
and it keeps lpVerbW unchanged.
|
||||
also explorer.exe sends 0 in lpVerbW.
|
||||
We try to keep compatibility with Windows Explorer here.
|
||||
*/
|
||||
commandInfo.lpVerbW = NULL;
|
||||
|
||||
const UString currentFolderUnicode = _currentFolderPrefix;
|
||||
commandInfo.lpDirectoryW = currentFolderUnicode;
|
||||
commandInfo.lpTitleW = L"";
|
||||
// commandInfo.ptInvoke.x = xPos;
|
||||
@@ -885,6 +1044,8 @@ bool CPanel::InvokePluginCommand(int id,
|
||||
KillSelection();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
MessageBox_Error_HRESULT_Caption(result, L"InvokeCommand");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -947,22 +1108,22 @@ bool CPanel::OnContextMenu(HANDLE windowHandle, int xPos, int yPos)
|
||||
CMyComPtr<IContextMenu> systemContextMenu;
|
||||
CreateFileMenu(menu, sevenZipContextMenu, systemContextMenu, false);
|
||||
|
||||
int result = menu.Track(TPM_LEFTALIGN
|
||||
unsigned id = menu.Track(TPM_LEFTALIGN
|
||||
#ifndef UNDER_CE
|
||||
| TPM_RIGHTBUTTON
|
||||
#endif
|
||||
| TPM_RETURNCMD | TPM_NONOTIFY,
|
||||
xPos, yPos, _listView);
|
||||
|
||||
if (result == 0)
|
||||
if (id == 0)
|
||||
return true;
|
||||
|
||||
if (result >= kMenuCmdID_Plugin_Start)
|
||||
if (id >= kMenuCmdID_Plugin_Start)
|
||||
{
|
||||
InvokePluginCommand(result, sevenZipContextMenu, systemContextMenu);
|
||||
InvokePluginCommand(id, sevenZipContextMenu, systemContextMenu);
|
||||
return true;
|
||||
}
|
||||
if (ExecuteFileCommand(result))
|
||||
if (ExecuteFileCommand(id))
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -48,9 +48,7 @@ public:
|
||||
CMyComPtr<IProgress> UpdateCallback;
|
||||
CUpdateCallback100Imp *UpdateCallbackSpec;
|
||||
|
||||
HRESULT Result;
|
||||
|
||||
CThreadFolderOperations(EFolderOpType opType): OpType(opType), Result(E_FAIL) {}
|
||||
CThreadFolderOperations(EFolderOpType opType): OpType(opType) {}
|
||||
HRESULT DoOperation(CPanel &panel, const UString &progressTitle, const UString &titleError);
|
||||
};
|
||||
|
||||
@@ -60,18 +58,14 @@ HRESULT CThreadFolderOperations::ProcessVirt()
|
||||
switch (OpType)
|
||||
{
|
||||
case FOLDER_TYPE_CREATE_FOLDER:
|
||||
Result = FolderOperations->CreateFolder(Name, UpdateCallback);
|
||||
break;
|
||||
return FolderOperations->CreateFolder(Name, UpdateCallback);
|
||||
case FOLDER_TYPE_DELETE:
|
||||
Result = FolderOperations->Delete(&Indices.Front(), Indices.Size(), UpdateCallback);
|
||||
break;
|
||||
return FolderOperations->Delete(&Indices.Front(), Indices.Size(), UpdateCallback);
|
||||
case FOLDER_TYPE_RENAME:
|
||||
Result = FolderOperations->Rename(Index, Name, UpdateCallback);
|
||||
break;
|
||||
return FolderOperations->Rename(Index, Name, UpdateCallback);
|
||||
default:
|
||||
Result = E_FAIL;
|
||||
return E_FAIL;
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +77,6 @@ HRESULT CThreadFolderOperations::DoOperation(CPanel &panel, const UString &progr
|
||||
|
||||
WaitMode = true;
|
||||
Sync.FinalMessage.ErrorMessage.Title = titleError;
|
||||
Result = S_OK;
|
||||
|
||||
UpdateCallbackSpec->Init();
|
||||
|
||||
@@ -94,7 +87,6 @@ HRESULT CThreadFolderOperations::DoOperation(CPanel &panel, const UString &progr
|
||||
UpdateCallbackSpec->Password = fl.Password;
|
||||
}
|
||||
|
||||
|
||||
MainWindow = panel._mainWindow; // panel.GetParent()
|
||||
MainTitle = "7-Zip"; // LangString(IDS_APP_TITLE);
|
||||
MainAddTitle = progressTitle + L' ';
|
||||
@@ -274,9 +266,9 @@ BOOL CPanel::OnBeginLabelEdit(LV_DISPINFOW * lpnmh)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool IsCorrectFsName(const UString &name)
|
||||
static bool IsCorrectFsName(const UString &name)
|
||||
{
|
||||
const UString lastPart = name.Ptr(name.ReverseFind_PathSepar() + 1);
|
||||
const UString lastPart = name.Ptr((unsigned)(name.ReverseFind_PathSepar() + 1));
|
||||
return
|
||||
lastPart != L"." &&
|
||||
lastPart != L"..";
|
||||
@@ -410,7 +402,7 @@ void CPanel::CreateFolder()
|
||||
{
|
||||
int pos = newName.Find(WCHAR_PATH_SEPARATOR);
|
||||
if (pos >= 0)
|
||||
newName.DeleteFrom(pos);
|
||||
newName.DeleteFrom((unsigned)(pos));
|
||||
if (!_mySelectMode)
|
||||
state.SelectedNames.Clear();
|
||||
state.FocusedName = newName;
|
||||
@@ -461,7 +453,7 @@ void CPanel::CreateFile()
|
||||
}
|
||||
int pos = newName.Find(WCHAR_PATH_SEPARATOR);
|
||||
if (pos >= 0)
|
||||
newName.DeleteFrom(pos);
|
||||
newName.DeleteFrom((unsigned)pos);
|
||||
if (!_mySelectMode)
|
||||
state.SelectedNames.Clear();
|
||||
state.FocusedName = newName;
|
||||
|
||||
@@ -193,7 +193,7 @@ void CPanel::SelectByType(bool selectMode)
|
||||
else
|
||||
{
|
||||
UString mask ('*');
|
||||
mask += name.Ptr(pos);
|
||||
mask += name.Ptr((unsigned)pos);
|
||||
FOR_VECTOR (i, _selectedStatusVector)
|
||||
if (IsItem_Folder(i) == isItemFolder && DoesWildcardMatchName(mask, GetItemName(i)))
|
||||
_selectedStatusVector[i] = selectMode;
|
||||
@@ -241,6 +241,9 @@ void CPanel::InvertSelection()
|
||||
void CPanel::KillSelection()
|
||||
{
|
||||
SelectAll(false);
|
||||
// ver 20.01: now we don't like that focused will be selected item.
|
||||
// So the following code was disabled:
|
||||
/*
|
||||
if (!_mySelectMode)
|
||||
{
|
||||
int focused = _listView.GetFocusedItem();
|
||||
@@ -254,6 +257,7 @@ void CPanel::KillSelection()
|
||||
_listView.SetItemState_Selected(focused);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void CPanel::OnLeftClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActivate)
|
||||
|
||||
@@ -95,7 +95,7 @@ void CPanel::SetSortRawStatus()
|
||||
}
|
||||
|
||||
|
||||
int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
|
||||
static int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
|
||||
{
|
||||
if (lpData == 0)
|
||||
return 0;
|
||||
@@ -182,7 +182,7 @@ int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
|
||||
return prop1.Compare(prop2);
|
||||
}
|
||||
|
||||
|
||||
int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData);
|
||||
int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
|
||||
{
|
||||
if (lpData == 0) return 0;
|
||||
|
||||
@@ -274,7 +274,7 @@ void CApp::Split()
|
||||
NFind::CFileInfo fileInfo;
|
||||
if (!fileInfo.Find(us2fs(srcPath + itemName)))
|
||||
{
|
||||
srcPanel.MessageBox_Error(L"Can not find file");
|
||||
srcPanel.MessageBox_Error(L"Cannot find file");
|
||||
return;
|
||||
}
|
||||
if (fileInfo.Size <= splitDialog.VolumeSizes.Front())
|
||||
|
||||
@@ -137,7 +137,7 @@ public:
|
||||
{
|
||||
_title = title;
|
||||
INT_PTR res = CModalDialog::Create(IDD_PROGRESS, wndParent);
|
||||
thread.Wait();
|
||||
thread.Wait_Close();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -536,10 +536,10 @@ bool CProgressDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
|
||||
labelSize = gSize - valueSize;
|
||||
|
||||
yPos = my;
|
||||
for (int i = 0; i < ARRAY_SIZE(kIDs); i += 2)
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(kIDs); i += 2)
|
||||
{
|
||||
int x = mx;
|
||||
const int kNumColumn1Items = 5 * 2;
|
||||
const unsigned kNumColumn1Items = 5 * 2;
|
||||
if (i >= kNumColumn1Items)
|
||||
{
|
||||
if (i == kNumColumn1Items)
|
||||
@@ -583,6 +583,7 @@ void CProgressDialog::SetProgressPos(UInt64 pos)
|
||||
|
||||
#define UINT_TO_STR_2(val) { s[0] = (wchar_t)('0' + (val) / 10); s[1] = (wchar_t)('0' + (val) % 10); s += 2; }
|
||||
|
||||
void GetTimeString(UInt64 timeValue, wchar_t *s);
|
||||
void GetTimeString(UInt64 timeValue, wchar_t *s)
|
||||
{
|
||||
UInt64 hours = timeValue / 3600;
|
||||
@@ -892,8 +893,8 @@ void CProgressDialog::UpdateStatInfo(bool showAll)
|
||||
int slashPos = _filePath.ReverseFind_PathSepar();
|
||||
if (slashPos >= 0)
|
||||
{
|
||||
s1.SetFrom(_filePath, slashPos + 1);
|
||||
s2 = _filePath.Ptr(slashPos + 1);
|
||||
s1.SetFrom(_filePath, (unsigned)(slashPos + 1));
|
||||
s2 = _filePath.Ptr((unsigned)(slashPos + 1));
|
||||
}
|
||||
else
|
||||
s2 = _filePath;
|
||||
@@ -942,7 +943,7 @@ INT_PTR CProgressDialog::Create(const UString &title, NWindows::CThread &thread,
|
||||
CWaitCursor waitCursor;
|
||||
HANDLE h[] = { thread, _createDialogEvent };
|
||||
|
||||
WRes res2 = WaitForMultipleObjects(ARRAY_SIZE(h), h, FALSE, kCreateDelay);
|
||||
DWORD res2 = WaitForMultipleObjects(ARRAY_SIZE(h), h, FALSE, kCreateDelay);
|
||||
if (res2 == WAIT_OBJECT_0 && !Sync.ThereIsMessage())
|
||||
return 0;
|
||||
}
|
||||
@@ -954,9 +955,8 @@ INT_PTR CProgressDialog::Create(const UString &title, NWindows::CThread &thread,
|
||||
{
|
||||
_wasCreated = true;
|
||||
_dialogCreatedEvent.Set();
|
||||
res = res;
|
||||
}
|
||||
thread.Wait();
|
||||
thread.Wait_Close();
|
||||
if (!MessagesDisplayed)
|
||||
MessageBoxW(wndParent, L"Progress Error", L"7-Zip", MB_ICONERROR);
|
||||
return res;
|
||||
|
||||
@@ -321,7 +321,7 @@ CProgressThreadVirt::Create()
|
||||
CProgressThreadVirt::Process()
|
||||
{
|
||||
{
|
||||
ProcessVirt(); // virtual function that must implement real work
|
||||
Result = ProcessVirt(); // virtual function that must implement real work
|
||||
}
|
||||
if (exceptions) or FinalMessage.ErrorMessage.Message
|
||||
{
|
||||
|
||||
@@ -44,7 +44,7 @@ DIALOG_ID DIALOG 0, 0, xs, ys MY_MODAL_RESIZE_DIALOG_STYLE MY_FONT
|
||||
CAPTION "Progress"
|
||||
{
|
||||
DEFPUSHBUTTON "&Background", IDB_PROGRESS_BACKGROUND, bx3, by, bxs, bys
|
||||
PUSHBUTTON "&Pause", IDB_PAUSE bx2, by, bxs, bys
|
||||
PUSHBUTTON "&Pause", IDB_PAUSE, bx2, by, bxs, bys
|
||||
PUSHBUTTON "Cancel", IDCANCEL, bx1, by, bxs, bys
|
||||
|
||||
LTEXT "Elapsed time:", IDT_PROGRESS_ELAPSED, m, y0, x0s, 8
|
||||
|
||||
@@ -62,7 +62,7 @@ static bool ReadPluginInfo(CPluginInfo &pluginInfo, bool needCheckDll)
|
||||
else
|
||||
{
|
||||
pluginInfo.ClassIDDefined = true;
|
||||
pluginInfo.ClassID = *(const GUID *)prop.bstrVal;
|
||||
pluginInfo.ClassID = *(const GUID *)(const void *)prop.bstrVal;
|
||||
}
|
||||
prop.Clear();
|
||||
|
||||
@@ -75,7 +75,7 @@ static bool ReadPluginInfo(CPluginInfo &pluginInfo, bool needCheckDll)
|
||||
else
|
||||
{
|
||||
pluginInfo.OptionsClassIDDefined = true;
|
||||
pluginInfo.OptionsClassID = *(const GUID *)prop.bstrVal;
|
||||
pluginInfo.OptionsClassID = *(const GUID *)(const void *)prop.bstrVal;
|
||||
}
|
||||
prop.Clear();
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ static LPCWSTR const kLangValueName = L"Lang";
|
||||
static LPCWSTR const kViewer = L"Viewer";
|
||||
static LPCWSTR const kEditor = L"Editor";
|
||||
static LPCWSTR const kDiff = L"Diff";
|
||||
static LPCWSTR const kVerCtrlPath = L"7vc";
|
||||
|
||||
static LPCTSTR const kShowDots = TEXT("ShowDots");
|
||||
static LPCTSTR const kShowRealFileIcons = TEXT("ShowRealFileIcons");
|
||||
@@ -70,6 +71,8 @@ void ReadRegEditor(bool useEditor, UString &path) { ReadCuString(kCU_FMPath, use
|
||||
void SaveRegDiff(const UString &path) { SaveCuString(kCU_FMPath, kDiff, path); }
|
||||
void ReadRegDiff(UString &path) { ReadCuString(kCU_FMPath, kDiff, path); }
|
||||
|
||||
void ReadReg_VerCtrlPath(UString &path) { ReadCuString(kCU_FMPath, kVerCtrlPath, path); }
|
||||
|
||||
static void Save7ZipOption(LPCTSTR value, bool enabled)
|
||||
{
|
||||
CKey key;
|
||||
|
||||
@@ -15,6 +15,8 @@ void ReadRegEditor(bool useEditor, UString &path);
|
||||
void SaveRegDiff(const UString &path);
|
||||
void ReadRegDiff(UString &path);
|
||||
|
||||
void ReadReg_VerCtrlPath(UString &path);
|
||||
|
||||
struct CFmSettings
|
||||
{
|
||||
bool ShowDots;
|
||||
|
||||
@@ -46,6 +46,7 @@ static const Byte kProps[] =
|
||||
kpidName
|
||||
};
|
||||
|
||||
UString RootFolder_GetName_Computer(int &iconIndex);
|
||||
UString RootFolder_GetName_Computer(int &iconIndex)
|
||||
{
|
||||
#ifdef USE_WIN_PATHS
|
||||
@@ -56,12 +57,14 @@ UString RootFolder_GetName_Computer(int &iconIndex)
|
||||
return LangString(IDS_COMPUTER);
|
||||
}
|
||||
|
||||
UString RootFolder_GetName_Network(int &iconIndex);
|
||||
UString RootFolder_GetName_Network(int &iconIndex)
|
||||
{
|
||||
iconIndex = GetIconIndexForCSIDL(CSIDL_NETWORK);
|
||||
return LangString(IDS_NETWORK);
|
||||
}
|
||||
|
||||
UString RootFolder_GetName_Documents(int &iconIndex);
|
||||
UString RootFolder_GetName_Documents(int &iconIndex)
|
||||
{
|
||||
iconIndex = GetIconIndexForCSIDL(CSIDL_PERSONAL);
|
||||
@@ -120,7 +123,7 @@ STDMETHODIMP CRootFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIA
|
||||
typedef BOOL (WINAPI *SHGetSpecialFolderPathWp)(HWND hwnd, LPWSTR pszPath, int csidl, BOOL fCreate);
|
||||
typedef BOOL (WINAPI *SHGetSpecialFolderPathAp)(HWND hwnd, LPSTR pszPath, int csidl, BOOL fCreate);
|
||||
|
||||
UString GetMyDocsPath()
|
||||
static UString GetMyDocsPath()
|
||||
{
|
||||
UString us;
|
||||
WCHAR s[MAX_PATH + 1];
|
||||
@@ -136,7 +139,7 @@ UString GetMyDocsPath()
|
||||
else
|
||||
{
|
||||
SHGetSpecialFolderPathAp getA = (SHGetSpecialFolderPathAp)
|
||||
::GetProcAddress(::GetModuleHandleA("shell32.dll"), "SHGetSpecialFolderPathA");
|
||||
(void *)::GetProcAddress(::GetModuleHandleA("shell32.dll"), "SHGetSpecialFolderPathA");
|
||||
CHAR s2[MAX_PATH + 1];
|
||||
if (getA && getA(0, s2, CSIDL_PERSONAL, FALSE))
|
||||
us = GetUnicodeString(s2);
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
|
||||
// #include "../../../Common/MyWindows.h"
|
||||
|
||||
// #include <commctrl.h>
|
||||
// #include <CommCtrl.h>
|
||||
// #include <ShlObj.h>
|
||||
// #include <shlwapi.h>
|
||||
// #include <Shlwapi.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,7 +23,7 @@ int GetIconIndexForCSIDL(int csidl)
|
||||
if (pidl)
|
||||
{
|
||||
SHFILEINFO shellInfo;
|
||||
SHGetFileInfo(LPCTSTR(pidl), FILE_ATTRIBUTE_NORMAL,
|
||||
SHGetFileInfo((LPCTSTR)(const void *)(pidl), FILE_ATTRIBUTE_NORMAL,
|
||||
&shellInfo, sizeof(shellInfo),
|
||||
SHGFI_PIDL | SHGFI_SYSICONINDEX);
|
||||
IMalloc *pMalloc;
|
||||
@@ -41,7 +41,7 @@ int GetIconIndexForCSIDL(int csidl)
|
||||
#ifndef _UNICODE
|
||||
typedef int (WINAPI * SHGetFileInfoWP)(LPCWSTR pszPath, DWORD attrib, SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags);
|
||||
|
||||
struct CSHGetFileInfoInit
|
||||
static struct CSHGetFileInfoInit
|
||||
{
|
||||
SHGetFileInfoWP shGetFileInfoW;
|
||||
CSHGetFileInfoInit()
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "../../../Common/MyWindows.h"
|
||||
|
||||
#include <commctrl.h>
|
||||
#include <CommCtrl.h>
|
||||
|
||||
#include "../../../Common/MyString.h"
|
||||
|
||||
|
||||
@@ -34,13 +34,16 @@ static const UInt32 kLangIDs[] =
|
||||
|
||||
CSysString CModifiedExtInfo::GetString() const
|
||||
{
|
||||
const char *s;
|
||||
if (State == kExtState_7Zip)
|
||||
return TEXT("7-Zip ZS");
|
||||
if (State == kExtState_Clear)
|
||||
return TEXT("");
|
||||
if (Other7Zip)
|
||||
return TEXT("[7-Zip ZS]");
|
||||
return ProgramKey;
|
||||
s = "7-Zip ZS";
|
||||
else if (State == kExtState_Clear)
|
||||
s = "";
|
||||
else if (Other7Zip)
|
||||
s = "[7-Zip ZS]";
|
||||
else
|
||||
return ProgramKey;
|
||||
return CSysString (s);
|
||||
};
|
||||
|
||||
|
||||
@@ -197,14 +200,14 @@ bool CSystemPage::OnInit()
|
||||
ci.mask = LVCF_TEXT | LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM;
|
||||
ci.cx = 128;
|
||||
ci.fmt = LVCFMT_CENTER;
|
||||
ci.pszText = (WCHAR *)(const WCHAR *)s;
|
||||
ci.pszText = s.Ptr_non_const();
|
||||
ci.iSubItem = 1;
|
||||
_listView.InsertColumn(1, &ci);
|
||||
|
||||
#if NUM_EXT_GROUPS > 1
|
||||
{
|
||||
LangString(IDS_SYSTEM_ALL_USERS, s);
|
||||
ci.pszText = (WCHAR *)(const WCHAR *)s;
|
||||
ci.pszText = s.Ptr_non_const();
|
||||
ci.iSubItem = 2;
|
||||
_listView.InsertColumn(2, &ci);
|
||||
}
|
||||
@@ -225,7 +228,7 @@ bool CSystemPage::OnInit()
|
||||
// ListView always uses internal iImage that is 0 by default?
|
||||
// so we always use LVIF_IMAGE.
|
||||
item.iImage = -1;
|
||||
item.pszText = (wchar_t *)(const wchar_t *)(LPCWSTR)extInfo.Ext;
|
||||
item.pszText = extInfo.Ext.Ptr_non_const();
|
||||
|
||||
CAssoc assoc;
|
||||
const CPluginToIcon &plug = extInfo.Plugins[0];
|
||||
|
||||
@@ -90,7 +90,7 @@ class CSystemPage: public NWindows::NControl::CPropertyPage
|
||||
|
||||
bool _needSave;
|
||||
|
||||
const HKEY GetHKey(unsigned
|
||||
HKEY GetHKey(unsigned
|
||||
#if NUM_EXT_GROUPS != 1
|
||||
group
|
||||
#endif
|
||||
|
||||
@@ -98,7 +98,7 @@ static int ComparePairItems(const CTextPair &p1, const CTextPair &p2)
|
||||
{ return ComparePairIDs(p1.ID, p2.ID); }
|
||||
|
||||
static int ComparePairItems(void *const *a1, void *const *a2, void * /* param */)
|
||||
{ return ComparePairItems(**(const CTextPair **)a1, **(const CTextPair **)a2); }
|
||||
{ return ComparePairItems(**(const CTextPair *const *)a1, **(const CTextPair *const *)a2); }
|
||||
|
||||
void CPairsStorage::Sort() { Pairs.Sort(ComparePairItems, 0); }
|
||||
|
||||
|
||||
367
CPP/7zip/UI/FileManager/VerCtrl.cpp
Normal file
367
CPP/7zip/UI/FileManager/VerCtrl.cpp
Normal file
@@ -0,0 +1,367 @@
|
||||
// VerCtrl.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Common/StringToInt.h"
|
||||
|
||||
#include "../../../Windows/FileName.h"
|
||||
#include "../../../Windows/FileFind.h"
|
||||
|
||||
#include "App.h"
|
||||
#include "RegistryUtils.h"
|
||||
#include "OverwriteDialog.h"
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NFind;
|
||||
using namespace NDir;
|
||||
|
||||
static UString ConvertPath_to_Ctrl(const UString &path)
|
||||
{
|
||||
UString s = path;
|
||||
s.Replace(L':', L'_');
|
||||
return s;
|
||||
}
|
||||
|
||||
struct CFileDataInfo
|
||||
{
|
||||
CByteBuffer Data;
|
||||
BY_HANDLE_FILE_INFORMATION Info;
|
||||
bool IsOpen;
|
||||
|
||||
CFileDataInfo(): IsOpen (false) {}
|
||||
UInt64 GetSize() const { return (((UInt64)Info.nFileSizeHigh) << 32) + Info.nFileSizeLow; }
|
||||
bool Read(const UString &path);
|
||||
};
|
||||
|
||||
|
||||
bool CFileDataInfo::Read(const UString &path)
|
||||
{
|
||||
IsOpen = false;
|
||||
NIO::CInFile file;
|
||||
if (!file.Open(path))
|
||||
return false;
|
||||
if (!file.GetFileInformation(&Info))
|
||||
return false;
|
||||
|
||||
const UInt64 size = GetSize();
|
||||
const size_t size2 = (size_t)size;
|
||||
if (size2 != size || size2 > (1 << 28))
|
||||
{
|
||||
SetLastError(1);
|
||||
return false;
|
||||
}
|
||||
|
||||
Data.Alloc(size2);
|
||||
|
||||
size_t processedSize;
|
||||
if (!file.ReadFull(Data, size2, processedSize))
|
||||
return false;
|
||||
if (processedSize != size2)
|
||||
{
|
||||
SetLastError(1);
|
||||
return false;
|
||||
}
|
||||
IsOpen = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static bool CreateComplexDir_for_File(const UString &path)
|
||||
{
|
||||
FString resDirPrefix;
|
||||
FString resFileName;
|
||||
if (!GetFullPathAndSplit(path, resDirPrefix, resFileName))
|
||||
return false;
|
||||
return CreateComplexDir(resDirPrefix);
|
||||
}
|
||||
|
||||
|
||||
static bool ParseNumberString(const FString &s, UInt32 &number)
|
||||
{
|
||||
const wchar_t *end;
|
||||
UInt64 result = ConvertStringToUInt64(s, &end);
|
||||
if (*end != 0 || s.IsEmpty() || result > (UInt32)0x7FFFFFFF)
|
||||
return false;
|
||||
number = (UInt32)result;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static void WriteFile(const FString &path, bool createAlways, const CFileDataInfo &fdi, const CPanel &panel)
|
||||
{
|
||||
NIO::COutFile outFile;
|
||||
if (!outFile.Create(path, createAlways)) // (createAlways = false) means CREATE_NEW
|
||||
{
|
||||
panel.MessageBox_LastError();
|
||||
return;
|
||||
}
|
||||
UInt32 processedSize;
|
||||
if (!outFile.Write(fdi.Data, (UInt32)fdi.Data.Size(), processedSize))
|
||||
{
|
||||
panel.MessageBox_LastError();
|
||||
return;
|
||||
}
|
||||
if (processedSize != fdi.Data.Size())
|
||||
{
|
||||
panel.MessageBox_Error(L"Write error");
|
||||
return;
|
||||
}
|
||||
if (!outFile.SetTime(
|
||||
&fdi.Info.ftCreationTime,
|
||||
&fdi.Info.ftLastAccessTime,
|
||||
&fdi.Info.ftLastWriteTime))
|
||||
{
|
||||
panel.MessageBox_LastError();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SetFileAttrib(path, fdi.Info.dwFileAttributes))
|
||||
{
|
||||
panel.MessageBox_LastError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CApp::VerCtrl(unsigned id)
|
||||
{
|
||||
const CPanel &panel = GetFocusedPanel();
|
||||
|
||||
if (!panel.Is_IO_FS_Folder())
|
||||
{
|
||||
panel.MessageBox_Error_UnsupportOperation();
|
||||
return;
|
||||
}
|
||||
|
||||
CRecordVector<UInt32> indices;
|
||||
panel.GetSelectedItemsIndices(indices);
|
||||
|
||||
if (indices.Size() != 1)
|
||||
{
|
||||
// panel.MessageBox_Error_UnsupportOperation();
|
||||
return;
|
||||
}
|
||||
|
||||
const UString path = panel.GetItemFullPath(indices[0]);
|
||||
|
||||
UString vercPath;
|
||||
ReadReg_VerCtrlPath(vercPath);
|
||||
if (vercPath.IsEmpty())
|
||||
return;
|
||||
NName::NormalizeDirPathPrefix(vercPath);
|
||||
|
||||
FString dirPrefix;
|
||||
FString fileName;
|
||||
if (!GetFullPathAndSplit(path, dirPrefix, fileName))
|
||||
{
|
||||
panel.MessageBox_LastError();
|
||||
return;
|
||||
}
|
||||
|
||||
const UString dirPrefix2 = vercPath + ConvertPath_to_Ctrl(dirPrefix);
|
||||
const UString path2 = dirPrefix2 + fileName;
|
||||
|
||||
bool sameTime = false;
|
||||
bool sameData = false;
|
||||
bool areIdentical = false;
|
||||
|
||||
CFileDataInfo fdi, fdi2;
|
||||
if (!fdi.Read(path))
|
||||
{
|
||||
panel.MessageBox_LastError();
|
||||
return;
|
||||
}
|
||||
|
||||
if (fdi2.Read(path2))
|
||||
{
|
||||
sameData = (fdi.Data == fdi2.Data);
|
||||
sameTime = (CompareFileTime(&fdi.Info.ftLastWriteTime, &fdi2.Info.ftLastWriteTime) == 0);
|
||||
areIdentical = (sameData && sameTime);
|
||||
}
|
||||
|
||||
const bool isReadOnly = NAttributes::IsReadOnly(fdi.Info.dwFileAttributes);
|
||||
|
||||
if (id == IDM_VER_EDIT)
|
||||
{
|
||||
if (!isReadOnly)
|
||||
{
|
||||
panel.MessageBox_Error(L"File is not read-only");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!areIdentical)
|
||||
{
|
||||
if (fdi2.IsOpen)
|
||||
{
|
||||
NFind::CEnumerator enumerator;
|
||||
FString d2 = dirPrefix2;
|
||||
d2 += "_7vc";
|
||||
d2.Add_PathSepar();
|
||||
d2 += fileName;
|
||||
d2.Add_PathSepar();
|
||||
enumerator.SetDirPrefix(d2);
|
||||
NFind::CDirEntry fi;
|
||||
Int32 maxVal = -1;
|
||||
while (enumerator.Next(fi))
|
||||
{
|
||||
UInt32 val;
|
||||
if (!ParseNumberString(fi.Name, val))
|
||||
continue;
|
||||
if ((Int32)val > maxVal)
|
||||
maxVal = val;
|
||||
}
|
||||
|
||||
UInt32 next = (UInt32)maxVal + 1;
|
||||
if (maxVal < 0)
|
||||
{
|
||||
next = 1;
|
||||
if (!::CreateComplexDir_for_File(path2))
|
||||
{
|
||||
panel.MessageBox_LastError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// we rename old file2 to some name;
|
||||
FString path_num = d2;
|
||||
{
|
||||
AString t;
|
||||
t.Add_UInt32((UInt32)next);
|
||||
while (t.Len() < 3)
|
||||
t.InsertAtFront('0');
|
||||
path_num += t;
|
||||
}
|
||||
|
||||
if (maxVal < 0)
|
||||
{
|
||||
if (!::CreateComplexDir_for_File(path_num))
|
||||
{
|
||||
panel.MessageBox_LastError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!NDir::MyMoveFile(path2, path_num))
|
||||
{
|
||||
panel.MessageBox_LastError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!::CreateComplexDir_for_File(path2))
|
||||
{
|
||||
panel.MessageBox_LastError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (!::CopyFile(fs2fas(path), fs2fas(path2), TRUE))
|
||||
{
|
||||
panel.MessageBox_LastError();
|
||||
return;
|
||||
}
|
||||
*/
|
||||
WriteFile(path2,
|
||||
false, // (createAlways = false) means CREATE_NEW
|
||||
fdi, panel);
|
||||
}
|
||||
|
||||
if (!SetFileAttrib(path, fdi.Info.dwFileAttributes & ~(DWORD)FILE_ATTRIBUTE_READONLY))
|
||||
{
|
||||
panel.MessageBox_LastError();
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (isReadOnly)
|
||||
{
|
||||
panel.MessageBox_Error(L"File is read-only");
|
||||
return;
|
||||
}
|
||||
|
||||
if (id == IDM_VER_COMMIT)
|
||||
{
|
||||
if (sameData)
|
||||
{
|
||||
if (!sameTime)
|
||||
{
|
||||
panel.MessageBox_Error(
|
||||
L"Same data, but different timestamps.\n"
|
||||
L"Use `Revert` to recover timestamp.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!SetFileAttrib(path, fdi.Info.dwFileAttributes | FILE_ATTRIBUTE_READONLY))
|
||||
{
|
||||
panel.MessageBox_LastError();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (id == IDM_VER_REVERT)
|
||||
{
|
||||
if (!fdi2.IsOpen)
|
||||
{
|
||||
panel.MessageBox_Error(L"No file to revert");
|
||||
return;
|
||||
}
|
||||
if (!sameData || !sameTime)
|
||||
{
|
||||
if (!sameData)
|
||||
{
|
||||
/*
|
||||
UString m;
|
||||
m = "Are you sure you want to revert file ?";
|
||||
m.Add_LF();
|
||||
m += path;
|
||||
if (::MessageBoxW(panel.GetParent(), m, L"Version Control: File Revert", MB_OKCANCEL | MB_ICONQUESTION) != IDOK)
|
||||
return;
|
||||
*/
|
||||
COverwriteDialog dialog;
|
||||
|
||||
dialog.OldFileInfo.SetTime(&fdi.Info.ftLastWriteTime);
|
||||
dialog.OldFileInfo.SetSize(fdi.GetSize());
|
||||
dialog.OldFileInfo.Name = path;
|
||||
|
||||
dialog.NewFileInfo.SetTime(&fdi2.Info.ftLastWriteTime);
|
||||
dialog.NewFileInfo.SetSize(fdi2.GetSize());
|
||||
dialog.NewFileInfo.Name = path2;
|
||||
|
||||
dialog.ShowExtraButtons = false;
|
||||
dialog.DefaultButton_is_NO = true;
|
||||
|
||||
INT_PTR writeAnswer = dialog.Create(panel.GetParent());
|
||||
|
||||
if (writeAnswer != IDYES)
|
||||
return;
|
||||
}
|
||||
|
||||
WriteFile(path,
|
||||
true, // (createAlways = true) means CREATE_ALWAYS
|
||||
fdi2, panel);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!SetFileAttrib(path, fdi2.Info.dwFileAttributes | FILE_ATTRIBUTE_READONLY))
|
||||
{
|
||||
panel.MessageBox_LastError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// if (id == IDM_VER_DIFF)
|
||||
{
|
||||
if (!fdi2.IsOpen)
|
||||
return;
|
||||
DiffFiles(path2, path);
|
||||
}
|
||||
}
|
||||
@@ -194,14 +194,14 @@ void CWindowInfo::Read(bool &windowPosDefined, bool &panelInfoDefined)
|
||||
}
|
||||
|
||||
|
||||
void SaveUi32Val(const TCHAR *name, UInt32 value)
|
||||
static void SaveUi32Val(const TCHAR *name, UInt32 value)
|
||||
{
|
||||
CKey key;
|
||||
key.Create(HKEY_CURRENT_USER, kCUBasePath);
|
||||
key.SetValue(name, value);
|
||||
}
|
||||
|
||||
bool ReadUi32Val(const TCHAR *name, UInt32 &value)
|
||||
static bool ReadUi32Val(const TCHAR *name, UInt32 &value)
|
||||
{
|
||||
CKey key;
|
||||
if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS)
|
||||
|
||||
@@ -56,6 +56,11 @@
|
||||
#define IDM_LINK 558
|
||||
#define IDM_ALT_STREAMS 559
|
||||
|
||||
#define IDM_VER_EDIT 580
|
||||
#define IDM_VER_COMMIT 581
|
||||
#define IDM_VER_REVERT 582
|
||||
#define IDM_VER_DIFF 583
|
||||
|
||||
#define IDM_OPEN_INSIDE_ONE 590
|
||||
#define IDM_OPEN_INSIDE_PARSER 591
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ BEGIN
|
||||
|
||||
IDS_FILE_EXIST "File {0} is already exist"
|
||||
IDS_WANT_UPDATE_MODIFIED_FILE "File '{0}' was modified.\nDo you want to update it in the archive?"
|
||||
IDS_CANNOT_UPDATE_FILE "Can not update file\n'{0}'"
|
||||
IDS_CANNOT_UPDATE_FILE "Cannot update file\n'{0}'"
|
||||
IDS_CANNOT_START_EDITOR "Cannot start editor."
|
||||
IDS_VIRUS "The file looks like a virus (the file name contains long spaces in name)."
|
||||
IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER "The operation cannot be called from a folder that has a long path."
|
||||
@@ -247,8 +247,8 @@ BEGIN
|
||||
IDS_COMBINE_TO "&Combine to:"
|
||||
IDS_COMBINING "Combining..."
|
||||
IDS_COMBINE_SELECT_ONE_FILE "Select only first part of split file"
|
||||
IDS_COMBINE_CANT_DETECT_SPLIT_FILE "Can not detect file as split file"
|
||||
IDS_COMBINE_CANT_FIND_MORE_THAN_ONE_PART "Can not find more than one part of split file"
|
||||
IDS_COMBINE_CANT_DETECT_SPLIT_FILE "Cannot detect file as split file"
|
||||
IDS_COMBINE_CANT_FIND_MORE_THAN_ONE_PART "Cannot find more than one part of split file"
|
||||
|
||||
END
|
||||
|
||||
|
||||
Reference in New Issue
Block a user