diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-06-20 10:40:05 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-06-20 10:40:05 -0400 |
| commit | 30e135e57622727c0c10299425730f8cf4588b82 (patch) | |
| tree | 51837579429a80147f7a3db47ebfe15c48b5e06d | |
| parent | 6c282a76b1b10adc86df1e89c3e7597675508355 (diff) | |
use linq on file system ops when possible
| -rw-r--r-- | MediaBrowser.Controller/IO/FileData.cs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/MediaBrowser.Controller/IO/FileData.cs b/MediaBrowser.Controller/IO/FileData.cs index 53dde4f5c..306de1e3c 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<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; |
