summaryrefslogtreecommitdiffstats
path: root/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp')
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp121
1 files changed, 121 insertions, 0 deletions
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp
new file mode 100644
index 000000000..98c75f4d9
--- /dev/null
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp
@@ -0,0 +1,121 @@
+// Zip/ArchiveFolder.cpp
+
+#include "StdAfx.h"
+
+#include "Agent.h"
+
+#include "Common/StringConvert.h"
+
+static inline UINT GetCurrentFileCodePage()
+ { return AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+
+void CArchiveFolderManager::LoadFormats()
+{
+ if (!_codecs)
+ {
+ _compressCodecsInfo = _codecs = new CCodecs;
+ _codecs->Load();
+ }
+}
+
+int CArchiveFolderManager::FindFormat(const UString &type)
+{
+ for (int i = 0; i < _codecs->Formats.Size(); i++)
+ if (type.CompareNoCase(_codecs->Formats[i].Name) == 0)
+ return i;
+ return -1;
+}
+
+STDMETHODIMP CArchiveFolderManager::OpenFolderFile(IInStream *inStream, 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(inStream, filePath, NULL, openArchiveCallback));
+ return agent->BindToRootFolder(resultFolder);
+}
+
+/*
+HRESULT CAgent::FolderReOpen(
+ IArchiveOpenCallback *openArchiveCallback)
+{
+ return ReOpenArchive(_archive, _archiveFilePath);
+}
+*/
+
+
+/*
+STDMETHODIMP CArchiveFolderManager::GetExtensions(const wchar_t *type, BSTR *extensions)
+{
+ *extensions = 0;
+ int formatIndex = FindFormat(type);
+ if (formatIndex < 0)
+ return E_INVALIDARG;
+ // Exts[0].Ext;
+ return StringToBstr(_codecs.Formats[formatIndex].GetAllExtensions(), extensions);
+}
+*/
+STDMETHODIMP CArchiveFolderManager::GetExtensions(BSTR *extensions)
+{
+ LoadFormats();
+ *extensions = 0;
+ UString res;
+ for (int i = 0; i < _codecs->Libs.Size(); i++)
+ {
+ const CCodecLib &lib = _codecs->Libs[i];
+ for (int j = 0; j < lib.IconPairs.Size(); j++)
+ {
+ if (!res.IsEmpty())
+ res += L' ';
+ res += lib.IconPairs[j].Ext;
+ }
+ }
+ return StringToBstr(res, extensions);
+}
+
+STDMETHODIMP CArchiveFolderManager::GetIconPath(const wchar_t *ext, BSTR *iconPath, Int32 *iconIndex)
+{
+ LoadFormats();
+ *iconPath = 0;
+ *iconIndex = 0;
+ for (int i = 0; i < _codecs->Libs.Size(); i++)
+ {
+ const CCodecLib &lib = _codecs->Libs[i];
+ int ii = lib.FindIconIndex(ext);
+ if (ii >= 0)
+ {
+ *iconIndex = ii;
+ return StringToBstr(GetUnicodeString(lib.Path, GetCurrentFileCodePage()), iconPath);
+ }
+ }
+ return S_OK;
+}
+
+/*
+STDMETHODIMP CArchiveFolderManager::GetTypes(BSTR *types)
+{
+ LoadFormats();
+ UString typesStrings;
+ for(int i = 0; i < _codecs.Formats.Size(); i++)
+ {
+ const CArcInfoEx &ai = _codecs.Formats[i];
+ if (ai.AssociateExts.Size() == 0)
+ continue;
+ if (i != 0)
+ typesStrings += L' ';
+ typesStrings += ai.Name;
+ }
+ return StringToBstr(typesStrings, types);
+}
+STDMETHODIMP CArchiveFolderManager::CreateFolderFile(const wchar_t * type,
+ const wchar_t * filePath, IProgress progress)
+{
+ return E_NOTIMPL;
+}
+*/