mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-22 10:04:44 +01:00
use linq on file system ops when possible
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user