MCPcopy Create free account
hub / github.com/Norbyte/ositools / UnzipToFolder

Function UnzipToFolder

OsiLoader/Utils.cpp:194–236  ·  view source on GitHub ↗

Unzip a zip file to the specified folder.

Source from the content-addressed store, hash-verified

192// Unzip a zip file to the specified folder.
193//
194HRESULT UnzipToFolder(PCWSTR pszZipFile, PCWSTR pszDestFolder)
195{
196 CComScopedInit comInit;
197
198 HRESULT hr;
199
200 CComPtr<IShellDispatch> spISD;
201 hr = spISD.CoCreateInstance(CLSID_Shell);
202 if (FAILED(hr))
203 return hr;
204
205 CComVariant vtZipFile(pszZipFile);
206 CComPtr<Folder> spZipFile;
207 hr = spISD->NameSpace(vtZipFile, &spZipFile);
208 if (FAILED(hr))
209 return hr;
210
211 CComVariant vtDestFolder(pszDestFolder);
212 CComPtr<Folder> spDestination;
213 hr = spISD->NameSpace(vtDestFolder, &spDestination);
214 if (FAILED(hr))
215 return hr;
216 if (!spDestination)
217 return E_POINTER;
218
219 CComPtr<FolderItems> spFilesInside;
220 hr = spZipFile->Items(&spFilesInside);
221 if (FAILED(hr))
222 return hr;
223
224 CComPtr<IDispatch> spDispItem;
225 hr = spFilesInside.QueryInterface(&spDispItem);
226 if (FAILED(hr))
227 return hr;
228
229 CComVariant vtItem(spDispItem);
230 CComVariant vtOptions(FOF_NO_UI);
231 hr = spDestination->CopyHere(vtItem, vtOptions);
232 if (FAILED(hr))
233 return hr;
234
235 return S_OK;
236}

Callers 1

TryToUpdateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected