diff options
author | Igor Pavlov <ipavlov@users.sourceforge.net> | 2015-11-03 03:00:00 +0300 |
---|---|---|
committer | Kornel LesiĆski <kornel@geekhood.net> | 2016-05-28 02:16:57 +0300 |
commit | 7c8a265a15125b64808e695882acd2a0298ebce4 (patch) | |
tree | 81fc9fdedc6b70b979a3dfe3a3041457a6e9468d /CPP/7zip/UI/FileManager/PanelItemOpen.cpp | |
parent | a663a6deb7a150f935fac7efdbf4d53d27369594 (diff) |
15.1015.10
Diffstat (limited to 'CPP/7zip/UI/FileManager/PanelItemOpen.cpp')
-rw-r--r-- | CPP/7zip/UI/FileManager/PanelItemOpen.cpp | 89 |
1 files changed, 71 insertions, 18 deletions
diff --git a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp index 6658923f..a4ab254d 100644 --- a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp +++ b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp @@ -27,6 +27,8 @@ #include "RegistryUtils.h" #include "UpdateCallback100.h" +#include "../GUI/ExtractRes.h" + #include "resource.h" using namespace NWindows; @@ -182,7 +184,8 @@ public: } }; -HRESULT CPanel::OpenItemAsArchive(IInStream *inStream, + +HRESULT CPanel::OpenAsArc(IInStream *inStream, const CTempFileInfo &tempFileInfo, const UString &virtualFilePath, const UString &arcFormat, @@ -191,6 +194,7 @@ HRESULT CPanel::OpenItemAsArchive(IInStream *inStream, encrypted = false; CFolderLink folderLink; (CTempFileInfo &)folderLink = tempFileInfo; + if (inStream) folderLink.IsVirtual = true; else @@ -224,6 +228,7 @@ HRESULT CPanel::OpenItemAsArchive(IInStream *inStream, folderLink.ParentFolderPath = GetFolderPath(_folder); else folderLink.ParentFolderPath = _currentFolderPrefix; + if (!_parentFolders.IsEmpty()) folderLink.ParentFolder = _folder; @@ -240,6 +245,7 @@ HRESULT CPanel::OpenItemAsArchive(IInStream *inStream, CMyComPtr<IGetFolderArcProps> getFolderArcProps; _folder.QueryInterface(IID_IGetFolderArcProps, &getFolderArcProps); _thereAreDeletedItems = false; + if (getFolderArcProps) { CMyComPtr<IFolderArcProps> arcProps; @@ -304,22 +310,58 @@ HRESULT CPanel::OpenItemAsArchive(IInStream *inStream, return S_OK; } -HRESULT CPanel::OpenItemAsArchive(const UString &relPath, const UString &arcFormat, bool &encrypted) + +HRESULT CPanel::OpenAsArc_Msg(IInStream *inStream, + const CTempFileInfo &tempFileInfo, + const UString &virtualFilePath, + const UString &arcFormat, + bool &encrypted, + bool showErrorMessage) +{ + HRESULT res = OpenAsArc(inStream, tempFileInfo, virtualFilePath, arcFormat, encrypted); + + if (res == S_OK) + return res; + if (res == E_ABORT) + return res; + + if (showErrorMessage && encrypted) + { + UString message = L"Error"; + if (res == S_FALSE) + { + message = MyFormatNew( + encrypted ? + IDS_CANT_OPEN_ENCRYPTED_ARCHIVE : + IDS_CANT_OPEN_ARCHIVE, + virtualFilePath); + } + else + message = HResultToMessage(res); + MessageBoxMyError(message); + } + + return res; +} + + +HRESULT CPanel::OpenAsArc_Name(const UString &relPath, const UString &arcFormat, bool &encrypted, bool showErrorMessage) { CTempFileInfo tfi; tfi.RelPath = relPath; tfi.FolderPath = us2fs(GetFsPath()); const UString fullPath = GetFsPath() + relPath; tfi.FilePath = us2fs(fullPath); - return OpenItemAsArchive(NULL, tfi, fullPath, arcFormat, encrypted); + return OpenAsArc_Msg(NULL, tfi, fullPath, arcFormat, encrypted, showErrorMessage); } -HRESULT CPanel::OpenItemAsArchive(int index, const wchar_t *type) + +HRESULT CPanel::OpenAsArc_Index(int index, const wchar_t *type, bool showErrorMessage) { CDisableTimerProcessing disableTimerProcessing1(*this); CDisableNotify disableNotify(*this); bool encrypted; - HRESULT res = OpenItemAsArchive(GetItemRelPath2(index), type ? type : L"", encrypted); + HRESULT res = OpenAsArc_Name(GetItemRelPath2(index), type ? type : L"", encrypted, showErrorMessage); if (res != S_OK) { RefreshTitle(true); // in case of error we must refresh changed title of 7zFM @@ -329,6 +371,7 @@ HRESULT CPanel::OpenItemAsArchive(int index, const wchar_t *type) return S_OK; } + HRESULT CPanel::OpenParentArchiveFolder() { CDisableTimerProcessing disableTimerProcessing(*this); @@ -359,6 +402,7 @@ HRESULT CPanel::OpenParentArchiveFolder() return S_OK; } + static const char *kStartExtensions = #ifdef UNDER_CE " cab" @@ -668,6 +712,7 @@ bool CPanel::IsVirus_Message(const UString &name) return true; } + void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal, const wchar_t *type) { CDisableTimerProcessing disableTimerProcessing(*this); @@ -689,7 +734,7 @@ void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal, const wchar if (tryInternal) if (!tryExternal || !DoItemAlwaysStart(name)) { - HRESULT res = OpenItemAsArchive(index, type); + HRESULT res = OpenAsArc_Index(index, type, true); disableNotify.Restore(); // we must restore to allow text notification update InvalidateList(); if (res == S_OK || res == E_ABORT) @@ -1069,22 +1114,18 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo if (subStream) { bool encrypted; - HRESULT res = OpenItemAsArchive(subStream, tempFileInfo, fullVirtPath, type ? type : L"", encrypted); + HRESULT res = OpenAsArc_Msg(subStream, tempFileInfo, fullVirtPath, type ? type : L"", encrypted, true); if (res == S_OK) { tempDirectory.DisableDeleting(); RefreshListCtrl(); return; } - if (res == E_ABORT) + if (res == E_ABORT || res != S_FALSE) return; - if (res != S_FALSE) - { - // probably we must show some message here - // return; - } if (!tryExternal) return; + tryAsArchive = false; } } } @@ -1183,12 +1224,21 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo CMyComPtr<IInStream> bufInStream = bufInStreamSpec; bufInStreamSpec->Init(file.Data, streamSize, virtFileSystem); bool encrypted; - if (OpenItemAsArchive(bufInStream, tempFileInfo, fullVirtPath, type ? type : L"", encrypted) == S_OK) + + HRESULT res = OpenAsArc_Msg(bufInStream, tempFileInfo, fullVirtPath, type ? type : L"", encrypted, true); + if (res == S_OK) { tempDirectory.DisableDeleting(); RefreshListCtrl(); return; } + + if (res == E_ABORT || res != S_FALSE) + return; + if (!tryExternal) + return; + + tryAsArchive = false; if (virtFileSystemSpec->FlushToDisk(true) != S_OK) return; } @@ -1209,14 +1259,20 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo if (tryAsArchive) { bool encrypted; - if (OpenItemAsArchive(NULL, tempFileInfo, fullVirtPath, type ? type : L"", encrypted) == S_OK) + HRESULT res = OpenAsArc_Msg(NULL, tempFileInfo, fullVirtPath, type ? type : L"", encrypted, true); + if (res == S_OK) { tempDirectory.DisableDeleting(); RefreshListCtrl(); return; } + if (res == E_ABORT || res != S_FALSE) + return; } + if (!tryExternal) + return; + CMyAutoPtr<CTmpProcessInfo> tmpProcessInfoPtr(new CTmpProcessInfo()); CTmpProcessInfo *tpi = tmpProcessInfoPtr.get(); tpi->FolderPath = tempDir; @@ -1230,9 +1286,6 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo CTmpProcessInfoRelease tmpProcessInfoRelease(*tpi); - if (!tryExternal) - return; - CProcess process; // HRESULT res; if (editMode) |