mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-21 05:10:25 +08:00
code_style: remove DirectoryInfoExtension.GetRelativePath since it is not safe while being used out of DirectoryInfoExtension.WalkFiles
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
@@ -57,10 +57,5 @@ namespace SourceGit
|
||||
// Ignore exceptions.
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetRelativePath(this DirectoryInfo dir, string fullpath)
|
||||
{
|
||||
return fullpath.Substring(dir.FullName.Length).TrimStart(Path.DirectorySeparatorChar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,10 +230,14 @@ namespace SourceGit.Models
|
||||
return null;
|
||||
|
||||
var options = new List<ExternalTool.LaunchOption>();
|
||||
var prefixLen = root.FullName.Length;
|
||||
root.WalkFiles(f =>
|
||||
{
|
||||
if (f.EndsWith(".code-workspace", StringComparison.OrdinalIgnoreCase))
|
||||
options.Add(new(root.GetRelativePath(f), f.Quoted()));
|
||||
{
|
||||
var display = f.Substring(prefixLen).TrimStart(Path.DirectorySeparatorChar);
|
||||
options.Add(new(display, f.Quoted()));
|
||||
}
|
||||
}, 2);
|
||||
return options;
|
||||
}
|
||||
|
||||
@@ -234,11 +234,15 @@ namespace SourceGit.Native
|
||||
return null;
|
||||
|
||||
var options = new List<Models.ExternalTool.LaunchOption>();
|
||||
var prefixLen = root.FullName.Length;
|
||||
root.WalkFiles(f =>
|
||||
{
|
||||
if (f.EndsWith(".sln", StringComparison.OrdinalIgnoreCase) ||
|
||||
f.EndsWith(".slnx", StringComparison.OrdinalIgnoreCase))
|
||||
options.Add(new(root.GetRelativePath(f), f.Quoted()));
|
||||
{
|
||||
var display = f.Substring(prefixLen).TrimStart(Path.DirectorySeparatorChar);
|
||||
options.Add(new(display, f.Quoted()));
|
||||
}
|
||||
});
|
||||
return options;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user