From 30e135e57622727c0c10299425730f8cf4588b82 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 20 Jun 2013 10:40:05 -0400 Subject: [PATCH] use linq on file system ops when possible --- MediaBrowser.Controller/IO/FileData.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Controller/IO/FileData.cs b/MediaBrowser.Controller/IO/FileData.cs index 53dde4f5cf..306de1e3c4 100644 --- a/MediaBrowser.Controller/IO/FileData.cs +++ b/MediaBrowser.Controller/IO/FileData.cs @@ -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(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(StringComparer.OrdinalIgnoreCase); + foreach (var entry in entries) { var isDirectory = (entry.Attributes & FileAttributes.Directory) == FileAttributes.Directory;