ppy/osu-framework

DirectorySelector fails to enumerate `~/Library/Application Support` directories

ILW8 opened this issue · 0 comments

ILW8 commented

When attempting to click ~/Library/Application Support using the in-game file browser, the file browser flashes red and refuses to go into the directory.

It looks like while DirectorySelector.TryGetEntriesForPath is iterating over/sorting directory entries, the below exception is thrown and and caught. It is likely due to DirectoryInfo.GetDirectories attempting to pre-populate DirectoryInfo.

System.UnauthorizedAccessException: Access to the path '/Users/daohe/Library/Application Support/com.apple.LaunchServicesTemplateApp.dv' is denied.

protected virtual bool TryGetEntriesForPath(DirectoryInfo path, out ICollection<DirectorySelectorItem> items)
{
items = new List<DirectorySelectorItem>();
try
{
foreach (var dir in path.GetDirectories().OrderBy(d => d.Name))
{
if (ShowHiddenItems.Value || !dir.Attributes.HasFlagFast(FileAttributes.Hidden))
items.Add(CreateDirectoryItem(dir));
}
return true;
}
catch
{
return false;
}
}

Inaccessible directories in ~/Library/Application Support/ has also been a problem with JetBrains IDEs (e.g. this RIDER issue). According to this IDEA issue, ~/Library/Application Support/com.apple.LaunchServicesTemplateApp.dv is used by macOS Sonoma to support the new "Add to Dock" feature.