blob: ce4239418f8deedd5749f3c8b45998476f1f2a24 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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;
}
|