-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInMemoryExtractCallback.cpp
69 lines (54 loc) · 1.71 KB
/
InMemoryExtractCallback.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
#include "InMemoryExtractCallback.h"
#include <boost/nowide/convert.hpp>
#include "InMemoryOutStream.h"
#include "fmt/core.h"
InMemoryArchiveExtractCallback::InMemoryArchiveExtractCallback() = default;
InMemoryArchiveExtractCallback::InMemoryArchiveExtractCallback(std::u8string Password) : Password(Password)
{}
InMemoryArchiveExtractCallback::~InMemoryArchiveExtractCallback() = default;
Z7_COM7F_IMF(InMemoryArchiveExtractCallback::SetTotal(UInt64 /* size */))
{
return S_OK;
}
Z7_COM7F_IMF(InMemoryArchiveExtractCallback::SetCompleted(const UInt64* /* completeValue */))
{
return S_OK;
}
Z7_COM7F_IMF(InMemoryArchiveExtractCallback::GetStream(UInt32 index,
ISequentialOutStream** outStream, Int32 askExtractMode))
{
if (askExtractMode != NArchive::NExtract::NAskMode::kExtract)
{
*outStream = nullptr;
return S_OK;
}
OutStream.Release();
OutStream = new InMemoryOutStream(Buffer);
Index = index;
*outStream = OutStream.Detach();
return S_OK;
}
Z7_COM7F_IMF(InMemoryArchiveExtractCallback::PrepareOperation(Int32 askExtractMode))
{
return S_OK;
}
Z7_COM7F_IMF(InMemoryArchiveExtractCallback::SetOperationResult(Int32 operationResult))
{
if (operationResult != NArchive::NExtract::NOperationResult::kOK)
{
fmt::print("SetOperationResult reported an error. Operation result: {}\n", operationResult);
return S_OK;
}
if (!Buffer.empty())
{
fmt::print("\nBinary content of item at index {}:\n{}\n", Index, std::string_view((const char*)Buffer.data(), Buffer.size()));
Buffer.clear();
}
return S_OK;
}
Z7_COM7F_IMF(InMemoryArchiveExtractCallback::CryptoGetTextPassword(BSTR* password))
{
if (!Password)
return E_ABORT;
return StringToBstr(boost::nowide::widen(Password.value()).c_str(), password);
}