aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.BuildTasks/FileSearchHelperMethods.cs
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2018-07-19 00:58:00 -0700
committerRob Mensching <rob@firegiant.com>2018-07-21 07:36:59 -0700
commit2724cfee4c163f3297ee25edfd2372767cfd4945 (patch)
tree8cdda34c83bea014a586a491e3b4b187ad8f16da /src/WixToolset.BuildTasks/FileSearchHelperMethods.cs
parent4d40bef9cf51b8cff7e1f6a73fdf68b9722eb8a0 (diff)
downloadwix-2724cfee4c163f3297ee25edfd2372767cfd4945.tar.gz
wix-2724cfee4c163f3297ee25edfd2372767cfd4945.tar.bz2
wix-2724cfee4c163f3297ee25edfd2372767cfd4945.zip
Move tool projects to Tools repo
Diffstat (limited to 'src/WixToolset.BuildTasks/FileSearchHelperMethods.cs')
-rw-r--r--src/WixToolset.BuildTasks/FileSearchHelperMethods.cs60
1 files changed, 0 insertions, 60 deletions
diff --git a/src/WixToolset.BuildTasks/FileSearchHelperMethods.cs b/src/WixToolset.BuildTasks/FileSearchHelperMethods.cs
deleted file mode 100644
index 6cc804eb..00000000
--- a/src/WixToolset.BuildTasks/FileSearchHelperMethods.cs
+++ /dev/null
@@ -1,60 +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.BuildTasks
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Diagnostics.CodeAnalysis;
8 using System.IO;
9 using System.Text;
10 using Microsoft.Build.Framework;
11
12 /// <summary>
13 /// Contains helper methods on searching for files
14 /// </summary>
15 public static class FileSearchHelperMethods
16 {
17 /// <summary>
18 /// Searches for the existence of a file in multiple directories.
19 /// Search is satisfied if default file path is valid and exists. If not,
20 /// file name is extracted from default path and combined with each of the directories
21 /// looking to see if it exists. If not found, input default path is returned.
22 /// </summary>
23 /// <param name="directories">Array of directories to look in, without filenames in them</param>
24 /// <param name="defaultFullPath">Default path - to use if not found</param>
25 /// <returns>File path if file found. Empty string if not found</returns>
26 public static string SearchFilePaths(string[] directories, string defaultFullPath)
27 {
28 if (String.IsNullOrEmpty(defaultFullPath))
29 {
30 return String.Empty;
31 }
32
33 if (File.Exists(defaultFullPath))
34 {
35 return defaultFullPath;
36 }
37
38 if (directories == null)
39 {
40 return string.Empty;
41 }
42
43 string fileName = Path.GetFileName(defaultFullPath);
44 foreach (string currentPath in directories)
45 {
46 if (String.IsNullOrEmpty(currentPath) || String.IsNullOrEmpty(currentPath.Trim()))
47 {
48 continue;
49 }
50
51 if (File.Exists(Path.Combine(currentPath, fileName)))
52 {
53 return Path.Combine(currentPath, fileName);
54 }
55 }
56
57 return String.Empty;
58 }
59 }
60}