Merge pull request #1265 from MediaBrowser/master

update use of FileAttributes
pull/702/head
Luke 9 years ago
commit 1051745fd1

@ -231,7 +231,7 @@ namespace MediaBrowser.Api
return false;
}
var isDirectory = i.Attributes.HasFlag(FileAttributes.Directory);
var isDirectory = i.IsDirectory;
if (!request.IncludeFiles && !isDirectory)
{
@ -250,7 +250,7 @@ namespace MediaBrowser.Api
{
Name = f.Name,
Path = f.FullName,
Type = f.Attributes.HasFlag(FileAttributes.Directory) ? FileSystemEntryType.Directory : FileSystemEntryType.File
Type = f.IsDirectory ? FileSystemEntryType.Directory : FileSystemEntryType.File
}).ToList();
}

@ -54,7 +54,7 @@ namespace MediaBrowser.Controller.IO
foreach (var entry in entries)
{
var isDirectory = (entry.Attributes & FileAttributes.Directory) == FileAttributes.Directory;
var isDirectory = entry.IsDirectory;
var fullName = entry.FullName;

@ -84,7 +84,7 @@ namespace MediaBrowser.Controller.Library
{
get
{
return (FileInfo.Attributes & FileAttributes.Directory) == FileAttributes.Directory;
return FileInfo.IsDirectory;
}
}

@ -95,7 +95,7 @@ namespace MediaBrowser.Controller.Providers
public IEnumerable<FileSystemMetadata> GetFiles(string path, bool clearCache)
{
return GetFileSystemEntries(path, clearCache).Where(i => (i.Attributes & FileAttributes.Directory) != FileAttributes.Directory);
return GetFileSystemEntries(path, clearCache).Where(i => !i.IsDirectory);
}
public FileSystemMetadata GetFile(string path)
@ -112,7 +112,7 @@ namespace MediaBrowser.Controller.Providers
public IEnumerable<FileSystemMetadata> GetDirectories(string path)
{
return GetFileSystemEntries(path, false).Where(i => (i.Attributes & FileAttributes.Directory) == FileAttributes.Directory);
return GetFileSystemEntries(path, false).Where(i => i.IsDirectory);
}
}
}

@ -68,7 +68,7 @@ namespace MediaBrowser.LocalMetadata.Images
return parentPathFiles
.Where(i =>
{
if ((i.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
if (i.IsDirectory)
{
return false;
}

@ -74,8 +74,7 @@ namespace MediaBrowser.LocalMetadata.Images
if (includeDirectories)
{
return directoryService.GetFileSystemEntries(path)
.Where(i => BaseItem.SupportedImageExtensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase) ||
(i.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
.Where(i => BaseItem.SupportedImageExtensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase) || i.IsDirectory)
.OrderBy(i => BaseItem.SupportedImageExtensionsList.IndexOf(i.Extension ?? string.Empty));
}
@ -378,7 +377,7 @@ namespace MediaBrowser.LocalMetadata.Images
private FileSystemMetadata GetImage(IEnumerable<FileSystemMetadata> files, string name)
{
return files.FirstOrDefault(i => ((i.Attributes & FileAttributes.Directory) != FileAttributes.Directory) && string.Equals(name, _fileSystem.GetFileNameWithoutExtension(i), StringComparison.OrdinalIgnoreCase));
return files.FirstOrDefault(i => !i.IsDirectory && string.Equals(name, _fileSystem.GetFileNameWithoutExtension(i), StringComparison.OrdinalIgnoreCase));
}
}
}

@ -94,7 +94,7 @@ namespace MediaBrowser.Server.Implementations.Library
// If the subclass didn't supply a name, add it here
if (string.IsNullOrEmpty(item.Name) && !string.IsNullOrEmpty(item.Path))
{
item.Name = GetDisplayName(fileInfo.Name, (fileInfo.Attributes & FileAttributes.Directory) == FileAttributes.Directory);
item.Name = GetDisplayName(fileInfo.Name, fileInfo.IsDirectory);
}
}

Loading…
Cancel
Save