blob: 331b171bc4e68acd459681c5e29f234831b4c00a (
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
// OpenCallback.cpp
#include "StdAfx.h"
#include "../../../Common/ComTry.h"
#include "../../../Common/StringConvert.h"
#include "../../../Windows/FileName.h"
#include "../../../Windows/PropVariant.h"
#include "../../Common/FileStreams.h"
#include "../Common/ZipRegistry.h"
#include "OpenCallback.h"
#include "PasswordDialog.h"
using namespace NWindows;
STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 *numFiles, const UInt64 *numBytes)
{
RINOK(ProgressDialog.Sync.CheckStop());
{
// NSynchronization::CCriticalSectionLock lock(_criticalSection);
if (numFiles)
{
ProgressDialog.Sync.Set_NumFilesTotal(*numFiles);
ProgressDialog.Sync.Set_BytesProgressMode(false);
}
if (numBytes)
ProgressDialog.Sync.Set_NumBytesTotal(*numBytes);
}
return S_OK;
}
STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *numFiles, const UInt64 *numBytes)
{
// NSynchronization::CCriticalSectionLock lock(_criticalSection);
if (numFiles)
ProgressDialog.Sync.Set_NumFilesCur(*numFiles);
if (numBytes)
ProgressDialog.Sync.Set_NumBytesCur(*numBytes);
return ProgressDialog.Sync.CheckStop();
}
STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 total)
{
RINOK(ProgressDialog.Sync.CheckStop());
ProgressDialog.Sync.Set_NumBytesTotal(total);
return S_OK;
}
STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *completed)
{
return ProgressDialog.Sync.Set_NumBytesCur(completed);
}
STDMETHODIMP COpenArchiveCallback::GetProperty(PROPID propID, PROPVARIANT *value)
{
NCOM::CPropVariant prop;
if (_subArchiveMode)
{
switch (propID)
{
case kpidName: prop = _subArchiveName; break;
}
}
else
{
switch (propID)
{
case kpidName: prop = _fileInfo.Name; break;
case kpidIsDir: prop = _fileInfo.IsDir(); break;
case kpidSize: prop = _fileInfo.Size; break;
case kpidAttrib: prop = (UInt32)_fileInfo.Attrib; break;
case kpidCTime: prop = _fileInfo.CTime; break;
case kpidATime: prop = _fileInfo.ATime; break;
case kpidMTime: prop = _fileInfo.MTime; break;
}
}
prop.Detach(value);
return S_OK;
}
STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name, IInStream **inStream)
{
COM_TRY_BEGIN
*inStream = NULL;
if (_subArchiveMode)
return S_FALSE;
FString fullPath;
if (!NFile::NName::GetFullPath(_folderPrefix, us2fs(name), fullPath))
return S_FALSE;
if (!_fileInfo.Find(fullPath))
return S_FALSE;
if (_fileInfo.IsDir())
return S_FALSE;
CInFileStream *inFile = new CInFileStream;
CMyComPtr<IInStream> inStreamTemp = inFile;
if (!inFile->Open(fullPath))
return ::GetLastError();
*inStream = inStreamTemp.Detach();
return S_OK;
COM_TRY_END
}
STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password)
{
COM_TRY_BEGIN
PasswordWasAsked = true;
if (!PasswordIsDefined)
{
CPasswordDialog dialog;
bool showPassword = NExtract::Read_ShowPassword();
dialog.ShowPassword = showPassword;
ProgressDialog.WaitCreating();
if (dialog.Create(ProgressDialog) != IDOK)
return E_ABORT;
Password = dialog.Password;
PasswordIsDefined = true;
if (dialog.ShowPassword != showPassword)
NExtract::Save_ShowPassword(dialog.ShowPassword);
}
return StringToBstr(Password, password);
COM_TRY_END
}
|