From ea3d18595a610ee07b03f07af4f03cf75b5ab420 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 29 Nov 2017 14:08:08 -0800 Subject: Improved cabinet handling --- src/wixnative/extractcab.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/wixnative/extractcab.cpp (limited to 'src/wixnative/extractcab.cpp') diff --git a/src/wixnative/extractcab.cpp b/src/wixnative/extractcab.cpp new file mode 100644 index 00000000..53f53266 --- /dev/null +++ b/src/wixnative/extractcab.cpp @@ -0,0 +1,50 @@ +// 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. + +#include "precomp.h" + +static HRESULT ProgressCallback(BOOL fBeginFile, LPCWSTR wzFileId, LPVOID pvContext); + + +HRESULT ExtractCabCommand( + __in int argc, + __in LPWSTR argv[] +) +{ + HRESULT hr = E_INVALIDARG; + LPCWSTR wzCabPath = NULL; + LPCWSTR wzOutputFolder = NULL; + + if (argc < 2) + { + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Must specify: cabPath outputFolder"); + } + + wzCabPath = argv[0]; + wzOutputFolder = argv[1]; + + hr = CabInitialize(FALSE); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "failed to initialize cabinet: %ls", wzCabPath); + + hr = CabExtract(wzCabPath, L"*", wzOutputFolder, ProgressCallback, NULL, 0); + ExitOnFailure(hr, "failed to compress files into cabinet: %ls", wzCabPath); + +LExit: + CabUninitialize(); + + return hr; +} + + +static HRESULT ProgressCallback( + __in BOOL fBeginFile, + __in LPCWSTR wzFileId, + __in LPVOID /*pvContext*/ +) +{ + if (fBeginFile) + { + ConsoleWriteLine(CONSOLE_COLOR_NORMAL, "%ls", wzFileId); + } + + return S_OK; +} -- cgit v1.2.3-55-g6feb