mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
plugin/explorer: ensure env var paths are absolute
This commit is contained in:
parent
400caa6ee4
commit
ac3ef9dbc7
1 changed files with 9 additions and 2 deletions
|
|
@ -22,11 +22,18 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
|
||||
foreach (DictionaryEntry special in Environment.GetEnvironmentVariables())
|
||||
{
|
||||
if (Directory.Exists(special.Value.ToString()))
|
||||
var path = special.Value.ToString();
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
// we add a trailing slash to the path to make sure drive paths become valid absolute paths.
|
||||
// for example, if %systemdrive% is C: we turn it to C:\
|
||||
path = path.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar;
|
||||
// if we don't have an absolute path, we use Path.GetFullPath to get one.
|
||||
// for example, if %homepath% is \Users\John we turn it to C:\Users\John
|
||||
path = Path.IsPathFullyQualified(path) ? path : Path.GetFullPath(path);
|
||||
// Variables are returned with a mixture of all upper/lower case.
|
||||
// Call ToLower() to make the results look consistent
|
||||
envStringPaths.Add(special.Key.ToString().ToLower(), special.Value.ToString());
|
||||
envStringPaths.Add(special.Key.ToString().ToLower(), path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue