diff options
author | Rob Mensching <rob@firegiant.com> | 2021-05-03 09:55:22 -0700 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2021-05-03 09:55:22 -0700 |
commit | ff659159e041bf6c083e6b7fcb9b726065a9dd73 (patch) | |
tree | ea95bf3d3e031edcee65de33b9e6954178be669c /src/ext/Util/be/UtilBundleExtension.cpp | |
parent | 8a8a25695351ee542f08886a9d0957c78c6af366 (diff) | |
download | wix-ff659159e041bf6c083e6b7fcb9b726065a9dd73.tar.gz wix-ff659159e041bf6c083e6b7fcb9b726065a9dd73.tar.bz2 wix-ff659159e041bf6c083e6b7fcb9b726065a9dd73.zip |
Move Util.wixext into ext
Diffstat (limited to 'src/ext/Util/be/UtilBundleExtension.cpp')
-rw-r--r-- | src/ext/Util/be/UtilBundleExtension.cpp | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/src/ext/Util/be/UtilBundleExtension.cpp b/src/ext/Util/be/UtilBundleExtension.cpp new file mode 100644 index 00000000..2ac842a5 --- /dev/null +++ b/src/ext/Util/be/UtilBundleExtension.cpp | |||
@@ -0,0 +1,87 @@ | |||
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 | #include "BextBaseBundleExtension.h" | ||
5 | |||
6 | class CWixUtilBundleExtension : public CBextBaseBundleExtension | ||
7 | { | ||
8 | public: // IBundleExtension | ||
9 | virtual STDMETHODIMP Search( | ||
10 | __in LPCWSTR wzId, | ||
11 | __in LPCWSTR wzVariable | ||
12 | ) | ||
13 | { | ||
14 | HRESULT hr = S_OK; | ||
15 | |||
16 | hr = UtilSearchExecute(&m_searches, wzId, wzVariable, m_pEngine); | ||
17 | |||
18 | return hr; | ||
19 | } | ||
20 | |||
21 | public: //CBextBaseBundleExtension | ||
22 | virtual STDMETHODIMP Initialize( | ||
23 | __in const BUNDLE_EXTENSION_CREATE_ARGS* pCreateArgs | ||
24 | ) | ||
25 | { | ||
26 | HRESULT hr = S_OK; | ||
27 | IXMLDOMDocument* pixdManifest = NULL; | ||
28 | IXMLDOMNode* pixnBundleExtension = NULL; | ||
29 | |||
30 | hr = CBextBaseBundleExtension::Initialize(pCreateArgs); | ||
31 | ExitOnFailure(hr, "CBextBaseBundleExtension initialization failed."); | ||
32 | |||
33 | hr = XmlLoadDocumentFromFile(m_sczBundleExtensionDataPath, &pixdManifest); | ||
34 | ExitOnFailure(hr, "Failed to load bundle extension manifest from path: %ls", m_sczBundleExtensionDataPath); | ||
35 | |||
36 | hr = BextGetBundleExtensionDataNode(pixdManifest, UTIL_BUNDLE_EXTENSION_ID, &pixnBundleExtension); | ||
37 | ExitOnFailure(hr, "Failed to get BundleExtension '%ls'", UTIL_BUNDLE_EXTENSION_ID); | ||
38 | |||
39 | hr = UtilSearchParseFromXml(&m_searches, pixnBundleExtension); | ||
40 | ExitOnFailure(hr, "Failed to parse searches from bundle extension manifest."); | ||
41 | |||
42 | LExit: | ||
43 | ReleaseObject(pixnBundleExtension); | ||
44 | ReleaseObject(pixdManifest); | ||
45 | |||
46 | return hr; | ||
47 | } | ||
48 | |||
49 | public: | ||
50 | CWixUtilBundleExtension( | ||
51 | __in IBundleExtensionEngine* pEngine | ||
52 | ) : CBextBaseBundleExtension(pEngine) | ||
53 | { | ||
54 | m_searches = { }; | ||
55 | } | ||
56 | |||
57 | ~CWixUtilBundleExtension() | ||
58 | { | ||
59 | UtilSearchUninitialize(&m_searches); | ||
60 | } | ||
61 | |||
62 | private: | ||
63 | UTIL_SEARCHES m_searches; | ||
64 | }; | ||
65 | |||
66 | HRESULT UtilBundleExtensionCreate( | ||
67 | __in IBundleExtensionEngine* pEngine, | ||
68 | __in const BUNDLE_EXTENSION_CREATE_ARGS* pArgs, | ||
69 | __out IBundleExtension** ppBundleExtension | ||
70 | ) | ||
71 | { | ||
72 | HRESULT hr = S_OK; | ||
73 | CWixUtilBundleExtension* pExtension = NULL; | ||
74 | |||
75 | pExtension = new CWixUtilBundleExtension(pEngine); | ||
76 | ExitOnNull(pExtension, hr, E_OUTOFMEMORY, "Failed to create new CWixUtilBundleExtension."); | ||
77 | |||
78 | hr = pExtension->Initialize(pArgs); | ||
79 | ExitOnFailure(hr, "CWixUtilBundleExtension initialization failed"); | ||
80 | |||
81 | *ppBundleExtension = pExtension; | ||
82 | pExtension = NULL; | ||
83 | |||
84 | LExit: | ||
85 | ReleaseObject(pExtension); | ||
86 | return hr; | ||
87 | } | ||