main
cpp 50 lines 1.24 KB
Raw
1 // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3 #include "precomp.h"
4
5 static HRESULT ProgressCallback(__in BOOL fBeginFile, __in_z LPCWSTR wzFileId, __in_opt LPVOID pvContext);
6
7
8 HRESULT ExtractCabCommand(
9 __in int argc,
10 __in_ecount(argc) LPWSTR argv[]
11 )
12 {
13 HRESULT hr = E_INVALIDARG;
14 LPCWSTR wzCabPath = NULL;
15 LPCWSTR wzOutputFolder = NULL;
16
17 if (argc < 2)
18 {
19 ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Must specify: cabPath outputFolder");
20 }
21
22 wzCabPath = argv[0];
23 wzOutputFolder = argv[1];
24
25 hr = CabInitialize(FALSE);
26 ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "failed to initialize cabinet: %ls", wzCabPath);
27
28 hr = CabExtract(wzCabPath, L"*", wzOutputFolder, ProgressCallback, NULL, 0);
29 ExitOnFailure(hr, "failed to compress files into cabinet: %ls", wzCabPath);
30
31 LExit:
32 CabUninitialize();
33
34 return hr;
35 }
36
37
38 static HRESULT ProgressCallback(
39 __in BOOL fBeginFile,
40 __in_z LPCWSTR wzFileId,
41 __in_opt LPVOID /*pvContext*/
42 )
43 {
44 if (fBeginFile)
45 {
46 ConsoleWriteLine(CONSOLE_COLOR_NORMAL, "%ls", wzFileId);
47 }
48
49 return S_OK;
50 }