mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Skip files/directories that cause...
...UnauthorizedAccessException (particularly when the search all starts from the root directory of an NTFS drive.)
This commit is contained in:
parent
7042002903
commit
dec085142b
1 changed files with 25 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
||||||
using System.IO;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace LibHac
|
namespace LibHac
|
||||||
{
|
{
|
||||||
|
@ -38,7 +39,29 @@ namespace LibHac
|
||||||
|
|
||||||
public string[] GetFileSystemEntries(string path, string searchPattern, SearchOption searchOption)
|
public string[] GetFileSystemEntries(string path, string searchPattern, SearchOption searchOption)
|
||||||
{
|
{
|
||||||
return Directory.GetFileSystemEntries(Path.Combine(Root, path), searchPattern, searchOption);
|
//return Directory.GetFileSystemEntries(Path.Combine(Root, path), searchPattern, searchOption);
|
||||||
|
var result = new List<string>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result.AddRange(GetFileSystemEntries(Path.Combine(Root, path), searchPattern));
|
||||||
|
}
|
||||||
|
catch { /**/ }
|
||||||
|
|
||||||
|
if (searchOption == SearchOption.TopDirectoryOnly)
|
||||||
|
return result.ToArray();
|
||||||
|
|
||||||
|
var searchDirectories = Directory.GetDirectories(Path.Combine(Root, path));
|
||||||
|
foreach (var search in searchDirectories)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result.AddRange(GetFileSystemEntries(search, searchPattern, searchOption));
|
||||||
|
}
|
||||||
|
catch { /**/ }
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetFullPath(string path)
|
public string GetFullPath(string path)
|
||||||
|
|
Loading…
Reference in a new issue