switched to built-in methods for directory browsing

pull/702/head
Luke Pulverenti 12 years ago
parent 70ae9a2c86
commit e744302709

@ -1,5 +1,4 @@
using MediaBrowser.Common.Net; using MediaBrowser.Common.Net;
using MediaBrowser.Controller.IO;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using MediaBrowser.Model.Net; using MediaBrowser.Model.Net;
using ServiceStack.ServiceHost; using ServiceStack.ServiceHost;
@ -206,19 +205,40 @@ namespace MediaBrowser.Api
/// <returns>IEnumerable{FileSystemEntryInfo}.</returns> /// <returns>IEnumerable{FileSystemEntryInfo}.</returns>
private IEnumerable<FileSystemEntryInfo> GetFileSystemEntries(GetDirectoryContents request) private IEnumerable<FileSystemEntryInfo> GetFileSystemEntries(GetDirectoryContents request)
{ {
var fileSystemEntries = FileSystem.GetFileSystemEntries(request.Path, "*", request.IncludeFiles, request.IncludeDirectories).Where(f => !f.IsSystemFile); var entries = new DirectoryInfo(request.Path).EnumerateFileSystemInfos("*", SearchOption.TopDirectoryOnly).Where(i =>
if (!request.IncludeHidden)
{ {
fileSystemEntries = fileSystemEntries.Where(f => !f.IsHidden); if (i.Attributes.HasFlag(FileAttributes.System))
} {
return false;
}
if (!request.IncludeHidden && i.Attributes.HasFlag(FileAttributes.Hidden))
{
return false;
}
var isDirectory = i.Attributes.HasFlag(FileAttributes.Directory);
if (!request.IncludeFiles && !isDirectory)
{
return false;
}
if (!request.IncludeDirectories && isDirectory)
{
return false;
}
return true;
});
return fileSystemEntries.Select(f => new FileSystemEntryInfo return entries.Select(f => new FileSystemEntryInfo
{ {
Name = f.cFileName, Name = f.Name,
Path = f.Path, Path = f.FullName,
Type = f.IsDirectory ? FileSystemEntryType.Directory : FileSystemEntryType.File Type = f.Attributes.HasFlag(FileAttributes.Directory) ? FileSystemEntryType.Directory : FileSystemEntryType.File
});
}).ToList();
} }
/// <summary> /// <summary>

Loading…
Cancel
Save