diff options
Diffstat (limited to 'src/libs/dutil')
-rw-r--r-- | src/libs/dutil/README.md | 32 | ||||
-rw-r--r-- | src/libs/dutil/WixToolset.DUtil/dutil.nuspec | 10 | ||||
-rw-r--r-- | src/libs/dutil/test/DUtilUnitTest/DUtilUnitTest.vcxproj | 3 | ||||
-rw-r--r-- | src/libs/dutil/test/DUtilUnitTest/LocControlsUtilTests.cpp | 81 | ||||
-rw-r--r-- | src/libs/dutil/test/DUtilUnitTest/LocStringsUtilTests.cpp (renamed from src/libs/dutil/test/DUtilUnitTest/LocUtilTests.cpp) | 71 | ||||
-rw-r--r-- | src/libs/dutil/test/DUtilUnitTest/PathUtilTest.cpp | 76 |
6 files changed, 166 insertions, 107 deletions
diff --git a/src/libs/dutil/README.md b/src/libs/dutil/README.md index 2d6605fe..ffc0aacd 100644 --- a/src/libs/dutil/README.md +++ b/src/libs/dutil/README.md | |||
@@ -1,2 +1,30 @@ | |||
1 | # dutil | 1 | # WixToolset.DUtil (dutil.lib) - foundation library for all native code in WiX Toolset |
2 | dutil.lib - foundation library for all native code in WiX Toolset | 2 | |
3 | The `WixToolset.DUtil` package provides native code utility functions used throughout the WiX Toolset. | ||
4 | |||
5 | [Web Site][web] | [Documentation][docs] | [Issue Tracker][issues] | [Discussions][discussions] | ||
6 | |||
7 | |||
8 | ## Open Source Maintenance Fee | ||
9 | |||
10 | To ensure the long-term sustainability of this project, users of this package who generate revenue must pay an [Open Source Maintenance Fee][osmf]. While the source code is freely available under the terms of the [LICENSE][license], this package and other aspects of the project require [adherence to the Open Source Maintenance Fee EULA][eula]. | ||
11 | |||
12 | To pay the Maintenance Fee, [become a Sponsor](https://github.com/sponsors/wixtoolset). | ||
13 | |||
14 | |||
15 | ## Additional resources | ||
16 | |||
17 | * [WiX Website][web] | ||
18 | * [WiX Documentation][docs] | ||
19 | * [WiX Issue Tracker][issues] | ||
20 | * [WiX Discussions][discussions] | ||
21 | |||
22 | |||
23 | [web]: https://www.firegiant.com/wixtoolset/ | ||
24 | [docs]: https://docs.firegiant.com/wixtoolset/ | ||
25 | [issues]: https://github.com/wixtoolset/issues/issues | ||
26 | [discussions]: https://github.com/orgs/wixtoolset/discussions | ||
27 | [sdk]: https://www.nuget.org/packages/WixToolset.Sdk/ | ||
28 | [osmf]: https://opensourcemaintenancefee.org/ | ||
29 | [license]: https://github.com/wixtoolset/wix/blob/main/LICENSE.TXT | ||
30 | [eula]: https://github.com/wixtoolset/wix/blob/main/OSMFEULA.txt | ||
diff --git a/src/libs/dutil/WixToolset.DUtil/dutil.nuspec b/src/libs/dutil/WixToolset.DUtil/dutil.nuspec index a87da122..5c4634e4 100644 --- a/src/libs/dutil/WixToolset.DUtil/dutil.nuspec +++ b/src/libs/dutil/WixToolset.DUtil/dutil.nuspec | |||
@@ -6,17 +6,19 @@ | |||
6 | <title>$title$</title> | 6 | <title>$title$</title> |
7 | <description>$description$</description> | 7 | <description>$description$</description> |
8 | <authors>$authors$</authors> | 8 | <authors>$authors$</authors> |
9 | <icon>wix.png</icon> | 9 | <icon>icon.png</icon> |
10 | <license type="expression">MS-RL</license> | 10 | <license type="file">OSMFEULA.txt</license> |
11 | <requireLicenseAcceptance>false</requireLicenseAcceptance> | 11 | <requireLicenseAcceptance>true</requireLicenseAcceptance> |
12 | <tags>$packageTags$</tags> | ||
12 | <copyright>$copyright$</copyright> | 13 | <copyright>$copyright$</copyright> |
13 | <projectUrl>$projectUrl$</projectUrl> | 14 | <projectUrl>$projectUrl$</projectUrl> |
14 | <repository type="$repositorytype$" url="$repositoryurl$" commit="$repositorycommit$" /> | 15 | <repository type="$repositorytype$" url="$repositoryurl$" commit="$repositorycommit$" /> |
15 | </metadata> | 16 | </metadata> |
16 | 17 | ||
17 | <files> | 18 | <files> |
19 | <file src="$eulaTxt$" /> | ||
20 | <file src="$iconPng$" /> | ||
18 | <file src="$projectFolder$\build\$id$.props" target="build\" /> | 21 | <file src="$projectFolder$\build\$id$.props" target="build\" /> |
19 | <file src="$projectFolder$\..\..\..\internal\images\wix.png" /> | ||
20 | <file src="$projectFolder$\inc\*" target="build\native\include" /> | 22 | <file src="$projectFolder$\inc\*" target="build\native\include" /> |
21 | <file src="..\..\v143\x64\dutil.lib" target="build\native\v14\x64" /> | 23 | <file src="..\..\v143\x64\dutil.lib" target="build\native\v14\x64" /> |
22 | <file src="..\..\v143\x86\dutil.lib" target="build\native\v14\x86" /> | 24 | <file src="..\..\v143\x86\dutil.lib" target="build\native\v14\x86" /> |
diff --git a/src/libs/dutil/test/DUtilUnitTest/DUtilUnitTest.vcxproj b/src/libs/dutil/test/DUtilUnitTest/DUtilUnitTest.vcxproj index 94826b8f..fccb73c4 100644 --- a/src/libs/dutil/test/DUtilUnitTest/DUtilUnitTest.vcxproj +++ b/src/libs/dutil/test/DUtilUnitTest/DUtilUnitTest.vcxproj | |||
@@ -55,7 +55,8 @@ | |||
55 | <ClCompile Include="FileUtilTest.cpp" /> | 55 | <ClCompile Include="FileUtilTest.cpp" /> |
56 | <ClCompile Include="GuidUtilTest.cpp" /> | 56 | <ClCompile Include="GuidUtilTest.cpp" /> |
57 | <ClCompile Include="IniUtilTest.cpp" /> | 57 | <ClCompile Include="IniUtilTest.cpp" /> |
58 | <ClCompile Include="LocUtilTests.cpp" /> | 58 | <ClCompile Include="LocControlsUtilTests.cpp" /> |
59 | <ClCompile Include="LocStringsUtilTests.cpp" /> | ||
59 | <ClCompile Include="MemUtilTest.cpp" /> | 60 | <ClCompile Include="MemUtilTest.cpp" /> |
60 | <ClCompile Include="MonUtilTest.cpp" /> | 61 | <ClCompile Include="MonUtilTest.cpp" /> |
61 | <ClCompile Include="PathUtilTest.cpp" /> | 62 | <ClCompile Include="PathUtilTest.cpp" /> |
diff --git a/src/libs/dutil/test/DUtilUnitTest/LocControlsUtilTests.cpp b/src/libs/dutil/test/DUtilUnitTest/LocControlsUtilTests.cpp new file mode 100644 index 00000000..fd8679cb --- /dev/null +++ b/src/libs/dutil/test/DUtilUnitTest/LocControlsUtilTests.cpp | |||
@@ -0,0 +1,81 @@ | |||
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 | using namespace System; | ||
6 | using namespace Xunit; | ||
7 | using namespace WixInternal::TestSupport; | ||
8 | |||
9 | namespace DutilTests | ||
10 | { | ||
11 | public ref class LocControlsUtil | ||
12 | { | ||
13 | public: | ||
14 | [Fact] | ||
15 | void CanLoadControlsWxl() | ||
16 | { | ||
17 | HRESULT hr = S_OK; | ||
18 | DWORD dwRetry = 0; | ||
19 | WIX_LOCALIZATION* pLoc = NULL; | ||
20 | LOC_CONTROL* pLocControl = NULL; | ||
21 | |||
22 | DutilInitialize(&DutilTestTraceError); | ||
23 | |||
24 | try | ||
25 | { | ||
26 | hr = XmlInitialize(); | ||
27 | NativeAssert::Succeeded(hr, "Failed to initialize Xml."); | ||
28 | |||
29 | pin_ptr<const wchar_t> wxlFilePath = PtrToStringChars(TestData::Get("TestData", "LocUtilTests", "controls.wxl")); | ||
30 | do | ||
31 | { | ||
32 | if (FAILED(hr)) | ||
33 | { | ||
34 | ::Sleep(500); | ||
35 | } | ||
36 | |||
37 | hr = LocLoadFromFile(wxlFilePath, &pLoc); | ||
38 | } while (FAILED(hr) && ++dwRetry < 5); | ||
39 | NativeAssert::Succeeded(hr, "Failed to parse controls.wxl: {0}", wxlFilePath); | ||
40 | |||
41 | Assert::Equal(3ul, pLoc->cLocControls); | ||
42 | |||
43 | hr = LocGetControl(pLoc, L"Control1", &pLocControl); | ||
44 | NativeAssert::Succeeded(hr, "Failed to get loc control 'Control1' from: {0}", wxlFilePath); | ||
45 | NativeAssert::StringEqual(L"Control1", pLocControl->wzControl); | ||
46 | NativeAssert::Equal(1, pLocControl->nX); | ||
47 | NativeAssert::Equal(2, pLocControl->nY); | ||
48 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nWidth); | ||
49 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nHeight); | ||
50 | NativeAssert::StringEqual(L"This is control #1", pLocControl->wzText); | ||
51 | |||
52 | hr = LocGetControl(pLoc, L"Control2", &pLocControl); | ||
53 | NativeAssert::Succeeded(hr, "Failed to get loc control 'Control2' from: {0}", wxlFilePath); | ||
54 | NativeAssert::StringEqual(L"Control2", pLocControl->wzControl); | ||
55 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nX); | ||
56 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nY); | ||
57 | NativeAssert::Equal(50, pLocControl->nWidth); | ||
58 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nHeight); | ||
59 | NativeAssert::StringEqual(L"This is control #2", pLocControl->wzText); | ||
60 | |||
61 | hr = LocGetControl(pLoc, L"Control3", &pLocControl); | ||
62 | NativeAssert::Succeeded(hr, "Failed to get loc control 'Control3' from: {0}", wxlFilePath); | ||
63 | NativeAssert::StringEqual(L"Control3", pLocControl->wzControl); | ||
64 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nX); | ||
65 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nY); | ||
66 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nWidth); | ||
67 | NativeAssert::Equal(150, pLocControl->nHeight); | ||
68 | NativeAssert::StringEqual(L"", pLocControl->wzText); | ||
69 | } | ||
70 | finally | ||
71 | { | ||
72 | if (pLoc) | ||
73 | { | ||
74 | LocFree(pLoc); | ||
75 | } | ||
76 | |||
77 | DutilUninitialize(); | ||
78 | } | ||
79 | } | ||
80 | }; | ||
81 | } | ||
diff --git a/src/libs/dutil/test/DUtilUnitTest/LocUtilTests.cpp b/src/libs/dutil/test/DUtilUnitTest/LocStringsUtilTests.cpp index 0376a340..04130098 100644 --- a/src/libs/dutil/test/DUtilUnitTest/LocUtilTests.cpp +++ b/src/libs/dutil/test/DUtilUnitTest/LocStringsUtilTests.cpp | |||
@@ -8,13 +8,14 @@ using namespace WixInternal::TestSupport; | |||
8 | 8 | ||
9 | namespace DutilTests | 9 | namespace DutilTests |
10 | { | 10 | { |
11 | public ref class LocUtil | 11 | public ref class LocStringsUtil |
12 | { | 12 | { |
13 | public: | 13 | public: |
14 | [Fact] | 14 | [Fact] |
15 | void CanLoadStringsWxl() | 15 | void CanLoadStringsWxl() |
16 | { | 16 | { |
17 | HRESULT hr = S_OK; | 17 | HRESULT hr = S_OK; |
18 | DWORD dwRetry = 0; | ||
18 | WIX_LOCALIZATION* pLoc = NULL; | 19 | WIX_LOCALIZATION* pLoc = NULL; |
19 | LOC_STRING* pLocString = NULL; | 20 | LOC_STRING* pLocString = NULL; |
20 | LPWSTR sczValue = NULL; | 21 | LPWSTR sczValue = NULL; |
@@ -27,7 +28,15 @@ namespace DutilTests | |||
27 | NativeAssert::Succeeded(hr, "Failed to initialize Xml."); | 28 | NativeAssert::Succeeded(hr, "Failed to initialize Xml."); |
28 | 29 | ||
29 | pin_ptr<const wchar_t> wxlFilePath = PtrToStringChars(TestData::Get("TestData", "LocUtilTests", "strings.wxl")); | 30 | pin_ptr<const wchar_t> wxlFilePath = PtrToStringChars(TestData::Get("TestData", "LocUtilTests", "strings.wxl")); |
30 | hr = LocLoadFromFile(wxlFilePath, &pLoc); | 31 | do |
32 | { | ||
33 | if (FAILED(hr)) | ||
34 | { | ||
35 | ::Sleep(500); | ||
36 | } | ||
37 | |||
38 | hr = LocLoadFromFile(wxlFilePath, &pLoc); | ||
39 | } while (FAILED(hr) && ++dwRetry < 5); | ||
31 | NativeAssert::Succeeded(hr, "Failed to parse strings.wxl: {0}", wxlFilePath); | 40 | NativeAssert::Succeeded(hr, "Failed to parse strings.wxl: {0}", wxlFilePath); |
32 | 41 | ||
33 | Assert::Equal(4ul, pLoc->cLocStrings); | 42 | Assert::Equal(4ul, pLoc->cLocStrings); |
@@ -89,63 +98,5 @@ namespace DutilTests | |||
89 | DutilUninitialize(); | 98 | DutilUninitialize(); |
90 | } | 99 | } |
91 | } | 100 | } |
92 | |||
93 | [Fact] | ||
94 | void CanLoadControlsWxl() | ||
95 | { | ||
96 | HRESULT hr = S_OK; | ||
97 | WIX_LOCALIZATION* pLoc = NULL; | ||
98 | LOC_CONTROL* pLocControl = NULL; | ||
99 | |||
100 | DutilInitialize(&DutilTestTraceError); | ||
101 | |||
102 | try | ||
103 | { | ||
104 | hr = XmlInitialize(); | ||
105 | NativeAssert::Succeeded(hr, "Failed to initialize Xml."); | ||
106 | |||
107 | pin_ptr<const wchar_t> wxlFilePath = PtrToStringChars(TestData::Get("TestData", "LocUtilTests", "controls.wxl")); | ||
108 | hr = LocLoadFromFile(wxlFilePath, &pLoc); | ||
109 | NativeAssert::Succeeded(hr, "Failed to parse controls.wxl: {0}", wxlFilePath); | ||
110 | |||
111 | Assert::Equal(3ul, pLoc->cLocControls); | ||
112 | |||
113 | hr = LocGetControl(pLoc, L"Control1", &pLocControl); | ||
114 | NativeAssert::Succeeded(hr, "Failed to get loc control 'Control1' from: {0}", wxlFilePath); | ||
115 | NativeAssert::StringEqual(L"Control1", pLocControl->wzControl); | ||
116 | NativeAssert::Equal(1, pLocControl->nX); | ||
117 | NativeAssert::Equal(2, pLocControl->nY); | ||
118 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nWidth); | ||
119 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nHeight); | ||
120 | NativeAssert::StringEqual(L"This is control #1", pLocControl->wzText); | ||
121 | |||
122 | hr = LocGetControl(pLoc, L"Control2", &pLocControl); | ||
123 | NativeAssert::Succeeded(hr, "Failed to get loc control 'Control2' from: {0}", wxlFilePath); | ||
124 | NativeAssert::StringEqual(L"Control2", pLocControl->wzControl); | ||
125 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nX); | ||
126 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nY); | ||
127 | NativeAssert::Equal(50, pLocControl->nWidth); | ||
128 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nHeight); | ||
129 | NativeAssert::StringEqual(L"This is control #2", pLocControl->wzText); | ||
130 | |||
131 | hr = LocGetControl(pLoc, L"Control3", &pLocControl); | ||
132 | NativeAssert::Succeeded(hr, "Failed to get loc control 'Control3' from: {0}", wxlFilePath); | ||
133 | NativeAssert::StringEqual(L"Control3", pLocControl->wzControl); | ||
134 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nX); | ||
135 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nY); | ||
136 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nWidth); | ||
137 | NativeAssert::Equal(150, pLocControl->nHeight); | ||
138 | NativeAssert::StringEqual(L"", pLocControl->wzText); | ||
139 | } | ||
140 | finally | ||
141 | { | ||
142 | if (pLoc) | ||
143 | { | ||
144 | LocFree(pLoc); | ||
145 | } | ||
146 | |||
147 | DutilUninitialize(); | ||
148 | } | ||
149 | } | ||
150 | }; | 101 | }; |
151 | } | 102 | } |
diff --git a/src/libs/dutil/test/DUtilUnitTest/PathUtilTest.cpp b/src/libs/dutil/test/DUtilUnitTest/PathUtilTest.cpp index 381ea39a..12a2aaf1 100644 --- a/src/libs/dutil/test/DUtilUnitTest/PathUtilTest.cpp +++ b/src/libs/dutil/test/DUtilUnitTest/PathUtilTest.cpp | |||
@@ -142,7 +142,15 @@ namespace DutilTests | |||
142 | else | 142 | else |
143 | { | 143 | { |
144 | NativeAssert::Succeeded(hr, "Failed to canonicalize path"); | 144 | NativeAssert::Succeeded(hr, "Failed to canonicalize path"); |
145 | NativeAssert::StringEqual(L"\\\\?\\C:\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789", sczCanonicalized); | 145 | |
146 | if ('\\' == *sczCanonicalized) | ||
147 | { | ||
148 | NativeAssert::StringEqual(L"\\\\?\\C:\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789", sczCanonicalized); | ||
149 | } | ||
150 | else | ||
151 | { | ||
152 | NativeAssert::StringEqual(L"C:\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789", sczCanonicalized); | ||
153 | } | ||
146 | } | 154 | } |
147 | 155 | ||
148 | hr = PathCanonicalizeForComparison(L"\\\\?\\C:\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789", 0, &sczCanonicalized); | 156 | hr = PathCanonicalizeForComparison(L"\\\\?\\C:\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789", 0, &sczCanonicalized); |
@@ -153,7 +161,15 @@ namespace DutilTests | |||
153 | else | 161 | else |
154 | { | 162 | { |
155 | NativeAssert::Succeeded(hr, "Failed to canonicalize path"); | 163 | NativeAssert::Succeeded(hr, "Failed to canonicalize path"); |
156 | NativeAssert::StringEqual(L"\\\\?\\C:\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789", sczCanonicalized); | 164 | |
165 | if ('\\' == *sczCanonicalized) | ||
166 | { | ||
167 | NativeAssert::StringEqual(L"\\\\?\\C:\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789", sczCanonicalized); | ||
168 | } | ||
169 | else | ||
170 | { | ||
171 | NativeAssert::StringEqual(L"C:\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789", sczCanonicalized); | ||
172 | } | ||
157 | } | 173 | } |
158 | 174 | ||
159 | hr = PathCanonicalizeForComparison(L"\\\\server", PATH_CANONICALIZE_KEEP_UNC_ROOT, &sczCanonicalized); | 175 | hr = PathCanonicalizeForComparison(L"\\\\server", PATH_CANONICALIZE_KEEP_UNC_ROOT, &sczCanonicalized); |
@@ -288,7 +304,15 @@ namespace DutilTests | |||
288 | { | 304 | { |
289 | hr = PathAllocCanonicalizePath(L"C:\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789", PATHCCH_ALLOW_LONG_PATHS, &sczCanonicalized); | 305 | hr = PathAllocCanonicalizePath(L"C:\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789", PATHCCH_ALLOW_LONG_PATHS, &sczCanonicalized); |
290 | NativeAssert::Succeeded(hr, "Failed to canonicalize path"); | 306 | NativeAssert::Succeeded(hr, "Failed to canonicalize path"); |
291 | NativeAssert::StringEqual(L"\\\\?\\C:\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789", sczCanonicalized); | 307 | |
308 | if ('\\' == *sczCanonicalized) | ||
309 | { | ||
310 | NativeAssert::StringEqual(L"\\\\?\\C:\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789", sczCanonicalized); | ||
311 | } | ||
312 | else | ||
313 | { | ||
314 | NativeAssert::StringEqual(L"C:\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789", sczCanonicalized); | ||
315 | } | ||
292 | 316 | ||
293 | hr = PathAllocCanonicalizePath(L"abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789", PATHCCH_ALLOW_LONG_PATHS, &sczCanonicalized); | 317 | hr = PathAllocCanonicalizePath(L"abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789\\abcdefghijklomnopqrstuvwxyz0123456789", PATHCCH_ALLOW_LONG_PATHS, &sczCanonicalized); |
294 | NativeAssert::Succeeded(hr, "Failed to canonicalize path"); | 318 | NativeAssert::Succeeded(hr, "Failed to canonicalize path"); |
@@ -937,50 +961,22 @@ namespace DutilTests | |||
937 | void PathGetTempPathTest() | 961 | void PathGetTempPathTest() |
938 | { | 962 | { |
939 | HRESULT hr = S_OK; | 963 | HRESULT hr = S_OK; |
940 | LPCWSTR wzEnvName = L"TMP"; | ||
941 | LPCWSTR wzEnvName2 = L"TEMP"; | ||
942 | LPCWSTR wzLongTempPath = L"C:\\aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\\"; | ||
943 | LPWSTR sczTempPath = NULL; | 964 | LPWSTR sczTempPath = NULL; |
944 | WCHAR wzOriginalTemp[MAX_PATH + 1] = { }; | ||
945 | WCHAR wzOriginalTemp2[MAX_PATH + 1] = { }; | ||
946 | DWORD cch = 0; | 965 | DWORD cch = 0; |
947 | DWORD cch2 = 0; | ||
948 | SIZE_T cchTemp = 0; | 966 | SIZE_T cchTemp = 0; |
949 | size_t cchTemp2 = 0; | 967 | WCHAR wzPath[MAX_PATH + 1]; |
950 | |||
951 | try | ||
952 | { | ||
953 | cch = ::GetEnvironmentVariableW(wzEnvName, wzOriginalTemp, countof(wzOriginalTemp)); | ||
954 | Assert::NotEqual<DWORD>(0, cch); | ||
955 | |||
956 | if (!::SetEnvironmentVariableW(wzEnvName, wzLongTempPath)) | ||
957 | { | ||
958 | Assert::Equal<DWORD>(0xFFFFFFFF, ::GetLastError()); | ||
959 | } | ||
960 | 968 | ||
961 | cch2 = ::GetEnvironmentVariableW(wzEnvName2, wzOriginalTemp2, countof(wzOriginalTemp2)); | 969 | hr = PathGetTempPath(&sczTempPath, &cchTemp); |
962 | Assert::NotEqual<DWORD>(0, cch2); | 970 | NativeAssert::Succeeded(hr, "Failed to get temp path."); |
963 | 971 | ||
964 | hr = PathGetTempPath(&sczTempPath, &cchTemp); | 972 | cch = countof(wzPath); |
965 | NativeAssert::Succeeded(hr, "Failed to get temp path."); | 973 | cch = ::GetTempPathW(cch, wzPath); |
974 | Assert::NotEqual((DWORD)0, cch); | ||
966 | 975 | ||
967 | PathFixedBackslashTerminate(wzOriginalTemp2, countof(wzOriginalTemp2)); | 976 | // normalize trailing backslash |
977 | PathFixedBackslashTerminate(wzPath, cch); | ||
968 | 978 | ||
969 | hr = ::StringCchLengthW(wzOriginalTemp2, countof(wzOriginalTemp2), &cchTemp2); | 979 | NativeAssert::StringEqual(wzPath, sczTempPath); |
970 | NativeAssert::Succeeded(hr, "Failed to get temp path length."); | ||
971 | |||
972 | NativeAssert::StringEqual(wzOriginalTemp2, sczTempPath); | ||
973 | Assert::Equal<SIZE_T>(cchTemp2, cchTemp); | ||
974 | } | ||
975 | finally | ||
976 | { | ||
977 | if (cch) | ||
978 | { | ||
979 | ::SetEnvironmentVariableW(wzEnvName, wzOriginalTemp); | ||
980 | } | ||
981 | |||
982 | ReleaseStr(sczTempPath); | ||
983 | } | ||
984 | } | 980 | } |
985 | 981 | ||
986 | [Fact] | 982 | [Fact] |