use linq on file system ops when possible

This commit is contained in:
Luke Pulverenti 2013-06-20 10:40:05 -04:00
parent 6c282a76b1
commit 30e135e576

View File

@ -3,6 +3,7 @@ using MediaBrowser.Model.Logging;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace MediaBrowser.Controller.IO
{
@ -29,10 +30,15 @@ namespace MediaBrowser.Controller.IO
throw new ArgumentNullException("path");
}
var dict = new Dictionary<string, FileSystemInfo>(StringComparer.OrdinalIgnoreCase);
var entries = new DirectoryInfo(path).EnumerateFileSystemInfos(searchPattern, SearchOption.TopDirectoryOnly);
if (!resolveShortcuts && flattenFolderDepth == 0)
{
return entries.ToDictionary(i => i.FullName, StringComparer.OrdinalIgnoreCase);
}
var dict = new Dictionary<string, FileSystemInfo>(StringComparer.OrdinalIgnoreCase);
foreach (var entry in entries)
{
var isDirectory = (entry.Attributes & FileAttributes.Directory) == FileAttributes.Directory;