diff options
| author | Rob Mensching <rob@firegiant.com> | 2022-10-14 09:34:30 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2022-10-14 20:13:50 -0700 |
| commit | 08f53f409020b12dffaa2aeefa943b667a4b9328 (patch) | |
| tree | 42bad414ff06c19fb881c7db1b145ec1d6885521 /src/internal/WixToolset.BaseBuildTasks.Sources/FileSearchHelperMethods.cs | |
| parent | 07b3d459ea0a45cbef29b98d283edafbab26462a (diff) | |
| download | wix-08f53f409020b12dffaa2aeefa943b667a4b9328.tar.gz wix-08f53f409020b12dffaa2aeefa943b667a4b9328.tar.bz2 wix-08f53f409020b12dffaa2aeefa943b667a4b9328.zip | |
Simplify reference resolution
WiX v3 extension loading had options that were rarely if ever used
and library paths modeled after C++. Given the new Sdk-style model
in WiX v4, we can simplify reference resolution.
Fixes 6945, 6946
Diffstat (limited to 'src/internal/WixToolset.BaseBuildTasks.Sources/FileSearchHelperMethods.cs')
| -rw-r--r-- | src/internal/WixToolset.BaseBuildTasks.Sources/FileSearchHelperMethods.cs | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/src/internal/WixToolset.BaseBuildTasks.Sources/FileSearchHelperMethods.cs b/src/internal/WixToolset.BaseBuildTasks.Sources/FileSearchHelperMethods.cs deleted file mode 100644 index 442fedd6..00000000 --- a/src/internal/WixToolset.BaseBuildTasks.Sources/FileSearchHelperMethods.cs +++ /dev/null | |||
| @@ -1,57 +0,0 @@ | |||
| 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 | namespace WixToolset.BaseBuildTasks | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.IO; | ||
| 7 | |||
| 8 | /// <summary> | ||
| 9 | /// Contains helper methods on searching for files | ||
| 10 | /// </summary> | ||
| 11 | public static class FileSearchHelperMethods | ||
| 12 | { | ||
| 13 | /// <summary> | ||
| 14 | /// Searches for the existence of a file in multiple directories. | ||
| 15 | /// Search is satisfied if default file path is valid and exists. If not, | ||
| 16 | /// file name is extracted from default path and combined with each of the directories | ||
| 17 | /// looking to see if it exists. If not found, input default path is returned. | ||
| 18 | /// </summary> | ||
| 19 | /// <param name="directories">Array of directories to look in, without filenames in them</param> | ||
| 20 | /// <param name="defaultFullPath">Default path - to use if not found</param> | ||
| 21 | /// <returns>File path if file found. Empty string if not found</returns> | ||
| 22 | public static string SearchFilePaths(string[] directories, string defaultFullPath) | ||
| 23 | { | ||
| 24 | if (String.IsNullOrEmpty(defaultFullPath)) | ||
| 25 | { | ||
| 26 | return String.Empty; | ||
| 27 | } | ||
| 28 | |||
| 29 | if (File.Exists(defaultFullPath)) | ||
| 30 | { | ||
| 31 | return defaultFullPath; | ||
| 32 | } | ||
| 33 | |||
| 34 | if (directories == null) | ||
| 35 | { | ||
| 36 | return String.Empty; | ||
| 37 | } | ||
| 38 | |||
| 39 | var fileName = Path.GetFileName(defaultFullPath); | ||
| 40 | foreach (var currentPath in directories) | ||
| 41 | { | ||
| 42 | if (String.IsNullOrWhiteSpace(currentPath)) | ||
| 43 | { | ||
| 44 | continue; | ||
| 45 | } | ||
| 46 | |||
| 47 | var path = Path.Combine(currentPath, fileName); | ||
| 48 | if (File.Exists(path)) | ||
| 49 | { | ||
| 50 | return path; | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | return String.Empty; | ||
| 55 | } | ||
| 56 | } | ||
| 57 | } | ||
