-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #197 from atifaziz/consolidate-schemes-search
Consolidate schemes path search code
- Loading branch information
Showing
3 changed files
with
51 additions
and
69 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,41 @@ | ||
// | ||
// Copyright (C) Microsoft. All rights reserved. | ||
// Licensed under the terms described in the LICENSE file in the root of this project. | ||
// | ||
|
||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
namespace ColorTool | ||
{ | ||
static class Scheme | ||
{ | ||
public static IEnumerable<string> GetSearchPaths(string schemeName, string extension) | ||
{ | ||
// Search order, for argument "name", where 'exe' is the dir of the exe. | ||
// 1. ./name | ||
// 2. ./name.ext | ||
// 3. ./schemes/name | ||
// 4. ./schemes/name.ext | ||
// 5. exe/schemes/name | ||
// 6. exe/schemes/name.ext | ||
// 7. name (as an absolute path) | ||
|
||
string cwd = "./"; | ||
yield return cwd + schemeName; | ||
|
||
string filename = schemeName + extension; | ||
yield return cwd + filename; | ||
|
||
string cwdSchemes = "./schemes/"; | ||
yield return cwdSchemes + schemeName; | ||
yield return cwdSchemes + filename; | ||
|
||
string exeDir = Directory.GetParent(System.Reflection.Assembly.GetEntryAssembly().Location).FullName; | ||
string exeSchemes = exeDir + "/schemes/"; | ||
yield return exeSchemes + schemeName; | ||
yield return exeSchemes + filename; | ||
yield return schemeName; | ||
} | ||
} | ||
} |
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