-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArchiveProperties.cpp
94 lines (77 loc) · 2.29 KB
/
ArchiveProperties.cpp
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
#include "ArchiveProperties.h"
#include <algorithm>
#include <7zip/Archive/IArchive.h>
#include "boost/nowide/convert.hpp"
void Archive7zProperties::applyProperties(IUnknown* Archive)
{
CMyComPtr<ISetProperties> SetProperties = [&]
{
void* Interface{};
Archive->QueryInterface(IID_ISetProperties, &Interface);
return static_cast<ISetProperties*>(Interface);
}();
std::vector<const wchar_t*> PropKeys(Properties.size());
std::ranges::transform(Properties, PropKeys.begin(), &std::wstring::c_str);
SetProperties->SetProperties(PropKeys.data(), Values.data(), PropKeys.size());
}
Archive7zProperties& Archive7zProperties::set(CompressHeaders Value)
{
return set(L"hc", Value.Value);
}
Archive7zProperties& Archive7zProperties::set(CompressHeadersFull Value)
{
return set(L"hcf", Value.Value);
}
Archive7zProperties& Archive7zProperties::set(EncryptHeaders Value)
{
return set(L"he", Value.Value);
}
Archive7zProperties& Archive7zProperties::set(Level Value)
{
return set(L"x", Value.Value);
}
Archive7zProperties& Archive7zProperties::set(NumberOfThreads Value)
{
return set(L"mt", Value.Value);
}
Archive7zProperties& Archive7zProperties::set(HashSize Value)
{
return set(L"crc", Value.Value);
}
Archive7zProperties& Archive7zProperties::set(Solid Value)
{
return set(L"s", Value.Value);
}
Archive7zProperties& Archive7zProperties::set(SolidOptions Value)
{
set(L"s", boost::nowide::widen(Value.Value));
return *this;
}
PROPVARIANT& Archive7zProperties::emplace_back(std::wstring_view Name)
{
Properties.emplace_back(Name);
auto& PropValue = Values.emplace_back();
PropVariantClear(&PropValue);
return PropValue;
}
Archive7zProperties& Archive7zProperties::set(std::wstring_view Name, bool Value)
{
auto& PropValue = emplace_back(Name);
PropValue.vt = VT_BOOL;
PropValue.boolVal = Value ? VARIANT_TRUE : VARIANT_FALSE;
return *this;
}
Archive7zProperties& Archive7zProperties::set(std::wstring_view Name, std::uint32_t Value)
{
auto& PropValue = emplace_back(Name);
PropValue.vt = VT_UI4;
PropValue.ulVal = Value;
return *this;
}
Archive7zProperties& Archive7zProperties::set(std::wstring_view Name, std::wstring_view Value)
{
auto& PropValue = emplace_back(Name);
PropValue.vt = VT_BSTR;
PropValue.bstrVal = ::SysAllocStringLen(Value.data(), static_cast<UINT>(Value.size()));
return *this;
}