|
|
|
@ -582,9 +582,7 @@ namespace Emby.Server.Implementations.IO
|
|
|
|
|
|
|
|
|
|
public virtual IEnumerable<FileSystemMetadata> GetDirectories(string path, bool recursive = false)
|
|
|
|
|
{
|
|
|
|
|
var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
|
|
|
|
|
|
|
|
|
return ToMetadata(new DirectoryInfo(path).EnumerateDirectories("*", searchOption));
|
|
|
|
|
return ToMetadata(new DirectoryInfo(path).EnumerateDirectories("*", GetEnumerationOptions(recursive)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual IEnumerable<FileSystemMetadata> GetFiles(string path, bool recursive = false)
|
|
|
|
@ -594,16 +592,16 @@ namespace Emby.Server.Implementations.IO
|
|
|
|
|
|
|
|
|
|
public virtual IEnumerable<FileSystemMetadata> GetFiles(string path, IReadOnlyList<string> extensions, bool enableCaseSensitiveExtensions, bool recursive = false)
|
|
|
|
|
{
|
|
|
|
|
var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
|
|
|
|
var enumerationOptions = GetEnumerationOptions(recursive);
|
|
|
|
|
|
|
|
|
|
// On linux and osx the search pattern is case sensitive
|
|
|
|
|
// If we're OK with case-sensitivity, and we're only filtering for one extension, then use the native method
|
|
|
|
|
if ((enableCaseSensitiveExtensions || _isEnvironmentCaseInsensitive) && extensions != null && extensions.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
return ToMetadata(new DirectoryInfo(path).EnumerateFiles("*" + extensions[0], searchOption));
|
|
|
|
|
return ToMetadata(new DirectoryInfo(path).EnumerateFiles("*" + extensions[0], enumerationOptions));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var files = new DirectoryInfo(path).EnumerateFiles("*", searchOption);
|
|
|
|
|
var files = new DirectoryInfo(path).EnumerateFiles("*", enumerationOptions);
|
|
|
|
|
|
|
|
|
|
if (extensions != null && extensions.Count > 0)
|
|
|
|
|
{
|
|
|
|
@ -625,10 +623,10 @@ namespace Emby.Server.Implementations.IO
|
|
|
|
|
public virtual IEnumerable<FileSystemMetadata> GetFileSystemEntries(string path, bool recursive = false)
|
|
|
|
|
{
|
|
|
|
|
var directoryInfo = new DirectoryInfo(path);
|
|
|
|
|
var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
|
|
|
|
var enumerationOptions = GetEnumerationOptions(recursive);
|
|
|
|
|
|
|
|
|
|
return ToMetadata(directoryInfo.EnumerateDirectories("*", searchOption))
|
|
|
|
|
.Concat(ToMetadata(directoryInfo.EnumerateFiles("*", searchOption)));
|
|
|
|
|
return ToMetadata(directoryInfo.EnumerateDirectories("*", enumerationOptions))
|
|
|
|
|
.Concat(ToMetadata(directoryInfo.EnumerateFiles("*", enumerationOptions)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEnumerable<FileSystemMetadata> ToMetadata(IEnumerable<FileSystemInfo> infos)
|
|
|
|
@ -638,8 +636,7 @@ namespace Emby.Server.Implementations.IO
|
|
|
|
|
|
|
|
|
|
public virtual IEnumerable<string> GetDirectoryPaths(string path, bool recursive = false)
|
|
|
|
|
{
|
|
|
|
|
var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
|
|
|
|
return Directory.EnumerateDirectories(path, "*", searchOption);
|
|
|
|
|
return Directory.EnumerateDirectories(path, "*", GetEnumerationOptions(recursive));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual IEnumerable<string> GetFilePaths(string path, bool recursive = false)
|
|
|
|
@ -649,16 +646,16 @@ namespace Emby.Server.Implementations.IO
|
|
|
|
|
|
|
|
|
|
public virtual IEnumerable<string> GetFilePaths(string path, string[] extensions, bool enableCaseSensitiveExtensions, bool recursive = false)
|
|
|
|
|
{
|
|
|
|
|
var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
|
|
|
|
var enumerationOptions = GetEnumerationOptions(recursive);
|
|
|
|
|
|
|
|
|
|
// On linux and osx the search pattern is case sensitive
|
|
|
|
|
// If we're OK with case-sensitivity, and we're only filtering for one extension, then use the native method
|
|
|
|
|
if ((enableCaseSensitiveExtensions || _isEnvironmentCaseInsensitive) && extensions != null && extensions.Length == 1)
|
|
|
|
|
{
|
|
|
|
|
return Directory.EnumerateFiles(path, "*" + extensions[0], searchOption);
|
|
|
|
|
return Directory.EnumerateFiles(path, "*" + extensions[0], enumerationOptions);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var files = Directory.EnumerateFiles(path, "*", searchOption);
|
|
|
|
|
var files = Directory.EnumerateFiles(path, "*", enumerationOptions);
|
|
|
|
|
|
|
|
|
|
if (extensions != null && extensions.Length > 0)
|
|
|
|
|
{
|
|
|
|
@ -679,8 +676,16 @@ namespace Emby.Server.Implementations.IO
|
|
|
|
|
|
|
|
|
|
public virtual IEnumerable<string> GetFileSystemEntryPaths(string path, bool recursive = false)
|
|
|
|
|
{
|
|
|
|
|
var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
|
|
|
|
return Directory.EnumerateFileSystemEntries(path, "*", searchOption);
|
|
|
|
|
return Directory.EnumerateFileSystemEntries(path, "*", GetEnumerationOptions(recursive));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private EnumerationOptions GetEnumerationOptions(bool recursive)
|
|
|
|
|
{
|
|
|
|
|
return new EnumerationOptions
|
|
|
|
|
{
|
|
|
|
|
RecurseSubdirectories = recursive,
|
|
|
|
|
IgnoreInaccessible = true
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void RunProcess(string path, string args, string workingDirectory)
|
|
|
|
|