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 '7zip/FileManager/PanelItemOpen.cpp')
-rwxr-xr-x7zip/FileManager/PanelItemOpen.cpp144
1 files changed, 94 insertions, 50 deletions
diff --git a/7zip/FileManager/PanelItemOpen.cpp b/7zip/FileManager/PanelItemOpen.cpp
index 5cf77b7c..25a25c8f 100755
--- a/7zip/FileManager/PanelItemOpen.cpp
+++ b/7zip/FileManager/PanelItemOpen.cpp
@@ -29,9 +29,9 @@ using namespace NFile;
using namespace NDirectory;
extern HWND g_HWND;
-
-static inline UINT GetCurrentFileCodePage()
- { return AreFileApisANSI() ? CP_ACP : CP_OEMCP;}
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
static wchar_t *kTempDirPrefix = L"7zO";
@@ -81,8 +81,7 @@ HRESULT CPanel::OpenItemAsArchive(const UString &name,
// _password.Empty();
NDLL::CLibrary library;
- RINOK(OpenFileFolderPlugin(GetUnicodeString(filePath),
- &library, &newFolder, GetParent()));
+ RINOK(OpenFileFolderPlugin(filePath, &library, &newFolder, GetParent()));
folderLink.ParentFolder = _folder;
folderLink.ItemName = name;
@@ -130,7 +129,7 @@ HRESULT CPanel::OpenParentArchiveFolder()
if (OnOpenItemChanged(folderLink.FolderPath, folderLink.ItemName) != S_OK)
{
::MessageBoxW(HWND(*this), MyFormatNew(IDS_CANNOT_UPDATE_FILE,
- 0x03020281, GetUnicodeString(folderLink.FilePath)), L"7-Zip", MB_OK | MB_ICONSTOP);
+ 0x03020281, folderLink.FilePath), L"7-Zip", MB_OK | MB_ICONSTOP);
return S_OK;
}
}
@@ -151,69 +150,114 @@ static bool DoItemAlwaysStart(const UString &name)
static HANDLE StartEditApplication(const UString &path, HWND window)
{
- CSysString command;
+ UString command;
ReadRegEditor(command);
if (command.IsEmpty())
{
if (!MyGetWindowsDirectory(command))
return 0;
NFile::NName::NormalizeDirPathPrefix(command);
- command += TEXT("notepad.exe");
+ command += L"notepad.exe";
}
- command = CSysString(TEXT("\"")) + command + CSysString(TEXT("\""));
- command += TEXT(" \"");
- command += GetSystemString(path);
- command += TEXT("\"");
-
- STARTUPINFO startupInfo;
- startupInfo.cb = sizeof(startupInfo);
- startupInfo.lpReserved = 0;
- startupInfo.lpDesktop = 0;
- startupInfo.lpTitle = 0;
- startupInfo.dwFlags = 0;
- startupInfo.cbReserved2 = 0;
- startupInfo.lpReserved2 = 0;
-
+ command = UString(L"\"") + command + UString(L"\"");
+ command += L" \"";
+ command += UString(path);
+ command += L"\"";
+
PROCESS_INFORMATION processInformation;
- BOOL result = ::CreateProcess(NULL, (TCHAR *)(const TCHAR *)command,
+ BOOL result;
+ #ifndef _UNICODE
+ if (!g_IsNT)
+ {
+ STARTUPINFOA startupInfo;
+ startupInfo.cb = sizeof(startupInfo);
+ startupInfo.lpReserved = 0;
+ startupInfo.lpDesktop = 0;
+ startupInfo.lpTitle = 0;
+ startupInfo.dwFlags = 0;
+ startupInfo.cbReserved2 = 0;
+ startupInfo.lpReserved2 = 0;
+
+ result = ::CreateProcessA(NULL, (CHAR *)(const CHAR *)GetSystemString(command),
+ NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation);
+ }
+ else
+ #endif
+ {
+ STARTUPINFOW startupInfo;
+ startupInfo.cb = sizeof(startupInfo);
+ startupInfo.lpReserved = 0;
+ startupInfo.lpDesktop = 0;
+ startupInfo.lpTitle = 0;
+ startupInfo.dwFlags = 0;
+ startupInfo.cbReserved2 = 0;
+ startupInfo.lpReserved2 = 0;
+
+ result = ::CreateProcessW(NULL, (WCHAR *)(const WCHAR *)command,
NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation);
+ }
+
if (result != FALSE)
{
::CloseHandle(processInformation.hThread);
return processInformation.hProcess;
}
- ::MessageBoxW(window, LangLoadStringW(IDS_CANNOT_START_EDITOR, 0x03020282),
+ ::MessageBoxW(window, LangString(IDS_CANNOT_START_EDITOR, 0x03020282),
L"7-Zip", MB_OK | MB_ICONSTOP);
return 0;
}
static HANDLE StartApplication(const UString &path, HWND window)
{
- SHELLEXECUTEINFO execInfo;
- execInfo.cbSize = sizeof(execInfo);
- execInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT;
- execInfo.hwnd = NULL;
- execInfo.lpVerb = NULL;
- const CSysString sysPath = GetSystemString(path);
- execInfo.lpFile = sysPath;
- execInfo.lpParameters = NULL;
- execInfo.lpDirectory = NULL;
- execInfo.nShow = SW_SHOWNORMAL;
- execInfo.hProcess = 0;
- bool success = BOOLToBool(::ShellExecuteEx(&execInfo));
- UINT32 result = (UINT32)execInfo.hInstApp;
+ UINT32 result;
+ HANDLE hProcess;
+ #ifndef _UNICODE
+ if (g_IsNT)
+ {
+ SHELLEXECUTEINFOW execInfo;
+ execInfo.cbSize = sizeof(execInfo);
+ execInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT;
+ execInfo.hwnd = NULL;
+ execInfo.lpVerb = NULL;
+ execInfo.lpFile = path;
+ execInfo.lpParameters = NULL;
+ execInfo.lpDirectory = NULL;
+ execInfo.nShow = SW_SHOWNORMAL;
+ execInfo.hProcess = 0;
+ ::ShellExecuteExW(&execInfo);
+ result = (UINT32)execInfo.hInstApp;
+ hProcess = execInfo.hProcess;
+ }
+ else
+ #endif
+ {
+ SHELLEXECUTEINFO execInfo;
+ execInfo.cbSize = sizeof(execInfo);
+ execInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT;
+ execInfo.hwnd = NULL;
+ execInfo.lpVerb = NULL;
+ const CSysString sysPath = GetSystemString(path);
+ execInfo.lpFile = sysPath;
+ execInfo.lpParameters = NULL;
+ execInfo.lpDirectory = NULL;
+ execInfo.nShow = SW_SHOWNORMAL;
+ execInfo.hProcess = 0;
+ ::ShellExecuteEx(&execInfo);
+ result = (UINT32)execInfo.hInstApp;
+ hProcess = execInfo.hProcess;
+ }
if(result <= 32)
{
switch(result)
{
case SE_ERR_NOASSOC:
- ::MessageBox(window,
- NError::MyFormatMessage(::GetLastError()),
- // TEXT("There is no application associated with the given file name extension"),
- TEXT("7-Zip"), MB_OK | MB_ICONSTOP);
+ ::MessageBoxW(window,
+ NError::MyFormatMessageW(::GetLastError()),
+ // L"There is no application associated with the given file name extension",
+ L"7-Zip", MB_OK | MB_ICONSTOP);
}
}
- return execInfo.hProcess;
+ return hProcess;
}
void CPanel::EditItem(int index)
@@ -268,7 +312,7 @@ LRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &item
CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
{
- MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return E_FAIL;
}
UStringVector fileNames;
@@ -342,7 +386,7 @@ static DWORD WINAPI MyThreadFunction(void *param)
if (SendMessage(tmpProcessInfo->Window, kOpenItemChanged, 0, (LONG_PTR)tmpProcessInfo) != 1)
{
::MessageBoxW(g_HWND, MyFormatNew(IDS_CANNOT_UPDATE_FILE,
- 0x03020281, GetUnicodeString(tmpProcessInfo->FilePath)), L"7-Zip", MB_OK | MB_ICONSTOP);
+ 0x03020281, tmpProcessInfo->FilePath), L"7-Zip", MB_OK | MB_ICONSTOP);
return 0;
}
}
@@ -365,7 +409,7 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal,
CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
{
- MessageBox(LangLoadStringW(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
return;
}
@@ -443,7 +487,7 @@ static bool CheckDeleteItem(UINT64 currentFileTime, UINT64 folderFileTime)
void DeleteOldTempFiles()
{
- CSysString tempPath;
+ UString tempPath;
if(!NFile::NDirectory::MyGetTempPath(tempPath))
throw 1;
@@ -452,10 +496,10 @@ void DeleteOldTempFiles()
UINT64 currentFileTime;
if(!::SystemTimeToFileTime(&systemTime, (FILETIME *)&currentFileTime))
throw 2;
- CSysString searchWildCard = tempPath + kTempDirPrefix + TEXT("*.tmp");
- searchWildCard += TCHAR(NName::kAnyStringWildcard);
- NFind::CEnumerator enumerator(searchWildCard);
- NFind::CFileInfo fileInfo;
+ UString searchWildCard = tempPath + kTempDirPrefix + L"*.tmp";
+ searchWildCard += WCHAR(NName::kAnyStringWildcard);
+ NFind::CEnumeratorW enumerator(searchWildCard);
+ NFind::CFileInfoW fileInfo;
while(enumerator.Next(fileInfo))
{
if (!fileInfo.IsDirectory())