summaryrefslogtreecommitdiff
path: root/src/internal/WixToolset.BaseBuildTasks.Sources/FileSearchHelperMethods.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/internal/WixToolset.BaseBuildTasks.Sources/FileSearchHelperMethods.cs')
-rw-r--r--src/internal/WixToolset.BaseBuildTasks.Sources/FileSearchHelperMethods.cs57
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
3namespace 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}