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/Agent/ArchiveFolderOpen.cpp')
-rwxr-xr-xCPP/7zip/UI/Agent/ArchiveFolderOpen.cpp98
1 files changed, 98 insertions, 0 deletions
diff --git a/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp b/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp
new file mode 100755
index 00000000..ce423941
--- /dev/null
+++ b/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp
@@ -0,0 +1,98 @@
+// Zip/ArchiveFolder.cpp
+
+#include "StdAfx.h"
+
+#include "Agent.h"
+
+#include "Common/StringConvert.h"
+
+#include "../Common/OpenArchive.h"
+
+static const UInt64 kMaxCheckStartPosition = 1 << 20;
+
+static inline UINT GetCurrentFileCodePage()
+ { return AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+
+void CArchiveFolderManager::LoadFormats()
+{
+ if (!_formatsLoaded)
+ ReadArchiverInfoList(_formats);
+}
+
+int CArchiveFolderManager::FindFormat(const UString &type)
+{
+ // LoadFormats();
+ for (int i = 0; i < _formats.Size(); i++)
+ if (type.CompareNoCase(_formats[i].Name) == 0)
+ return i;
+ return -1;
+}
+
+STDMETHODIMP CArchiveFolderManager::OpenFolderFile(const wchar_t *filePath,
+ IFolderFolder **resultFolder, IProgress *progress)
+{
+ CMyComPtr<IArchiveOpenCallback> openArchiveCallback;
+ if (progress != 0)
+ {
+ CMyComPtr<IProgress> progressWrapper = progress;
+ progressWrapper.QueryInterface(IID_IArchiveOpenCallback, &openArchiveCallback);
+ }
+ CAgent *agent = new CAgent();
+ CMyComPtr<IInFolderArchive> archive = agent;
+ RINOK(agent->Open(filePath, NULL, openArchiveCallback));
+ return agent->BindToRootFolder(resultFolder);
+}
+
+/*
+HRESULT CAgent::FolderReOpen(
+ IArchiveOpenCallback *openArchiveCallback)
+{
+ return ReOpenArchive(_archive, _archiveFilePath);
+}
+*/
+
+STDMETHODIMP CArchiveFolderManager::GetTypes(BSTR *types)
+{
+ LoadFormats();
+ UString typesStrings;
+ for(int i = 0; i < _formats.Size(); i++)
+ {
+ const CArchiverInfo &ai = _formats[i];
+ if (!ai.Associate)
+ continue;
+ if (i != 0)
+ typesStrings += L' ';
+ typesStrings += ai.Name;
+ }
+ CMyComBSTR valueTemp = typesStrings;
+ *types = valueTemp.Detach();
+ return S_OK;
+}
+
+STDMETHODIMP CArchiveFolderManager::GetExtension(const wchar_t *type, BSTR *extension)
+{
+ *extension = 0;
+ int formatIndex = FindFormat(type);
+ if (formatIndex < 0)
+ return E_INVALIDARG;
+ CMyComBSTR valueTemp = _formats[formatIndex].Extensions[0].Ext;
+ *extension = valueTemp.Detach();
+ return S_OK;
+}
+
+STDMETHODIMP CArchiveFolderManager::GetIconPath(const wchar_t *type, BSTR *iconPath)
+{
+ *iconPath = 0;
+ int formatIndex = FindFormat(type);
+ if (formatIndex < 0)
+ return E_INVALIDARG;
+ CMyComBSTR iconPathTemp = _formats[formatIndex].FilePath;
+ *iconPath = iconPathTemp.Detach();
+ return S_OK;
+}
+
+STDMETHODIMP CArchiveFolderManager::CreateFolderFile(const wchar_t * /* type */,
+ const wchar_t * /* filePath */, IProgress * /* progress */)
+{
+ return E_NOTIMPL;
+}