Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/7zip/UI/FileManager')
-rwxr-xr-xCPP/7zip/UI/FileManager/App.cpp27
-rwxr-xr-xCPP/7zip/UI/FileManager/App.h2
-rwxr-xr-xCPP/7zip/UI/FileManager/BrowseDialog.cpp38
-rwxr-xr-xCPP/7zip/UI/FileManager/BrowseDialog.h6
-rwxr-xr-xCPP/7zip/UI/FileManager/ExtractCallback.cpp45
-rwxr-xr-xCPP/7zip/UI/FileManager/ExtractCallback.h1
-rwxr-xr-xCPP/7zip/UI/FileManager/FM.cpp35
-rwxr-xr-xCPP/7zip/UI/FileManager/FSDrives.cpp48
-rwxr-xr-xCPP/7zip/UI/FileManager/FSDrives.h8
-rwxr-xr-xCPP/7zip/UI/FileManager/FSFolder.cpp88
-rwxr-xr-xCPP/7zip/UI/FileManager/FSFolder.h26
-rwxr-xr-xCPP/7zip/UI/FileManager/FSFolderCopy.cpp157
-rwxr-xr-xCPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp39
-rwxr-xr-xCPP/7zip/UI/FileManager/FileFolderPluginOpen.h2
-rwxr-xr-xCPP/7zip/UI/FileManager/FilePlugins.cpp104
-rwxr-xr-xCPP/7zip/UI/FileManager/FilePlugins.h47
-rwxr-xr-xCPP/7zip/UI/FileManager/FoldersPage.cpp8
-rwxr-xr-xCPP/7zip/UI/FileManager/HelpUtils.cpp10
-rwxr-xr-xCPP/7zip/UI/FileManager/IFolder.h3
-rwxr-xr-xCPP/7zip/UI/FileManager/LangUtils.cpp51
-rwxr-xr-xCPP/7zip/UI/FileManager/LangUtils.h6
-rwxr-xr-xCPP/7zip/UI/FileManager/ListViewDialog.cpp7
-rwxr-xr-xCPP/7zip/UI/FileManager/MenuPage.cpp2
-rwxr-xr-xCPP/7zip/UI/FileManager/MessagesDialog.cpp5
-rwxr-xr-xCPP/7zip/UI/FileManager/MyLoadMenu.cpp31
-rwxr-xr-xCPP/7zip/UI/FileManager/NetFolder.cpp10
-rwxr-xr-xCPP/7zip/UI/FileManager/OpenCallback.cpp13
-rwxr-xr-xCPP/7zip/UI/FileManager/OpenCallback.h6
-rwxr-xr-xCPP/7zip/UI/FileManager/OptionsDialog.cpp10
-rwxr-xr-xCPP/7zip/UI/FileManager/Panel.cpp67
-rwxr-xr-xCPP/7zip/UI/FileManager/Panel.h47
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelCrc.cpp44
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelDrag.cpp28
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelFolderChange.cpp68
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelItemOpen.cpp323
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelItems.cpp11
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelListNotify.cpp18
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelMenu.cpp3
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelOperations.cpp28
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelSelect.cpp14
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelSort.cpp4
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelSplitFile.cpp68
-rwxr-xr-xCPP/7zip/UI/FileManager/PasswordDialog.cpp23
-rwxr-xr-xCPP/7zip/UI/FileManager/PasswordDialog.h8
-rwxr-xr-xCPP/7zip/UI/FileManager/PluginLoader.h4
-rwxr-xr-xCPP/7zip/UI/FileManager/ProgramLocation.cpp21
-rwxr-xr-xCPP/7zip/UI/FileManager/ProgramLocation.h4
-rwxr-xr-xCPP/7zip/UI/FileManager/ProgressDialog2.cpp17
-rwxr-xr-xCPP/7zip/UI/FileManager/ProgressDialog2.h7
-rwxr-xr-xCPP/7zip/UI/FileManager/ProgressDialog2Res.h4
-rwxr-xr-xCPP/7zip/UI/FileManager/RegistryAssociations.cpp295
-rwxr-xr-xCPP/7zip/UI/FileManager/RegistryAssociations.h47
-rwxr-xr-xCPP/7zip/UI/FileManager/RegistryPlugins.cpp18
-rwxr-xr-xCPP/7zip/UI/FileManager/RegistryPlugins.h6
-rwxr-xr-xCPP/7zip/UI/FileManager/RootFolder.cpp8
-rwxr-xr-xCPP/7zip/UI/FileManager/SettingsPage.cpp1
-rwxr-xr-xCPP/7zip/UI/FileManager/SysIconUtils.cpp38
-rwxr-xr-xCPP/7zip/UI/FileManager/SysIconUtils.h5
-rwxr-xr-xCPP/7zip/UI/FileManager/SystemPage.cpp591
-rwxr-xr-xCPP/7zip/UI/FileManager/SystemPage.h108
-rwxr-xr-xCPP/7zip/UI/FileManager/SystemPage.rc17
-rwxr-xr-xCPP/7zip/UI/FileManager/SystemPageRes.h6
-rwxr-xr-xCPP/7zip/UI/FileManager/resource.h1
-rwxr-xr-xCPP/7zip/UI/FileManager/resource.rc3
64 files changed, 1418 insertions, 1372 deletions
diff --git a/CPP/7zip/UI/FileManager/App.cpp b/CPP/7zip/UI/FileManager/App.cpp
index c195a79d..5f31f607 100755
--- a/CPP/7zip/UI/FileManager/App.cpp
+++ b/CPP/7zip/UI/FileManager/App.cpp
@@ -11,6 +11,8 @@
#include "Windows/COM.h"
#include "Windows/Error.h"
#include "Windows/FileDir.h"
+#include "Windows/FileName.h"
+
#include "Windows/PropVariant.h"
#include "Windows/PropVariantConversions.h"
#include "Windows/Thread.h"
@@ -31,7 +33,7 @@ using namespace NFind;
extern DWORD g_ComCtl32Version;
extern HINSTANCE g_hInstance;
-static LPCWSTR kTempDirPrefix = L"7zE";
+static CFSTR kTempDirPrefix = FTEXT("7zE");
void CPanelCallbackImp::OnTab()
{
@@ -374,7 +376,7 @@ static void ReducePathToRealFileSystemPath(UString &path)
{
while (!path.IsEmpty())
{
- if (NFind::DoesDirExist(path))
+ if (NFind::DoesDirExist(us2fs(path)))
{
NName::NormalizeDirPathPrefix(path);
break;
@@ -510,6 +512,8 @@ UString CPanel::GetItemsInfoString(const CRecordVector<UInt32> &indices)
return info;
}
+bool IsCorrectFsName(const UString name);
+
void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
{
int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
@@ -599,10 +603,10 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
if (indices.Size() > 1 ||
(!destPath.IsEmpty() && destPath.Back() == WCHAR_PATH_SEPARATOR) ||
- NFind::DoesDirExist(destPath) ||
+ NFind::DoesDirExist(us2fs(destPath)) ||
srcPanel.IsArcFolder())
{
- NDirectory::CreateComplexDirectory(destPath);
+ NDirectory::CreateComplexDirectory(us2fs(destPath));
NName::NormalizeDirPathPrefix(destPath);
if (!CheckFolderPath(destPath))
{
@@ -616,11 +620,16 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
}
else
{
+ if (!IsCorrectFsName(destPath))
+ {
+ srcPanel.MessageBoxError(E_INVALIDARG);
+ return;
+ }
int pos = destPath.ReverseFind(WCHAR_PATH_SEPARATOR);
if (pos >= 0)
{
UString prefix = destPath.Left(pos + 1);
- NDirectory::CreateComplexDirectory(prefix);
+ NDirectory::CreateComplexDirectory(us2fs(prefix));
if (!CheckFolderPath(prefix))
{
srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
@@ -645,8 +654,8 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
bool useSrcPanel = (!useDestPanel || !srcPanel.IsFsOrDrivesFolder() || destPanel.IsFSFolder());
bool useTemp = useSrcPanel && useDestPanel;
- NFile::NDirectory::CTempDirectoryW tempDirectory;
- UString tempDirPrefix;
+ NFile::NDirectory::CTempDir tempDirectory;
+ FString tempDirPrefix;
if (useTemp)
{
tempDirectory.Create(kTempDirPrefix);
@@ -662,7 +671,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
HRESULT result;
if (useSrcPanel)
{
- UString folder = useTemp ? tempDirPrefix : destPath;
+ UString folder = useTemp ? fs2us(tempDirPrefix) : destPath;
result = srcPanel.CopyTo(indices, folder, move, true, 0);
if (result != S_OK)
{
@@ -681,7 +690,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
UStringVector filePaths;
UString folderPrefix;
if (useTemp)
- folderPrefix = tempDirPrefix;
+ folderPrefix = fs2us(tempDirPrefix);
else
folderPrefix = srcPanel._currentFolderPrefix;
filePaths.Reserve(indices.Size());
diff --git a/CPP/7zip/UI/FileManager/App.h b/CPP/7zip/UI/FileManager/App.h
index a057c34e..2af63b47 100755
--- a/CPP/7zip/UI/FileManager/App.h
+++ b/CPP/7zip/UI/FileManager/App.h
@@ -202,7 +202,7 @@ public:
void SelectSpec(bool selectMode) { GetFocusedPanel().SelectSpec(selectMode); }
void SelectByType(bool selectMode) { GetFocusedPanel().SelectByType(selectMode); }
- void RefreshStatusBar() { GetFocusedPanel().RefreshStatusBar(); }
+ void Refresh_StatusBar() { GetFocusedPanel().Refresh_StatusBar(); }
void SetListViewMode(UInt32 index) { GetFocusedPanel().SetListViewMode(index); }
UInt32 GetListViewMode() { return GetFocusedPanel().GetListViewMode(); }
diff --git a/CPP/7zip/UI/FileManager/BrowseDialog.cpp b/CPP/7zip/UI/FileManager/BrowseDialog.cpp
index 602b12f3..1c350064 100755
--- a/CPP/7zip/UI/FileManager/BrowseDialog.cpp
+++ b/CPP/7zip/UI/FileManager/BrowseDialog.cpp
@@ -2,13 +2,14 @@
#include "StdAfx.h"
-#ifdef UNDER_CE
+#include "BrowseDialog.h"
+
+#ifdef USE_MY_BROWSE_DIALOG
#include "Common/IntToString.h"
#include "Windows/PropVariantConversions.h"
-#include "BrowseDialog.h"
#include "LangUtils.h"
#include "PropertyNameRes.h"
@@ -60,7 +61,7 @@ bool CBrowseDialog::OnInit()
_list.Attach(GetItem(IDC_BROWSE_LIST));
#ifndef UNDER_CE
- _list.SetUnicodeFormat(true);
+ _list.SetUnicodeFormat();
#endif
#ifndef _SFX
@@ -191,8 +192,8 @@ int CBrowseDialog::CompareItems(LPARAM lParam1, LPARAM lParam2)
{
if (lParam1 == kParentIndex) return -1;
if (lParam2 == kParentIndex) return 1;
- const CFileInfoW &f1 = _files[(int)lParam1];
- const CFileInfoW &f2 = _files[(int)lParam2];
+ const CFileInfo &f1 = _files[(int)lParam1];
+ const CFileInfo &f2 = _files[(int)lParam2];
bool isDir1 = f1.IsDir();
bool isDir2 = f2.IsDir();
@@ -225,12 +226,12 @@ static HRESULT GetNormalizedError()
HRESULT CBrowseDialog::Reload(const UString &pathPrefix, const UString &selectedName)
{
- CEnumeratorW enumerator(pathPrefix + L'*');
- CObjectVector<CFileInfoW> files;
+ CEnumerator enumerator(us2fs(pathPrefix + L'*'));
+ CObjectVector<CFileInfo> files;
for (;;)
{
bool found;
- CFileInfoW fi;
+ CFileInfo fi;
if (!enumerator.Next(fi, found))
return GetNormalizedError();
if (!found)
@@ -278,16 +279,17 @@ HRESULT CBrowseDialog::Reload(const UString &pathPrefix, const UString &selected
for (int i = 0; i < _files.Size(); i++)
{
- const CFileInfoW &fi = _files[i];
+ const CFileInfo &fi = _files[i];
item.iItem = index;
- if (fi.Name.CompareNoCase(selectedName) == 0)
+ const UString name = fs2us(fi.Name);
+ if (name.CompareNoCase(selectedName) == 0)
cursorIndex = item.iItem;
item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
int subItem = 0;
item.iSubItem = subItem++;
item.lParam = i;
- item.pszText = (wchar_t *)(const wchar_t *)fi.Name;
- item.iImage = _extToIconMap.GetIconIndex(fi.Attrib, Path + fi.Name);
+ item.pszText = (wchar_t *)(const wchar_t *)name;
+ item.iImage = _extToIconMap.GetIconIndex(fi.Attrib, Path + name);
if (item.iImage < 0)
item.iImage = 0;
_list.InsertItem(&item);
@@ -325,7 +327,7 @@ HRESULT CBrowseDialog::Reload()
{
int fileIndex = GetRealItemIndex(index);
if (fileIndex != kParentIndex)
- selectedCur = _files[fileIndex].Name;
+ selectedCur = fs2us(_files[fileIndex].Name);
}
return Reload(Path, selectedCur);
}
@@ -443,13 +445,13 @@ void CBrowseDialog::FinishOnOK()
OpenParentFolder();
return;
}
- const CFileInfoW &file = _files[fileIndex];
+ const CFileInfo &file = _files[fileIndex];
if (file.IsDir() != FolderMode)
{
ShowSelectError();
return;
}
- Path += file.Name;
+ Path += fs2us(file.Name);
}
End(IDOK);
}
@@ -464,7 +466,7 @@ void CBrowseDialog::OnItemEnter()
OpenParentFolder();
else
{
- const CFileInfoW &file = _files[fileIndex];
+ const CFileInfo &file = _files[fileIndex];
if (!file.IsDir())
{
if (!FolderMode)
@@ -473,7 +475,7 @@ void CBrowseDialog::OnItemEnter()
ShowSelectError();
return;
}
- HRESULT res = Reload(Path + file.Name + WCHAR_PATH_SEPARATOR, L"");
+ HRESULT res = Reload(Path + fs2us(file.Name) + WCHAR_PATH_SEPARATOR, L"");
if (res != S_OK)
ShowError(HResultToMessage(res));
}
@@ -481,6 +483,8 @@ void CBrowseDialog::OnItemEnter()
void CBrowseDialog::OnOK()
{
+ // When we press "Enter" in listview, windows sends message to first Button.
+ // We check that message was from listview;
if (GetFocus() == _list)
{
OnItemEnter();
diff --git a/CPP/7zip/UI/FileManager/BrowseDialog.h b/CPP/7zip/UI/FileManager/BrowseDialog.h
index 41eb6b50..f597d1c3 100755
--- a/CPP/7zip/UI/FileManager/BrowseDialog.h
+++ b/CPP/7zip/UI/FileManager/BrowseDialog.h
@@ -4,6 +4,10 @@
#define __BROWSE_DIALOG_H
#ifdef UNDER_CE
+#define USE_MY_BROWSE_DIALOG
+#endif
+
+#ifdef USE_MY_BROWSE_DIALOG
#include "Windows/FileFind.h"
@@ -16,7 +20,7 @@
class CBrowseDialog: public NWindows::NControl::CModalDialog
{
NWindows::NControl::CListView _list;
- CObjectVector<NWindows::NFile::NFind::CFileInfoW> _files;
+ CObjectVector<NWindows::NFile::NFind::CFileInfo> _files;
CExtToIconMap _extToIconMap;
int _sortIndex;
bool _ascending;
diff --git a/CPP/7zip/UI/FileManager/ExtractCallback.cpp b/CPP/7zip/UI/FileManager/ExtractCallback.cpp
index d27db23f..90076ebb 100755
--- a/CPP/7zip/UI/FileManager/ExtractCallback.cpp
+++ b/CPP/7zip/UI/FileManager/ExtractCallback.cpp
@@ -2,12 +2,18 @@
#include "StdAfx.h"
+#include "Common/StringConvert.h"
+
#include "Windows/Error.h"
#include "Windows/FileDir.h"
#include "Windows/FileFind.h"
#include "../../Common/FilePathAutoRename.h"
+#ifndef _SFX
+#include "../Common/ZipRegistry.h"
+#endif
+
#include "../GUI/ExtractRes.h"
#include "ExtractCallback.h"
@@ -177,6 +183,11 @@ STDMETHODIMP CExtractCallbackImp::MessageError(const wchar_t *message)
return S_OK;
}
+HRESULT CExtractCallbackImp::MessageError(const char *message, const FString &path)
+{
+ return MessageError(GetUnicodeString(message) + fs2us(path));
+}
+
STDMETHODIMP CExtractCallbackImp::ShowMessage(const wchar_t *message)
{
AddErrorMessage(message);
@@ -296,7 +307,7 @@ HRESULT CExtractCallbackImp::OpenResult(const wchar_t *name, HRESULT result, boo
MyLoadStringW(IDS_MEM_ERROR);
#endif
else
- NError::MyFormatMessage(result, message2);
+ message2 = NError::MyFormatMessageW(result);
message += message2;
}
MessageError(message);
@@ -339,11 +350,19 @@ STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password)
if (!PasswordIsDefined)
{
CPasswordDialog dialog;
+ #ifndef _SFX
+ bool showPassword = NExtract::Read_ShowPassword();
+ dialog.ShowPassword = showPassword;
+ #endif
ProgressDialog->WaitCreating();
if (dialog.Create(*ProgressDialog) == IDCANCEL)
return E_ABORT;
Password = dialog.Password;
PasswordIsDefined = true;
+ #ifndef _SFX
+ if (dialog.ShowPassword != showPassword)
+ NExtract::Save_ShowPassword(dialog.ShowPassword);
+ #endif
}
return StringToBstr(Password, password);
}
@@ -366,19 +385,16 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
*writeAnswer = BoolToInt(false);
UString destPathSpec = destPath;
- UString destPathSys = destPathSpec;
+ FString destPathSys = us2fs(destPath);
bool srcIsFolderSpec = IntToBool(srcIsFolder);
- CFileInfoW destFileInfo;
+ CFileInfo destFileInfo;
if (destFileInfo.Find(destPathSys))
{
if (srcIsFolderSpec)
{
if (!destFileInfo.IsDir())
{
- UString message = UString(L"can not replace file \'")
- + destPathSpec +
- UString(L"\' with folder with same name");
- RINOK(MessageError(message));
+ RINOK(MessageError("can not replace file with folder with same name: ", destPathSys));
return E_ABORT;
}
*writeAnswer = BoolToInt(false);
@@ -386,10 +402,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
}
if (destFileInfo.IsDir())
{
- UString message = UString(L"can not replace folder \'")
- + destPathSpec +
- UString(L"\' with file with same name");
- RINOK(MessageError(message));
+ RINOK(MessageError("can not replace folder with file with same name: ", destPathSys));
return E_FAIL;
}
@@ -432,19 +445,15 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
{
if (!AutoRenamePath(destPathSys))
{
- UString message = UString(L"can not create name of file ")
- + destPathSys;
- RINOK(MessageError(message));
+ RINOK(MessageError("can not create name for file: ", destPathSys));
return E_ABORT;
}
- destPathResultTemp = destPathSys;
+ destPathResultTemp = fs2us(destPathSys);
}
else
if (!NFile::NDirectory::DeleteFileAlways(destPathSys))
{
- UString message = UString(L"can not delete output file ")
- + destPathSys;
- RINOK(MessageError(message));
+ RINOK(MessageError("can not delete output file: ", destPathSys));
return E_ABORT;
}
}
diff --git a/CPP/7zip/UI/FileManager/ExtractCallback.h b/CPP/7zip/UI/FileManager/ExtractCallback.h
index b4e88fd5..19c29e77 100755
--- a/CPP/7zip/UI/FileManager/ExtractCallback.h
+++ b/CPP/7zip/UI/FileManager/ExtractCallback.h
@@ -35,6 +35,7 @@ class CExtractCallbackImp:
#endif
public CMyUnknownImp
{
+ HRESULT MessageError(const char *message, const FString &path);
public:
MY_QUERYINTERFACE_BEGIN2(IFolderOperationsExtractCallback)
MY_QUERYINTERFACE_ENTRY(IFolderArchiveExtractCallback)
diff --git a/CPP/7zip/UI/FileManager/FM.cpp b/CPP/7zip/UI/FileManager/FM.cpp
index f3b48704..147a1fb7 100755
--- a/CPP/7zip/UI/FileManager/FM.cpp
+++ b/CPP/7zip/UI/FileManager/FM.cpp
@@ -33,7 +33,9 @@ using namespace NFind;
#define MENU_HEIGHT 26
+#ifdef _WIN32
HINSTANCE g_hInstance;
+#endif
HWND g_HWND;
bool g_OpenArchive = false;
static UString g_MainPath;
@@ -114,7 +116,7 @@ public:
};
static bool g_CanChangeSplitter = false;
-static UINT32 g_SplitterPos = 0;
+static UInt32 g_SplitterPos = 0;
static CSplitterPos g_Splitter;
static bool g_PanelsInfoDefined = false;
@@ -208,7 +210,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
ySize = rect.bottom - rect.top;
}
- UINT32 numPanels, currentPanel;
+ UInt32 numPanels, currentPanel;
g_PanelsInfoDefined = ReadPanelsInfo(numPanels, currentPanel, g_SplitterPos);
if (g_PanelsInfoDefined)
{
@@ -409,6 +411,30 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
{
#ifdef _WIN32
+ /*
+ #ifndef _WIN64
+ #ifndef UNDER_CE
+ {
+ HMODULE hMod = GetModuleHandle("Kernel32.dll");
+ if (hMod)
+ {
+ typedef BOOL (WINAPI *PSETDEP)(DWORD);
+ #define MY_PROCESS_DEP_ENABLE 1
+ PSETDEP procSet = (PSETDEP)GetProcAddress(hMod,"SetProcessDEPPolicy");
+ if (procSet)
+ procSet(MY_PROCESS_DEP_ENABLE);
+
+ typedef BOOL (WINAPI *HSI)(HANDLE, HEAP_INFORMATION_CLASS ,PVOID, SIZE_T);
+ HSI hsi = (HSI)GetProcAddress(hMod, "HeapSetInformation");
+ #define MY_HeapEnableTerminationOnCorruption ((HEAP_INFORMATION_CLASS)1)
+ if (hsi)
+ hsi(NULL, MY_HeapEnableTerminationOnCorruption, NULL, 0);
+ }
+ }
+ #endif
+ #endif
+ */
+
NT_CHECK
SetLargePageSize();
@@ -639,7 +665,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
bool needOpenFile = false;
if (!g_MainPath.IsEmpty() /* && g_OpenArchive */)
{
- if (NFile::NFind::DoesFileExist(g_MainPath))
+ if (NFile::NFind::DoesFileExist(us2fs(g_MainPath)))
needOpenFile = true;
}
HRESULT res = g_App.Create(hWnd, g_MainPath, g_ArcFormat, xSizes, archiveIsOpened, encrypted);
@@ -665,8 +691,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (res == E_OUTOFMEMORY)
message = LangString(IDS_MEM_ERROR, 0x0200060B);
else
- if (!NError::MyFormatMessage(res, message))
- message = L"Error";
+ message = NError::MyFormatMessageW(res);
}
}
MessageBoxW(0, message, L"7-zip", MB_ICONERROR);
diff --git a/CPP/7zip/UI/FileManager/FSDrives.cpp b/CPP/7zip/UI/FileManager/FSDrives.cpp
index 87ee3fc9..823b0826 100755
--- a/CPP/7zip/UI/FileManager/FSDrives.cpp
+++ b/CPP/7zip/UI/FileManager/FSDrives.cpp
@@ -26,9 +26,9 @@ using namespace NWindows;
using namespace NFile;
using namespace NFind;
-static const wchar_t *kVolPrefix = L"\\\\.\\";
+static CFSTR kVolPrefix = FTEXT("\\\\.\\");
-UString CDriveInfo::GetDeviceFileIoName() const
+FString CDriveInfo::GetDeviceFileIoName() const
{
return kVolPrefix + Name;
}
@@ -40,7 +40,7 @@ struct CPhysTempBuffer
~CPhysTempBuffer() { MidFree(buffer); }
};
-static HRESULT CopyFileSpec(LPCWSTR fromPath, LPCWSTR toPath, bool writeToDisk, UInt64 fileSize,
+static HRESULT CopyFileSpec(CFSTR fromPath, CFSTR toPath, bool writeToDisk, UInt64 fileSize,
UInt32 bufferSize, UInt64 progressStart, IProgress *progress)
{
NFile::NIO::CInFile inFile;
@@ -120,17 +120,17 @@ STDMETHODIMP CFSDrives::LoadItems()
{
_drives.Clear();
- UStringVector driveStrings;
+ FStringVector driveStrings;
MyGetLogicalDriveStrings(driveStrings);
for (int i = 0; i < driveStrings.Size(); i++)
{
CDriveInfo di;
- const UString &driveName = driveStrings[i];
+ const FString &driveName = driveStrings[i];
di.FullSystemName = driveName;
-
- di.Name = di.FullSystemName.Left(di.FullSystemName.Length() - 1);
+ if (!driveName.IsEmpty())
+ di.Name = driveName.Left(driveName.Length() - 1);
di.ClusterSize = 0;
di.DriveSize = 0;
di.FreeSpace = 0;
@@ -150,14 +150,11 @@ STDMETHODIMP CFSDrives::LoadItems()
}
if (needRead)
{
- UString volumeName, fileSystemName;
DWORD volumeSerialNumber, maximumComponentLength, fileSystemFlags;
NFile::NSystem::MyGetVolumeInformation(driveName,
- volumeName,
+ di.VolumeName,
&volumeSerialNumber, &maximumComponentLength, &fileSystemFlags,
- fileSystemName);
- di.VolumeName = volumeName;
- di.FileSystemName = fileSystemName;
+ di.FileSystemName);
NFile::NSystem::MyGetDiskFreeSpace(driveName,
di.ClusterSize, di.DriveSize, di.FreeSpace);
@@ -198,7 +195,7 @@ STDMETHODIMP CFSDrives::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT
return S_OK;
}
-HRESULT CFSDrives::BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder)
+HRESULT CFSDrives::BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder)
{
*resultFolder = 0;
if (_volumeMode)
@@ -232,7 +229,7 @@ STDMETHODIMP CFSDrives::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
STDMETHODIMP CFSDrives::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
{
- return BindToFolderSpec(name, resultFolder);
+ return BindToFolderSpec(us2fs(name), resultFolder);
}
STDMETHODIMP CFSDrives::BindToParentFolder(IFolderFolder **resultFolder)
@@ -252,7 +249,7 @@ STDMETHODIMP CFSDrives::GetFolderProperty(PROPID propID, PROPVARIANT *value)
case kpidType: prop = L"FSDrives"; break;
case kpidPath:
if (_volumeMode)
- prop = kVolPrefix;
+ prop = fs2us(kVolPrefix);
else
prop = LangString(IDS_COMPUTER, 0x03020300) + UString(WCHAR_PATH_SEPARATOR);
break;
@@ -325,7 +322,7 @@ STDMETHODIMP CFSDrives::CopyTo(const UInt32 *indices, UInt32 numItems,
UString destPath = path;
if (destPath.IsEmpty())
return E_INVALIDARG;
- bool directName = (destPath[destPath.Length() - 1] != WCHAR_PATH_SEPARATOR);
+ bool directName = (destPath.Back() != WCHAR_PATH_SEPARATOR);
if (directName)
{
if (numItems > 1)
@@ -339,18 +336,18 @@ STDMETHODIMP CFSDrives::CopyTo(const UInt32 *indices, UInt32 numItems,
int index = indices[i];
const CDriveInfo &di = _drives[index];
UString destPath2 = destPath;
- UString name = di.Name;
+ UString name = fs2us(di.Name);
if (!directName)
{
UString destName = name;
- if (!destName.IsEmpty() && destName[destName.Length() - 1] == L':')
+ if (!destName.IsEmpty() && destName.Back() == L':')
{
- destName.Delete(destName.Length() - 1);
+ destName.DeleteBack();
destName += GetExt(index);
}
destPath2 += destName;
}
- UString srcPath = di.GetDeviceFileIoName();
+ FString srcPath = di.GetDeviceFileIoName();
UInt64 fileSize = 0;
if (GetLength(index, fileSize) != S_OK)
@@ -363,16 +360,16 @@ STDMETHODIMP CFSDrives::CopyTo(const UInt32 *indices, UInt32 numItems,
Int32 writeAskResult;
CMyComBSTR destPathResult;
- RINOK(callback->AskWrite(srcPath, BoolToInt(false), NULL, &fileSize,
+ RINOK(callback->AskWrite(fs2us(srcPath), BoolToInt(false), NULL, &fileSize,
destPath2, &destPathResult, &writeAskResult));
if (!IntToBool(writeAskResult))
continue;
- RINOK(callback->SetCurrentFilePath(srcPath));
+ RINOK(callback->SetCurrentFilePath(fs2us(srcPath)));
static const UInt32 kBufferSize = (4 << 20);
UInt32 bufferSize = (di.DriveType == DRIVE_REMOVABLE) ? (18 << 10) * 4 : kBufferSize;
- RINOK(CopyFileSpec(srcPath, destPathResult, false, fileSize, bufferSize, completedSize, callback));
+ RINOK(CopyFileSpec(srcPath, us2fs(destPathResult), false, fileSize, bufferSize, completedSize, callback));
completedSize += fileSize;
}
return S_OK;
@@ -393,6 +390,11 @@ STDMETHODIMP CFSDrives::CopyFrom(const wchar_t * /* fromFolderPath */,
return E_NOTIMPL;
}
+STDMETHODIMP CFSDrives::CopyFromFile(UInt32 /* index */, const wchar_t * /* fullFilePath */, IProgress * /* progress */)
+{
+ return E_NOTIMPL;
+}
+
STDMETHODIMP CFSDrives::CreateFolder(const wchar_t * /* name */, IProgress * /* progress */)
{
return E_NOTIMPL;
diff --git a/CPP/7zip/UI/FileManager/FSDrives.h b/CPP/7zip/UI/FileManager/FSDrives.h
index fc99bce7..a0cfd9be 100755
--- a/CPP/7zip/UI/FileManager/FSDrives.h
+++ b/CPP/7zip/UI/FileManager/FSDrives.h
@@ -10,8 +10,8 @@
struct CDriveInfo
{
- UString Name;
- UString FullSystemName;
+ FString Name;
+ FString FullSystemName;
bool KnownSizes;
UInt64 DriveSize;
UInt64 FreeSpace;
@@ -21,7 +21,7 @@ struct CDriveInfo
UString FileSystemName;
UINT DriveType;
- UString GetDeviceFileIoName() const;
+ FString GetDeviceFileIoName() const;
};
class CFSDrives:
@@ -33,7 +33,7 @@ class CFSDrives:
CObjectVector<CDriveInfo> _drives;
bool _volumeMode;
- HRESULT BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder);
+ HRESULT BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder);
UString GetExt(int index) const;
HRESULT GetLength(int index, UInt64 &length) const;
public:
diff --git a/CPP/7zip/UI/FileManager/FSFolder.cpp b/CPP/7zip/UI/FileManager/FSFolder.cpp
index 1b3837cf..e4cb9f27 100755
--- a/CPP/7zip/UI/FileManager/FSFolder.cpp
+++ b/CPP/7zip/UI/FileManager/FSFolder.cpp
@@ -24,7 +24,7 @@
namespace NWindows {
namespace NFile {
-bool GetLongPath(LPCWSTR path, UString &longPath);
+bool GetLongPath(CFSTR path, UString &longPath);
}}
@@ -47,7 +47,7 @@ static STATPROPSTG kProps[] =
{ NULL, kpidPrefix, VT_BSTR}
};
-HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder)
+HRESULT CFSFolder::Init(const FString &path, IFolderFolder *parentFolder)
{
_parentFolder = parentFolder;
_path = path;
@@ -65,25 +65,25 @@ HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder)
{
DWORD lastError = GetLastError();
CFindFile findFile;
- CFileInfoW fi;
- if (!findFile.FindFirst(_path + UString(L"*"), fi))
+ CFileInfo fi;
+ if (!findFile.FindFirst(_path + FCHAR_ANY_MASK, fi))
return lastError;
}
return S_OK;
}
-HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress)
+static HRESULT GetFolderSize(const FString &path, UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress)
{
RINOK(progress->SetCompleted(NULL));
numFiles = numFolders = size = 0;
- CEnumeratorW enumerator(path + UString(WSTRING_PATH_SEPARATOR L"*"));
- CFileInfoW fi;
+ CEnumerator enumerator(path + FSTRING_PATH_SEPARATOR FSTRING_ANY_MASK);
+ CFileInfo fi;
while (enumerator.Next(fi))
{
if (fi.IsDir())
{
UInt64 subFolders, subFiles, subSize;
- RINOK(GetFolderSize(path + UString(WCHAR_PATH_SEPARATOR) + fi.Name, subFolders, subFiles, subSize, progress));
+ RINOK(GetFolderSize(path + FCHAR_PATH_SEPARATOR + fi.Name, subFolders, subFiles, subSize, progress));
numFolders += subFolders;
numFolders++;
numFiles += subFiles;
@@ -98,10 +98,10 @@ HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles,
return S_OK;
}
-HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const UString &path)
+HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const FString &path)
{
{
- CEnumeratorW enumerator(path + L"*");
+ CEnumerator enumerator(path + FCHAR_ANY_MASK);
CDirItem fi;
while (enumerator.Next(fi))
{
@@ -128,7 +128,7 @@ HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const UString &path)
{
CDirItem &item = dirItem.Files[i];
if (item.IsDir())
- LoadSubItems(item, path + item.Name + WCHAR_PATH_SEPARATOR);
+ LoadSubItems(item, path + item.Name + FCHAR_PATH_SEPARATOR);
}
return S_OK;
}
@@ -166,7 +166,7 @@ STDMETHODIMP CFSFolder::LoadItems()
return S_OK;
}
-static const wchar_t *kDescriptionFileName = L"descript.ion";
+static CFSTR kDescriptionFileName = FTEXT("descript.ion");
bool CFSFolder::LoadComments()
{
@@ -244,10 +244,10 @@ STDMETHODIMP CFSFolder::GetNumberOfSubFolders(UInt32 *numSubFolders)
*/
#ifndef UNDER_CE
-static bool MyGetCompressedFileSizeW(LPCWSTR fileName, UInt64 &size)
+static bool MyGetCompressedFileSizeW(CFSTR fileName, UInt64 &size)
{
DWORD highPart;
- DWORD lowPart = ::GetCompressedFileSizeW(fileName, &highPart);
+ DWORD lowPart = ::GetCompressedFileSizeW(fs2us(fileName), &highPart);
if (lowPart == INVALID_FILE_SIZE && ::GetLastError() != NO_ERROR)
{
#ifdef WIN_LONG_PATH
@@ -274,7 +274,7 @@ STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT
switch(propID)
{
case kpidIsDir: prop = fi.IsDir(); break;
- case kpidName: prop = fi.Name; break;
+ case kpidName: prop = fs2us(fi.Name); break;
case kpidSize: if (!fi.IsDir()) prop = fi.Size; break;
case kpidPackSize:
#ifdef UNDER_CE
@@ -298,7 +298,7 @@ STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT
{
LoadComments();
UString comment;
- if (_comments.GetValue(GetRelPath(fi), comment))
+ if (_comments.GetValue(fs2us(GetRelPath(fi)), comment))
prop = comment;
break;
}
@@ -313,29 +313,29 @@ STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT
return S_OK;
}
-HRESULT CFSFolder::BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder)
+HRESULT CFSFolder::BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder)
{
*resultFolder = 0;
CFSFolder *folderSpec = new CFSFolder;
CMyComPtr<IFolderFolder> subFolder = folderSpec;
- RINOK(folderSpec->Init(_path + name + UString(WCHAR_PATH_SEPARATOR), 0));
+ RINOK(folderSpec->Init(_path + name + FCHAR_PATH_SEPARATOR, 0));
*resultFolder = subFolder.Detach();
return S_OK;
}
-UString CFSFolder::GetPrefix(const CDirItem &item) const
+FString CFSFolder::GetPrefix(const CDirItem &item) const
{
- UString path;
+ FString path;
CDirItem *cur = item.Parent;
while (cur->Parent != 0)
{
- path = cur->Name + UString(WCHAR_PATH_SEPARATOR) + path;
+ path = cur->Name + FCHAR_PATH_SEPARATOR + path;
cur = cur->Parent;
}
return path;
}
-UString CFSFolder::GetRelPath(const CDirItem &item) const
+FString CFSFolder::GetRelPath(const CDirItem &item) const
{
return GetPrefix(item) + item.Name;
}
@@ -351,7 +351,7 @@ STDMETHODIMP CFSFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
STDMETHODIMP CFSFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
{
- return BindToFolderSpec(name, resultFolder);
+ return BindToFolderSpec(us2fs(name), resultFolder);
}
STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
@@ -365,11 +365,11 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
}
if (_path.IsEmpty())
return E_INVALIDARG;
- int pos = _path.ReverseFind(WCHAR_PATH_SEPARATOR);
+ int pos = _path.ReverseFind(FCHAR_PATH_SEPARATOR);
if (pos < 0 || pos != _path.Length() - 1)
return E_FAIL;
- UString parentPath = _path.Left(pos);
- pos = parentPath.ReverseFind(WCHAR_PATH_SEPARATOR);
+ FString parentPath = _path.Left(pos);
+ pos = parentPath.ReverseFind(FCHAR_PATH_SEPARATOR);
if (pos < 0)
{
#ifdef UNDER_CE
@@ -382,17 +382,17 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
#endif
return S_OK;
}
- UString parentPathReduced = parentPath.Left(pos);
+ FString parentPathReduced = parentPath.Left(pos);
parentPath = parentPath.Left(pos + 1);
#ifndef UNDER_CE
- pos = parentPathReduced.ReverseFind(WCHAR_PATH_SEPARATOR);
+ pos = parentPathReduced.ReverseFind(FCHAR_PATH_SEPARATOR);
if (pos == 1)
{
- if (parentPath[0] != WCHAR_PATH_SEPARATOR)
+ if (parentPath[0] != FCHAR_PATH_SEPARATOR)
return E_FAIL;
CNetFolder *netFolderSpec = new CNetFolder;
CMyComPtr<IFolderFolder> netFolder = netFolderSpec;
- netFolderSpec->Init(parentPath);
+ netFolderSpec->Init(fs2us(parentPath));
*resultFolder = netFolder.Detach();
return S_OK;
}
@@ -421,7 +421,7 @@ STDMETHODIMP CFSFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
switch(propID)
{
case kpidType: prop = L"FSFolder"; break;
- case kpidPath: prop = _path; break;
+ case kpidPath: prop = fs2us(_path); break;
}
prop.Detach(value);
return S_OK;
@@ -532,13 +532,13 @@ STDMETHODIMP CFSFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgr
return result;
}
-HRESULT CFSFolder::GetComplexName(const wchar_t *name, UString &resultPath)
+HRESULT CFSFolder::GetComplexName(CFSTR name, FString &resultPath)
{
- UString newName = name;
+ FString newName = name;
resultPath = _path + newName;
if (newName.Length() < 1)
return S_OK;
- if (newName[0] == WCHAR_PATH_SEPARATOR)
+ if (newName[0] == FCHAR_PATH_SEPARATOR)
{
resultPath = newName;
return S_OK;
@@ -552,11 +552,11 @@ HRESULT CFSFolder::GetComplexName(const wchar_t *name, UString &resultPath)
STDMETHODIMP CFSFolder::CreateFolder(const wchar_t *name, IProgress * /* progress */)
{
- UString processedName;
- RINOK(GetComplexName(name, processedName));
- if(NDirectory::MyCreateDirectory(processedName))
+ FString processedName;
+ RINOK(GetComplexName(us2fs(name), processedName));
+ if (NDirectory::MyCreateDirectory(processedName))
return S_OK;
- if(::GetLastError() == ERROR_ALREADY_EXISTS)
+ if (::GetLastError() == ERROR_ALREADY_EXISTS)
return ::GetLastError();
if (!NDirectory::CreateComplexDirectory(processedName))
return ::GetLastError();
@@ -565,8 +565,8 @@ STDMETHODIMP CFSFolder::CreateFolder(const wchar_t *name, IProgress * /* progres
STDMETHODIMP CFSFolder::CreateFile(const wchar_t *name, IProgress * /* progress */)
{
- UString processedName;
- RINOK(GetComplexName(name, processedName));
+ FString processedName;
+ RINOK(GetComplexName(us2fs(name), processedName));
NIO::COutFile outFile;
if (!outFile.Create(processedName, false))
return ::GetLastError();
@@ -576,8 +576,8 @@ STDMETHODIMP CFSFolder::CreateFile(const wchar_t *name, IProgress * /* progress
STDMETHODIMP CFSFolder::Rename(UInt32 index, const wchar_t *newName, IProgress * /* progress */)
{
const CDirItem &fi = *_refs[index];
- const UString fullPrefix = _path + GetPrefix(fi);
- if (!NDirectory::MyMoveFile(fullPrefix + fi.Name, fullPrefix + newName))
+ const FString fullPrefix = _path + GetPrefix(fi);
+ if (!NDirectory::MyMoveFile(fullPrefix + fi.Name, fullPrefix + us2fs(newName)))
return GetLastError();
return S_OK;
}
@@ -588,7 +588,7 @@ STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress
for (UInt32 i = 0; i < numItems; i++)
{
const CDirItem &fi = *_refs[indices[i]];
- const UString fullPath = _path + GetRelPath(fi);
+ const FString fullPath = _path + GetRelPath(fi);
bool result;
if (fi.IsDir())
result = NDirectory::RemoveDirectoryWithSubItems(fullPath);
@@ -614,7 +614,7 @@ STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID,
{
case kpidComment:
{
- UString filename = fi.Name;
+ UString filename = fs2us(fi.Name);
filename.Trim();
if (value->vt == VT_EMPTY)
_comments.DeletePair(filename);
diff --git a/CPP/7zip/UI/FileManager/FSFolder.h b/CPP/7zip/UI/FileManager/FSFolder.h
index e39004ad..13e9e018 100755
--- a/CPP/7zip/UI/FileManager/FSFolder.h
+++ b/CPP/7zip/UI/FileManager/FSFolder.h
@@ -1,7 +1,7 @@
// FSFolder.h
-#ifndef __FSFOLDER_H
-#define __FSFOLDER_H
+#ifndef __FS_FOLDER_H
+#define __FS_FOLDER_H
#include "Common/MyCom.h"
@@ -14,7 +14,7 @@ namespace NFsFolder {
class CFSFolder;
-struct CFileInfoEx: public NWindows::NFile::NFind::CFileInfoW
+struct CFileInfoEx: public NWindows::NFile::NFind::CFileInfo
{
#ifndef UNDER_CE
bool CompressedSizeIsDefined;
@@ -74,7 +74,7 @@ public:
STDMETHOD(GetSystemIconIndex)(UInt32 index, Int32 *iconIndex);
private:
- UString _path;
+ FString _path;
CDirItem _root;
CRecordVector<CDirItem *> _refs;
@@ -90,24 +90,24 @@ private:
HRESULT GetItemsFullSize(const UInt32 *indices, UInt32 numItems,
UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress);
HRESULT GetItemFullSize(int index, UInt64 &size, IProgress *progress);
- HRESULT GetComplexName(const wchar_t *name, UString &resultPath);
- HRESULT BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder);
+ HRESULT GetComplexName(CFSTR name, FString &resultPath);
+ HRESULT BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder);
bool LoadComments();
bool SaveComments();
- HRESULT LoadSubItems(CDirItem &dirItem, const UString &path);
+ HRESULT LoadSubItems(CDirItem &dirItem, const FString &path);
void AddRefs(CDirItem &dirItem);
public:
- HRESULT Init(const UString &path, IFolderFolder *parentFolder);
+ HRESULT Init(const FString &path, IFolderFolder *parentFolder);
#ifdef UNDER_CE
- HRESULT InitToRoot() { return Init(L"\\", NULL); }
+ HRESULT InitToRoot() { return Init(FTEXT("\\"), NULL); }
#endif
CFSFolder() : _flatMode(false) {}
- UString GetPrefix(const CDirItem &item) const;
- UString GetRelPath(const CDirItem &item) const;
- UString GetRelPath(UInt32 index) const { return GetRelPath(*_refs[index]); }
+ FString GetPrefix(const CDirItem &item) const;
+ FString GetRelPath(const CDirItem &item) const;
+ FString GetRelPath(UInt32 index) const { return GetRelPath(*_refs[index]); }
void Clear()
{
@@ -116,8 +116,6 @@ public:
}
};
-HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress);
-
}
#endif
diff --git a/CPP/7zip/UI/FileManager/FSFolderCopy.cpp b/CPP/7zip/UI/FileManager/FSFolderCopy.cpp
index b6ffd574..c31498c7 100755
--- a/CPP/7zip/UI/FileManager/FSFolderCopy.cpp
+++ b/CPP/7zip/UI/FileManager/FSFolderCopy.cpp
@@ -102,13 +102,7 @@ typedef BOOL (WINAPI * CopyFileExPointerW)(
IN DWORD dwCopyFlags
);
-#ifndef _UNICODE
-static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
-static CSysString GetSysPath(LPCWSTR sysPath)
- { return UnicodeStringToMultiByte(sysPath, GetCurrentCodePage()); }
-#endif
-
-static bool MyCopyFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progress, UInt64 &completedSize)
+static bool MyCopyFile(CFSTR existingFile, CFSTR newFile, IProgress *progress, UInt64 &completedSize)
{
CProgressInfo progressInfo;
progressInfo.Progress = progress;
@@ -128,8 +122,8 @@ static bool MyCopyFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progres
CopyFileExPointerW copyFunctionW = (CopyFileExPointerW)
My_GetProcAddress(::GetModuleHandleW(k_DllName), "CopyFileExW");
if (copyFunctionW == 0)
- return BOOLToBool(::CopyFileW(existingFile, newFile, TRUE));
- if (copyFunctionW(existingFile, newFile, CopyProgressRoutine,
+ return BOOLToBool(::CopyFileW(fs2us(existingFile), fs2us(newFile), TRUE));
+ if (copyFunctionW(fs2us(existingFile), fs2us(newFile), CopyProgressRoutine,
&progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
return true;
#ifdef WIN_LONG_PATH
@@ -150,13 +144,13 @@ static bool MyCopyFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progres
"CopyFileExA");
if (copyFunction != 0)
{
- if (copyFunction(GetSysPath(existingFile), GetSysPath(newFile),
+ if (copyFunction(fs2fas(existingFile), fs2fas(newFile),
CopyProgressRoutine,&progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
return true;
if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
return false;
}
- return BOOLToBool(::CopyFile(GetSysPath(existingFile), GetSysPath(newFile), TRUE));
+ return BOOLToBool(::CopyFile(fs2fas(existingFile), fs2fas(newFile), TRUE));
}
#endif
}
@@ -169,7 +163,7 @@ typedef BOOL (WINAPI * MoveFileWithProgressPointer)(
IN DWORD dwFlags
);
-static bool MyMoveFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progress, UInt64 &completedSize)
+static bool MyMoveFile(CFSTR existingFile, CFSTR newFile, IProgress *progress, UInt64 &completedSize)
{
#ifndef UNDER_CE
// if (IsItWindows2000orHigher())
@@ -184,7 +178,7 @@ static bool MyMoveFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progres
if (moveFunction != 0)
{
if (moveFunction(
- existingFile, newFile, CopyProgressRoutine,
+ fs2us(existingFile), fs2us(newFile), CopyProgressRoutine,
&progressInfo, MOVEFILE_COPY_ALLOWED))
return true;
if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
@@ -207,41 +201,48 @@ static bool MyMoveFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progres
return NDirectory::MyMoveFile(existingFile, newFile);
}
+static HRESULT SendMessageError(IFolderOperationsExtractCallback *callback,
+ const wchar_t *message, const FString &fileName)
+{
+ return callback->ShowMessage(message + fs2us(fileName));
+}
+
+static HRESULT SendMessageError(IFolderOperationsExtractCallback *callback,
+ const char *message, const FString &fileName)
+{
+ return SendMessageError(callback, MultiByteToUnicodeString(message), fileName);
+}
+
static HRESULT MyCopyFile(
- const UString &srcPath,
- const CFileInfoW &srcFileInfo,
- const UString &destPathSpec,
+ const FString &srcPath,
+ const CFileInfo &srcFileInfo,
+ const FString &destPathSpec,
IFolderOperationsExtractCallback *callback,
UInt64 &completedSize)
{
- UString destPath = destPathSpec;
+ FString destPath = destPathSpec;
if (destPath.CompareNoCase(srcPath) == 0)
{
- UString message = UString(L"can not move file \'") + destPath + UString(L"\' onto itself");
- RINOK(callback->ShowMessage(message));
+ RINOK(SendMessageError(callback, "can not copy file onto itself: ", destPath));
return E_ABORT;
}
Int32 writeAskResult;
CMyComBSTR destPathResult;
RINOK(callback->AskWrite(
- srcPath,
+ fs2us(srcPath),
BoolToInt(false),
&srcFileInfo.MTime, &srcFileInfo.Size,
- destPath,
+ fs2us(destPath),
&destPathResult,
&writeAskResult));
if (IntToBool(writeAskResult))
{
- UString destPathNew = UString(destPathResult);
- RINOK(callback->SetCurrentFilePath(srcPath));
+ FString destPathNew = us2fs(destPathResult);
+ RINOK(callback->SetCurrentFilePath(fs2us(srcPath)));
if (!MyCopyFile(srcPath, destPathNew, callback, completedSize))
{
- UString message = NError::MyFormatMessageW(GetLastError()) +
- UString(L" \'") +
- UString(destPathNew) +
- UString(L"\'");
- RINOK(callback->ShowMessage(message));
+ RINOK(SendMessageError(callback, NError::MyFormatMessageW(GetLastError()) + L" : ", destPathNew));
return E_ABORT;
}
}
@@ -249,44 +250,41 @@ static HRESULT MyCopyFile(
return callback->SetCompleted(&completedSize);
}
-static UString CombinePath(const UString &folderPath, const UString &fileName)
+static FString CombinePath(const FString &folderPath, const FString &fileName)
{
- return folderPath + UString(WCHAR_PATH_SEPARATOR) + fileName;
+ return folderPath + FCHAR_PATH_SEPARATOR + fileName;
}
static HRESULT CopyFolder(
- const UString &srcPath,
- const UString &destPathSpec,
+ const FString &srcPath,
+ const FString &destPathSpec,
IFolderOperationsExtractCallback *callback,
UInt64 &completedSize)
{
RINOK(callback->SetCompleted(&completedSize));
- const UString destPath = destPathSpec;
+ const FString destPath = destPathSpec;
int len = srcPath.Length();
if (destPath.Length() >= len && srcPath.CompareNoCase(destPath.Left(len)) == 0)
{
- if (destPath.Length() == len || destPath[len] == WCHAR_PATH_SEPARATOR)
+ if (destPath.Length() == len || destPath[len] == FCHAR_PATH_SEPARATOR)
{
- UString message = UString(L"can not copy folder \'") +
- destPath + UString(L"\' onto itself");
- RINOK(callback->ShowMessage(message));
+ RINOK(SendMessageError(callback, "can not copy folder onto itself: ", destPath));
return E_ABORT;
}
}
if (!NDirectory::CreateComplexDirectory(destPath))
{
- UString message = UString(L"can not create folder ") + destPath;
- RINOK(callback->ShowMessage(message));
+ RINOK(SendMessageError(callback, "can not create folder: ", destPath));
return E_ABORT;
}
- CEnumeratorW enumerator(CombinePath(srcPath, L"*"));
+ CEnumerator enumerator(CombinePath(srcPath, FSTRING_ANY_MASK));
CFileInfoEx fi;
while (enumerator.Next(fi))
{
- const UString srcPath2 = CombinePath(srcPath, fi.Name);
- const UString destPath2 = CombinePath(destPath, fi.Name);
+ const FString srcPath2 = CombinePath(srcPath, fi.Name);
+ const FString destPath2 = CombinePath(destPath, fi.Name);
if (fi.IsDir())
{
RINOK(CopyFolder(srcPath2, destPath2, callback, completedSize))
@@ -313,7 +311,7 @@ STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
UString destPath = path;
if (destPath.IsEmpty())
return E_INVALIDARG;
- bool directName = (destPath[destPath.Length() - 1] != WCHAR_PATH_SEPARATOR);
+ bool directName = (destPath.Back() != WCHAR_PATH_SEPARATOR);
if (directName)
{
if (numItems > 1)
@@ -337,10 +335,10 @@ STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
for (UInt32 i = 0; i < numItems; i++)
{
const CDirItem &fi = *_refs[indices[i]];
- UString destPath2 = destPath;
+ FString destPath2 = us2fs(destPath);
if (!directName)
destPath2 += fi.Name;
- UString srcPath = _path + GetPrefix(fi) + fi.Name;
+ FString srcPath = _path + GetPrefix(fi) + fi.Name;
if (fi.IsDir())
{
RINOK(CopyFolder(srcPath, destPath2, callback, completedSize));
@@ -356,40 +354,35 @@ STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
/////////////////////////////////////////////////
// Move Operations
-HRESULT MyMoveFile(
- const UString &srcPath,
- const CFileInfoW &srcFileInfo,
- const UString &destPathSpec,
+static HRESULT MyMoveFile(
+ const FString &srcPath,
+ const CFileInfo &srcFileInfo,
+ const FString &destPath,
IFolderOperationsExtractCallback *callback,
UInt64 &completedSize)
{
- UString destPath = destPathSpec;
if (destPath.CompareNoCase(srcPath) == 0)
{
- UString message = UString(L"can not move file \'")
- + destPath +
- UString(L"\' onto itself");
- RINOK(callback->ShowMessage(message));
+ RINOK(SendMessageError(callback, "can not move file onto itself: ", srcPath));
return E_ABORT;
}
Int32 writeAskResult;
CMyComBSTR destPathResult;
RINOK(callback->AskWrite(
- srcPath,
+ fs2us(srcPath),
BoolToInt(false),
&srcFileInfo.MTime, &srcFileInfo.Size,
- destPath,
+ fs2us(destPath),
&destPathResult,
&writeAskResult));
if (IntToBool(writeAskResult))
{
- UString destPathNew = UString(destPathResult);
- RINOK(callback->SetCurrentFilePath(srcPath));
+ FString destPathNew = us2fs(destPathResult);
+ RINOK(callback->SetCurrentFilePath(fs2us(srcPath)));
if (!MyMoveFile(srcPath, destPathNew, callback, completedSize))
{
- UString message = UString(L"can not move to file ") + destPathNew;
- RINOK(callback->ShowMessage(message));
+ RINOK(SendMessageError(callback, "can not move to file: ", destPathNew));
}
}
completedSize += srcFileInfo.Size;
@@ -397,21 +390,18 @@ HRESULT MyMoveFile(
return S_OK;
}
-HRESULT MyMoveFolder(
- const UString &srcPath,
- const UString &destPathSpec,
+static HRESULT MyMoveFolder(
+ const FString &srcPath,
+ const FString &destPath,
IFolderOperationsExtractCallback *callback,
UInt64 &completedSize)
{
- UString destPath = destPathSpec;
int len = srcPath.Length();
if (destPath.Length() >= len && srcPath.CompareNoCase(destPath.Left(len)) == 0)
{
- if (destPath.Length() == len || destPath[len] == WCHAR_PATH_SEPARATOR)
+ if (destPath.Length() == len || destPath[len] == FCHAR_PATH_SEPARATOR)
{
- UString message = UString(L"can not move folder \'") +
- destPath + UString(L"\' onto itself");
- RINOK(callback->ShowMessage(message));
+ RINOK(SendMessageError(callback, "can not move folder onto itself: ", destPath));
return E_ABORT;
}
}
@@ -421,17 +411,16 @@ HRESULT MyMoveFolder(
if (!NDirectory::CreateComplexDirectory(destPath))
{
- UString message = UString(L"can not create folder ") + destPath;
- RINOK(callback->ShowMessage(message));
+ RINOK(SendMessageError(callback, "can not create folder: ", destPath));
return E_ABORT;
}
{
- CEnumeratorW enumerator(CombinePath(srcPath, L"*"));
+ CEnumerator enumerator(CombinePath(srcPath, FSTRING_ANY_MASK));
CFileInfoEx fi;
while (enumerator.Next(fi))
{
- const UString srcPath2 = CombinePath(srcPath, fi.Name);
- const UString destPath2 = CombinePath(destPath, fi.Name);
+ const FString srcPath2 = CombinePath(srcPath, fi.Name);
+ const FString destPath2 = CombinePath(destPath, fi.Name);
if (fi.IsDir())
{
RINOK(MyMoveFolder(srcPath2, destPath2, callback, completedSize));
@@ -444,8 +433,7 @@ HRESULT MyMoveFolder(
}
if (!NDirectory::MyRemoveDirectory(srcPath))
{
- UString message = UString(L"can not remove folder") + srcPath;
- RINOK(callback->ShowMessage(message));
+ RINOK(SendMessageError(callback, "can not remove folder: ", srcPath));
return E_ABORT;
}
return S_OK;
@@ -465,10 +453,10 @@ STDMETHODIMP CFSFolder::MoveTo(
RINOK(callback->SetTotal(totalSize));
RINOK(callback->SetNumFiles(numFiles));
- UString destPath = path;
+ FString destPath = us2fs(path);
if (destPath.IsEmpty())
return E_INVALIDARG;
- bool directName = (destPath[destPath.Length() - 1] != WCHAR_PATH_SEPARATOR);
+ bool directName = (destPath.Back() != FCHAR_PATH_SEPARATOR);
if (directName)
{
if (numItems > 1)
@@ -477,9 +465,7 @@ STDMETHODIMP CFSFolder::MoveTo(
else
if (!NDirectory::CreateComplexDirectory(destPath))
{
- UString message = UString(L"can not create folder ") +
- destPath;
- RINOK(callback->ShowMessage(message));
+ RINOK(SendMessageError(callback, "can not create folder: ", destPath));
return E_ABORT;
}
@@ -488,10 +474,10 @@ STDMETHODIMP CFSFolder::MoveTo(
for (UInt32 i = 0; i < numItems; i++)
{
const CDirItem &fi = *_refs[indices[i]];
- UString destPath2 = destPath;
+ FString destPath2 = destPath;
if (!directName)
destPath2 += fi.Name;
- UString srcPath = _path + GetPrefix(fi) + fi.Name;
+ FString srcPath = _path + GetPrefix(fi) + fi.Name;
if (fi.IsDir())
{
RINOK(MyMoveFolder(srcPath, destPath2, callback, completedSize));
@@ -515,7 +501,7 @@ STDMETHODIMP CFSFolder::CopyFrom(const wchar_t * /* fromFolderPath */,
{
UString path = (UString)fromFolderPath + itemsPaths[i];
- CFileInfoW fi;
+ CFileInfo fi;
if (!FindFile(path, fi))
return ::GetLastError();
if (fi.IsDir())
@@ -544,4 +530,9 @@ STDMETHODIMP CFSFolder::CopyFrom(const wchar_t * /* fromFolderPath */,
return E_NOTIMPL;
}
+STDMETHODIMP CFSFolder::CopyFromFile(UInt32 /* index */, const wchar_t * /* fullFilePath */, IProgress * /* progress */)
+{
+ return E_NOTIMPL;
+}
+
}
diff --git a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp
index 08f15c18..d29ac44c 100755
--- a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp
+++ b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp
@@ -4,6 +4,7 @@
#include "resource.h"
+#include "Windows/FileName.h"
#include "Windows/Thread.h"
#include "../Agent/Agent.h"
@@ -11,11 +12,9 @@
#include "LangUtils.h"
#include "OpenCallback.h"
#include "PluginLoader.h"
-#include "RegistryAssociations.h"
#include "RegistryPlugins.h"
using namespace NWindows;
-using namespace NRegistryAssociations;
struct CThreadArchiveOpen
{
@@ -56,9 +55,29 @@ static int FindPlugin(const CObjectVector<CPluginInfo> &plugins, const UString &
}
*/
+static const FChar kExtensionDelimiter = FTEXT('.');
+
+static void SplitNameToPureNameAndExtension(const FString &fullName,
+ FString &pureName, FString &extensionDelimiter, FString &extension)
+{
+ int index = fullName.ReverseFind(kExtensionDelimiter);
+ if (index < 0)
+ {
+ pureName = fullName;
+ extensionDelimiter.Empty();
+ extension.Empty();
+ }
+ else
+ {
+ pureName = fullName.Left(index);
+ extensionDelimiter = kExtensionDelimiter;
+ extension = fullName.Mid(index + 1);
+ }
+}
+
HRESULT OpenFileFolderPlugin(
IInStream *inStream,
- const UString &path,
+ const FString &path,
const UString &arcFormat,
HMODULE *module,
IFolderFolder **resultFolder,
@@ -68,11 +87,11 @@ HRESULT OpenFileFolderPlugin(
CObjectVector<CPluginInfo> plugins;
ReadFileFolderPluginInfoList(plugins);
- UString extension, name, pureName, dot;
+ FString extension, name, pureName, dot;
- int slashPos = path.ReverseFind(WCHAR_PATH_SEPARATOR);
- UString dirPrefix;
- UString fileName;
+ int slashPos = path.ReverseFind(FCHAR_PATH_SEPARATOR);
+ FString dirPrefix;
+ FString fileName;
if (slashPos >= 0)
{
dirPrefix = path.Left(slashPos + 1);
@@ -81,7 +100,7 @@ HRESULT OpenFileFolderPlugin(
else
fileName = path;
- NFile::NName::SplitNameToPureNameAndExtension(fileName, pureName, dot, extension);
+ SplitNameToPureNameAndExtension(fileName, pureName, dot, extension);
/*
if (!extension.IsEmpty())
@@ -124,12 +143,12 @@ HRESULT OpenFileFolderPlugin(
t.OpenCallbackSpec->ParentWindow = parentWindow;
if (inStream)
- t.OpenCallbackSpec->SetSubArchiveName(fileName);
+ t.OpenCallbackSpec->SetSubArchiveName(fs2us(fileName));
else
t.OpenCallbackSpec->LoadFileInfo(dirPrefix, fileName);
t.InStream = inStream;
- t.Path = path;
+ t.Path = fs2us(path);
t.ArcFormat = arcFormat;
UString progressTitle = LangString(IDS_OPENNING, 0x03020283);
diff --git a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h
index 85717efd..593880e9 100755
--- a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h
+++ b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h
@@ -3,7 +3,7 @@
#ifndef __FILE_FOLDER_PLUGIN_OPEN_H
#define __FILE_FOLDER_PLUGIN_OPEN_H
-HRESULT OpenFileFolderPlugin(IInStream *inStream, const UString &path, const UString &arcFormat,
+HRESULT OpenFileFolderPlugin(IInStream *inStream, const FString &path, const UString &arcFormat,
HMODULE *module, IFolderFolder **resultFolder, HWND parentWindow, bool &encrypted, UString &password);
#endif
diff --git a/CPP/7zip/UI/FileManager/FilePlugins.cpp b/CPP/7zip/UI/FileManager/FilePlugins.cpp
index 22993383..b81850fd 100755
--- a/CPP/7zip/UI/FileManager/FilePlugins.cpp
+++ b/CPP/7zip/UI/FileManager/FilePlugins.cpp
@@ -2,73 +2,39 @@
#include "StdAfx.h"
-#include "Common/MyCom.h"
-
#include "../Agent/Agent.h"
#include "FilePlugins.h"
#include "PluginLoader.h"
#include "StringUtils.h"
-using namespace NRegistryAssociations;
-
-int CExtDatabase::FindExtInfoBig(const UString &ext)
-{
- for (int i = 0; i < ExtBigItems.Size(); i++)
- if (ExtBigItems[i].Ext.CompareNoCase(ext) == 0)
- return i;
- return -1;
-}
-
-int CExtDatabase::FindPlugin(const UString &plugin)
+int CExtDatabase::FindExt(const UString &ext)
{
- for (int i = 0; i < Plugins.Size(); i++)
- if (Plugins[i].Name.CompareNoCase(plugin) == 0)
+ for (int i = 0; i < Exts.Size(); i++)
+ if (Exts[i].Ext.CompareNoCase(ext) == 0)
return i;
return -1;
}
void CExtDatabase::Read()
{
- /*
- CObjectVector<CExtInfo> extItems;
- ReadInternalAssociations(extItems);
- */
ReadFileFolderPluginInfoList(Plugins);
- /*
- for (int i = 0; i < extItems.Size(); i++)
- {
- const CExtInfo &extInfo = extItems[i];
- CExtInfoBig extInfoBig;
- extInfoBig.Ext = extInfo.Ext;
- extInfoBig.Associated = false;
- for (int p = 0; p < extInfo.Plugins.Size(); p++)
- {
- int pluginIndex = FindPlugin(extInfo.Plugins[p]);
- if (pluginIndex >= 0)
- extInfoBig.PluginsPairs.Add(CPluginEnabledPair(pluginIndex, true));
- }
- ExtBigItems.Add(extInfoBig);
- }
- */
for (int pluginIndex = 0; pluginIndex < Plugins.Size(); pluginIndex++)
{
- const CPluginInfo &pluginInfo = Plugins[pluginIndex];
+ const CPluginInfo &plugin = Plugins[pluginIndex];
- CPluginLibrary pluginLibrary;
+ CPluginLibrary pluginLib;
CMyComPtr<IFolderManager> folderManager;
- if (pluginInfo.FilePath.IsEmpty())
+ if (plugin.FilePath.IsEmpty())
folderManager = new CArchiveFolderManager;
- else if (pluginLibrary.LoadAndCreateManager(pluginInfo.FilePath,
- pluginInfo.ClassID, &folderManager) != S_OK)
+ else if (pluginLib.LoadAndCreateManager(plugin.FilePath, plugin.ClassID, &folderManager) != S_OK)
continue;
CMyComBSTR extBSTR;
if (folderManager->GetExtensions(&extBSTR) != S_OK)
return;
- const UString ext2 = (const wchar_t *)extBSTR;
UStringVector exts;
- SplitString(ext2, exts);
+ SplitString((const wchar_t *)extBSTR, exts);
for (int i = 0; i < exts.Size(); i++)
{
const UString &ext = exts[i];
@@ -76,44 +42,28 @@ void CExtDatabase::Read()
if (ext == L"cab")
continue;
#endif
- int index = FindExtInfoBig(ext);
- if (index < 0)
- {
- CExtInfoBig extInfo;
- extInfo.PluginsPairs.Add(CPluginEnabledPair(pluginIndex, false));
- extInfo.Associated = false;
- extInfo.Ext = ext;
- ExtBigItems.Add(extInfo);
- }
+
+ Int32 iconIndex;
+ CMyComBSTR iconPath;
+ CPluginToIcon plugPair;
+ plugPair.PluginIndex = pluginIndex;
+ if (folderManager->GetIconPath(ext, &iconPath, &iconIndex) == S_OK)
+ if (iconPath != 0)
+ {
+ plugPair.IconPath = (const wchar_t *)iconPath;
+ plugPair.IconIndex = iconIndex;
+ }
+
+ int index = FindExt(ext);
+ if (index >= 0)
+ Exts[index].Plugins.Add(plugPair);
else
{
- CExtInfoBig &extInfo = ExtBigItems[index];
- int pluginIndexIndex = extInfo.FindPlugin(pluginIndex);
- if (pluginIndexIndex < 0)
- extInfo.PluginsPairs.Add(CPluginEnabledPair(pluginIndex, false));
+ CExtPlugins extInfo;
+ extInfo.Plugins.Add(plugPair);
+ extInfo.Ext = ext;
+ Exts.Add(extInfo);
}
}
}
}
-
-void CExtDatabase::Save()
-{
- /*
- CObjectVector<CExtInfo> extItems;
- for (int i = 0; i < ExtBigItems.Size(); i++)
- {
- const CExtInfoBig &extInfoBig = ExtBigItems[i];
- CExtInfo extInfo;
- // extInfo.Enabled = extInfoBig.Associated;
- extInfo.Ext = extInfoBig.Ext;
- for (int p = 0; p < extInfoBig.PluginsPairs.Size(); p++)
- {
- CPluginEnabledPair pluginPair = extInfoBig.PluginsPairs[p];
- if (pluginPair.Enabled)
- extInfo.Plugins.Add(Plugins[pluginPair.Index].Name);
- }
- extItems.Add(extInfo);
- }
- WriteInternalAssociations(extItems);
- */
-}
diff --git a/CPP/7zip/UI/FileManager/FilePlugins.h b/CPP/7zip/UI/FileManager/FilePlugins.h
index 1becb9d1..43b05f92 100755
--- a/CPP/7zip/UI/FileManager/FilePlugins.h
+++ b/CPP/7zip/UI/FileManager/FilePlugins.h
@@ -1,54 +1,33 @@
// FilePlugins.h
-#ifndef __FILEPLUGINS_H
-#define __FILEPLUGINS_H
+#ifndef __FILE_PLUGINS_H
+#define __FILE_PLUGINS_H
#include "RegistryPlugins.h"
-#include "RegistryAssociations.h"
-struct CPluginEnabledPair
+struct CPluginToIcon
{
- int Index;
- bool Enabled;
- CPluginEnabledPair(int index, bool enabled): Index(index),Enabled(enabled) {}
+ int PluginIndex;
+ UString IconPath;
+ int IconIndex;
+
+ CPluginToIcon(): IconIndex(-1) {}
};
-struct CExtInfoBig
+struct CExtPlugins
{
UString Ext;
- bool Associated;
- CRecordVector<CPluginEnabledPair> PluginsPairs;
- int FindPlugin(int pluginIndex)
- {
- for (int i = 0; i < PluginsPairs.Size(); i++)
- if (PluginsPairs[i].Index == pluginIndex)
- return i;
- return -1;
- }
+ CObjectVector<CPluginToIcon> Plugins;
};
class CExtDatabase
{
+ int FindExt(const UString &ext);
public:
- CObjectVector<CExtInfoBig> ExtBigItems;
+ CObjectVector<CExtPlugins> Exts;
CObjectVector<CPluginInfo> Plugins;
- int FindExtInfoBig(const UString &ext);
- int FindPlugin(const UString &plugin);
-
- UString GetMainPluginNameForExtItem(int extIndex) const
- {
- const CExtInfoBig &extInfo = ExtBigItems[extIndex];
- if (extInfo.PluginsPairs.IsEmpty())
- return UString();
- else
- return Plugins[extInfo.PluginsPairs.Front().Index].Name;
- }
-
+
void Read();
- void Save();
};
-
#endif
-
-
diff --git a/CPP/7zip/UI/FileManager/FoldersPage.cpp b/CPP/7zip/UI/FileManager/FoldersPage.cpp
index 068b9d47..b7366fed 100755
--- a/CPP/7zip/UI/FileManager/FoldersPage.cpp
+++ b/CPP/7zip/UI/FileManager/FoldersPage.cpp
@@ -42,7 +42,7 @@ bool CFoldersPage::OnInit()
m_WorkPath.Init(*this, IDC_FOLDERS_WORK_EDIT_PATH);
m_ButtonSetWorkPath.Init(*this, IDC_FOLDERS_WORK_BUTTON_PATH);
- m_WorkPath.SetText(m_WorkDirInfo.Path);
+ m_WorkPath.SetText(fs2us(m_WorkDirInfo.Path));
MyEnableControls();
@@ -66,7 +66,9 @@ void CFoldersPage::MyEnableControls()
void CFoldersPage::GetWorkDir(NWorkDir::CInfo &workDirInfo)
{
- m_WorkPath.GetText(workDirInfo.Path);
+ UString s;
+ m_WorkPath.GetText(s);
+ workDirInfo.Path = us2fs(s);
workDirInfo.ForRemovableOnly = IsButtonCheckedBool(IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE);
workDirInfo.Mode = NWorkDir::NMode::EEnum(GetWorkMode());
}
@@ -143,7 +145,7 @@ LONG CFoldersPage::OnApply()
return PSNRET_NOERROR;
}
-static LPCWSTR kFoldersTopic = L"fm/plugins/7-zip/options.htm#folders";
+static LPCWSTR kFoldersTopic = L"fm/options.htm#folders";
void CFoldersPage::OnNotifyHelp()
{
diff --git a/CPP/7zip/UI/FileManager/HelpUtils.cpp b/CPP/7zip/UI/FileManager/HelpUtils.cpp
index a1c17399..3128cb28 100755
--- a/CPP/7zip/UI/FileManager/HelpUtils.cpp
+++ b/CPP/7zip/UI/FileManager/HelpUtils.cpp
@@ -5,8 +5,8 @@
#include <HtmlHelp.h>
#include "Common/StringConvert.h"
+#include "Windows/DLL.h"
#include "HelpUtils.h"
-#include "ProgramLocation.h"
static LPCWSTR kHelpFileName = L"7-zip.chm::/";
@@ -17,11 +17,7 @@ void ShowHelpWindow(HWND, LPCWSTR)
#else
void ShowHelpWindow(HWND hwnd, LPCWSTR topicFile)
{
- UString path;
- if (!::GetProgramFolderPath(path))
- return;
- path += kHelpFileName;
- path += topicFile;
- HtmlHelp(hwnd, GetSystemString(path), HH_DISPLAY_TOPIC, NULL);
+ FString path = NWindows::NDLL::GetModuleDirPrefix();
+ HtmlHelp(hwnd, GetSystemString(fs2us(path) + kHelpFileName + topicFile), HH_DISPLAY_TOPIC, NULL);
}
#endif
diff --git a/CPP/7zip/UI/FileManager/IFolder.h b/CPP/7zip/UI/FileManager/IFolder.h
index 743017b8..d6cce88f 100755
--- a/CPP/7zip/UI/FileManager/IFolder.h
+++ b/CPP/7zip/UI/FileManager/IFolder.h
@@ -70,8 +70,9 @@ FOLDER_INTERFACE_SUB(IFolderOperationsExtractCallback, IProgress, 0x0B)
STDMETHOD(CopyFrom)(const wchar_t *fromFolderPath, \
const wchar_t **itemsPaths, UInt32 numItems, IProgress *progress) x; \
STDMETHOD(SetProperty)(UInt32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress) x; \
+ STDMETHOD(CopyFromFile)(UInt32 index, const wchar_t *fullFilePath, IProgress *progress) x; \
-FOLDER_INTERFACE(IFolderOperations, 0x06)
+FOLDER_INTERFACE(IFolderOperations, 0x12)
{
INTERFACE_FolderOperations(PURE)
};
diff --git a/CPP/7zip/UI/FileManager/LangUtils.cpp b/CPP/7zip/UI/FileManager/LangUtils.cpp
index 52f85348..20f4655b 100755
--- a/CPP/7zip/UI/FileManager/LangUtils.cpp
+++ b/CPP/7zip/UI/FileManager/LangUtils.cpp
@@ -2,14 +2,16 @@
#include "StdAfx.h"
-#include "LangUtils.h"
#include "Common/StringConvert.h"
#include "Common/StringToInt.h"
+
+#include "Windows/DLL.h"
+#include "Windows/FileFind.h"
#include "Windows/Synchronization.h"
#include "Windows/Window.h"
-#include "Windows/FileFind.h"
+
+#include "LangUtils.h"
#include "RegistryUtils.h"
-#include "ProgramLocation.h"
using namespace NWindows;
@@ -20,20 +22,23 @@ UString g_LangID;
extern bool g_IsNT;
#endif
+static FString GetLangDirPrefix()
+{
+ return NDLL::GetModuleDirPrefix() + FString(FTEXT("Lang") FSTRING_PATH_SEPARATOR);
+}
+
void ReloadLang()
{
ReadRegLang(g_LangID);
g_Lang.Clear();
if (!g_LangID.IsEmpty() && g_LangID != L"-")
{
- UString langPath = g_LangID;
+ FString langPath = us2fs(g_LangID);
if (langPath.Find(WCHAR_PATH_SEPARATOR) < 0)
{
- if (langPath.Find(L'.') < 0)
- langPath += L".txt";
- UString folderPath;
- if (GetProgramFolderPath(folderPath))
- langPath = folderPath + UString(L"Lang" WSTRING_PATH_SEPARATOR) + langPath;
+ if (langPath.Find(FTEXT('.')) < 0)
+ langPath += FTEXT(".txt");
+ langPath = GetLangDirPrefix() + langPath;
}
g_Lang.Open(langPath);
}
@@ -51,7 +56,7 @@ void LoadLangOneTime()
ReloadLang();
}
-void LangSetDlgItemsText(HWND dialogWindow, CIDLangPair *idLangPairs, int numItems)
+void LangSetDlgItemsText(HWND dialogWindow, const CIDLangPair *idLangPairs, int numItems)
{
for (int i = 0; i < numItems; i++)
{
@@ -85,30 +90,26 @@ UString LangString(UINT resourceID, UInt32 langID)
UString message;
if (g_Lang.GetMessage(langID, message))
return message;
- return NWindows::MyLoadStringW(resourceID);
+ return MyLoadStringW(resourceID);
}
void LoadLangs(CObjectVector<CLangEx> &langs)
{
langs.Clear();
- UString folderPath;
- if (!::GetProgramFolderPath(folderPath))
- return;
- folderPath += L"Lang" WSTRING_PATH_SEPARATOR;
- NWindows::NFile::NFind::CEnumeratorW enumerator(folderPath + L"*.txt");
- NWindows::NFile::NFind::CFileInfoW fileInfo;
- while (enumerator.Next(fileInfo))
+ const FString dirPrefix = GetLangDirPrefix();
+ NFile::NFind::CEnumerator enumerator(dirPrefix + FTEXT("*.txt"));
+ NFile::NFind::CFileInfo fi;
+ while (enumerator.Next(fi))
{
- if (fileInfo.IsDir())
+ if (fi.IsDir())
continue;
- CLangEx lang;
- UString filePath = folderPath + fileInfo.Name;
const int kExtSize = 4;
- const UString ext = fileInfo.Name.Right(kExtSize);
- if (ext.CompareNoCase(L".txt") != 0)
+ const FString ext = fi.Name.Right(kExtSize);
+ if (ext.CompareNoCase(FTEXT(".txt")) != 0)
continue;
- lang.ShortName = fileInfo.Name.Left(fileInfo.Name.Length() - kExtSize);
- if (lang.Lang.Open(filePath))
+ CLangEx lang;
+ lang.ShortName = fs2us(fi.Name.Left(fi.Name.Length() - kExtSize));
+ if (lang.Lang.Open(dirPrefix + fi.Name))
langs.Add(lang);
}
}
diff --git a/CPP/7zip/UI/FileManager/LangUtils.h b/CPP/7zip/UI/FileManager/LangUtils.h
index 40debdfe..d11082f6 100755
--- a/CPP/7zip/UI/FileManager/LangUtils.h
+++ b/CPP/7zip/UI/FileManager/LangUtils.h
@@ -1,7 +1,7 @@
// LangUtils.h
-#ifndef __LANGUTILS_H
-#define __LANGUTILS_H
+#ifndef __LANG_UTILS_H
+#define __LANG_UTILS_H
#include "Common/Lang.h"
#include "Windows/ResourceString.h"
@@ -26,7 +26,7 @@ struct CLangEx
void LoadLangs(CObjectVector<CLangEx> &langs);
-void LangSetDlgItemsText(HWND dialogWindow, CIDLangPair *idLangPairs, int numItems);
+void LangSetDlgItemsText(HWND dialogWindow, const CIDLangPair *idLangPairs, int numItems);
void LangSetWindowText(HWND window, UInt32 langID);
UString LangString(UInt32 langID);
diff --git a/CPP/7zip/UI/FileManager/ListViewDialog.cpp b/CPP/7zip/UI/FileManager/ListViewDialog.cpp
index f70572b9..b3e989c4 100755
--- a/CPP/7zip/UI/FileManager/ListViewDialog.cpp
+++ b/CPP/7zip/UI/FileManager/ListViewDialog.cpp
@@ -125,17 +125,12 @@ bool CListViewDialog::OnNotify(UINT /* controlID */, LPNMHDR header)
}
case 'A':
{
- // probably that code is unused ?
- /*
bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
if (ctrl)
{
- int numItems = _listView.GetItemCount();
- for (int i = 0; i < numItems; i++)
- _listView.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
+ _listView.SelectAll();
return true;
}
- */
}
}
}
diff --git a/CPP/7zip/UI/FileManager/MenuPage.cpp b/CPP/7zip/UI/FileManager/MenuPage.cpp
index e1041204..c3e013b5 100755
--- a/CPP/7zip/UI/FileManager/MenuPage.cpp
+++ b/CPP/7zip/UI/FileManager/MenuPage.cpp
@@ -23,7 +23,7 @@ static CIDLangPair kIDLangPairs[] =
{ IDC_SYSTEM_STATIC_CONTEXT_MENU_ITEMS, 0x01000310}
};
-static LPCWSTR kSystemTopic = L"fm/plugins/7-zip/options.htm#system";
+static LPCWSTR kSystemTopic = L"fm/options.htm#sevenZip";
struct CContextMenuItem
{
diff --git a/CPP/7zip/UI/FileManager/MessagesDialog.cpp b/CPP/7zip/UI/FileManager/MessagesDialog.cpp
index 3d73ade1..05aa823f 100755
--- a/CPP/7zip/UI/FileManager/MessagesDialog.cpp
+++ b/CPP/7zip/UI/FileManager/MessagesDialog.cpp
@@ -51,10 +51,7 @@ bool CMessagesDialog::OnInit()
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
#endif
_messageList.Attach(GetItem(IDC_MESSAGE_LIST));
-
- #ifndef UNDER_CE
- _messageList.SetUnicodeFormat(true);
- #endif
+ _messageList.SetUnicodeFormat();
_messageList.InsertColumn(0, L"", 30);
diff --git a/CPP/7zip/UI/FileManager/MyLoadMenu.cpp b/CPP/7zip/UI/FileManager/MyLoadMenu.cpp
index ccfd33cc..b16e8948 100755
--- a/CPP/7zip/UI/FileManager/MyLoadMenu.cpp
+++ b/CPP/7zip/UI/FileManager/MyLoadMenu.cpp
@@ -513,6 +513,13 @@ bool ExecuteFileCommand(int id)
return true;
}
+static void MyBenchmark(bool totalMode)
+{
+ CPanel::CDisableTimerProcessing disableTimerProcessing1(g_App.Panels[0]);
+ CPanel::CDisableTimerProcessing disableTimerProcessing2(g_App.Panels[1]);
+ Benchmark(totalMode);
+}
+
bool OnMenuCommand(HWND hWnd, int id)
{
if (ExecuteFileCommand(id))
@@ -538,31 +545,31 @@ bool OnMenuCommand(HWND hWnd, int id)
break;
case IDM_SELECT_ALL:
g_App.SelectAll(true);
- g_App.RefreshStatusBar();
+ g_App.Refresh_StatusBar();
break;
case IDM_DESELECT_ALL:
g_App.SelectAll(false);
- g_App.RefreshStatusBar();
+ g_App.Refresh_StatusBar();
break;
case IDM_INVERT_SELECTION:
g_App.InvertSelection();
- g_App.RefreshStatusBar();
+ g_App.Refresh_StatusBar();
break;
case IDM_SELECT:
g_App.SelectSpec(true);
- g_App.RefreshStatusBar();
+ g_App.Refresh_StatusBar();
break;
case IDM_DESELECT:
g_App.SelectSpec(false);
- g_App.RefreshStatusBar();
+ g_App.Refresh_StatusBar();
break;
case IDM_SELECT_BY_TYPE:
g_App.SelectByType(true);
- g_App.RefreshStatusBar();
+ g_App.Refresh_StatusBar();
break;
case IDM_DESELECT_BY_TYPE:
g_App.SelectByType(false);
- g_App.RefreshStatusBar();
+ g_App.Refresh_StatusBar();
break;
//View
@@ -646,13 +653,9 @@ bool OnMenuCommand(HWND hWnd, int id)
OptionsDialog(hWnd, g_hInstance);
break;
- case IDM_BENCHMARK:
- {
- CPanel::CDisableTimerProcessing disableTimerProcessing1(g_App.Panels[0]);
- CPanel::CDisableTimerProcessing disableTimerProcessing2(g_App.Panels[1]);
- Benchmark();
- break;
- }
+ case IDM_BENCHMARK: MyBenchmark(false); break;
+ case IDM_BENCHMARK2: MyBenchmark(true); break;
+
// Help
case IDM_HELP_CONTENTS:
ShowHelpWindow(NULL, kFMHelpTopic);
diff --git a/CPP/7zip/UI/FileManager/NetFolder.cpp b/CPP/7zip/UI/FileManager/NetFolder.cpp
index e1fa1965..07387328 100755
--- a/CPP/7zip/UI/FileManager/NetFolder.cpp
+++ b/CPP/7zip/UI/FileManager/NetFolder.cpp
@@ -136,8 +136,8 @@ STDMETHODIMP CNetFolder::LoadItems()
resource.RemoteName = _path + resource.Name;
NFile::NFind::CFindFile findFile;
- NFile::NFind::CFileInfoW fileInfo;
- if (!findFile.FindFirst(resource.RemoteName + UString(WCHAR_PATH_SEPARATOR) + UString(L"*"), fileInfo))
+ NFile::NFind::CFileInfo fileInfo;
+ if (!findFile.FindFirst(us2fs(resource.RemoteName) + FString(FCHAR_PATH_SEPARATOR) + FCHAR_ANY_MASK, fileInfo))
continue;
resource.Usage = RESOURCEUSAGE_CONNECTABLE;
resource.LocalNameIsDefined = false;
@@ -185,7 +185,7 @@ STDMETHODIMP CNetFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder
{
NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder;
CMyComPtr<IFolderFolder> subFolder = fsFolderSpec;
- RINOK(fsFolderSpec->Init(resource.RemoteName + WCHAR_PATH_SEPARATOR, this));
+ RINOK(fsFolderSpec->Init(us2fs(resource.RemoteName + WCHAR_PATH_SEPARATOR), this));
*resultFolder = subFolder.Detach();
}
else
@@ -253,7 +253,7 @@ STDMETHODIMP CNetFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex)
if (resource.DisplayType == RESOURCEDISPLAYTYPE_SERVER ||
resource.Usage == RESOURCEUSAGE_CONNECTABLE)
{
- if (GetRealIconIndex(resource.RemoteName, 0, iconIndexTemp))
+ if (GetRealIconIndex(us2fs(resource.RemoteName), 0, iconIndexTemp))
{
*iconIndex = iconIndexTemp;
return S_OK;
@@ -261,7 +261,7 @@ STDMETHODIMP CNetFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex)
}
else
{
- if (GetRealIconIndex(TEXT(""), FILE_ATTRIBUTE_DIRECTORY, iconIndexTemp))
+ if (GetRealIconIndex(FTEXT(""), FILE_ATTRIBUTE_DIRECTORY, iconIndexTemp))
{
*iconIndex = iconIndexTemp;
return S_OK;
diff --git a/CPP/7zip/UI/FileManager/OpenCallback.cpp b/CPP/7zip/UI/FileManager/OpenCallback.cpp
index 72245ac4..95daf37a 100755
--- a/CPP/7zip/UI/FileManager/OpenCallback.cpp
+++ b/CPP/7zip/UI/FileManager/OpenCallback.cpp
@@ -8,6 +8,8 @@
#include "../../Common/FileStreams.h"
+#include "../Common/ZipRegistry.h"
+
#include "OpenCallback.h"
#include "PasswordDialog.h"
@@ -82,16 +84,15 @@ STDMETHODIMP COpenArchiveCallback::GetProperty(PROPID propID, PROPVARIANT *value
return S_OK;
}
-STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name,
- IInStream **inStream)
+STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name, IInStream **inStream)
{
*inStream = NULL;
if (_subArchiveMode)
return S_FALSE;
- NFile::NFind::CFileInfoW fileInfo;
+ NFile::NFind::CFileInfo fileInfo;
- UString fullPath = _folderPrefix + name;
+ FString fullPath = _folderPrefix + us2fs(name);
if (!fileInfo.Find(fullPath))
return S_FALSE;
_fileInfo = fileInfo;
@@ -111,6 +112,8 @@ STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password)
if (!PasswordIsDefined)
{
CPasswordDialog dialog;
+ bool showPassword = NExtract::Read_ShowPassword();
+ dialog.ShowPassword = showPassword;
ProgressDialog.WaitCreating();
if (dialog.Create(ProgressDialog) == IDCANCEL)
@@ -118,6 +121,8 @@ STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password)
Password = dialog.Password;
PasswordIsDefined = true;
+ if (dialog.ShowPassword != showPassword)
+ NExtract::Save_ShowPassword(dialog.ShowPassword);
}
return StringToBstr(Password, password);
}
diff --git a/CPP/7zip/UI/FileManager/OpenCallback.h b/CPP/7zip/UI/FileManager/OpenCallback.h
index 559eb8fc..a0c0167e 100755
--- a/CPP/7zip/UI/FileManager/OpenCallback.h
+++ b/CPP/7zip/UI/FileManager/OpenCallback.h
@@ -27,8 +27,8 @@ class COpenArchiveCallback:
public ICryptoGetTextPassword,
public CMyUnknownImp
{
- UString _folderPrefix;
- NWindows::NFile::NFind::CFileInfoW _fileInfo;
+ FString _folderPrefix;
+ NWindows::NFile::NFind::CFileInfo _fileInfo;
NWindows::NSynchronization::CCriticalSection _criticalSection;
bool _subArchiveMode;
UString _subArchiveName;
@@ -75,7 +75,7 @@ public:
_subArchiveMode = false;
}
*/
- void LoadFileInfo(const UString &folderPrefix, const UString &fileName)
+ void LoadFileInfo(const FString &folderPrefix, const FString &fileName)
{
_folderPrefix = folderPrefix;
if (!_fileInfo.Find(_folderPrefix + fileName))
diff --git a/CPP/7zip/UI/FileManager/OptionsDialog.cpp b/CPP/7zip/UI/FileManager/OptionsDialog.cpp
index 7a7e90fb..a1ef1b1d 100755
--- a/CPP/7zip/UI/FileManager/OptionsDialog.cpp
+++ b/CPP/7zip/UI/FileManager/OptionsDialog.cpp
@@ -24,7 +24,6 @@
#include "App.h"
#include "LangUtils.h"
#include "MyLoadMenu.h"
-#include "ProgramLocation.h"
#include "resource.h"
@@ -42,11 +41,10 @@ static void ShowMenuErrorMessage(const wchar_t *m)
static int DllRegisterServer2(const char *name)
{
- NWindows::NDLL::CLibrary lib;
+ NDLL::CLibrary lib;
- UString prefix;
- GetProgramFolderPath(prefix);
- if (!lib.Load(prefix + L"7-zip.dll"))
+ FString prefix = NDLL::GetModuleDirPrefix();
+ if (!lib.Load(prefix + FTEXT("7-zip.dll")))
{
ShowMenuErrorMessage(L"7-Zip cannot load 7-zip.dll");
return E_FAIL;
@@ -94,7 +92,7 @@ void OptionsDialog(HWND hwndOwner, HINSTANCE /* hInstance */)
CFoldersPage foldersPage;
CObjectVector<NControl::CPageInfo> pages;
- UINT32 langIDs[] = { 0x03010300,
+ const UInt32 langIDs[] = { 0x03010300,
// 0x03010100,
0xFFFFFFFF,
0x01000200, 0x03010200, 0x03010400, 0x01000400};
diff --git a/CPP/7zip/UI/FileManager/Panel.cpp b/CPP/7zip/UI/FileManager/Panel.cpp
index 27aa7a54..ebbe12b9 100755
--- a/CPP/7zip/UI/FileManager/Panel.cpp
+++ b/CPP/7zip/UI/FileManager/Panel.cpp
@@ -79,6 +79,7 @@ HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
_mainWindow = mainWindow;
_processTimer = true;
_processNotify = true;
+ _processStatusBar = true;
_panelCallback = panelCallback;
_appState = appState;
@@ -91,8 +92,11 @@ HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
if (!currentFolderPrefix.IsEmpty())
if (currentFolderPrefix[0] == L'.')
- if (!NFile::NDirectory::MyGetFullPathName(currentFolderPrefix, cfp))
- cfp = currentFolderPrefix;
+ {
+ FString cfpF;
+ if (NFile::NDirectory::MyGetFullPathName(us2fs(currentFolderPrefix), cfpF))
+ cfp = fs2us(cfpF);
+ }
RINOK(BindToPath(cfp, arcFormat, archiveIsOpened, encrypted));
if (!CreateEx(0, kClassName, 0, WS_CHILD | WS_VISIBLE,
@@ -104,7 +108,7 @@ HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
LRESULT CPanel::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
- switch(message)
+ switch (message)
{
case kShiftSelectMessage:
OnShiftSelectMessage();
@@ -117,12 +121,15 @@ LRESULT CPanel::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
return 0;
case kOpenItemChanged:
return OnOpenItemChanged(lParam);
- case kRefreshStatusBar:
- OnRefreshStatusBar();
+ case kRefresh_StatusBar:
+ if (_processStatusBar)
+ Refresh_StatusBar();
return 0;
- case kRefreshHeaderComboBox:
+ #ifdef UNDER_CE
+ case kRefresh_HeaderComboBox:
LoadFullPathAndShow();
return 0;
+ #endif
case WM_TIMER:
OnTimer();
return 0;
@@ -139,15 +146,6 @@ LRESULT CPanel::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
return CWindow2::OnMessage(message, wParam, lParam);
}
-static LRESULT APIENTRY ListViewSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- CWindow tempDialog(hwnd);
- CMyListView *w = (CMyListView *)(tempDialog.GetUserDataLongPtr());
- if (w == NULL)
- return 0;
- return w->OnMessage(message, wParam, lParam);
-}
-
LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_CHAR)
@@ -187,7 +185,7 @@ LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
// bool leftCtrl = (::GetKeyState(VK_LCONTROL) & 0x8000) != 0;
// bool RightCtrl = (::GetKeyState(VK_RCONTROL) & 0x8000) != 0;
bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
- switch(wParam)
+ switch (wParam)
{
/*
case VK_RETURN:
@@ -233,12 +231,7 @@ LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
_panel->_lastFocusedIsList = true;
_panel->_panelCallback->PanelWasFocused();
}
- #ifndef _UNICODE
- if (g_IsNT)
- return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam);
- else
- #endif
- return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
+ return CListView2::OnMessage(message, wParam, lParam);
}
/*
@@ -365,21 +358,9 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
HWND(*this), (HMENU)(UINT_PTR)(_baseID + 1), g_hInstance, NULL))
return false;
- #ifndef UNDER_CE
- _listView.SetUnicodeFormat(true);
- #endif
-
- _listView.SetUserDataLongPtr(LONG_PTR(&_listView));
+ _listView.SetUnicodeFormat();
_listView._panel = this;
-
- #ifndef _UNICODE
- if(g_IsNT)
- _listView._origWindowProc =
- (WNDPROC)_listView.SetLongPtrW(GWLP_WNDPROC, LONG_PTR(ListViewSubclassProc));
- else
- #endif
- _listView._origWindowProc =
- (WNDPROC)_listView.SetLongPtr(GWLP_WNDPROC, LONG_PTR(ListViewSubclassProc));
+ _listView.SetWindowProc();
_listView.SetImageList(GetSysImageList(true), LVSIL_SMALL);
_listView.SetImageList(GetSysImageList(false), LVSIL_NORMAL);
@@ -552,7 +533,6 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
// InitListCtrl();
RefreshListCtrl();
- RefreshStatusBar();
return true;
}
@@ -614,7 +594,7 @@ bool CPanel::OnSize(WPARAM /* wParam */, int xSize, int ySize)
bool CPanel::OnNotifyReBar(LPNMHDR header, LRESULT & /* result */)
{
- switch(header->code)
+ switch (header->code)
{
case RBN_HEIGHTCHANGE:
{
@@ -790,9 +770,10 @@ void CPanel::ChangeFlatMode()
}
-void CPanel::RefreshStatusBar()
+void CPanel::Post_Refresh_StatusBar()
{
- PostMessage(kRefreshStatusBar);
+ if (_processStatusBar)
+ PostMessage(kRefresh_StatusBar);
}
void CPanel::AddToArchive()
@@ -953,6 +934,12 @@ void CPanel::TestArchives()
extracter.ExtractCallbackSpec = new CExtractCallbackImp;
extracter.ExtractCallback = extracter.ExtractCallbackSpec;
extracter.ExtractCallbackSpec->ProgressDialog = &extracter.ProgressDialog;
+ if (!_parentFolders.IsEmpty())
+ {
+ const CFolderLink &fl = _parentFolders.Back();
+ extracter.ExtractCallbackSpec->PasswordIsDefined = fl.UsePassword;
+ extracter.ExtractCallbackSpec->Password = fl.Password;
+ }
if (indices.IsEmpty())
return;
diff --git a/CPP/7zip/UI/FileManager/Panel.h b/CPP/7zip/UI/FileManager/Panel.h
index 9cda94a4..e33a37a2 100755
--- a/CPP/7zip/UI/FileManager/Panel.h
+++ b/CPP/7zip/UI/FileManager/Panel.h
@@ -85,13 +85,14 @@ public:
struct CTempFileInfo
{
- UString ItemName;
- UString FolderPath;
- UString FilePath;
- NWindows::NFile::NFind::CFileInfoW FileInfo;
+ UInt32 FileIndex; // index of file in folder
+ UString RelPath; // Relative path of file from Folder
+ FString FolderPath;
+ FString FilePath;
+ NWindows::NFile::NFind::CFileInfo FileInfo;
bool NeedDelete;
- CTempFileInfo(): NeedDelete(false) {}
+ CTempFileInfo(): FileIndex((UInt32)(Int32)-1), NeedDelete(false) {}
void DeleteDirAndFile() const
{
if (NeedDelete)
@@ -100,7 +101,7 @@ struct CTempFileInfo
NWindows::NFile::NDirectory::MyRemoveDirectory(FolderPath);
}
}
- bool WasChanged(const NWindows::NFile::NFind::CFileInfoW &newFileInfo) const
+ bool WasChanged(const NWindows::NFile::NFind::CFileInfo &newFileInfo) const
{
return newFileInfo.Size != FileInfo.Size ||
CompareFileTime(&newFileInfo.MTime, &FileInfo.MTime) != 0;
@@ -118,7 +119,7 @@ struct CFolderLink: public CTempFileInfo
UString VirtualPath;
CFolderLink(): UsePassword(false), IsVirtual(false) {}
- bool WasChanged(const NWindows::NFile::NFind::CFileInfoW &newFileInfo) const
+ bool WasChanged(const NWindows::NFile::NFind::CFileInfo &newFileInfo) const
{
return IsVirtual || CTempFileInfo::WasChanged(newFileInfo);
}
@@ -131,18 +132,19 @@ enum MyMessages
kReLoadMessage,
kSetFocusToListView,
kOpenItemChanged,
- kRefreshStatusBar,
- kRefreshHeaderComboBox
+ kRefresh_StatusBar
+ #ifdef UNDER_CE
+ , kRefresh_HeaderComboBox
+ #endif
};
UString GetFolderPath(IFolderFolder * folder);
class CPanel;
-class CMyListView: public NWindows::NControl::CListView
+class CMyListView: public NWindows::NControl::CListView2
{
public:
- WNDPROC _origWindowProc;
CPanel *_panel;
LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
};
@@ -482,34 +484,33 @@ public:
bool _processTimer;
bool _processNotify;
+ bool _processStatusBar;
class CDisableTimerProcessing
{
bool _processTimerMem;
bool _processNotifyMem;
+ bool _processStatusBarMem;
CPanel &_panel;
public:
- CDisableTimerProcessing(CPanel &panel): _panel(panel)
- {
- Disable();
- }
+ CDisableTimerProcessing(CPanel &panel): _panel(panel) { Disable(); }
+ ~CDisableTimerProcessing() { Restore(); }
void Disable()
{
_processTimerMem = _panel._processTimer;
_processNotifyMem = _panel._processNotify;
+ _processStatusBarMem = _panel._processStatusBar;
_panel._processTimer = false;
_panel._processNotify = false;
+ _panel._processStatusBar = false;
}
void Restore()
{
_panel._processTimer = _processTimerMem;
_panel._processNotify = _processNotifyMem;
- }
- ~CDisableTimerProcessing()
- {
- Restore();
+ _panel._processStatusBar = _processStatusBarMem;
}
CDisableTimerProcessing& operator=(const CDisableTimerProcessing &) {; }
};
@@ -544,11 +545,11 @@ public:
const UString &virtualFilePath,
const UString &arcFormat,
bool &encrypted);
- HRESULT OpenItemAsArchive(const UString &name, const UString &arcFormat, bool &encrypted);
+ HRESULT OpenItemAsArchive(const UString &relPath, const UString &arcFormat, bool &encrypted);
HRESULT OpenItemAsArchive(int index);
void OpenItemInArchive(int index, bool tryInternal, bool tryExternal,
bool editMode);
- HRESULT OnOpenItemChanged(const UString &folderPath, const UString &itemName, bool usePassword, const UString &password);
+ HRESULT OnOpenItemChanged(UInt32 index, const wchar_t *fullFilePath, bool usePassword, const UString &password);
LRESULT OnOpenItemChanged(LPARAM lParam);
void OpenItem(int index, bool tryInternal, bool tryExternal);
@@ -565,8 +566,8 @@ public:
void ChangeFlatMode();
bool GetFlatMode() const { return _flatMode; }
- void RefreshStatusBar();
- void OnRefreshStatusBar();
+ void Post_Refresh_StatusBar();
+ void Refresh_StatusBar();
void AddToArchive();
diff --git a/CPP/7zip/UI/FileManager/PanelCrc.cpp b/CPP/7zip/UI/FileManager/PanelCrc.cpp
index 6b00a9b5..2dd5e7ce 100755
--- a/CPP/7zip/UI/FileManager/PanelCrc.cpp
+++ b/CPP/7zip/UI/FileManager/PanelCrc.cpp
@@ -29,13 +29,13 @@ static const UInt32 kBufSize = (1 << 15);
struct CDirEnumerator
{
bool FlatMode;
- UString BasePrefix;
- UStringVector FileNames;
+ FString BasePrefix;
+ FStringVector FileNames;
- CObjectVector<NFind::CEnumeratorW> Enumerators;
- UStringVector Prefixes;
+ CObjectVector<NFind::CEnumerator> Enumerators;
+ FStringVector Prefixes;
int Index;
- HRESULT GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &fullPath);
+ HRESULT GetNextFile(NFind::CFileInfo &fileInfo, bool &filled, FString &fullPath);
void Init();
CDirEnumerator(): FlatMode(false) {};
@@ -54,7 +54,7 @@ static HRESULT GetNormalizedError()
return (errorCode == 0) ? E_FAIL : errorCode;
}
-HRESULT CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &resPath)
+HRESULT CDirEnumerator::GetNextFile(NFind::CFileInfo &fileInfo, bool &filled, FString &resPath)
{
filled = false;
for (;;)
@@ -63,8 +63,8 @@ HRESULT CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, U
{
if (Index >= FileNames.Size())
return S_OK;
- const UString &path = FileNames[Index];
- int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR);
+ const FString &path = FileNames[Index];
+ int pos = path.ReverseFind(FCHAR_PATH_SEPARATOR);
resPath.Empty();
if (pos >= 0)
resPath = path.Left(pos + 1);
@@ -106,8 +106,8 @@ HRESULT CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, U
resPath += fileInfo.Name;
if (!FlatMode && fileInfo.IsDir())
{
- UString prefix = resPath + WCHAR_PATH_SEPARATOR;
- Enumerators.Add(NFind::CEnumeratorW(BasePrefix + prefix + (UString)(wchar_t)NName::kAnyStringWildcard));
+ FString prefix = resPath + FCHAR_PATH_SEPARATOR;
+ Enumerators.Add(NFind::CEnumerator(BasePrefix + prefix + FCHAR_ANY_MASK));
Prefixes.Add(prefix);
}
filled = true;
@@ -212,13 +212,13 @@ HRESULT CThreadCrc::ProcessVirt()
for (;;)
{
- NFind::CFileInfoW fileInfo;
+ NFind::CFileInfo fileInfo;
bool filled;
- UString resPath;
+ FString resPath;
HRESULT errorCode = Enumerator.GetNextFile(fileInfo, filled, resPath);
if (errorCode != 0)
{
- ErrorPath1 = resPath;
+ SetErrorPath1(resPath);
return errorCode;
}
if (!filled)
@@ -228,7 +228,7 @@ HRESULT CThreadCrc::ProcessVirt()
totalSize += fileInfo.Size;
NumFilesScan++;
}
- sync.SetCurrentFileName(scanningStr + resPath);
+ sync.SetCurrentFileName(scanningStr + fs2us(resPath));
sync.SetProgress(totalSize, 0);
RINOK(sync.SetPosAndCheckPaused(0));
}
@@ -239,13 +239,13 @@ HRESULT CThreadCrc::ProcessVirt()
for (;;)
{
- NFind::CFileInfoW fileInfo;
+ NFind::CFileInfo fileInfo;
bool filled;
- UString resPath;
+ FString resPath;
HRESULT errorCode = Enumerator.GetNextFile(fileInfo, filled, resPath);
if (errorCode != 0)
{
- ErrorPath1 = resPath;
+ SetErrorPath1(resPath);
return errorCode;
}
if (!filled)
@@ -263,10 +263,10 @@ HRESULT CThreadCrc::ProcessVirt()
if (!inFile.Open(Enumerator.BasePrefix + resPath))
{
errorCode = GetNormalizedError();
- ErrorPath1 = resPath;
+ SetErrorPath1(resPath);
return errorCode;
}
- sync.SetCurrentFileName(resPath);
+ sync.SetCurrentFileName(fs2us(resPath));
sync.SetNumFilesCur(NumFiles);
NumFiles++;
for (;;)
@@ -275,7 +275,7 @@ HRESULT CThreadCrc::ProcessVirt()
if (!inFile.Read(buffer, kBufSize, processedSize))
{
errorCode = GetNormalizedError();
- ErrorPath1 = resPath;
+ SetErrorPath1(resPath);
return errorCode;
}
if (processedSize == 0)
@@ -323,8 +323,8 @@ void CApp::CalculateCrc()
{
CThreadCrc t;
for (int i = 0; i < indices.Size(); i++)
- t.Enumerator.FileNames.Add(srcPanel.GetItemRelPath(indices[i]));
- t.Enumerator.BasePrefix = srcPanel.GetFsPath();
+ t.Enumerator.FileNames.Add(us2fs(srcPanel.GetItemRelPath(indices[i])));
+ t.Enumerator.BasePrefix = us2fs(srcPanel.GetFsPath());
t.Enumerator.FlatMode = GetFlatMode();
t.ProgressDialog.ShowCompressionInfo = false;
diff --git a/CPP/7zip/UI/FileManager/PanelDrag.cpp b/CPP/7zip/UI/FileManager/PanelDrag.cpp
index eb5ad871..02bccc03 100755
--- a/CPP/7zip/UI/FileManager/PanelDrag.cpp
+++ b/CPP/7zip/UI/FileManager/PanelDrag.cpp
@@ -10,6 +10,7 @@
#include "Windows/Memory.h"
#include "Windows/FileDir.h"
+#include "Windows/FileName.h"
#include "Windows/Shell.h"
#include "../Common/ArchiveName.h"
@@ -26,7 +27,7 @@ using namespace NWindows;
extern bool g_IsNT;
#endif
-static wchar_t *kTempDirPrefix = L"7zE";
+static CFSTR kTempDirPrefix = FTEXT("7zE");
static LPCTSTR kSvenZipSetFolderFormat = TEXT("7-Zip::SetTargetFolder");
////////////////////////////////////////////////////////
@@ -304,12 +305,12 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
// CSelectedState selState;
// SaveSelectedState(selState);
- UString dirPrefix;
- NFile::NDirectory::CTempDirectoryW tempDirectory;
+ FString dirPrefix;
+ NFile::NDirectory::CTempDir tempDirectory;
bool isFSFolder = IsFSFolder();
if (isFSFolder)
- dirPrefix = _currentFolderPrefix;
+ dirPrefix = us2fs(_currentFolderPrefix);
else
{
tempDirectory.Create(kTempDirPrefix);
@@ -330,7 +331,7 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
s = GetItemRelPath(index);
else
s = GetItemName(index);
- names.Add(dirPrefix + s);
+ names.Add(fs2us(dirPrefix) + s);
}
if (!CopyNamesToHGlobal(dataObjectSpec->hGlobal, names))
return;
@@ -341,7 +342,7 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
dropSourceSpec->NeedExtract = !isFSFolder;
dropSourceSpec->Panel = this;
dropSourceSpec->Indices = indices;
- dropSourceSpec->Folder = dirPrefix;
+ dropSourceSpec->Folder = fs2us(dirPrefix);
dropSourceSpec->DataObjectSpec = dataObjectSpec;
dropSourceSpec->DataObject = dataObjectSpec;
@@ -748,9 +749,9 @@ void CPanel::CompressDropFiles(HDROP dr)
}
*/
-static bool IsFolderInTemp(const UString &path)
+static bool IsFolderInTemp(const FString &path)
{
- UString tempPath;
+ FString tempPath;
if (!NFile::NDirectory::MyGetTempPath(tempPath))
return false;
if (tempPath.IsEmpty())
@@ -760,9 +761,10 @@ static bool IsFolderInTemp(const UString &path)
static bool AreThereNamesFromTemp(const UStringVector &fileNames)
{
- UString tempPath;
- if (!NFile::NDirectory::MyGetTempPath(tempPath))
+ FString tempPathF;
+ if (!NFile::NDirectory::MyGetTempPath(tempPathF))
return false;
+ UString tempPath = fs2us(tempPathF);
if (tempPath.IsEmpty())
return false;
for (int i = 0; i < fileNames.Size(); i++)
@@ -784,8 +786,10 @@ void CPanel::CompressDropFiles(const UStringVector &fileNames, const UString &fo
UString folderPath2 = folderPath;
if (folderPath2.IsEmpty())
{
- NFile::NDirectory::GetOnlyDirPrefix(fileNames.Front(), folderPath2);
- if (IsFolderInTemp(folderPath2))
+ FString folderPath2F;
+ NFile::NDirectory::GetOnlyDirPrefix(us2fs(fileNames.Front()), folderPath2F);
+ folderPath2 = fs2us(folderPath2F);
+ if (IsFolderInTemp(folderPath2F))
folderPath2 = ROOT_FS_FOLDER;
}
const UString archiveName = CreateArchiveName(fileNames.Front(), (fileNames.Size() > 1), false);
diff --git a/CPP/7zip/UI/FileManager/PanelFolderChange.cpp b/CPP/7zip/UI/FileManager/PanelFolderChange.cpp
index afa4c041..995124be 100755
--- a/CPP/7zip/UI/FileManager/PanelFolderChange.cpp
+++ b/CPP/7zip/UI/FileManager/PanelFolderChange.cpp
@@ -5,6 +5,7 @@
#include "Common/StringConvert.h"
#include "Common/Wildcard.h"
+#include "Windows/FileName.h"
#include "Windows/PropVariant.h"
#include "../../PropID.h"
@@ -73,11 +74,11 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo
CloseOpenFolders();
UString sysPath = fullPath;
- CFileInfoW fileInfo;
+ CFileInfo fileInfo;
UStringVector reducedParts;
while (!sysPath.IsEmpty())
{
- if (fileInfo.Find(sysPath))
+ if (fileInfo.Find(us2fs(sysPath)))
break;
int pos = sysPath.ReverseFind(WCHAR_PATH_SEPARATOR);
if (pos < 0)
@@ -104,17 +105,14 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo
}
else
{
- UString dirPrefix;
- if (!NDirectory::GetOnlyDirPrefix(sysPath, dirPrefix))
- dirPrefix.Empty();
- if (_folder->BindToFolder(dirPrefix, &newFolder) == S_OK)
+ FString dirPrefix, fileName;
+ NDirectory::GetFullPathAndSplit(us2fs(sysPath), dirPrefix, fileName);
+ if (_folder->BindToFolder(fs2us(dirPrefix), &newFolder) == S_OK)
{
_folder = newFolder;
LoadFullPath();
- UString fileName;
- if (NDirectory::GetOnlyName(sysPath, fileName))
{
- HRESULT res = OpenItemAsArchive(fileName, arcFormat, encrypted);
+ HRESULT res = OpenItemAsArchive(fs2us(fileName), arcFormat, encrypted);
if (res != S_FALSE)
{
RINOK(res);
@@ -176,14 +174,14 @@ void CPanel::LoadFullPath()
{
const CFolderLink &folderLink = _parentFolders[i];
_currentFolderPrefix += GetFolderPath(folderLink.ParentFolder);
- _currentFolderPrefix += folderLink.ItemName;
+ _currentFolderPrefix += folderLink.RelPath;
_currentFolderPrefix += WCHAR_PATH_SEPARATOR;
}
if (_folder)
_currentFolderPrefix += GetFolderPath(_folder);
}
-static int GetRealIconIndex(LPCWSTR path, DWORD attributes)
+static int GetRealIconIndex(CFSTR path, DWORD attributes)
{
int index = -1;
if (GetRealIconIndex(path, attributes, index) != 0)
@@ -209,15 +207,22 @@ void CPanel::LoadFullPathAndShow()
#else
1
#endif
- && path[path.Length() - 1] == WCHAR_PATH_SEPARATOR)
- path.Delete(path.Length() - 1);
+ && path.Back() == WCHAR_PATH_SEPARATOR)
+ path.DeleteBack();
- CFileInfoW info;
DWORD attrib = FILE_ATTRIBUTE_DIRECTORY;
- if (info.Find(path))
- attrib = info.Attrib;
-
- item.iImage = GetRealIconIndex(path, attrib);
+
+ // GetRealIconIndex is slow for direct DVD/UDF path. So we use dummy path
+ UString excludePrefix = L"\\\\.\\";
+ UString path2 = L"_TestFolder_";
+ if (excludePrefix != path.Left(excludePrefix.Length()))
+ {
+ path2 = path;
+ CFileInfo info;
+ if (info.Find(us2fs(path)))
+ attrib = info.Attrib;
+ }
+ item.iImage = GetRealIconIndex(us2fs(path2), attrib);
if (item.iImage >= 0)
{
@@ -356,11 +361,11 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result)
UString name = pathParts[i];
sumPass += name;
sumPass += WCHAR_PATH_SEPARATOR;
- CFileInfoW info;
+ CFileInfo info;
DWORD attrib = FILE_ATTRIBUTE_DIRECTORY;
- if (info.Find(sumPass))
+ if (info.Find(us2fs(sumPass)))
attrib = info.Attrib;
- AddComboBoxItem(name.IsEmpty() ? L"\\" : name, GetRealIconIndex(sumPass, attrib), i, false);
+ AddComboBoxItem(name.IsEmpty() ? L"\\" : name, GetRealIconIndex(us2fs(sumPass), attrib), i, false);
ComboBoxPaths.Add(sumPass);
}
@@ -374,16 +379,16 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result)
name = RootFolder_GetName_Computer(iconIndex);
AddComboBoxItem(name, iconIndex, 0, true);
- UStringVector driveStrings;
+ FStringVector driveStrings;
MyGetLogicalDriveStrings(driveStrings);
for (i = 0; i < driveStrings.Size(); i++)
{
- UString s = driveStrings[i];
- ComboBoxPaths.Add(s);
+ FString s = driveStrings[i];
+ ComboBoxPaths.Add(fs2us(s));
int iconIndex = GetRealIconIndex(s, 0);
- if (s.Length() > 0 && s[s.Length() - 1] == WCHAR_PATH_SEPARATOR)
- s.Delete(s.Length() - 1);
- AddComboBoxItem(s, iconIndex, 1, false);
+ if (s.Length() > 0 && s.Back() == FCHAR_PATH_SEPARATOR)
+ s.DeleteBack();
+ AddComboBoxItem(fs2us(s), iconIndex, 1, false);
}
name = RootFolder_GetName_Network(iconIndex);
@@ -407,9 +412,8 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result)
{
PostMessage(kSetFocusToListView);
#ifdef UNDER_CE
- PostMessage(kRefreshHeaderComboBox);
+ PostMessage(kRefresh_HeaderComboBox);
#endif
-
return true;
}
}
@@ -522,7 +526,7 @@ void CPanel::OpenParentFolder()
CFolderLink &link = _parentFolders.Back();
_folder = link.ParentFolder;
_library.Attach(link.Library.Detach());
- focucedName = link.ItemName;
+ focucedName = link.RelPath;
if (_parentFolders.Size() > 1)
OpenParentArchiveFolder();
_parentFolders.DeleteBack();
@@ -540,7 +544,6 @@ void CPanel::OpenParentFolder()
// ::SetCurrentDirectory(::_currentFolderPrefix);
RefreshListCtrl(focucedName, -1, true, selectedItems);
_listView.EnsureVisible(_listView.GetFocusedItem(), false);
- RefreshStatusBar();
}
void CPanel::CloseOpenFolders()
@@ -607,7 +610,6 @@ void CPanel::OpenFolder(int index)
LoadFullPath();
// ::SetCurrentDirectory(::_currentFolderPrefix);
RefreshListCtrl();
- UINT state = LVIS_SELECTED;
- _listView.SetItemState(_listView.GetFocusedItem(), state, state);
+ _listView.SetItemState_Selected(_listView.GetFocusedItem());
_listView.EnsureVisible(_listView.GetFocusedItem(), false);
}
diff --git a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
index 934e98d3..6c4309c6 100755
--- a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
+++ b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
@@ -2,12 +2,15 @@
#include "StdAfx.h"
+#include <tlhelp32.h>
+
#include "Common/AutoPtr.h"
#include "Common/StringConvert.h"
#include "Windows/Error.h"
#include "Windows/FileDir.h"
#include "Windows/FileFind.h"
+#include "Windows/FileName.h"
#include "Windows/Process.h"
#include "Windows/PropVariant.h"
#include "Windows/Thread.h"
@@ -33,8 +36,122 @@ using namespace NDirectory;
extern bool g_IsNT;
#endif
-static wchar_t *kTempDirPrefix = L"7zO";
+static CFSTR kTempDirPrefix = FTEXT("7zO");
+
+#ifndef UNDER_CE
+
+class CProcessSnapshot
+{
+ HANDLE _handle;
+public:
+ CProcessSnapshot(): _handle(INVALID_HANDLE_VALUE) {};
+ ~CProcessSnapshot() { Close(); }
+
+ bool Close()
+ {
+ if (_handle == INVALID_HANDLE_VALUE)
+ return true;
+ if (!::CloseHandle(_handle))
+ return false;
+ _handle = INVALID_HANDLE_VALUE;
+ return true;
+ }
+
+ bool Create()
+ {
+ _handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
+ return (_handle != INVALID_HANDLE_VALUE);
+ }
+
+ bool GetFirstProcess(PROCESSENTRY32 *pe) { return BOOLToBool(Process32First(_handle, pe)); }
+ bool GetNextProcess(PROCESSENTRY32 *pe) { return BOOLToBool(Process32Next(_handle, pe)); }
+};
+
+#endif
+
+typedef DWORD (WINAPI *GetProcessIdFunc)(HANDLE process);
+
+class CChildProcesses
+{
+ #ifndef UNDER_CE
+ CRecordVector<DWORD> _ids;
+ #endif
+public:
+ CRecordVector<HANDLE> Handles;
+ CRecordVector<bool> NeedWait;
+
+ ~CChildProcesses() { CloseAll(); }
+ void DisableWait(int index) { NeedWait[index] = false; }
+
+ void CloseAll()
+ {
+ for (int i = 0; i < Handles.Size(); i++)
+ {
+ HANDLE h = Handles[i];
+ if (h != NULL)
+ CloseHandle(h);
+ }
+ Handles.Clear();
+ NeedWait.Clear();
+ }
+
+ void AddProcess(HANDLE h)
+ {
+ #ifndef UNDER_CE
+ GetProcessIdFunc func = (GetProcessIdFunc)::GetProcAddress(::GetModuleHandleA("kernel32.dll"), "GetProcessId");
+ if (func)
+ _ids.AddToUniqueSorted(func(h));
+ #endif
+ Handles.Add(h);
+ NeedWait.Add(true);
+ }
+
+ void Update()
+ {
+ #ifndef UNDER_CE
+ CRecordVector<DWORD> ids, parents;
+ {
+ CProcessSnapshot snapshot;
+ if (snapshot.Create())
+ {
+ PROCESSENTRY32 pe;
+ memset(&pe, 0, sizeof(pe));
+ pe.dwSize = sizeof(pe);
+ BOOL res = snapshot.GetFirstProcess(&pe);
+ while (res)
+ {
+ ids.Add(pe.th32ProcessID);
+ parents.Add(pe.th32ParentProcessID);
+ res = snapshot.GetNextProcess(&pe);
+ }
+ }
+ }
+ for (;;)
+ {
+ int i;
+ for (i = 0; i < ids.Size(); i++)
+ {
+ DWORD id = ids[i];
+ if (_ids.FindInSorted(parents[i]) >= 0 &&
+ _ids.FindInSorted(id) < 0)
+ {
+ HANDLE hProcess = OpenProcess(SYNCHRONIZE, FALSE, id);
+ if (hProcess)
+ {
+ _ids.AddToUniqueSorted(id);
+ Handles.Add(hProcess);
+ NeedWait.Add(true);
+ break;
+ }
+ }
+ }
+ if (i == ids.Size())
+ break;
+ }
+ #endif
+ }
+};
static bool IsNameVirus(const UString &name)
{
@@ -43,11 +160,12 @@ static bool IsNameVirus(const UString &name)
struct CTmpProcessInfo: public CTempFileInfo
{
- HANDLE ProcessHandle;
+ CChildProcesses Processes;
HWND Window;
UString FullPathFolderPrefix;
bool UsePassword;
UString Password;
+
CTmpProcessInfo(): UsePassword(false) {}
};
@@ -56,8 +174,8 @@ class CTmpProcessInfoRelease
CTmpProcessInfo *_tmpProcessInfo;
public:
bool _needDelete;
- CTmpProcessInfoRelease(CTmpProcessInfo &tmpProcessInfo):
- _tmpProcessInfo(&tmpProcessInfo), _needDelete(true) {}
+ CTmpProcessInfoRelease(CTmpProcessInfo &tpi):
+ _tmpProcessInfo(&tpi), _needDelete(true) {}
~CTmpProcessInfoRelease()
{
if (_needDelete)
@@ -96,7 +214,7 @@ HRESULT CPanel::OpenItemAsArchive(IInStream *inStream,
UString password;
RINOK(OpenFileFolderPlugin(inStream,
- folderLink.FilePath.IsEmpty() ? virtualFilePath : folderLink.FilePath,
+ folderLink.FilePath.IsEmpty() ? us2fs(virtualFilePath) : folderLink.FilePath,
arcFormat,
&library, &newFolder, GetParent(), encrypted, password));
@@ -157,13 +275,14 @@ HRESULT CPanel::OpenItemAsArchive(IInStream *inStream,
return S_OK;
}
-HRESULT CPanel::OpenItemAsArchive(const UString &name, const UString &arcFormat, bool &encrypted)
+HRESULT CPanel::OpenItemAsArchive(const UString &relPath, const UString &arcFormat, bool &encrypted)
{
CTempFileInfo tfi;
- tfi.ItemName = name;
- tfi.FolderPath = _currentFolderPrefix;
- tfi.FilePath = _currentFolderPrefix + name;
- return OpenItemAsArchive(NULL, tfi, _currentFolderPrefix + name, arcFormat, encrypted);
+ tfi.RelPath = relPath;
+ tfi.FolderPath = us2fs(_currentFolderPrefix);
+ const UString fullPath = _currentFolderPrefix + relPath;
+ tfi.FilePath = us2fs(fullPath);
+ return OpenItemAsArchive(NULL, tfi, fullPath, arcFormat, encrypted);
}
HRESULT CPanel::OpenItemAsArchive(int index)
@@ -180,21 +299,21 @@ HRESULT CPanel::OpenParentArchiveFolder()
CDisableTimerProcessing disableTimerProcessing1(*this);
if (_parentFolders.Size() < 2)
return S_OK;
+ const CFolderLink &folderLinkPrev = _parentFolders[_parentFolders.Size() - 2];
const CFolderLink &folderLink = _parentFolders.Back();
- NFind::CFileInfoW newFileInfo;
+ NFind::CFileInfo newFileInfo;
if (newFileInfo.Find(folderLink.FilePath))
{
if (folderLink.WasChanged(newFileInfo))
{
- UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE,
- 0x03020280, folderLink.ItemName);
+ UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE, 0x03020280, folderLink.RelPath);
if (::MessageBoxW(HWND(*this), message, L"7-Zip", MB_OKCANCEL | MB_ICONQUESTION) == IDOK)
{
- if (OnOpenItemChanged(folderLink.FolderPath, folderLink.ItemName,
- folderLink.UsePassword, folderLink.Password) != S_OK)
+ if (OnOpenItemChanged(folderLink.FileIndex, folderLink.FilePath,
+ folderLinkPrev.UsePassword, folderLinkPrev.Password) != S_OK)
{
::MessageBoxW(HWND(*this), MyFormatNew(IDS_CANNOT_UPDATE_FILE,
- 0x03020281, folderLink.FilePath), L"7-Zip", MB_OK | MB_ICONSTOP);
+ 0x03020281, fs2us(folderLink.FilePath)), L"7-Zip", MB_OK | MB_ICONSTOP);
return S_OK;
}
}
@@ -263,9 +382,11 @@ static HRESULT StartEditApplication(const UString &path, HWND window, CProcess &
#ifdef UNDER_CE
command = L"\\Windows\\";
#else
- if (!MyGetWindowsDirectory(command))
+ FString winDir;
+ if (!MyGetWindowsDirectory(winDir))
return 0;
- NFile::NName::NormalizeDirPathPrefix(command);
+ NFile::NName::NormalizeDirPathPrefix(winDir);
+ command = fs2us(winDir);
#endif
command += L"notepad.exe";
}
@@ -466,8 +587,8 @@ class CThreadCopyFrom: public CProgressThreadVirt
{
HRESULT ProcessVirt();
public:
- UString PathPrefix;
- UString Name;
+ UString FullPath;
+ UInt32 ItemIndex;
CMyComPtr<IFolderOperations> FolderOperations;
CMyComPtr<IProgress> UpdateCallback;
@@ -476,14 +597,10 @@ public:
HRESULT CThreadCopyFrom::ProcessVirt()
{
- UStringVector fileNames;
- CRecordVector<const wchar_t *> fileNamePointers;
- fileNames.Add(Name);
- fileNamePointers.Add(fileNames[0]);
- return FolderOperations->CopyFrom(PathPrefix, &fileNamePointers.Front(), fileNamePointers.Size(), UpdateCallback);
+ return FolderOperations->CopyFromFile(ItemIndex, FullPath, UpdateCallback);
}
-HRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &itemName,
+HRESULT CPanel::OnOpenItemChanged(UInt32 index, const wchar_t *fullFilePath,
bool usePassword, const UString &password)
{
CMyComPtr<IFolderOperations> folderOperations;
@@ -497,41 +614,48 @@ HRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &item
t.UpdateCallbackSpec = new CUpdateCallback100Imp;
t.UpdateCallback = t.UpdateCallbackSpec;
t.UpdateCallbackSpec->ProgressDialog = &t.ProgressDialog;
- t.Name = itemName;
- t.PathPrefix = folderPath;
- NName::NormalizeDirPathPrefix(t.PathPrefix);
+ t.ItemIndex = index;
+ t.FullPath = fullFilePath;
t.FolderOperations = folderOperations;
t.UpdateCallbackSpec->Init(usePassword, password);
- RINOK(t.Create(itemName, (HWND)*this));
+ RINOK(t.Create(GetItemName(index), (HWND)*this));
return t.Result;
}
LRESULT CPanel::OnOpenItemChanged(LPARAM lParam)
{
- CTmpProcessInfo &tmpProcessInfo = *(CTmpProcessInfo *)lParam;
- // LoadCurrentPath()
- if (tmpProcessInfo.FullPathFolderPrefix != _currentFolderPrefix)
+ CTmpProcessInfo &tpi = *(CTmpProcessInfo *)lParam;
+ if (tpi.FullPathFolderPrefix != _currentFolderPrefix)
return 0;
+ UInt32 fileIndex = tpi.FileIndex;
+ UInt32 numItems;
+ _folder->GetNumberOfItems(&numItems);
+
+ // This code is not 100% OK for cases when there are several files with
+ // tpi.RelPath name and there are changes in archive before update.
+ // So tpi.FileIndex can point to another file.
+
+ if (fileIndex >= numItems || GetItemRelPath(fileIndex) != tpi.RelPath)
+ {
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ if (GetItemRelPath(i) == tpi.RelPath)
+ break;
+ if (i == numItems)
+ return 0;
+ fileIndex = i;
+ }
CSelectedState state;
SaveSelectedState(state);
- HRESULT result = OnOpenItemChanged(tmpProcessInfo.FolderPath, tmpProcessInfo.ItemName,
- tmpProcessInfo.UsePassword, tmpProcessInfo.Password);
+ HRESULT result = OnOpenItemChanged(fileIndex, tpi.FilePath, tpi.UsePassword, tpi.Password);
if (result != S_OK)
return 0;
RefreshListCtrl(state);
return 1;
}
-/*
-class CTmpProcessInfoList
-{
-public:
- CObjectVector<CTmpProcessInfo> _items;
-} g_TmpProcessInfoList;
-*/
-
class CExitEventLauncher
{
public:
@@ -547,42 +671,64 @@ public:
static THREAD_FUNC_DECL MyThreadFunction(void *param)
{
CMyAutoPtr<CTmpProcessInfo> tmpProcessInfoPtr((CTmpProcessInfo *)param);
- const CTmpProcessInfo *tmpProcessInfo = tmpProcessInfoPtr.get();
+ CTmpProcessInfo *tpi = tmpProcessInfoPtr.get();
+ CChildProcesses &processes = tpi->Processes;
- HANDLE hProcess = tmpProcessInfo->ProcessHandle;
- HANDLE events[2] = { g_ExitEventLauncher._exitEvent, hProcess};
- DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE);
- ::CloseHandle(hProcess);
- if (waitResult == WAIT_OBJECT_0 + 0)
- return 0;
- if (waitResult != WAIT_OBJECT_0 + 1)
- return 1;
- Sleep(200);
- NFind::CFileInfoW newFileInfo;
- if (newFileInfo.Find(tmpProcessInfo->FilePath))
+ for (;;)
+ {
+ CRecordVector<HANDLE> handles;
+ CRecordVector<int> indices;
+ for (int i = 0; i < processes.Handles.Size(); i++)
+ {
+ if (processes.NeedWait[i])
+ {
+ handles.Add(processes.Handles[i]);
+ indices.Add(i);
+ }
+ }
+ if (handles.IsEmpty())
+ break;
+
+ handles.Add(g_ExitEventLauncher._exitEvent);
+
+ DWORD waitResult = ::WaitForMultipleObjects(handles.Size(), &handles.Front(), FALSE, INFINITE);
+
+ if (waitResult >= (DWORD)handles.Size() - 1)
+ {
+ processes.CloseAll();
+ return waitResult >= (DWORD)handles.Size() ? 1 : 0;
+ }
+ processes.Update();
+ processes.DisableWait(indices[waitResult]);
+ }
+
+ NFind::CFileInfo newFileInfo;
+ if (newFileInfo.Find(tpi->FilePath))
{
- if (tmpProcessInfo->WasChanged(newFileInfo))
+ if (tpi->WasChanged(newFileInfo))
{
UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE,
- 0x03020280, tmpProcessInfo->ItemName);
+ 0x03020280, tpi->RelPath);
if (::MessageBoxW(g_HWND, message, L"7-Zip", MB_OKCANCEL | MB_ICONQUESTION) == IDOK)
{
- if (SendMessage(tmpProcessInfo->Window, kOpenItemChanged, 0, (LONG_PTR)tmpProcessInfo) != 1)
+ if (SendMessage(tpi->Window, kOpenItemChanged, 0, (LONG_PTR)tpi) != 1)
{
::MessageBoxW(g_HWND, MyFormatNew(IDS_CANNOT_UPDATE_FILE,
- 0x03020281, tmpProcessInfo->FilePath), L"7-Zip", MB_OK | MB_ICONSTOP);
+ 0x03020281, fs2us(tpi->FilePath)), L"7-Zip", MB_OK | MB_ICONSTOP);
return 0;
}
}
}
}
- tmpProcessInfo->DeleteDirAndFile();
+ tpi->DeleteDirAndFile();
return 0;
}
void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bool editMode)
{
const UString name = GetItemName(index);
+ const UString relPath = GetItemRelPath(index);
+
if (IsNameVirus(name))
{
MessageBoxErrorLang(IDS_VIRUS, 0x03020284);
@@ -598,18 +744,22 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
bool tryAsArchive = tryInternal && (!tryExternal || !DoItemAlwaysStart(name));
- UString fullVirtPath = _currentFolderPrefix + name;
+ UString fullVirtPath = _currentFolderPrefix + relPath;
- NFile::NDirectory::CTempDirectoryW tempDirectory;
- tempDirectory.Create(kTempDirPrefix);
- UString tempDir = tempDirectory.GetPath();
- UString tempDirNorm = tempDir;
+ NFile::NDirectory::CTempDir tempDirectory;
+ if (!tempDirectory.Create(kTempDirPrefix))
+ {
+ MessageBoxLastError();
+ return;
+ }
+ FString tempDir = tempDirectory.GetPath();
+ FString tempDirNorm = tempDir;
NFile::NName::NormalizeDirPathPrefix(tempDirNorm);
-
- UString tempFilePath = tempDirNorm + GetCorrectFsPath(name);
+ FString tempFilePath = tempDirNorm + us2fs(GetCorrectFsPath(name));
CTempFileInfo tempFileInfo;
- tempFileInfo.ItemName = name;
+ tempFileInfo.FileIndex = index;
+ tempFileInfo.RelPath = relPath;
tempFileInfo.FolderPath = tempDir;
tempFileInfo.FilePath = tempFilePath;
tempFileInfo.NeedDelete = true;
@@ -655,7 +805,7 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
password = fl.Password;
}
- HRESULT result = CopyTo(indices, tempDirNorm, false, true, &messages, usePassword, password);
+ HRESULT result = CopyTo(indices, fs2us(tempDirNorm), false, true, &messages, usePassword, password);
if (_parentFolders.Size() > 0)
{
@@ -686,17 +836,17 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
}
CMyAutoPtr<CTmpProcessInfo> tmpProcessInfoPtr(new CTmpProcessInfo());
- CTmpProcessInfo *tmpProcessInfo = tmpProcessInfoPtr.get();
- tmpProcessInfo->FolderPath = tempDir;
- tmpProcessInfo->FilePath = tempFilePath;
- tmpProcessInfo->NeedDelete = true;
- tmpProcessInfo->UsePassword = usePassword;
- tmpProcessInfo->Password = password;
-
- if (!tmpProcessInfo->FileInfo.Find(tempFilePath))
+ CTmpProcessInfo *tpi = tmpProcessInfoPtr.get();
+ tpi->FolderPath = tempDir;
+ tpi->FilePath = tempFilePath;
+ tpi->NeedDelete = true;
+ tpi->UsePassword = usePassword;
+ tpi->Password = password;
+
+ if (!tpi->FileInfo.Find(tempFilePath))
return;
- CTmpProcessInfoRelease tmpProcessInfoRelease(*tmpProcessInfo);
+ CTmpProcessInfoRelease tmpProcessInfoRelease(*tpi);
if (!tryExternal)
return;
@@ -704,20 +854,21 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
CProcess process;
HRESULT res;
if (editMode)
- res = StartEditApplication(tempFilePath, (HWND)*this, process);
+ res = StartEditApplication(fs2us(tempFilePath), (HWND)*this, process);
else
- res = StartApplication(tempDirNorm, tempFilePath, (HWND)*this, process);
+ res = StartApplication(fs2us(tempDirNorm), fs2us(tempFilePath), (HWND)*this, process);
if ((HANDLE)process == 0)
return;
- tmpProcessInfo->Window = (HWND)(*this);
- tmpProcessInfo->FullPathFolderPrefix = _currentFolderPrefix;
- tmpProcessInfo->ItemName = name;
- tmpProcessInfo->ProcessHandle = process.Detach();
+ tpi->Window = (HWND)(*this);
+ tpi->FullPathFolderPrefix = _currentFolderPrefix;
+ tpi->FileIndex = index;
+ tpi->RelPath = relPath;
+ tpi->Processes.AddProcess(process.Detach());
NWindows::CThread thread;
- if (thread.Create(MyThreadFunction, tmpProcessInfo) != S_OK)
+ if (thread.Create(MyThreadFunction, tpi) != S_OK)
throw 271824;
tempDirectory.DisableDeleting();
tmpProcessInfoPtr.release();
@@ -744,7 +895,7 @@ void DeleteOldTempFiles()
UString searchWildCard = tempPath + kTempDirPrefix + L"*.tmp";
searchWildCard += WCHAR(NName::kAnyStringWildcard);
NFind::CEnumeratorW enumerator(searchWildCard);
- NFind::CFileInfoW fileInfo;
+ NFind::CFileInfo fileInfo;
while(enumerator.Next(fileInfo))
{
if (!fileInfo.IsDir())
diff --git a/CPP/7zip/UI/FileManager/PanelItems.cpp b/CPP/7zip/UI/FileManager/PanelItems.cpp
index 17cc3fcb..daa150c6 100755
--- a/CPP/7zip/UI/FileManager/PanelItems.cpp
+++ b/CPP/7zip/UI/FileManager/PanelItems.cpp
@@ -416,7 +416,7 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
if (_currentFolderPrefix.IsEmpty())
{
int iconIndexTemp;
- GetRealIconIndex(itemName + WCHAR_PATH_SEPARATOR, attrib, iconIndexTemp);
+ GetRealIconIndex(us2fs(itemName) + FCHAR_PATH_SEPARATOR, attrib, iconIndexTemp);
item.iImage = iconIndexTemp;
}
else
@@ -450,6 +450,7 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
/*
_listView.UpdateWindow();
*/
+ Refresh_StatusBar();
return S_OK;
}
@@ -458,7 +459,7 @@ void CPanel::GetSelectedItemsIndices(CRecordVector<UInt32> &indices) const
indices.Clear();
/*
int itemIndex = -1;
- while ((itemIndex = _listView.GetNextItem(itemIndex, LVNI_SELECTED)) != -1)
+ while ((itemIndex = _listView.GetNextSelectedItem(itemIndex)) != -1)
{
LPARAM param;
if (_listView.GetItemParam(itemIndex, param))
@@ -481,7 +482,7 @@ void CPanel::GetOperatedItemIndices(CRecordVector<UInt32> &indices) const
int focusedItem = _listView.GetFocusedItem();
if (focusedItem >= 0)
{
- if (_listView.GetItemState(focusedItem, LVIS_SELECTED) == LVIS_SELECTED)
+ if (_listView.IsItemSelected(focusedItem))
{
int realIndex = GetRealItemIndex(focusedItem);
if (realIndex != kParentIndex)
@@ -565,8 +566,7 @@ void CPanel::OpenSelectedItems(bool tryInternal)
if (focusedItem >= 0)
{
int realIndex = GetRealItemIndex(focusedItem);
- if (realIndex == kParentIndex && (tryInternal || indices.Size() == 0) &&
- _listView.GetItemState(focusedItem, LVIS_SELECTED) == LVIS_SELECTED)
+ if (realIndex == kParentIndex && (tryInternal || indices.Size() == 0) && _listView.IsItemSelected(focusedItem))
indices.Insert(0, realIndex);
}
@@ -787,7 +787,6 @@ void CPanel::OnReload()
HRESULT res = RefreshListCtrlSaveFocused();
if (res != S_OK)
MessageBoxError(res);
- OnRefreshStatusBar();
}
void CPanel::OnTimer()
diff --git a/CPP/7zip/UI/FileManager/PanelListNotify.cpp b/CPP/7zip/UI/FileManager/PanelListNotify.cpp
index 2051b5c6..f28311a4 100755
--- a/CPP/7zip/UI/FileManager/PanelListNotify.cpp
+++ b/CPP/7zip/UI/FileManager/PanelListNotify.cpp
@@ -77,7 +77,7 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
if (_dontShowMode)
return 0;
- UINT32 realIndex = GetRealIndex(item);
+ UInt32 realIndex = GetRealIndex(item);
/*
if ((item.mask & LVIF_IMAGE) != 0)
{
@@ -113,7 +113,7 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
if (realIndex == kParentIndex)
return 0;
UString s;
- UINT32 subItemIndex = item.iSubItem;
+ UInt32 subItemIndex = item.iSubItem;
PROPID propID = _visibleProperties[subItemIndex].ID;
/*
{
@@ -222,7 +222,7 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result)
{
if (!_mySelectMode)
OnItemChanged((LPNMLISTVIEW)header);
- RefreshStatusBar();
+ Post_Refresh_StatusBar();
}
return false;
}
@@ -248,7 +248,7 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result)
case LVN_KEYDOWN:
{
bool boolResult = OnKeyDown(LPNMLVKEYDOWN(header), result);
- RefreshStatusBar();
+ Post_Refresh_StatusBar();
return boolResult;
}
@@ -273,7 +273,7 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result)
break;
case NM_RCLICK:
- RefreshStatusBar();
+ Post_Refresh_StatusBar();
break;
/*
@@ -301,7 +301,7 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result)
{
// we need SetFocusToList, if we drag-select items from other panel.
SetFocusToList();
- RefreshStatusBar();
+ Post_Refresh_StatusBar();
if (_mySelectMode)
#ifndef UNDER_CE
if (g_ComCtl32Version >= MAKELONG(71, 4))
@@ -325,7 +325,7 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result)
case LVN_BEGINDRAG:
{
OnDrag((LPNMLISTVIEW)header);
- RefreshStatusBar();
+ Post_Refresh_StatusBar();
break;
}
// case LVN_BEGINRDRAG:
@@ -390,9 +390,9 @@ bool CPanel::OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result)
return false;
}
-void CPanel::OnRefreshStatusBar()
+void CPanel::Refresh_StatusBar()
{
- CRecordVector<UINT32> indices;
+ CRecordVector<UInt32> indices;
GetOperatedItemIndices(indices);
_statusBar.SetText(0, MyFormatNew(IDS_N_SELECTED_ITEMS, 0x02000301, NumberToString(indices.Size())));
diff --git a/CPP/7zip/UI/FileManager/PanelMenu.cpp b/CPP/7zip/UI/FileManager/PanelMenu.cpp
index 549b28da..badf531b 100755
--- a/CPP/7zip/UI/FileManager/PanelMenu.cpp
+++ b/CPP/7zip/UI/FileManager/PanelMenu.cpp
@@ -564,6 +564,7 @@ bool CPanel::InvokePluginCommand(int id,
CMINVOKECOMMANDINFOEX
#endif
commandInfo;
+ memset(&commandInfo, 0, sizeof(commandInfo));
commandInfo.cbSize = sizeof(commandInfo);
commandInfo.fMask = 0
#ifndef UNDER_CE
@@ -576,8 +577,8 @@ bool CPanel::InvokePluginCommand(int id,
CSysString currentFolderSys = GetSystemString(_currentFolderPrefix);
commandInfo.lpDirectory = (LPCSTR)(LPCTSTR)(currentFolderSys);
commandInfo.nShow = SW_SHOW;
- commandInfo.lpParameters = NULL;
#ifndef UNDER_CE
+ commandInfo.lpParametersW = NULL;
commandInfo.lpTitle = "";
commandInfo.lpVerbW = (LPCWSTR)(MAKEINTRESOURCEW(offset));
UString currentFolderUnicode = _currentFolderPrefix;
diff --git a/CPP/7zip/UI/FileManager/PanelOperations.cpp b/CPP/7zip/UI/FileManager/PanelOperations.cpp
index 0c6d3122..9c109d0d 100755
--- a/CPP/7zip/UI/FileManager/PanelOperations.cpp
+++ b/CPP/7zip/UI/FileManager/PanelOperations.cpp
@@ -284,6 +284,24 @@ BOOL CPanel::OnBeginLabelEdit(LV_DISPINFOW * lpnmh)
return FALSE;
}
+static UString GetLastPart(const UString name)
+{
+ int slashPos = name.ReverseFind(L'/');
+ #ifdef _WIN32
+ int slash1Pos = name.ReverseFind(L'\\');
+ slashPos = MyMax(slashPos, slash1Pos);
+ #endif
+ return name.Mid(slashPos + 1);
+}
+
+bool IsCorrectFsName(const UString name)
+{
+ const UString lastPart = GetLastPart(name);
+ return
+ lastPart != L"." &&
+ lastPart != L"..";
+}
+
BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh)
{
if (lpnmh->item.pszText == NULL)
@@ -295,6 +313,11 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh)
return FALSE;
}
const UString newName = lpnmh->item.pszText;
+ if (!IsCorrectFsName(newName))
+ {
+ MessageBoxError(E_INVALIDARG);
+ return FALSE;
+ }
CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
SaveSelectedState(_selectedState);
@@ -353,6 +376,11 @@ void CPanel::CreateFolder()
return;
UString newName = comboDialog.Value;
+ if (!IsCorrectFsName(newName))
+ {
+ MessageBoxError(E_INVALIDARG);
+ return;
+ }
{
CThreadFolderOperations op(FOLDER_TYPE_CREATE_FOLDER);
diff --git a/CPP/7zip/UI/FileManager/PanelSelect.cpp b/CPP/7zip/UI/FileManager/PanelSelect.cpp
index 29cf576b..b31c2e9d 100755
--- a/CPP/7zip/UI/FileManager/PanelSelect.cpp
+++ b/CPP/7zip/UI/FileManager/PanelSelect.cpp
@@ -78,7 +78,7 @@ void CPanel::OnInsert()
UINT state = (_listView.GetItemState(focusedItem, LVIS_CUT) == 0) ?
LVIS_CUT : 0;
_listView.SetItemState(focusedItem, state, LVIS_CUT);
- // _listView.SetItemState(focusedItem, LVIS_SELECTED, LVIS_SELECTED);
+ // _listView.SetItemState_Selected(focusedItem);
*/
int focusedItem = _listView.GetFocusedItem();
@@ -90,7 +90,7 @@ void CPanel::OnInsert()
_selectedStatusVector[realIndex] = isSelected;
if (!_mySelectMode)
- _listView.SetItemState(focusedItem, isSelected ? LVIS_SELECTED: 0, LVIS_SELECTED);
+ _listView.SetItemState_Selected(focusedItem, isSelected);
_listView.RedrawItem(focusedItem);
@@ -135,11 +135,7 @@ void CPanel::UpdateSelection()
{
int realIndex = GetRealItemIndex(i);
if (realIndex != kParentIndex)
- {
- UINT value = 0;
- value = _selectedStatusVector[realIndex] ? LVIS_SELECTED: 0;
- _listView.SetItemState(i, value, LVIS_SELECTED);
- }
+ _listView.SetItemState_Selected(i, _selectedStatusVector[realIndex]);
}
_enableItemChangeNotify = enableTemp;
}
@@ -174,7 +170,7 @@ void CPanel::SelectByType(bool selectMode)
bool isItemFolder = IsItemFolder(realIndex);
/*
- UINT32 numItems;
+ UInt32 numItems;
_folder->GetNumberOfItems(&numItems);
if ((UInt32)_selectedStatusVector.Size() != numItems)
throw 11111;
@@ -251,7 +247,7 @@ void CPanel::KillSelection()
int realIndex = GetRealItemIndex(focused);
if (realIndex != kParentIndex)
_selectedStatusVector[realIndex] = true;
- _listView.SetItemState(focused, LVIS_SELECTED, LVIS_SELECTED);
+ _listView.SetItemState_Selected(focused);
}
}
}
diff --git a/CPP/7zip/UI/FileManager/PanelSort.cpp b/CPP/7zip/UI/FileManager/PanelSort.cpp
index 186315b3..5ac04800 100755
--- a/CPP/7zip/UI/FileManager/PanelSort.cpp
+++ b/CPP/7zip/UI/FileManager/PanelSort.cpp
@@ -63,8 +63,8 @@ int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
NCOM::CPropVariant prop1, prop2;
// Name must be first property
- panel->_folder->GetProperty((UINT32)lParam1, propID, &prop1);
- panel->_folder->GetProperty((UINT32)lParam2, propID, &prop2);
+ panel->_folder->GetProperty((UInt32)lParam1, propID, &prop1);
+ panel->_folder->GetProperty((UInt32)lParam2, propID, &prop2);
if (prop1.vt != prop2.vt)
{
return MyCompare(prop1.vt, prop2.vt);
diff --git a/CPP/7zip/UI/FileManager/PanelSplitFile.cpp b/CPP/7zip/UI/FileManager/PanelSplitFile.cpp
index 213c2d48..ba0bedf8 100755
--- a/CPP/7zip/UI/FileManager/PanelSplitFile.cpp
+++ b/CPP/7zip/UI/FileManager/PanelSplitFile.cpp
@@ -7,6 +7,7 @@
#include "Windows/Error.h"
#include "Windows/FileIO.h"
#include "Windows/FileFind.h"
+#include "Windows/FileName.h"
#include "../GUI/ExtractRes.h"
@@ -89,8 +90,8 @@ class CThreadSplit: public CProgressThreadVirt
{
HRESULT ProcessVirt();
public:
- UString FilePath;
- UString VolBasePath;
+ FString FilePath;
+ FString VolBasePath;
UInt64 NumVolumes;
CRecordVector<UInt64> VolumeSizes;
};
@@ -136,15 +137,15 @@ HRESULT CThreadSplit::ProcessVirt()
needSize = processedSize;
if (curVolSize == 0)
{
- UString name = VolBasePath;
- name += L'.';
- name += seqName.GetNextName();
- sync.SetCurrentFileName(name);
+ FString name = VolBasePath;
+ name += FTEXT('.');
+ name += us2fs(seqName.GetNextName());
+ sync.SetCurrentFileName(fs2us(name));
sync.SetNumFilesCur(numFiles++);
if (!outFile.Create(name, false))
{
HRESULT res = GetLastError();
- ErrorPath1 = name;
+ SetErrorPath1(name);
return res;
}
}
@@ -206,8 +207,8 @@ void CApp::Split()
if (splitDialog.Create(srcPanel.GetParent()) == IDCANCEL)
return;
- NFile::NFind::CFileInfoW fileInfo;
- if (!fileInfo.Find(srcPath + itemName))
+ NFile::NFind::CFileInfo fileInfo;
+ if (!fileInfo.Find(us2fs(srcPath + itemName)))
{
srcPanel.MessageBoxMyError(L"Can not find file");
return;
@@ -230,7 +231,7 @@ void CApp::Split()
path = splitDialog.Path;
NFile::NName::NormalizeDirPathPrefix(path);
- if (!NFile::NDirectory::CreateComplexDirectory(path))
+ if (!NFile::NDirectory::CreateComplexDirectory(us2fs(path)))
{
srcPanel.MessageBoxMyError(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, 0x02000603, path));
return;
@@ -253,8 +254,8 @@ void CApp::Split()
progressDialog.Sync.SetTitleFileName(itemName);
- spliter.FilePath = srcPath + itemName;
- spliter.VolBasePath = path + itemName;
+ spliter.FilePath = us2fs(srcPath + itemName);
+ spliter.VolBasePath = us2fs(path + itemName);
spliter.VolumeSizes = splitDialog.VolumeSizes;
// if (splitDialog.VolumeSizes.Size() == 0) return;
@@ -279,9 +280,9 @@ class CThreadCombine: public CProgressThreadVirt
{
HRESULT ProcessVirt();
public:
- UString InputDirPrefix;
- UStringVector Names;
- UString OutputPath;
+ FString InputDirPrefix;
+ FStringVector Names;
+ FString OutputPath;
UInt64 TotalSize;
};
@@ -291,7 +292,7 @@ HRESULT CThreadCombine::ProcessVirt()
if (!outFile.Create(OutputPath, false))
{
HRESULT res = GetLastError();
- ErrorPath1 = OutputPath;
+ SetErrorPath1(OutputPath);
return res;
}
@@ -306,21 +307,21 @@ HRESULT CThreadCombine::ProcessVirt()
for (int i = 0; i < Names.Size(); i++)
{
NFile::NIO::CInFile inFile;
- const UString nextName = InputDirPrefix + Names[i];
+ const FString nextName = InputDirPrefix + Names[i];
if (!inFile.Open(nextName))
{
HRESULT res = GetLastError();
- ErrorPath1 = nextName;
+ SetErrorPath1(nextName);
return res;
}
- sync.SetCurrentFileName(nextName);
+ sync.SetCurrentFileName(fs2us(nextName));
for (;;)
{
UInt32 processedSize;
if (!inFile.Read(buffer, kBufSize, processedSize))
{
HRESULT res = GetLastError();
- ErrorPath1 = nextName;
+ SetErrorPath1(nextName);
return res;
}
if (processedSize == 0)
@@ -329,7 +330,7 @@ HRESULT CThreadCombine::ProcessVirt()
if (!outFile.Write(buffer, needSize, processedSize))
{
HRESULT res = GetLastError();
- ErrorPath1 = OutputPath;
+ SetErrorPath1(OutputPath);
return res;
}
if (needSize != processedSize)
@@ -392,10 +393,10 @@ void CApp::Combine()
combiner.TotalSize = 0;
for (;;)
{
- NFile::NFind::CFileInfoW fileInfo;
- if (!fileInfo.Find(srcPath + nextName) || fileInfo.IsDir())
+ NFile::NFind::CFileInfo fileInfo;
+ if (!fileInfo.Find(us2fs(srcPath + nextName)) || fileInfo.IsDir())
break;
- combiner.Names.Add(nextName);
+ combiner.Names.Add(us2fs(nextName));
combiner.TotalSize += fileInfo.Size;
nextName = volSeqName.GetNextName();
}
@@ -419,12 +420,12 @@ void CApp::Combine()
int i;
for (i = 0; i < combiner.Names.Size() && i < 2; i++)
- AddInfoFileName(combiner.Names[i], info);
+ AddInfoFileName(fs2us(combiner.Names[i]), info);
if (i != combiner.Names.Size())
{
if (i + 1 != combiner.Names.Size())
AddInfoFileName(L"...", info);
- AddInfoFileName(combiner.Names.Back(), info);
+ AddInfoFileName(fs2us(combiner.Names.Back()), info);
}
{
@@ -441,7 +442,7 @@ void CApp::Combine()
}
NFile::NName::NormalizeDirPathPrefix(path);
- if (!NFile::NDirectory::CreateComplexDirectory(path))
+ if (!NFile::NDirectory::CreateComplexDirectory(us2fs(path)))
{
srcPanel.MessageBoxMyError(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, 0x02000603, path));
return;
@@ -450,18 +451,17 @@ void CApp::Combine()
UString outName = volSeqName.UnchangedPart;
while (!outName.IsEmpty())
{
- int lastIndex = outName.Length() - 1;
- if (outName[lastIndex] != L'.')
+ if (outName.Back() != L'.')
break;
- outName.Delete(lastIndex);
+ outName.DeleteBack();
}
if (outName.IsEmpty())
outName = L"file";
- NFile::NFind::CFileInfoW fileInfo;
+ NFile::NFind::CFileInfo fileInfo;
UString destFilePath = path + outName;
- combiner.OutputPath = destFilePath;
- if (fileInfo.Find(destFilePath))
+ combiner.OutputPath = us2fs(destFilePath);
+ if (fileInfo.Find(combiner.OutputPath))
{
srcPanel.MessageBoxMyError(MyFormatNew(IDS_FILE_EXIST, 0x03020A04, destFilePath));
return;
@@ -477,7 +477,7 @@ void CApp::Combine()
progressDialog.MainTitle = progressWindowTitle;
progressDialog.MainAddTitle = title + UString(L" ");
- combiner.InputDirPrefix = srcPath;
+ combiner.InputDirPrefix = us2fs(srcPath);
// CPanel::CDisableTimerProcessing disableTimerProcessing1(srcPanel);
// CPanel::CDisableTimerProcessing disableTimerProcessing2(destPanel);
diff --git a/CPP/7zip/UI/FileManager/PasswordDialog.cpp b/CPP/7zip/UI/FileManager/PasswordDialog.cpp
index eaf90a24..92826a1f 100755
--- a/CPP/7zip/UI/FileManager/PasswordDialog.cpp
+++ b/CPP/7zip/UI/FileManager/PasswordDialog.cpp
@@ -18,6 +18,17 @@ static CIDLangPair kIDLangPairs[] =
};
#endif
+void CPasswordDialog::ReadControls()
+{
+ _passwordControl.GetText(Password);
+ ShowPassword = IsButtonCheckedBool(IDC_CHECK_PASSWORD_SHOW);
+}
+
+void CPasswordDialog::SetTextSpec()
+{
+ _passwordControl.SetPasswordChar(ShowPassword ? 0: TEXT('*'));
+ _passwordControl.SetText(Password);
+}
bool CPasswordDialog::OnInit()
{
@@ -26,8 +37,8 @@ bool CPasswordDialog::OnInit()
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
#endif
_passwordControl.Attach(GetItem(IDC_EDIT_PASSWORD));
- _passwordControl.SetText(Password);
- _passwordControl.SetPasswordChar(TEXT('*'));
+ CheckButton(IDC_CHECK_PASSWORD_SHOW, ShowPassword);
+ SetTextSpec();
return CModalDialog::OnInit();
}
@@ -35,10 +46,8 @@ bool CPasswordDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
{
if (buttonID == IDC_CHECK_PASSWORD_SHOW)
{
- _passwordControl.SetPasswordChar(IsButtonCheckedBool(IDC_CHECK_PASSWORD_SHOW) ? 0: TEXT('*'));
- UString password;
- _passwordControl.GetText(password);
- _passwordControl.SetText(password);
+ ReadControls();
+ SetTextSpec();
return true;
}
return CDialog::OnButtonClicked(buttonID, buttonHWND);
@@ -46,6 +55,6 @@ bool CPasswordDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
void CPasswordDialog::OnOK()
{
- _passwordControl.GetText(Password);
+ ReadControls();
CModalDialog::OnOK();
}
diff --git a/CPP/7zip/UI/FileManager/PasswordDialog.h b/CPP/7zip/UI/FileManager/PasswordDialog.h
index e5a96073..1d903249 100755
--- a/CPP/7zip/UI/FileManager/PasswordDialog.h
+++ b/CPP/7zip/UI/FileManager/PasswordDialog.h
@@ -1,7 +1,7 @@
// PasswordDialog.h
-#ifndef __PASSWORDDIALOG_H
-#define __PASSWORDDIALOG_H
+#ifndef __PASSWORD_DIALOG_H
+#define __PASSWORD_DIALOG_H
#include "Windows/Control/Dialog.h"
#include "Windows/Control/Edit.h"
@@ -13,8 +13,12 @@ class CPasswordDialog: public NWindows::NControl::CModalDialog
virtual void OnOK();
virtual bool OnInit();
virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
+ void SetTextSpec();
+ void ReadControls();
public:
UString Password;
+ bool ShowPassword;
+ CPasswordDialog(): ShowPassword(false) {}
INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_PASSWORD, parentWindow); }
};
diff --git a/CPP/7zip/UI/FileManager/PluginLoader.h b/CPP/7zip/UI/FileManager/PluginLoader.h
index 3cf15aa5..cb7d4d7c 100755
--- a/CPP/7zip/UI/FileManager/PluginLoader.h
+++ b/CPP/7zip/UI/FileManager/PluginLoader.h
@@ -5,6 +5,8 @@
#include "Windows/DLL.h"
+#include "IFolder.h"
+
typedef UINT32 (WINAPI * CreateObjectPointer)(const GUID *clsID, const GUID *interfaceID, void **outObject);
class CPluginLibrary: public NWindows::NDLL::CLibrary
@@ -17,7 +19,7 @@ public:
return GetLastError();
return createObject(&clsID, &IID_IFolderManager, (void **)manager);
}
- HRESULT LoadAndCreateManager(LPCWSTR filePath, REFGUID clsID, IFolderManager **manager)
+ HRESULT LoadAndCreateManager(CFSTR filePath, REFGUID clsID, IFolderManager **manager)
{
if (!Load(filePath))
return GetLastError();
diff --git a/CPP/7zip/UI/FileManager/ProgramLocation.cpp b/CPP/7zip/UI/FileManager/ProgramLocation.cpp
index ce2d178e..50ca5ca5 100755
--- a/CPP/7zip/UI/FileManager/ProgramLocation.cpp
+++ b/CPP/7zip/UI/FileManager/ProgramLocation.cpp
@@ -1,24 +1,3 @@
// ProgramLocation.cpp
#include "StdAfx.h"
-
-#include "../../../../C/Types.h"
-
-#include "ProgramLocation.h"
-
-#include "Windows/DLL.h"
-
-using namespace NWindows;
-
-extern HINSTANCE g_hInstance;
-
-bool GetProgramFolderPath(UString &folder)
-{
- if (!NDLL::MyGetModuleFileName(g_hInstance, folder))
- return false;
- int pos = folder.ReverseFind(WCHAR_PATH_SEPARATOR);
- if (pos < 0)
- return false;
- folder = folder.Left(pos + 1);
- return true;
-}
diff --git a/CPP/7zip/UI/FileManager/ProgramLocation.h b/CPP/7zip/UI/FileManager/ProgramLocation.h
index 55c56144..6bfb711e 100755
--- a/CPP/7zip/UI/FileManager/ProgramLocation.h
+++ b/CPP/7zip/UI/FileManager/ProgramLocation.h
@@ -3,8 +3,4 @@
#ifndef __PROGRAM_LOCATION_H
#define __PROGRAM_LOCATION_H
-#include "Common/MyString.h"
-
-bool GetProgramFolderPath(UString &folder); // normalized
-
#endif
diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.cpp b/CPP/7zip/UI/FileManager/ProgressDialog2.cpp
index 3d878a61..bd77d20d 100755
--- a/CPP/7zip/UI/FileManager/ProgressDialog2.cpp
+++ b/CPP/7zip/UI/FileManager/ProgressDialog2.cpp
@@ -146,6 +146,7 @@ bool CProgressDialog::OnInit()
m_ProgressBar.Attach(GetItem(IDC_PROGRESS1));
_messageList.Attach(GetItem(IDC_PROGRESS_LIST));
+ _messageList.SetUnicodeFormat();
_wasCreated = true;
_dialogCreatedEvent.Set();
@@ -154,7 +155,6 @@ bool CProgressDialog::OnInit()
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
#endif
-
CWindow window(GetItem(IDC_BUTTON_PROGRESS_PRIORITY));
window.GetText(backgroundString);
backgroundedString = backgroundString;
@@ -171,11 +171,6 @@ bool CProgressDialog::OnInit()
SetPauseText();
SetPriorityText();
-
- #ifndef UNDER_CE
- _messageList.SetUnicodeFormat(true);
- #endif
-
_messageList.InsertColumn(0, L"", 30);
const UString s = LangStringSpec(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN, 0x02000A80);
@@ -957,10 +952,8 @@ UString HResultToMessage(HRESULT errorCode)
UString message;
if (errorCode == E_OUTOFMEMORY)
message = LangStringSpec(IDS_MEM_ERROR, 0x0200060B);
- else if (!NError::MyFormatMessage(errorCode, message))
- message.Empty();
- if (message.IsEmpty())
- message = L"Error";
+ else
+ message = NError::MyFormatMessageW(errorCode);
return message;
}
@@ -989,8 +982,8 @@ void CProgressThreadVirt::Process()
m = HResultToMessage(Result);
}
AddMessageToString(m, ErrorMessage);
- AddMessageToString(m, ErrorPath1);
- AddMessageToString(m, ErrorPath2);
+ AddMessageToString(m, fs2us(ErrorPath1));
+ AddMessageToString(m, fs2us(ErrorPath2));
if (m.IsEmpty())
{
diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.h b/CPP/7zip/UI/FileManager/ProgressDialog2.h
index ed096f06..81a64e32 100755
--- a/CPP/7zip/UI/FileManager/ProgressDialog2.h
+++ b/CPP/7zip/UI/FileManager/ProgressDialog2.h
@@ -323,10 +323,10 @@ public:
class CProgressThreadVirt
{
+ FString ErrorPath1;
+ FString ErrorPath2;
protected:
UString ErrorMessage;
- UString ErrorPath1;
- UString ErrorPath2;
UString OkMessage;
UString OkMessageTitle;
@@ -350,6 +350,9 @@ public:
return 0;
}
+ void SetErrorPath1(const FString &path) { ErrorPath1 = path; }
+ void SetErrorPath2(const FString &path) { ErrorPath2 = path; }
+
HRESULT Create(const UString &title, HWND parentWindow = 0);
CProgressThreadVirt(): Result(E_FAIL), ThreadFinishedOK(false) {}
};
diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2Res.h b/CPP/7zip/UI/FileManager/ProgressDialog2Res.h
index 21ac03c2..be5af607 100755
--- a/CPP/7zip/UI/FileManager/ProgressDialog2Res.h
+++ b/CPP/7zip/UI/FileManager/ProgressDialog2Res.h
@@ -35,7 +35,11 @@
#define IDC_PROGRESS_ERRORS_VALUE 1031
#define IDC_PROGRESS_LIST 1032
+#ifdef UNDER_CE
#define MY_PROGRESS_VALUE_UNITS 44
+#else
+#define MY_PROGRESS_VALUE_UNITS 76
+#endif
#define MY_PROGRESS_LABEL_UNITS_MIN 60
#define MY_PROGRESS_LABEL_UNITS_START 90
#define MY_PROGRESS_PAD_UNITS 4
diff --git a/CPP/7zip/UI/FileManager/RegistryAssociations.cpp b/CPP/7zip/UI/FileManager/RegistryAssociations.cpp
index f7edbb4b..487b6060 100755
--- a/CPP/7zip/UI/FileManager/RegistryAssociations.cpp
+++ b/CPP/7zip/UI/FileManager/RegistryAssociations.cpp
@@ -2,234 +2,151 @@
#include "StdAfx.h"
-#include "RegistryAssociations.h"
-
#include "Common/IntToString.h"
#include "Common/StringConvert.h"
#include "Common/StringToInt.h"
#include "Windows/Registry.h"
-#include "Windows/Synchronization.h"
-#include "StringUtils.h"
+#include "RegistryAssociations.h"
using namespace NWindows;
using namespace NRegistry;
-namespace NRegistryAssociations {
+namespace NRegistryAssoc {
-static NSynchronization::CCriticalSection g_CriticalSection;
-
-#define REG_PATH_FM TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-Zip") TEXT(STRING_PATH_SEPARATOR) TEXT("FM")
-
-/*
-
-static const TCHAR *kCUKeyPath = REG_PATH_FM;
-static const WCHAR *kExtPlugins = L"Plugins";
-static const TCHAR *kExtEnabled = TEXT("Enabled");
-
-#define kAssociations TEXT("Associations")
-#define kAssociationsPath REG_PATH_FM TEXT(STRING_PATH_SEPARATOR) kAssociations
-
-bool ReadInternalAssociation(const wchar_t *ext, CExtInfo &extInfo)
-{
- NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
- CKey key;
- if (key.Open(HKEY_CURRENT_USER,
- CSysString(kAssociationsPath TEXT(STRING_PATH_SEPARATOR)) +
- GetSystemString(ext), KEY_READ) != ERROR_SUCCESS)
- return false;
- UString pluginsString;
- key.QueryValue(kExtPlugins, pluginsString);
- SplitString(pluginsString, extInfo.Plugins);
- return true;
-}
-
-void ReadInternalAssociations(CObjectVector<CExtInfo> &items)
-{
- items.Clear();
- NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
- CKey associationsKey;
- if (associationsKey.Open(HKEY_CURRENT_USER, kAssociationsPath, KEY_READ) != ERROR_SUCCESS)
- return;
- CSysStringVector extNames;
- associationsKey.EnumKeys(extNames);
- for(int i = 0; i < extNames.Size(); i++)
- {
- const CSysString extName = extNames[i];
- CExtInfo extInfo;
- // extInfo.Enabled = false;
- extInfo.Ext = GetUnicodeString(extName);
- CKey key;
- if (key.Open(associationsKey, extName, KEY_READ) != ERROR_SUCCESS)
- return;
- UString pluginsString;
- key.QueryValue(kExtPlugins, pluginsString);
- SplitString(pluginsString, extInfo.Plugins);
- // if (key.QueryValue(kExtEnabled, extInfo.Enabled) != ERROR_SUCCESS)
- // extInfo.Enabled = false;
- items.Add(extInfo);
- }
-}
-
-void WriteInternalAssociations(const CObjectVector<CExtInfo> &items)
-{
- NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
- CKey mainKey;
- mainKey.Create(HKEY_CURRENT_USER, kCUKeyPath);
- mainKey.RecurseDeleteKey(kAssociations);
- CKey associationsKey;
- associationsKey.Create(mainKey, kAssociations);
- for(int i = 0; i < items.Size(); i++)
- {
- const CExtInfo &extInfo = items[i];
- CKey key;
- key.Create(associationsKey, GetSystemString(extInfo.Ext));
- key.SetValue(kExtPlugins, JoinStrings(extInfo.Plugins));
- // key.SetValue(kExtEnabled, extInfo.Enabled);
- }
-}
-*/
-
-///////////////////////////////////
-// External
+// static NSynchronization::CCriticalSection g_CriticalSection;
-static const TCHAR *kShellNewKeyName = TEXT("ShellNew");
-static const TCHAR *kShellNewDataValueName = TEXT("Data");
-
+static const TCHAR *kClasses = TEXT("Software\\Classes\\");
+// static const TCHAR *kShellNewKeyName = TEXT("ShellNew");
+// static const TCHAR *kShellNewDataValueName = TEXT("Data");
static const TCHAR *kDefaultIconKeyName = TEXT("DefaultIcon");
static const TCHAR *kShellKeyName = TEXT("shell");
static const TCHAR *kOpenKeyName = TEXT("open");
static const TCHAR *kCommandKeyName = TEXT("command");
static const TCHAR *k7zipPrefix = TEXT("7-Zip.");
-static CSysString GetExtensionKeyName(const CSysString &extension)
+static CSysString GetExtProgramKeyName(const CSysString &ext)
{
- return CSysString(TEXT(".")) + extension;
+ return CSysString(k7zipPrefix) + ext;
}
-static CSysString GetExtProgramKeyName(const CSysString &extension)
+static CSysString GetFullKeyPath(HKEY hkey, const CSysString &name)
{
- return CSysString(k7zipPrefix) + extension;
+ CSysString s;
+ if (hkey != HKEY_CLASSES_ROOT)
+ s = kClasses;
+ return s + name;
}
-static bool CheckShellExtensionInfo2(const CSysString &extension,
- CSysString programKeyName, UString &iconPath, int &iconIndex)
+static CSysString GetExtKeyPath(HKEY hkey, const CSysString &ext)
{
- iconIndex = -1;
- iconPath.Empty();
- NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
- CKey extKey;
- if (extKey.Open(HKEY_CLASSES_ROOT, GetExtensionKeyName(extension), KEY_READ) != ERROR_SUCCESS)
- return false;
- if (extKey.QueryValue(NULL, programKeyName) != ERROR_SUCCESS)
- return false;
- UString s = GetUnicodeString(k7zipPrefix);
- if (s.CompareNoCase(GetUnicodeString(programKeyName.Left(s.Length()))) != 0)
- return false;
- CKey iconKey;
- if (extKey.Open(HKEY_CLASSES_ROOT, programKeyName + CSysString(TEXT(CHAR_PATH_SEPARATOR)) + kDefaultIconKeyName, KEY_READ) != ERROR_SUCCESS)
- return false;
- UString value;
- if (extKey.QueryValue(NULL, value) == ERROR_SUCCESS)
+ return GetFullKeyPath(hkey, (TEXT(".")) + ext);
+}
+
+bool CShellExtInfo::ReadFromRegistry(HKEY hkey, const CSysString &ext)
+{
+ ProgramKey.Empty();
+ IconPath.Empty();
+ IconIndex = -1;
+ // NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ {
+ CKey extKey;
+ if (extKey.Open(hkey, GetExtKeyPath(hkey, ext), KEY_READ) != ERROR_SUCCESS)
+ return false;
+ if (extKey.QueryValue(NULL, ProgramKey) != ERROR_SUCCESS)
+ return false;
+ }
{
- int pos = value.ReverseFind(L',');
- iconPath = value;
- if (pos >= 0)
+ CKey iconKey;
+ if (iconKey.Open(hkey, GetFullKeyPath(hkey, ProgramKey + CSysString(TEXT(CHAR_PATH_SEPARATOR)) + kDefaultIconKeyName), KEY_READ) == ERROR_SUCCESS)
{
- const wchar_t *end;
- UInt64 index = ConvertStringToUInt64((const wchar_t *)value + pos + 1, &end);
- if (*end == 0)
+ UString value;
+ if (iconKey.QueryValue(NULL, value) == ERROR_SUCCESS)
{
- iconIndex = (int)index;
- iconPath = value.Left(pos);
+ int pos = value.ReverseFind(L',');
+ IconPath = value;
+ if (pos >= 0)
+ {
+ const wchar_t *end;
+ Int64 index = ConvertStringToInt64((const wchar_t *)value + pos + 1, &end);
+ if (*end == 0)
+ {
+ IconIndex = (int)index;
+ IconPath = value.Left(pos);
+ }
+ }
}
}
}
return true;
}
-bool CheckShellExtensionInfo(const CSysString &extension, UString &iconPath, int &iconIndex)
-{
- NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
- CSysString programKeyName;
- if (!CheckShellExtensionInfo2(extension, programKeyName, iconPath, iconIndex))
- return false;
- CKey extProgKey;
- return (extProgKey.Open(HKEY_CLASSES_ROOT, programKeyName, KEY_READ) == ERROR_SUCCESS);
-}
-
-static void DeleteShellExtensionKey(const CSysString &extension)
+bool CShellExtInfo::IsIt7Zip() const
{
- NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
- CKey rootKey;
- rootKey.Attach(HKEY_CLASSES_ROOT);
- rootKey.RecurseDeleteKey(GetExtensionKeyName(extension));
- rootKey.Detach();
+ UString s = GetUnicodeString(k7zipPrefix);
+ return (s.CompareNoCase(GetUnicodeString(ProgramKey.Left(s.Length()))) == 0);
}
-static void DeleteShellExtensionProgramKey(const CSysString &extension)
+LONG DeleteShellExtensionInfo(HKEY hkey, const CSysString &ext)
{
- NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ // NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
CKey rootKey;
- rootKey.Attach(HKEY_CLASSES_ROOT);
- rootKey.RecurseDeleteKey(GetExtProgramKeyName(extension));
+ rootKey.Attach(hkey);
+ LONG res = rootKey.RecurseDeleteKey(GetExtKeyPath(hkey, ext));
+ // then we delete only 7-Zip.* key.
+ rootKey.RecurseDeleteKey(GetFullKeyPath(hkey, GetExtProgramKeyName(ext)));
rootKey.Detach();
+ return res;
}
-void DeleteShellExtensionInfo(const CSysString &extension)
-{
- CSysString programKeyName;
- UString iconPath;
- int iconIndex;
- if (CheckShellExtensionInfo2(extension, programKeyName, iconPath, iconIndex))
- DeleteShellExtensionKey(extension);
- DeleteShellExtensionProgramKey(extension);
-}
-
-void AddShellExtensionInfo(const CSysString &extension,
+LONG AddShellExtensionInfo(HKEY hkey,
+ const CSysString &ext,
const UString &programTitle,
const UString &programOpenCommand,
- const UString &iconPath, int iconIndex,
- const void *shellNewData, int shellNewDataSize)
+ const UString &iconPath, int iconIndex
+ // , const void *shellNewData, int shellNewDataSize
+ )
{
- DeleteShellExtensionKey(extension);
- DeleteShellExtensionProgramKey(extension);
- NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ LONG res = 0;
+ DeleteShellExtensionInfo(hkey, ext);
+ // NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
CSysString programKeyName;
{
- CSysString ext = extension;
+ CSysString ext2 = ext;
if (iconIndex < 0)
- ext = TEXT("*");
- programKeyName = GetExtProgramKeyName(ext);
+ ext2 = TEXT("*");
+ programKeyName = GetExtProgramKeyName(ext2);
}
{
CKey extKey;
- extKey.Create(HKEY_CLASSES_ROOT, GetExtensionKeyName(extension));
+ res = extKey.Create(hkey, GetExtKeyPath(hkey, ext));
extKey.SetValue(NULL, programKeyName);
+ /*
if (shellNewData != NULL)
{
CKey shellNewKey;
shellNewKey.Create(extKey, kShellNewKeyName);
shellNewKey.SetValue(kShellNewDataValueName, shellNewData, shellNewDataSize);
}
+ */
}
CKey programKey;
- programKey.Create(HKEY_CLASSES_ROOT, programKeyName);
+ programKey.Create(hkey, GetFullKeyPath(hkey, programKeyName));
programKey.SetValue(NULL, programTitle);
{
CKey iconKey;
- iconKey.Create(programKey, kDefaultIconKeyName);
UString iconPathFull = iconPath;
if (iconIndex < 0)
iconIndex = 0;
// if (iconIndex >= 0)
{
- iconPathFull += L",";
+ iconPathFull += L',';
wchar_t s[16];
- ConvertUInt32ToString(iconIndex, s);
+ ConvertInt64ToString(iconIndex, s);
iconPathFull += s;
}
+ iconKey.Create(programKey, kDefaultIconKeyName);
iconKey.SetValue(NULL, iconPathFull);
}
@@ -243,70 +160,8 @@ void AddShellExtensionInfo(const CSysString &extension,
CKey commandKey;
commandKey.Create(openKey, kCommandKeyName);
-
commandKey.SetValue(NULL, programOpenCommand);
+ return res;
}
-///////////////////////////
-// ContextMenu
-/*
-
-static const TCHAR *kContextMenuKeyName = TEXT("\\shellex\\ContextMenuHandlers\\7-Zip");
-static const TCHAR *kContextMenuHandlerCLASSIDValue =
- TEXT("{23170F69-40C1-278A-1000-000100020000}");
-static const TCHAR *kRootKeyNameForFile = TEXT("*");
-static const TCHAR *kRootKeyNameForFolder = TEXT("Folder");
-
-static CSysString GetFullContextMenuKeyName(const CSysString &aKeyName)
- { return (aKeyName + kContextMenuKeyName); }
-
-static bool CheckContextMenuHandlerCommon(const CSysString &aKeyName)
-{
- NSynchronization::CCriticalSectionLock lock(&g_CriticalSection, true);
- CKey aKey;
- if (aKey.Open(HKEY_CLASSES_ROOT, GetFullContextMenuKeyName(aKeyName), KEY_READ)
- != ERROR_SUCCESS)
- return false;
- CSysString aValue;
- if (aKey.QueryValue(NULL, aValue) != ERROR_SUCCESS)
- return false;
- return (aValue.CompareNoCase(kContextMenuHandlerCLASSIDValue) == 0);
-}
-
-bool CheckContextMenuHandler()
-{
- return CheckContextMenuHandlerCommon(kRootKeyNameForFile) &&
- CheckContextMenuHandlerCommon(kRootKeyNameForFolder);
-}
-
-static void DeleteContextMenuHandlerCommon(const CSysString &aKeyName)
-{
- CKey rootKey;
- rootKey.Attach(HKEY_CLASSES_ROOT);
- rootKey.RecurseDeleteKey(GetFullContextMenuKeyName(aKeyName));
- rootKey.Detach();
-}
-
-void DeleteContextMenuHandler()
-{
- DeleteContextMenuHandlerCommon(kRootKeyNameForFile);
- DeleteContextMenuHandlerCommon(kRootKeyNameForFolder);
-}
-
-static void AddContextMenuHandlerCommon(const CSysString &aKeyName)
-{
- DeleteContextMenuHandlerCommon(aKeyName);
- NSynchronization::CCriticalSectionLock lock(&g_CriticalSection, true);
- CKey aKey;
- aKey.Create(HKEY_CLASSES_ROOT, GetFullContextMenuKeyName(aKeyName));
- aKey.SetValue(NULL, kContextMenuHandlerCLASSIDValue);
-}
-
-void AddContextMenuHandler()
-{
- AddContextMenuHandlerCommon(kRootKeyNameForFile);
- AddContextMenuHandlerCommon(kRootKeyNameForFolder);
-}
-*/
-
}
diff --git a/CPP/7zip/UI/FileManager/RegistryAssociations.h b/CPP/7zip/UI/FileManager/RegistryAssociations.h
index 5390b9db..0be8244e 100755
--- a/CPP/7zip/UI/FileManager/RegistryAssociations.h
+++ b/CPP/7zip/UI/FileManager/RegistryAssociations.h
@@ -1,46 +1,31 @@
// RegistryAssociations.h
-#ifndef __REGISTRYASSOCIATIONS_H
-#define __REGISTRYASSOCIATIONS_H
+#ifndef __REGISTRY_ASSOCIATIONS_H
+#define __REGISTRY_ASSOCIATIONS_H
#include "Common/MyString.h"
-namespace NRegistryAssociations {
+namespace NRegistryAssoc {
- /*
- struct CExtInfo
+ struct CShellExtInfo
{
- UString Ext;
- UStringVector Plugins;
- // bool Enabled;
- };
- bool ReadInternalAssociation(const wchar_t *ext, CExtInfo &extInfo);
- void ReadInternalAssociations(CObjectVector<CExtInfo> &items);
- void WriteInternalAssociations(const CObjectVector<CExtInfo> &items);
- */
+ CSysString ProgramKey;
+ UString IconPath;
+ int IconIndex;
- bool CheckShellExtensionInfo(const CSysString &extension, UString &iconPath, int &iconIndex);
+ bool ReadFromRegistry(HKEY hkey, const CSysString &ext);
+ bool IsIt7Zip() const;
+ };
- // void ReadCompressionInfo(NZipSettings::NCompression::CInfo &anInfo,
- void DeleteShellExtensionInfo(const CSysString &extension);
+ LONG DeleteShellExtensionInfo(HKEY hkey, const CSysString &ext);
- void AddShellExtensionInfo(const CSysString &extension,
+ LONG AddShellExtensionInfo(HKEY hkey,
+ const CSysString &ext,
const UString &programTitle,
const UString &programOpenCommand,
- const UString &iconPath, int iconIndex,
- const void *shellNewData, int shellNewDataSize);
-
-
- ///////////////////////////
- // ContextMenu
- /*
- bool CheckContextMenuHandler();
- void AddContextMenuHandler();
- void DeleteContextMenuHandler();
- */
-
+ const UString &iconPath, int iconIndex
+ // , const void *shellNewData, int shellNewDataSize
+ );
}
-// bool GetProgramDirPrefix(CSysString &aFolder);
-
#endif
diff --git a/CPP/7zip/UI/FileManager/RegistryPlugins.cpp b/CPP/7zip/UI/FileManager/RegistryPlugins.cpp
index d49eaa6e..54254f1f 100755
--- a/CPP/7zip/UI/FileManager/RegistryPlugins.cpp
+++ b/CPP/7zip/UI/FileManager/RegistryPlugins.cpp
@@ -3,12 +3,11 @@
#include "StdAfx.h"
#include "Windows/DLL.h"
-#include "Windows/PropVariant.h"
#include "Windows/FileFind.h"
+#include "Windows/PropVariant.h"
-#include "ProgramLocation.h"
-#include "RegistryPlugins.h"
#include "IFolder.h"
+#include "RegistryPlugins.h"
using namespace NWindows;
using namespace NFile;
@@ -91,23 +90,20 @@ static bool ReadPluginInfo(CPluginInfo &pluginInfo, bool needCheckDll)
return true;
}
-UString GetProgramFolderPrefix();
-
void ReadPluginInfoList(CObjectVector<CPluginInfo> &plugins)
{
plugins.Clear();
- UString baseFolderPrefix;
- GetProgramFolderPath(baseFolderPrefix);
+ FString baseFolderPrefix = NDLL::GetModuleDirPrefix();
{
CPluginInfo pluginInfo;
- pluginInfo.FilePath = baseFolderPrefix + L"7-zip.dll";
+ pluginInfo.FilePath = baseFolderPrefix + FTEXT("7-zip.dll");
if (::ReadPluginInfo(pluginInfo, false))
plugins.Add(pluginInfo);
}
- UString folderPath = baseFolderPrefix + L"Plugins" WSTRING_PATH_SEPARATOR;
- NFind::CEnumeratorW enumerator(folderPath + L"*");
- NFind::CFileInfoW fileInfo;
+ FString folderPath = baseFolderPrefix + FTEXT("Plugins") FSTRING_PATH_SEPARATOR;
+ NFind::CEnumerator enumerator(folderPath + FCHAR_ANY_MASK);
+ NFind::CFileInfo fileInfo;
while (enumerator.Next(fileInfo))
{
if (fileInfo.IsDir())
diff --git a/CPP/7zip/UI/FileManager/RegistryPlugins.h b/CPP/7zip/UI/FileManager/RegistryPlugins.h
index 77055ac7..20f2ec34 100755
--- a/CPP/7zip/UI/FileManager/RegistryPlugins.h
+++ b/CPP/7zip/UI/FileManager/RegistryPlugins.h
@@ -1,7 +1,7 @@
// RegistryPlugins.h
-#ifndef __REGISTRYPLUGINS_H
-#define __REGISTRYPLUGINS_H
+#ifndef __REGISTRY_PLUGINS_H
+#define __REGISTRY_PLUGINS_H
#include "Common/MyString.h"
@@ -12,7 +12,7 @@ enum EPluginType
struct CPluginInfo
{
- UString FilePath;
+ FString FilePath;
EPluginType Type;
UString Name;
CLSID ClassID;
diff --git a/CPP/7zip/UI/FileManager/RootFolder.cpp b/CPP/7zip/UI/FileManager/RootFolder.cpp
index 0715a8be..a81f94c1 100755
--- a/CPP/7zip/UI/FileManager/RootFolder.cpp
+++ b/CPP/7zip/UI/FileManager/RootFolder.cpp
@@ -30,7 +30,7 @@ static const STATPROPSTG kProps[] =
UString RootFolder_GetName_Computer(int &iconIndex)
{
#ifdef UNDER_CE
- GetRealIconIndex(L"\\", FILE_ATTRIBUTE_DIRECTORY, iconIndex);
+ GetRealIconIndex(FTEXT("\\"), FILE_ATTRIBUTE_DIRECTORY, iconIndex);
#else
iconIndex = GetIconIndexForCSIDL(CSIDL_DRIVES);
#endif
@@ -123,7 +123,7 @@ UString GetMyDocsPath()
us = GetUnicodeString(s2);
}
#endif
- if (us.Length() > 0 && us[us.Length() - 1] != WCHAR_PATH_SEPARATOR)
+ if (us.Length() > 0 && us.Back() != WCHAR_PATH_SEPARATOR)
us += WCHAR_PATH_SEPARATOR;
return us;
}
@@ -159,7 +159,7 @@ STDMETHODIMP CRootFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolde
{
NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder;
subFolder = fsFolderSpec;
- RINOK(fsFolderSpec->Init(s, NULL));
+ RINOK(fsFolderSpec->Init(us2fs(s), NULL));
}
}
#endif
@@ -227,7 +227,7 @@ STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resu
name2 += WCHAR_PATH_SEPARATOR;
NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder;
subFolder = fsFolderSpec;
- if (fsFolderSpec->Init(name2, 0) != S_OK)
+ if (fsFolderSpec->Init(us2fs(name2), 0) != S_OK)
{
#ifndef UNDER_CE
if (name2[0] == WCHAR_PATH_SEPARATOR)
diff --git a/CPP/7zip/UI/FileManager/SettingsPage.cpp b/CPP/7zip/UI/FileManager/SettingsPage.cpp
index 10d063f7..866b0b2d 100755
--- a/CPP/7zip/UI/FileManager/SettingsPage.cpp
+++ b/CPP/7zip/UI/FileManager/SettingsPage.cpp
@@ -10,7 +10,6 @@
#include "HelpUtils.h"
#include "LangUtils.h"
-#include "ProgramLocation.h"
#include "RegistryUtils.h"
#include "SettingsPage.h"
diff --git a/CPP/7zip/UI/FileManager/SysIconUtils.cpp b/CPP/7zip/UI/FileManager/SysIconUtils.cpp
index e359ed2b..e537621e 100755
--- a/CPP/7zip/UI/FileManager/SysIconUtils.cpp
+++ b/CPP/7zip/UI/FileManager/SysIconUtils.cpp
@@ -24,7 +24,7 @@ int GetIconIndexForCSIDL(int csidl)
SHGFI_PIDL | SHGFI_SYSICONINDEX);
IMalloc *pMalloc;
SHGetMalloc(&pMalloc);
- if(pMalloc)
+ if (pMalloc)
{
pMalloc->Free(pidl);
pMalloc->Release();
@@ -34,16 +34,6 @@ int GetIconIndexForCSIDL(int csidl)
return 0;
}
-DWORD_PTR GetRealIconIndex(LPCTSTR path, DWORD attrib, int &iconIndex)
-{
- SHFILEINFO shellInfo;
- DWORD_PTR res = ::SHGetFileInfo(path, FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo,
- sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX);
- iconIndex = shellInfo.iIcon;
- return res;
-}
-
-
#ifndef _UNICODE
typedef int (WINAPI * SHGetFileInfoWP)(LPCWSTR pszPath, DWORD attrib, SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags);
@@ -70,28 +60,32 @@ static DWORD_PTR MySHGetFileInfoW(LPCWSTR pszPath, DWORD attrib, SHFILEINFOW *ps
pszPath, attrib, psfi, cbFileInfo, uFlags);
}
-#ifndef _UNICODE
-// static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
-DWORD_PTR GetRealIconIndex(LPCWSTR path, DWORD attrib, int &iconIndex)
+DWORD_PTR GetRealIconIndex(CFSTR path, DWORD attrib, int &iconIndex)
{
- if(g_IsNT)
+ #ifndef _UNICODE
+ if (!g_IsNT)
{
- SHFILEINFOW shellInfo;
- DWORD_PTR res = ::MySHGetFileInfoW(path, FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo,
+ SHFILEINFO shellInfo;
+ DWORD_PTR res = ::SHGetFileInfo(fs2fas(path), FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo,
sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX);
iconIndex = shellInfo.iIcon;
return res;
}
else
- return GetRealIconIndex(UnicodeStringToMultiByte(path), attrib, iconIndex);
+ #endif
+ {
+ SHFILEINFOW shellInfo;
+ DWORD_PTR res = ::MySHGetFileInfoW(fs2us(path), FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo,
+ sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX);
+ iconIndex = shellInfo.iIcon;
+ return res;
+ }
}
-#endif
-DWORD_PTR GetRealIconIndex(const UString &fileName, DWORD attrib,
- int &iconIndex, UString &typeName)
+DWORD_PTR GetRealIconIndex(const UString &fileName, DWORD attrib, int &iconIndex, UString &typeName)
{
#ifndef _UNICODE
- if(!g_IsNT)
+ if (!g_IsNT)
{
SHFILEINFO shellInfo;
shellInfo.szTypeName[0] = 0;
diff --git a/CPP/7zip/UI/FileManager/SysIconUtils.h b/CPP/7zip/UI/FileManager/SysIconUtils.h
index 5ba9c57f..129de781 100755
--- a/CPP/7zip/UI/FileManager/SysIconUtils.h
+++ b/CPP/7zip/UI/FileManager/SysIconUtils.h
@@ -39,10 +39,7 @@ public:
int GetIconIndex(DWORD attrib, const UString &fileName);
};
-DWORD_PTR GetRealIconIndex(LPCTSTR path, DWORD attrib, int &iconIndex);
-#ifndef _UNICODE
-DWORD_PTR GetRealIconIndex(LPCWSTR path, DWORD attrib, int &iconIndex);
-#endif
+DWORD_PTR GetRealIconIndex(CFSTR path, DWORD attrib, int &iconIndex);
int GetIconIndexForCSIDL(int csidl);
inline HIMAGELIST GetSysImageList(bool smallIcons)
diff --git a/CPP/7zip/UI/FileManager/SystemPage.cpp b/CPP/7zip/UI/FileManager/SystemPage.cpp
index 3681992d..359656ea 100755
--- a/CPP/7zip/UI/FileManager/SystemPage.cpp
+++ b/CPP/7zip/UI/FileManager/SystemPage.cpp
@@ -1,172 +1,266 @@
// SystemPage.cpp
#include "StdAfx.h"
-#include "SystemPageRes.h"
-#include "SystemPage.h"
#include "Common/StringConvert.h"
-#include "Common/MyCom.h"
-#include "Windows/Defs.h"
-#include "Windows/Control/ListView.h"
-#include "Windows/FileFind.h"
+#include "Windows/DLL.h"
+#include "Windows/Error.h"
-#include "IFolder.h"
#include "HelpUtils.h"
+#include "IFolder.h"
#include "LangUtils.h"
-#include "PluginLoader.h"
-#include "ProgramLocation.h"
-#include "StringUtils.h"
-
#include "PropertyNameRes.h"
-#include "../Agent/Agent.h"
+#include "SystemPage.h"
+#include "SystemPageRes.h"
-using namespace NRegistryAssociations;
+static const CIDLangPair kIDLangPairs[] =
+{
+ { IDC_SYSTEM_STATIC_ASSOCIATE, 0x03010302}
+ // { IDC_SYSTEM_SELECT_ALL, 0x03000330}
+};
-const int kRefreshpluginsListMessage = WM_USER + 1;
-const int kUpdateDatabase = kRefreshpluginsListMessage + 1;
+static LPCWSTR kSystemTopic = L"FM/options.htm#system";
-static CIDLangPair kIDLangPairs[] =
+CSysString CModifiedExtInfo::GetString() const
{
- { IDC_SYSTEM_STATIC_ASSOCIATE, 0x03010302},
- { IDC_SYSTEM_SELECT_ALL, 0x03000330}
+ if (State == kExtState_7Zip)
+ return TEXT("7-Zip");
+ if (State == kExtState_Clear)
+ return TEXT("");
+ if (Other7Zip)
+ return TEXT("[7-Zip]");
+ return ProgramKey;
};
-static LPCWSTR kSystemTopic = L"FM/options.htm#system";
+int CSystemPage::AddIcon(const UString &iconPath, int iconIndex)
+{
+ if (iconPath.IsEmpty())
+ return -1;
+ if (iconIndex == -1)
+ iconIndex = 0;
+ HICON hicon;
+ #ifdef UNDER_CE
+ ExtractIconExW(iconPath, iconIndex, NULL, &hicon, 1);
+ if (!hicon)
+ #else
+ // we expand path from REG_EXPAND_SZ registry item.
+ UString path;
+ DWORD size = MAX_PATH + 10;
+ DWORD needLen = ::ExpandEnvironmentStringsW(iconPath, path.GetBuffer((int)size + 1), size);
+ path.ReleaseBuffer();
+ if (needLen == 0 || needLen >= size)
+ path = iconPath;
+ int num = ExtractIconExW(path, iconIndex, NULL, &hicon, 1);
+ if (num != 1 || !hicon)
+ #endif
+ return -1;
+ _imageList.AddIcon(hicon);
+ DestroyIcon(hicon);
+ return _numIcons++;
+}
+void CSystemPage::RefreshListItem(int group, int listIndex)
+{
+ const CAssoc &assoc = _items[GetRealIndex(listIndex)];
+ _listView.SetSubItem(listIndex, group + 1, assoc.Pair[group].GetString());
+ LVITEMW newItem;
+ memset(&newItem, 0, sizeof(newItem));
+ newItem.iItem = listIndex;
+ newItem.mask = LVIF_IMAGE;
+ newItem.iImage = assoc.GetIconIndex();
+ _listView.SetItem(&newItem);
+}
+
+void CSystemPage::ChangeState(int group, const CIntVector &indices)
+{
+ if (indices.IsEmpty())
+ return;
+
+ bool thereAreClearItems = false;
+ int counters[3] = { 0, 0, 0 };
+
+ int i;
+ for (i = 0; i < indices.Size(); i++)
+ {
+ const CModifiedExtInfo &mi = _items[GetRealIndex(indices[i])].Pair[group];
+ int state = kExtState_7Zip;
+ if (mi.State == kExtState_7Zip)
+ state = kExtState_Clear;
+ else if (mi.State == kExtState_Clear)
+ {
+ thereAreClearItems = true;
+ if (mi.Other)
+ state = kExtState_Other;
+ }
+ counters[state]++;
+ }
+
+ int state = kExtState_Clear;
+ if (counters[kExtState_Other] != 0)
+ state = kExtState_Other;
+ else if (counters[kExtState_7Zip] != 0)
+ state = kExtState_7Zip;
+
+ for (i = 0; i < indices.Size(); i++)
+ {
+ int listIndex = indices[i];
+ CAssoc &assoc = _items[GetRealIndex(listIndex)];
+ CModifiedExtInfo &mi = assoc.Pair[group];
+ bool change = false;
+ switch (state)
+ {
+ case kExtState_Clear: change = true; break;
+ case kExtState_Other: change = mi.Other; break;
+ default: change = !(mi.Other && thereAreClearItems); break;
+ }
+ if (change)
+ {
+ mi.State = state;
+ RefreshListItem(group, listIndex);
+ }
+ }
+ Changed();
+}
bool CSystemPage::OnInit()
{
- _initMode = true;
- LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ LangSetDlgItemsText((HWND)*this, kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+
+ _listView.Attach(GetItem(IDC_SYSTEM_LIST_ASSOCIATE));
+ _listView.SetUnicodeFormat();
+ DWORD newFlags = LVS_EX_FULLROWSELECT;
+ _listView.SetExtendedListViewStyle(newFlags, newFlags);
- _listViewExt.Attach(GetItem(IDC_SYSTEM_LIST_ASSOCIATE));
- _listViewPlugins.Attach(GetItem(IDC_SYSTEM_LIST_PLUGINS));
+ _numIcons = 0;
+ _imageList.Create(16, 16, ILC_MASK | ILC_COLOR32, 0, 0);
- /*
- CheckButton(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU,
- NRegistryAssociations::CheckContextMenuHandler());
- */
+ _listView.SetImageList(_imageList, LVSIL_SMALL);
- UINT32 newFlags = LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT;
- _listViewExt.SetExtendedListViewStyle(newFlags, newFlags);
- _listViewPlugins.SetExtendedListViewStyle(newFlags, newFlags);
+ _listView.InsertColumn(0, LangString(IDS_PROP_FILE_TYPE, 0x02000214), 72);
- _listViewExt.InsertColumn(0, LangString(IDS_PROP_EXTENSION, 0x02000205), 40);
- const UString s = LangString(IDS_PLUGIN, 0x03010310);
- _listViewExt.InsertColumn(1, s, 40);
+ CSysString s;
- _listViewPlugins.InsertColumn(0, s, 40);
+ #if NUM_EXT_GROUPS == 1
+ s = TEXT("Program");
+ #else
+ #ifndef UNDER_CE
+ DWORD size = 256;
+ BOOL res = GetUserName(s.GetBuffer(size), &size);
+ s.ReleaseBuffer();
+ if (!res)
+ #endif
+ s = TEXT("Current User");
+ #endif
- _extDatabase.Read();
+ LVCOLUMN ci;
+ ci.mask = LVCF_TEXT | LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM;
+ ci.cx = 100;
+ ci.pszText = (TCHAR *)(const TCHAR *)s;
+ ci.iSubItem = 1;
+ ci.fmt = LVCFMT_CENTER;
+ _listView.InsertColumn(1, &ci);
- for (int i = 0; i < _extDatabase.ExtBigItems.Size(); i++)
+ #if NUM_EXT_GROUPS > 1
{
- CExtInfoBig &extInfo = _extDatabase.ExtBigItems[i];
-
- int itemIndex = _listViewExt.InsertItem(i, (LPCWSTR)extInfo.Ext);
+ ci.iSubItem = 2;
+ ci.pszText = TEXT("All Users");
+ _listView.InsertColumn(2, &ci);
+ }
+ #endif
- UString iconPath;
- int iconIndex;
- extInfo.Associated = NRegistryAssociations::CheckShellExtensionInfo(GetSystemString(extInfo.Ext), iconPath, iconIndex);
- if (extInfo.Associated && !NWindows::NFile::NFind::DoesFileExist(iconPath))
- extInfo.Associated = false;
- _listViewExt.SetCheckState(itemIndex, extInfo.Associated);
+ _extDB.Read();
+ _items.Clear();
- SetMainPluginText(itemIndex, i);
+ for (int i = 0; i < _extDB.Exts.Size(); i++)
+ {
+ const CExtPlugins &extInfo = _extDB.Exts[i];
+
+ LVITEMW item;
+ item.iItem = i;
+ item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
+ item.lParam = i;
+ item.iSubItem = 0;
+ // 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;
+
+ CAssoc assoc;
+ const CPluginToIcon &plug = extInfo.Plugins[0];
+ assoc.SevenZipImageIndex = AddIcon(plug.IconPath, plug.IconIndex);
+
+ CSysString texts[NUM_EXT_GROUPS];
+ int g;
+ for (g = 0; g < NUM_EXT_GROUPS; g++)
+ {
+ CModifiedExtInfo &mi = assoc.Pair[g];
+ mi.ReadFromRegistry(GetHKey(g), GetSystemString(extInfo.Ext));
+ mi.SetState(plug.IconPath);
+ mi.ImageIndex = AddIcon(mi.IconPath, mi.IconIndex);
+ texts[g] = mi.GetString();
+ }
+ item.iImage = assoc.GetIconIndex();
+ int itemIndex = _listView.InsertItem(&item);
+ for (g = 0; g < NUM_EXT_GROUPS; g++)
+ _listView.SetSubItem(itemIndex, 1 + g, texts[g]);
+ _items.Add(assoc);
}
- // _listViewExt.SortItems();
- if (_listViewExt.GetItemCount() > 0)
- _listViewExt.SetItemState_FocusedSelected(0);
- RefreshPluginsList(-1);
- _initMode = false;
+ if (_listView.GetItemCount() > 0)
+ _listView.SetItemState(0, LVIS_FOCUSED, LVIS_FOCUSED);
return CPropertyPage::OnInit();
}
-void CSystemPage::SetMainPluginText(int itemIndex, int indexInDatabase)
-{
- _listViewExt.SetSubItem(itemIndex, 1, _extDatabase.GetMainPluginNameForExtItem(indexInDatabase));
-}
-
static UString GetProgramCommand()
{
- UString path = L"\"";
- UString folder;
- if (GetProgramFolderPath(folder))
- path += folder;
- path += L"7zFM.exe\" \"%1\"";
- return path;
-}
-
-static UString GetIconPath(const UString &filePath,
- const CLSID &clsID, const UString &extension, Int32 &iconIndex)
-{
- CPluginLibrary library;
- CMyComPtr<IFolderManager> folderManager;
- CMyComPtr<IFolderFolder> folder;
- if (filePath.IsEmpty())
- folderManager = new CArchiveFolderManager;
- else if (library.LoadAndCreateManager(filePath, clsID, &folderManager) != S_OK)
- return UString();
- CMyComBSTR extBSTR;
- if (folderManager->GetExtensions(&extBSTR) != S_OK)
- return UString();
- const UString ext2 = (const wchar_t *)extBSTR;
- UStringVector exts;
- SplitString(ext2, exts);
- for (int i = 0; i < exts.Size(); i++)
- {
- const UString &plugExt = exts[i];
- if (extension.CompareNoCase((const wchar_t *)plugExt) == 0)
- {
- CMyComBSTR iconPathTemp;
- if (folderManager->GetIconPath(plugExt, &iconPathTemp, &iconIndex) != S_OK)
- break;
- if (iconPathTemp != 0)
- return (const wchar_t *)iconPathTemp;
- }
- }
- return UString();
+ return L"\"" + fs2us(NWindows::NDLL::GetModuleDirPrefix()) + L"7zFM.exe\" \"%1\"";
}
LONG CSystemPage::OnApply()
{
- UpdateDatabase();
- _extDatabase.Save();
- UString command = GetProgramCommand();
+ const UString command = GetProgramCommand();
- for (int i = 0; i < _extDatabase.ExtBigItems.Size(); i++)
+ LONG res = 0;
+
+ for (int listIndex = 0; listIndex < _extDB.Exts.Size(); listIndex++)
{
- const CExtInfoBig &extInfo = _extDatabase.ExtBigItems[i];
- if (extInfo.Associated)
+ int realIndex = GetRealIndex(listIndex);
+ const CExtPlugins &extInfo = _extDB.Exts[realIndex];
+ CAssoc &assoc = _items[realIndex];
+
+ for (int g = 0; g < NUM_EXT_GROUPS; g++)
{
- UString title = extInfo.Ext + UString(L" Archive");
- UString command = GetProgramCommand();
- UString iconPath;
- Int32 iconIndex = -1;
- if (!extInfo.PluginsPairs.IsEmpty())
+ CModifiedExtInfo &mi = assoc.Pair[g];
+ HKEY key = GetHKey(g);
+ if (mi.OldState != mi.State)
{
- const CPluginInfo &plugin = _extDatabase.Plugins[extInfo.PluginsPairs[0].Index];
- iconPath = GetIconPath(plugin.FilePath, plugin.ClassID, extInfo.Ext, iconIndex);
+ LONG res2 = 0;
+ if (mi.State == kExtState_7Zip)
+ {
+ UString title = extInfo.Ext + UString(L" Archive");
+ const CPluginToIcon &plug = extInfo.Plugins[0];
+ res2 = NRegistryAssoc::AddShellExtensionInfo(key, GetSystemString(extInfo.Ext),
+ title, command, plug.IconPath, plug.IconIndex);
+ }
+ else if (mi.State == kExtState_Clear)
+ res2 = NRegistryAssoc::DeleteShellExtensionInfo(key, GetSystemString(extInfo.Ext));
+ if (res == 0)
+ res = res2;
+ if (res2 == 0)
+ mi.OldState = mi.State;
+ mi.State = mi.OldState;
+ RefreshListItem(g, listIndex);
}
- NRegistryAssociations::AddShellExtensionInfo(GetSystemString(extInfo.Ext),
- title, command, iconPath, iconIndex, NULL, 0);
}
- else
- NRegistryAssociations::DeleteShellExtensionInfo(GetSystemString(extInfo.Ext));
}
- /*
- if (IsButtonCheckedBool(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU))
- NRegistryAssociations::AddContextMenuHandler();
- else
- NRegistryAssociations::DeleteContextMenuHandler();
- */
#ifndef UNDER_CE
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
WasChanged = true;
#endif
+ if (res != 0)
+ MessageBoxW(*this, NWindows::NError::MyFormatMessageW(res), L"7-Zip", MB_ICONERROR);
return PSNRET_NOERROR;
}
@@ -175,228 +269,119 @@ void CSystemPage::OnNotifyHelp()
ShowHelpWindow(NULL, kSystemTopic);
}
-void CSystemPage::SelectAll()
-{
- int count = _listViewExt.GetItemCount();
- for (int i = 0; i < count; i++)
- _listViewExt.SetCheckState(i, true);
- UpdateDatabase();
-}
-
bool CSystemPage::OnButtonClicked(int buttonID, HWND buttonHWND)
{
- switch(buttonID)
+ switch (buttonID)
{
+ /*
case IDC_SYSTEM_SELECT_ALL:
- {
- SelectAll();
- Changed();
+ _listView.SelectAll();
+ return true;
+ */
+ case IDC_SYSTEM_BUTTON_CURRENT:
+ case IDC_SYSTEM_BUTTON_ALL:
+ ChangeState(buttonID == IDC_SYSTEM_BUTTON_CURRENT ? 0 : 1);
return true;
- }
}
return CPropertyPage::OnButtonClicked(buttonID, buttonHWND);
}
bool CSystemPage::OnNotify(UINT controlID, LPNMHDR lParam)
{
- if (lParam->hwndFrom == HWND(_listViewExt))
+ if (lParam->hwndFrom == HWND(_listView))
{
- switch(lParam->code)
+ switch (lParam->code)
{
- case (LVN_ITEMCHANGED):
- return OnItemChanged((const NMLISTVIEW *)lParam);
- case NM_RCLICK:
- case NM_DBLCLK:
- case LVN_KEYDOWN:
- case NM_CLICK:
- case LVN_BEGINRDRAG:
- PostMessage(kRefreshpluginsListMessage, 0);
- PostMessage(kUpdateDatabase, 0);
- break;
- }
- }
- else if (lParam->hwndFrom == HWND(_listViewPlugins))
- {
- switch(lParam->code)
- {
- case NM_RCLICK:
- case NM_DBLCLK:
- // case LVN_KEYDOWN:
+ case NM_RETURN:
+ {
+ ChangeState(0);
+ return true;
+ }
+ break;
case NM_CLICK:
- case LVN_BEGINRDRAG:
- PostMessage(kUpdateDatabase, 0);
- break;
-
- case (LVN_ITEMCHANGED):
{
- OnItemChanged((const NMLISTVIEW *)lParam);
- PostMessage(kUpdateDatabase, 0);
+ #ifdef UNDER_CE
+ NMLISTVIEW *item = (NMLISTVIEW *)lParam;
+ #else
+ NMITEMACTIVATE *item = (NMITEMACTIVATE *)lParam;
+ if (item->uKeyFlags == 0)
+ #endif
+ {
+ int realIndex = GetRealIndex(item->iItem);
+ if (realIndex >= 0)
+ {
+ if (item->iSubItem >= 1 && item->iSubItem <= 2)
+ {
+ CIntVector indices;
+ indices.Add(item->iItem);
+ ChangeState(item->iSubItem < 2 ? 0 : 1, indices);
+ }
+ }
+ }
break;
}
case LVN_KEYDOWN:
{
- OnPluginsKeyDown((LPNMLVKEYDOWN)lParam);
- PostMessage(kUpdateDatabase, 0);
+ if (OnListKeyDown(LPNMLVKEYDOWN(lParam)))
+ return true;
break;
}
+ /*
+ case NM_RCLICK:
+ case NM_DBLCLK:
+ case LVN_BEGINRDRAG:
+ // PostMessage(kRefreshpluginsListMessage, 0);
+ PostMessage(kUpdateDatabase, 0);
+ break;
+ */
}
}
return CPropertyPage::OnNotify(controlID, lParam);
}
-bool CSystemPage::OnPluginsKeyDown(LPNMLVKEYDOWN keyDownInfo)
+void CSystemPage::ChangeState(int group)
{
- bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
- // bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
- switch(keyDownInfo->wVKey)
- {
- case VK_UP:
- {
- if (alt)
- MovePlugin(true);
- return true;
- }
- case VK_DOWN:
- {
- if (alt)
- MovePlugin(false);
- return true;
- }
- }
- return false;
+ CIntVector indices;
+ int itemIndex = -1;
+ while ((itemIndex = _listView.GetNextSelectedItem(itemIndex)) != -1)
+ indices.Add(itemIndex);
+ if (indices.IsEmpty())
+ for (int i = 0; i < _items.Size(); i++)
+ indices.Add(i);
+ ChangeState(group, indices);
}
-void CSystemPage::MovePlugin(bool upDirection)
+bool CSystemPage::OnListKeyDown(LPNMLVKEYDOWN keyDownInfo)
{
- int selectedPlugin = _listViewPlugins.GetSelectionMark();
- if (selectedPlugin < 0)
- return;
- int newIndex = selectedPlugin + (upDirection ? -1: 1);
- if (newIndex < 0 || newIndex >= _listViewPlugins.GetItemCount())
- return;
- int selectedExtIndex = GetSelectedExtIndex();
- if (selectedExtIndex < 0)
- return;
- CExtInfoBig &extInfo = _extDatabase.ExtBigItems[selectedExtIndex];
- CPluginEnabledPair pluginPairTemp = extInfo.PluginsPairs[newIndex];
- extInfo.PluginsPairs[newIndex] = extInfo.PluginsPairs[selectedPlugin];
- extInfo.PluginsPairs[selectedPlugin] = pluginPairTemp;
-
- SetMainPluginText(_listViewExt.GetSelectionMark(), selectedExtIndex);
- RefreshPluginsList(newIndex);
-
- Changed();
-}
-
-bool CSystemPage::OnItemChanged(const NMLISTVIEW *info)
-{
- if (_initMode)
- return true;
- if ((info->uChanged & LVIF_STATE) != 0)
- {
- UINT oldState = info->uOldState & LVIS_STATEIMAGEMASK;
- UINT newState = info->uNewState & LVIS_STATEIMAGEMASK;
- if (oldState != newState)
- Changed();
- }
- // PostMessage(kRefreshpluginsListMessage, 0);
- // RefreshPluginsList();
- return true;
-}
-
-bool CSystemPage::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
-{
- switch(message)
- {
- case kRefreshpluginsListMessage:
- RefreshPluginsList(-1);
- return true;
- case kUpdateDatabase:
- UpdateDatabase();
- return true;
- }
- return CPropertyPage::OnMessage(message, wParam, lParam);
-}
+ bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
+ bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
-void CSystemPage::UpdateDatabase()
-{
- int i;
- for (i = 0; i < _listViewExt.GetItemCount(); i++)
- {
- LPARAM param;
- if (!_listViewExt.GetItemParam(i, param))
- return;
- CExtInfoBig &extInfo = _extDatabase.ExtBigItems[(int)param];
- extInfo.Associated = _listViewExt.GetCheckState(i);
- }
+ if (alt)
+ return false;
- int selectedExtIndex = GetSelectedExtIndex();
- if (selectedExtIndex < 0)
- return;
-
- CExtInfoBig &extInfo = _extDatabase.ExtBigItems[selectedExtIndex];
- for (i = 0; i < _listViewPlugins.GetItemCount(); i++)
+ if ((ctrl && keyDownInfo->wVKey == 'A') ||
+ (!ctrl && keyDownInfo->wVKey == VK_MULTIPLY))
{
- extInfo.PluginsPairs[i].Enabled = _listViewPlugins.GetCheckState(i);
+ _listView.SelectAll();
+ return true;
}
-}
-
-
-
-int CSystemPage::GetSelectedExtIndex()
-{
- int selectedIndex = _listViewExt.GetSelectionMark();
- if (selectedIndex < 0)
- return -1;
- LPARAM param;
- if (!_listViewExt.GetItemParam(selectedIndex, param))
- return -1;
- return (int)param;
-}
-
-
-void CSystemPage::RefreshPluginsList(int selectIndex)
-{
- _listViewPlugins.DeleteAllItems();
- int selectedExtIndex = GetSelectedExtIndex();
- if (selectedExtIndex < 0)
- return;
- const CExtInfoBig &extInfo = _extDatabase.ExtBigItems[selectedExtIndex];
- _initMode = true;
- for (int i = 0; i < extInfo.PluginsPairs.Size(); i++)
+ switch (keyDownInfo->wVKey)
{
- CPluginEnabledPair pluginPair = extInfo.PluginsPairs[i];
- int itemIndex = _listViewPlugins.InsertItem(i, _extDatabase.Plugins[pluginPair.Index].Name);
- _listViewPlugins.SetCheckState(itemIndex, pluginPair.Enabled);
- }
- if (_listViewPlugins.GetItemCount() > 0)
- {
- if (selectIndex < 0)
- selectIndex = 0;
- _listViewPlugins.SetItemState_FocusedSelected(selectIndex);
+ case VK_SPACE:
+ case VK_ADD:
+ case VK_SUBTRACT:
+ case VK_SEPARATOR:
+ case VK_DIVIDE:
+ #ifndef UNDER_CE
+ case VK_OEM_PLUS:
+ case VK_OEM_MINUS:
+ #endif
+ if (!ctrl)
+ {
+ ChangeState(keyDownInfo->wVKey == VK_SPACE ? 0 : 1);
+ return true;
+ }
}
- _initMode = false;
+ return false;
}
-
-
-
-/*
-static BYTE kZipShellNewData[] =
- { 0x50-1, 0x4B, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0 };
-
-static BYTE kRarShellNewData[] =
- { 0x52-1, 0x61, 0x72, 0x21, 0x1A, 7, 0, 0xCF, 0x90, 0x73, 0, 0, 0x0D, 0, 0, 0, 0, 0, 0, 0};
-
-class CSignatureMaker
-{
-public:
- CSignatureMaker()
- {
- kZipShellNewData[0]++;
- kRarShellNewData[0]++;
- };
-};
-
-static CSignatureMaker g_SignatureMaker;
-*/
diff --git a/CPP/7zip/UI/FileManager/SystemPage.h b/CPP/7zip/UI/FileManager/SystemPage.h
index 967731fd..a4b4ab92 100755
--- a/CPP/7zip/UI/FileManager/SystemPage.h
+++ b/CPP/7zip/UI/FileManager/SystemPage.h
@@ -3,39 +3,117 @@
#ifndef __SYSTEM_PAGE_H
#define __SYSTEM_PAGE_H
-#include "Windows/Control/PropertyPage.h"
+#include "Windows/Control/ImageList.h"
#include "Windows/Control/ListView.h"
+#include "Windows/Control/PropertyPage.h"
#include "FilePlugins.h"
+#include "RegistryAssociations.h"
+
+enum EExtState
+{
+ kExtState_Clear = 0,
+ kExtState_Other,
+ kExtState_7Zip
+};
+
+struct CModifiedExtInfo: public NRegistryAssoc::CShellExtInfo
+{
+ int OldState;
+ int State;
+ int ImageIndex;
+ bool Other;
+ bool Other7Zip;
+
+ CModifiedExtInfo(): ImageIndex(-1) {}
+
+ CSysString GetString() const;
+
+ void SetState(const UString &iconPath)
+ {
+ State = kExtState_Clear;
+ Other = false;
+ Other7Zip = false;
+ if (!ProgramKey.IsEmpty())
+ {
+ State = kExtState_Other;
+ Other = true;
+ if (IsIt7Zip())
+ {
+ Other7Zip = (iconPath.CompareNoCase(IconPath) != 0);
+ if (!Other7Zip)
+ {
+ State = kExtState_7Zip;
+ Other = false;
+ }
+ }
+ }
+ OldState = State;
+ };
+};
+
+struct CAssoc
+{
+ CModifiedExtInfo Pair[2];
+ int SevenZipImageIndex;
+
+ int GetIconIndex() const
+ {
+ for (int i = 0; i < 2; i++)
+ {
+ const CModifiedExtInfo &pair = Pair[i];
+ if (pair.State == kExtState_Clear)
+ continue;
+ if (pair.State == kExtState_7Zip)
+ return SevenZipImageIndex;
+ if (pair.ImageIndex != -1)
+ return pair.ImageIndex;
+ }
+ return -1;
+ }
+};
+
+#ifdef UNDER_CE
+ #define NUM_EXT_GROUPS 1
+#else
+ #define NUM_EXT_GROUPS 2
+#endif
class CSystemPage: public NWindows::NControl::CPropertyPage
{
- bool _initMode;
- CExtDatabase _extDatabase;
+ CExtDatabase _extDB;
+ CObjectVector<CAssoc> _items;
- NWindows::NControl::CListView _listViewExt;
- NWindows::NControl::CListView _listViewPlugins;
+ int _numIcons;
+ NWindows::NControl::CImageList _imageList;
+ NWindows::NControl::CListView _listView;
- void SetMainPluginText(int itemIndex, int indexInDatabase);
+ const HKEY GetHKey(int group) const
+ {
+ #if NUM_EXT_GROUPS == 1
+ return HKEY_CLASSES_ROOT;
+ #else
+ return group == 0 ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
+ #endif
+ }
- int GetSelectedExtIndex();
- void RefreshPluginsList(int selectIndex);
- void MovePlugin(bool upDirection);
- void UpdateDatabase();
- void SelectAll();
+ int AddIcon(const UString &path, int iconIndex);
+ int GetRealIndex(int listIndex) const { return listIndex; }
+ void RefreshListItem(int group, int listIndex);
+ void ChangeState(int group, const CIntVector &indices);
+ void ChangeState(int group);
+ bool OnListKeyDown(LPNMLVKEYDOWN keyDownInfo);
+
public:
bool WasChanged;
CSystemPage(): WasChanged(false) {}
- virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
+
virtual bool OnInit();
virtual void OnNotifyHelp();
virtual bool OnNotify(UINT controlID, LPNMHDR lParam);
- virtual bool OnItemChanged(const NMLISTVIEW *info);
-
virtual LONG OnApply();
virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
- bool OnPluginsKeyDown(LPNMLVKEYDOWN keyDownInfo);
};
#endif
diff --git a/CPP/7zip/UI/FileManager/SystemPage.rc b/CPP/7zip/UI/FileManager/SystemPage.rc
index 52e60d19..49581c9b 100755
--- a/CPP/7zip/UI/FileManager/SystemPage.rc
+++ b/CPP/7zip/UI/FileManager/SystemPage.rc
@@ -2,16 +2,18 @@
#include "../../GuiCommon.rc"
#define xc 200
-#define yc 200
+#define yc 250
IDD_SYSTEM MY_PAGE
CAPTION "System"
BEGIN
LTEXT "Associate 7-Zip with:", IDC_SYSTEM_STATIC_ASSOCIATE, m, m, xc, 8
+ PUSHBUTTON "+", IDC_SYSTEM_BUTTON_CURRENT, 72, m + 12, 40, bys
+ PUSHBUTTON "+", IDC_SYSTEM_BUTTON_ALL, 140, m + 12, 40, bys
CONTROL "List1", IDC_SYSTEM_LIST_ASSOCIATE, "SysListView32",
- LVS_LIST | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | WS_BORDER | WS_TABSTOP,
- m, m + 12, xc, (yc - m - 12 - 1 - bys)
- PUSHBUTTON "Select all", IDC_SYSTEM_SELECT_ALL, m, (ys - m - bys), 90, bys
+ LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,
+ m, m + 32, xc, (yc - m - 32 - 1)
+; PUSHBUTTON "Select all", IDC_SYSTEM_SELECT_ALL, m, m + 12, 60, bys
END
#ifdef UNDER_CE
@@ -28,10 +30,11 @@ IDD_SYSTEM_2 MY_PAGE
CAPTION "System"
BEGIN
LTEXT "Associate 7-Zip with:", IDC_SYSTEM_STATIC_ASSOCIATE, m, m, xc, 8
+ PUSHBUTTON "+", IDC_SYSTEM_BUTTON_CURRENT, 60, m + 12, 40, bys
CONTROL "List1", IDC_SYSTEM_LIST_ASSOCIATE, "SysListView32",
- LVS_LIST | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | WS_BORDER | WS_TABSTOP,
- m, m + 12, xc, (yc - m - 12 - 1 - bys - 8)
- PUSHBUTTON "Select all", IDC_SYSTEM_SELECT_ALL, m, (ys - m - bys - 8), 90, bys
+ LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,
+ m, m + 32, xc, (yc - m - 32 - 1 - 8)
+; PUSHBUTTON "Select all", IDC_SYSTEM_SELECT_ALL, m, m + 12, 60, bys
END
#endif
diff --git a/CPP/7zip/UI/FileManager/SystemPageRes.h b/CPP/7zip/UI/FileManager/SystemPageRes.h
index b60b4533..133996e7 100755
--- a/CPP/7zip/UI/FileManager/SystemPageRes.h
+++ b/CPP/7zip/UI/FileManager/SystemPageRes.h
@@ -4,5 +4,7 @@
// #define IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU 1010
#define IDC_SYSTEM_STATIC_ASSOCIATE 1020
#define IDC_SYSTEM_LIST_ASSOCIATE 1021
-#define IDC_SYSTEM_LIST_PLUGINS 1022
-#define IDC_SYSTEM_SELECT_ALL 1023
+// #define IDC_SYSTEM_LIST_PLUGINS 1022
+// #define IDC_SYSTEM_SELECT_ALL 1023
+#define IDC_SYSTEM_BUTTON_CURRENT 1024
+#define IDC_SYSTEM_BUTTON_ALL 1025
diff --git a/CPP/7zip/UI/FileManager/resource.h b/CPP/7zip/UI/FileManager/resource.h
index 13c8e0e7..cdb77edf 100755
--- a/CPP/7zip/UI/FileManager/resource.h
+++ b/CPP/7zip/UI/FileManager/resource.h
@@ -52,6 +52,7 @@
#define IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT 463
#define IDM_OPTIONS 510
#define IDM_BENCHMARK 511
+#define IDM_BENCHMARK2 512
#define IDM_HELP_CONTENTS 610
#define IDM_ABOUT 620
#define IDS_BOOKMARK 720
diff --git a/CPP/7zip/UI/FileManager/resource.rc b/CPP/7zip/UI/FileManager/resource.rc
index 833cb374..2952ce5a 100755
--- a/CPP/7zip/UI/FileManager/resource.rc
+++ b/CPP/7zip/UI/FileManager/resource.rc
@@ -95,6 +95,9 @@ BEGIN
BEGIN
MENUITEM "&Options...", IDM_OPTIONS
MENUITEM "&Benchmark", IDM_BENCHMARK
+ #ifdef UNDER_CE
+ MENUITEM "&Benchmark2", IDM_BENCHMARK2
+ #endif
#ifndef UNDER_CE
END
POPUP "&Help"