|
2 | 2 | using System.Collections;
|
3 | 3 | using System.Collections.Generic;
|
4 | 4 | using System.IO;
|
5 |
| -using System.Text; |
| 5 | +using Flow.Launcher.Plugin.SharedCommands; |
6 | 6 |
|
7 | 7 | namespace Flow.Launcher.Plugin.Explorer.Search
|
8 | 8 | {
|
@@ -37,20 +37,22 @@ internal static bool BeginsWithEnvironmentVar(string search)
|
37 | 37 | internal static Dictionary<string, string> LoadEnvironmentStringPaths()
|
38 | 38 | {
|
39 | 39 | var envStringPaths = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
|
| 40 | + var homedrive = Environment.GetEnvironmentVariable("HOMEDRIVE")?.EnsureTrailingSlash() ?? "C:\\"; |
40 | 41 |
|
41 | 42 | foreach (DictionaryEntry special in Environment.GetEnvironmentVariables())
|
42 | 43 | {
|
43 | 44 | var path = special.Value.ToString();
|
44 |
| - if (Directory.Exists(path)) |
45 |
| - { |
46 |
| - // we add a trailing slash to the path to make sure drive paths become valid absolute paths. |
47 |
| - // for example, if %systemdrive% is C: we turn it to C:\ |
48 |
| - path = path.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar; |
| 45 | + // we add a trailing slash to the path to make sure drive paths become valid absolute paths. |
| 46 | + // for example, if %systemdrive% is C: we turn it to C:\ |
| 47 | + path = path.EnsureTrailingSlash(); |
49 | 48 |
|
50 |
| - // if we don't have an absolute path, we use Path.GetFullPath to get one. |
51 |
| - // for example, if %homepath% is \Users\John we turn it to C:\Users\John |
52 |
| - path = Path.IsPathFullyQualified(path) ? path : Path.GetFullPath(path); |
| 49 | + // if we don't have an absolute path, we use Path.GetFullPath to get one. |
| 50 | + // for example, if %homepath% is \Users\John we turn it to C:\Users\John |
| 51 | + // Add basepath for GetFullPath() to parse %HOMEPATH% correctly |
| 52 | + path = Path.IsPathFullyQualified(path) ? path : Path.GetFullPath(path, homedrive); |
53 | 53 |
|
| 54 | + if (Directory.Exists(path)) |
| 55 | + { |
54 | 56 | // Variables are returned with a mixture of all upper/lower case.
|
55 | 57 | // Call ToUpper() to make the results look consistent
|
56 | 58 | envStringPaths.Add(special.Key.ToString().ToUpper(), path);
|
|
0 commit comments