|
|
@ -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 (i.Attributes.HasFlag(FileAttributes.System))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!request.IncludeHidden && i.Attributes.HasFlag(FileAttributes.Hidden))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!request.IncludeHidden)
|
|
|
|
var isDirectory = i.Attributes.HasFlag(FileAttributes.Directory);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!request.IncludeFiles && !isDirectory)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fileSystemEntries = fileSystemEntries.Where(f => !f.IsHidden);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return fileSystemEntries.Select(f => new FileSystemEntryInfo
|
|
|
|
if (!request.IncludeDirectories && isDirectory)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Name = f.cFileName,
|
|
|
|
return false;
|
|
|
|
Path = f.Path,
|
|
|
|
}
|
|
|
|
Type = f.IsDirectory ? FileSystemEntryType.Directory : FileSystemEntryType.File
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return entries.Select(f => new FileSystemEntryInfo
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Name = f.Name,
|
|
|
|
|
|
|
|
Path = f.FullName,
|
|
|
|
|
|
|
|
Type = f.Attributes.HasFlag(FileAttributes.Directory) ? FileSystemEntryType.Directory : FileSystemEntryType.File
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).ToList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|