forked from mosa/MOSA-Project
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
103 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) MOSA Project. Licensed under the New BSD License. | ||
|
||
namespace Mosa.Compiler.Common; | ||
|
||
public static class FileFinder | ||
{ | ||
public static string Find(string file, IList<string> searchpaths) | ||
{ | ||
if (File.Exists(file)) | ||
return file; | ||
|
||
foreach (var path in searchpaths) | ||
{ | ||
var fullpath = Path.Combine(path, file); | ||
|
||
if (File.Exists(fullpath)) | ||
{ | ||
return fullpath; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public static string SearchSubdirectories(string path, string filename) | ||
{ | ||
if (!Directory.Exists(path)) | ||
return null; | ||
|
||
var enumerationOptions = new EnumerationOptions() | ||
{ | ||
IgnoreInaccessible = true, | ||
MaxRecursionDepth = 5, | ||
RecurseSubdirectories = true, | ||
MatchType = MatchType.Simple, | ||
MatchCasing = MatchCasing.PlatformDefault, | ||
ReturnSpecialDirectories = false, | ||
AttributesToSkip = FileAttributes.ReparsePoint | FileAttributes.Device | ||
}; | ||
|
||
var result = Directory.GetFiles(path, filename, enumerationOptions); | ||
|
||
if (result?.Length >= 1) | ||
{ | ||
return Path.GetDirectoryName(result[0]); | ||
} | ||
|
||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.