Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: third_party/lzma/v4_65/files/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // ArchiveOpenCallback.cpp
2
3 #include "StdAfx.h"
4
5 #include "ArchiveOpenCallback.h"
6
7 #include "Common/StringConvert.h"
8 #include "Common/ComTry.h"
9 #include "Windows/PropVariant.h"
10
11 #include "../../Common/FileStreams.h"
12
13 using namespace NWindows;
14
15 STDMETHODIMP COpenCallbackImp::SetTotal(const UInt64 *files, const UInt64 *bytes )
16 {
17 COM_TRY_BEGIN
18 if (ReOpenCallback)
19 return ReOpenCallback->SetTotal(files, bytes);
20 if (!Callback)
21 return S_OK;
22 return Callback->Open_SetTotal(files, bytes);
23 COM_TRY_END
24 }
25
26 STDMETHODIMP COpenCallbackImp::SetCompleted(const UInt64 *files, const UInt64 *b ytes)
27 {
28 COM_TRY_BEGIN
29 if (ReOpenCallback)
30 return ReOpenCallback->SetCompleted(files, bytes);
31 if (!Callback)
32 return S_OK;
33 return Callback->Open_SetCompleted(files, bytes);
34 COM_TRY_END
35 }
36
37 STDMETHODIMP COpenCallbackImp::GetProperty(PROPID propID, PROPVARIANT *value)
38 {
39 COM_TRY_BEGIN
40 NCOM::CPropVariant prop;
41 if (_subArchiveMode)
42 switch(propID)
43 {
44 case kpidName: prop = _subArchiveName; break;
45 }
46 else
47 switch(propID)
48 {
49 case kpidName: prop = _fileInfo.Name; break;
50 case kpidIsDir: prop = _fileInfo.IsDir(); break;
51 case kpidSize: prop = _fileInfo.Size; break;
52 case kpidAttrib: prop = (UInt32)_fileInfo.Attrib; break;
53 case kpidCTime: prop = _fileInfo.CTime; break;
54 case kpidATime: prop = _fileInfo.ATime; break;
55 case kpidMTime: prop = _fileInfo.MTime; break;
56 }
57 prop.Detach(value);
58 return S_OK;
59 COM_TRY_END
60 }
61
62 int COpenCallbackImp::FindName(const UString &name)
63 {
64 for (int i = 0; i < FileNames.Size(); i++)
65 if (name.CompareNoCase(FileNames[i]) == 0)
66 return i;
67 return -1;
68 }
69
70 struct CInFileStreamVol: public CInFileStream
71 {
72 UString Name;
73 COpenCallbackImp *OpenCallbackImp;
74 CMyComPtr<IArchiveOpenCallback> OpenCallbackRef;
75 ~CInFileStreamVol()
76 {
77 int index = OpenCallbackImp->FindName(Name);
78 if (index >= 0)
79 OpenCallbackImp->FileNames.Delete(index);
80 }
81 };
82
83 STDMETHODIMP COpenCallbackImp::GetStream(const wchar_t *name, IInStream **inStre am)
84 {
85 COM_TRY_BEGIN
86 if (_subArchiveMode)
87 return S_FALSE;
88 if (Callback)
89 {
90 RINOK(Callback->Open_CheckBreak());
91 }
92 *inStream = NULL;
93 UString fullPath = _folderPrefix + name;
94 if (!NFile::NFind::FindFile(fullPath, _fileInfo))
95 return S_FALSE;
96 if (_fileInfo.IsDir())
97 return S_FALSE;
98 CInFileStreamVol *inFile = new CInFileStreamVol;
99 CMyComPtr<IInStream> inStreamTemp = inFile;
100 if (!inFile->Open(fullPath))
101 return ::GetLastError();
102 *inStream = inStreamTemp.Detach();
103 inFile->Name = name;
104 inFile->OpenCallbackImp = this;
105 inFile->OpenCallbackRef = this;
106 FileNames.Add(name);
107 TotalSize += _fileInfo.Size;
108 return S_OK;
109 COM_TRY_END
110 }
111
112 #ifndef _NO_CRYPTO
113 STDMETHODIMP COpenCallbackImp::CryptoGetTextPassword(BSTR *password)
114 {
115 COM_TRY_BEGIN
116 if (ReOpenCallback)
117 {
118 CMyComPtr<ICryptoGetTextPassword> getTextPassword;
119 ReOpenCallback.QueryInterface(IID_ICryptoGetTextPassword, &getTextPassword);
120 if (getTextPassword)
121 return getTextPassword->CryptoGetTextPassword(password);
122 }
123 if (!Callback)
124 return E_NOTIMPL;
125 return Callback->Open_CryptoGetTextPassword(password);
126 COM_TRY_END
127 }
128 #endif
129
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698