Skip to content

Commit

Permalink
Avoid crashing when permission to PWD directory is denied
Browse files Browse the repository at this point in the history
  • Loading branch information
PaddiM8 committed Oct 8, 2024
1 parent 605b699 commit d05e29f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Std/Environment/Environment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,16 @@ public static List<string> GetDirectoryNames(string path)
return [];

var directoryNames = new List<string>();
var directoryInfo = new DirectoryInfo(path);

DirectoryInfo directoryInfo;
try
{
directoryInfo = new DirectoryInfo(path);
}
catch
{
return [];
}

while (directoryInfo.Parent != null)
{
Expand Down

0 comments on commit d05e29f

Please sign in to comment.