diff --git a/MediaBrowser.Api/EnvironmentService.cs b/MediaBrowser.Api/EnvironmentService.cs
index 9d11178c84..d88d855940 100644
--- a/MediaBrowser.Api/EnvironmentService.cs
+++ b/MediaBrowser.Api/EnvironmentService.cs
@@ -207,11 +207,6 @@ namespace MediaBrowser.Api
{
var entries = new DirectoryInfo(request.Path).EnumerateFileSystemInfos().Where(i =>
{
- if (i.Attributes.HasFlag(FileAttributes.System))
- {
- return false;
- }
-
if (!request.IncludeHidden && i.Attributes.HasFlag(FileAttributes.Hidden))
{
return false;
diff --git a/MediaBrowser.Controller/Drawing/ImageExtensions.cs b/MediaBrowser.Controller/Drawing/ImageExtensions.cs
index 79b877b943..847c5dbe03 100644
--- a/MediaBrowser.Controller/Drawing/ImageExtensions.cs
+++ b/MediaBrowser.Controller/Drawing/ImageExtensions.cs
@@ -73,23 +73,23 @@ namespace MediaBrowser.Controller.Drawing
{
// http://msdn.microsoft.com/en-us/library/system.drawing.graphics.fromimage.aspx
- if (format.HasFlag(PixelFormat.Indexed))
+ if (format == PixelFormat.Indexed)
{
return false;
}
- if (format.HasFlag(PixelFormat.Undefined))
+ if (format == PixelFormat.Undefined)
{
return false;
}
- if (format.HasFlag(PixelFormat.DontCare))
+ if (format == PixelFormat.DontCare)
{
return false;
}
- if (format.HasFlag(PixelFormat.Format16bppArgb1555))
+ if (format == PixelFormat.Format16bppArgb1555)
{
return false;
}
- if (format.HasFlag(PixelFormat.Format16bppGrayScale))
+ if (format == PixelFormat.Format16bppGrayScale)
{
return false;
}
@@ -160,7 +160,7 @@ namespace MediaBrowser.Controller.Drawing
}
// Graphics.FromImage will throw an exception if the PixelFormat is Indexed, so we need to handle that here
- var thumbnail = bmp.PixelFormat.HasFlag(PixelFormat.Indexed) ? new Bitmap(croppedWidth, croppedHeight) : new Bitmap(croppedWidth, croppedHeight, bmp.PixelFormat);
+ var thumbnail = bmp.PixelFormat == PixelFormat.Indexed ? new Bitmap(croppedWidth, croppedHeight) : new Bitmap(croppedWidth, croppedHeight, bmp.PixelFormat);
// Preserve the original resolution
thumbnail.SetResolution(bmp.HorizontalResolution, bmp.VerticalResolution);
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index 974b3f864e..2852843ef8 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -279,7 +279,7 @@ namespace MediaBrowser.Controller.Entities
// Record the name of each file
// Need to sort these because accoring to msdn docs, our i/o methods are not guaranteed in any order
foreach (var file in ResolveArgs.FileSystemChildren
- .Where(i => !i.Attributes.HasFlag(FileAttributes.System))
+ .Where(i => (i.Attributes & FileAttributes.System) != FileAttributes.System)
.OrderBy(f => f.Name))
{
sb.Append(file.Name);
@@ -363,12 +363,15 @@ namespace MediaBrowser.Controller.Entities
return new ItemResolveArgs(ConfigurationManager.ApplicationPaths);
}
+ var isDirectory = false;
+
if (UseParentPathToCreateResolveArgs)
{
path = System.IO.Path.GetDirectoryName(path);
+ isDirectory = true;
}
- pathInfo = pathInfo ?? FileSystem.GetFileSystemInfo(path);
+ pathInfo = pathInfo ?? (isDirectory ? new DirectoryInfo(path) : FileSystem.GetFileSystemInfo(path));
if (pathInfo == null || !pathInfo.Exists)
{
diff --git a/MediaBrowser.Controller/IO/FileData.cs b/MediaBrowser.Controller/IO/FileData.cs
index 6d1e3e05aa..8896d4fc1f 100644
--- a/MediaBrowser.Controller/IO/FileData.cs
+++ b/MediaBrowser.Controller/IO/FileData.cs
@@ -35,7 +35,7 @@ namespace MediaBrowser.Controller.IO
foreach (var entry in entries)
{
- var isDirectory = entry.Attributes.HasFlag(FileAttributes.Directory);
+ var isDirectory = (entry.Attributes & FileAttributes.Directory) == FileAttributes.Directory;
if (resolveShortcuts && FileSystem.IsShortcut(entry.FullName))
{
diff --git a/MediaBrowser.Controller/IO/NativeMethods.cs b/MediaBrowser.Controller/IO/NativeMethods.cs
index 2f15f124dd..5b9bf52a8b 100644
--- a/MediaBrowser.Controller/IO/NativeMethods.cs
+++ b/MediaBrowser.Controller/IO/NativeMethods.cs
@@ -216,103 +216,6 @@ namespace MediaBrowser.Controller.IO
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = NativeMethods.MAX_ALTERNATE)]
public string cAlternate;
- ///
- /// Gets a value indicating whether this instance is hidden.
- ///
- /// true if this instance is hidden; otherwise, false.
- public bool IsHidden
- {
- get
- {
- return dwFileAttributes.HasFlag(FileAttributes.Hidden);
- }
- }
-
- ///
- /// Gets a value indicating whether this instance is system file.
- ///
- /// true if this instance is system file; otherwise, false.
- public bool IsSystemFile
- {
- get
- {
- return dwFileAttributes.HasFlag(FileAttributes.System);
- }
- }
-
- ///
- /// Gets a value indicating whether this instance is directory.
- ///
- /// true if this instance is directory; otherwise, false.
- public bool IsDirectory
- {
- get
- {
- return dwFileAttributes.HasFlag(FileAttributes.Directory);
- }
- }
-
- ///
- /// Gets the creation time UTC.
- ///
- /// The creation time UTC.
- public DateTime CreationTimeUtc
- {
- get
- {
- return ParseFileTime(ftCreationTime);
- }
- }
-
- ///
- /// Gets the last access time UTC.
- ///
- /// The last access time UTC.
- public DateTime LastAccessTimeUtc
- {
- get
- {
- return ParseFileTime(ftLastAccessTime);
- }
- }
-
- ///
- /// Gets the last write time UTC.
- ///
- /// The last write time UTC.
- public DateTime LastWriteTimeUtc
- {
- get
- {
- return ParseFileTime(ftLastWriteTime);
- }
- }
-
- ///
- /// Parses the file time.
- ///
- /// The filetime.
- /// DateTime.
- private DateTime ParseFileTime(FILETIME filetime)
- {
- long highBits = filetime.dwHighDateTime;
- highBits = highBits << 32;
-
- var val = highBits + (long) filetime.dwLowDateTime;
-
- if (val < 0L)
- {
- return DateTime.MinValue;
- }
-
- if (val > 2650467743999999999L)
- {
- return DateTime.MaxValue;
- }
-
- return DateTime.FromFileTimeUtc(val);
- }
-
///
/// Gets or sets the path.
///
diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs
index dd2afcb3f5..7e84350b37 100644
--- a/MediaBrowser.Controller/Library/ILibraryManager.cs
+++ b/MediaBrowser.Controller/Library/ILibraryManager.cs
@@ -26,12 +26,11 @@ namespace MediaBrowser.Controller.Library
///
/// Resolves a path into a BaseItem
///
- /// The path.
- /// The parent.
/// The file info.
+ /// The parent.
/// BaseItem.
///
- BaseItem ResolvePath(string path, Folder parent = null, FileSystemInfo fileInfo = null);
+ BaseItem ResolvePath(FileSystemInfo fileInfo, Folder parent = null);
///
/// Resolves a set of files into a list of BaseItem
diff --git a/MediaBrowser.Controller/Library/ItemResolveArgs.cs b/MediaBrowser.Controller/Library/ItemResolveArgs.cs
index 0ddf61f197..9ca2b6ad5a 100644
--- a/MediaBrowser.Controller/Library/ItemResolveArgs.cs
+++ b/MediaBrowser.Controller/Library/ItemResolveArgs.cs
@@ -68,7 +68,7 @@ namespace MediaBrowser.Controller.Library
{
get
{
- return FileInfo.Attributes.HasFlag(FileAttributes.Directory);
+ return (FileInfo.Attributes & FileAttributes.Directory) == FileAttributes.Directory;
}
}
@@ -80,7 +80,7 @@ namespace MediaBrowser.Controller.Library
{
get
{
- return FileInfo.Attributes.HasFlag(FileAttributes.Hidden);
+ return (FileInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden;
}
}
@@ -92,7 +92,7 @@ namespace MediaBrowser.Controller.Library
{
get
{
- return FileInfo.Attributes.HasFlag(FileAttributes.System);
+ return (FileInfo.Attributes & FileAttributes.System) == FileAttributes.System;
}
}
@@ -213,7 +213,7 @@ namespace MediaBrowser.Controller.Library
///
public void AddMetadataFile(string path)
{
- var file = FileSystem.GetFileSystemInfo(path);
+ var file = new FileInfo(path);
if (!file.Exists)
{
diff --git a/MediaBrowser.Controller/Library/TVUtils.cs b/MediaBrowser.Controller/Library/TVUtils.cs
index 046dd7698f..921bbb808f 100644
--- a/MediaBrowser.Controller/Library/TVUtils.cs
+++ b/MediaBrowser.Controller/Library/TVUtils.cs
@@ -197,12 +197,17 @@ namespace MediaBrowser.Controller.Library
{
var attributes = child.Attributes;
- if (attributes.HasFlag(FileAttributes.Hidden) || attributes.HasFlag(FileAttributes.System))
+ if ((attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
{
continue;
}
- if (attributes.HasFlag(FileAttributes.Directory))
+ if ((attributes & FileAttributes.System) == FileAttributes.System)
+ {
+ continue;
+ }
+
+ if ((attributes & FileAttributes.Directory) == FileAttributes.Directory)
{
if (IsSeasonFolder(child.FullName))
{
diff --git a/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs b/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs
index 9c76680c7e..c546594534 100644
--- a/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs
+++ b/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs
@@ -96,7 +96,7 @@ namespace MediaBrowser.Controller.Resolvers
}
// See if a different path came out of the resolver than what went in
- if (!args.Path.Equals(item.Path, StringComparison.OrdinalIgnoreCase))
+ if (!string.Equals(args.Path, item.Path, StringComparison.OrdinalIgnoreCase))
{
var childData = args.IsDirectory ? args.GetFileSystemEntryByPath(item.Path) : null;
diff --git a/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs b/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs
index 612dc0d42f..ebb79e96bb 100644
--- a/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs
+++ b/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs
@@ -47,20 +47,30 @@ namespace MediaBrowser.Server.Implementations.Library
{
var parentFolderName = Path.GetFileName(Path.GetDirectoryName(args.Path));
- if (string.Equals(parentFolderName, BaseItem.ThemeSongsFolderName, StringComparison.OrdinalIgnoreCase) || string.Equals(parentFolderName, BaseItem.ThemeVideosFolderName, StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(parentFolderName, BaseItem.ThemeSongsFolderName, StringComparison.OrdinalIgnoreCase))
+ {
+ return false;
+ }
+ if (string.Equals(parentFolderName, BaseItem.ThemeVideosFolderName, StringComparison.OrdinalIgnoreCase))
{
return false;
}
// Drives will sometimes be hidden
- if (args.Path.EndsWith(":\\", StringComparison.OrdinalIgnoreCase))
+ if (args.Path.EndsWith(Path.VolumeSeparatorChar + "\\", StringComparison.OrdinalIgnoreCase))
+ {
+ return false;
+ }
+
+ // Shares will sometimes be hidden
+ if (args.Path.StartsWith("\\", StringComparison.OrdinalIgnoreCase))
{
- if (new DriveInfo(args.Path).IsReady)
+ // Look for a share, e.g. \\server\movies
+ // Is there a better way to detect if a path is a share without using native code?
+ if (args.Path.Substring(2).Split(Path.DirectorySeparatorChar).Length == 2)
{
return false;
}
-
- _logger.Error("Operating system reports drive is not ready: {0}", args.Path);
}
return true;
diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
index fb05c8c438..bc122ff6d1 100644
--- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
+++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
@@ -446,24 +446,21 @@ namespace MediaBrowser.Server.Implementations.Library
///
/// Resolves a path into a BaseItem
///
- /// The path.
- /// The parent.
/// The file info.
+ /// The parent.
/// BaseItem.
///
- public BaseItem ResolvePath(string path, Folder parent = null, FileSystemInfo fileInfo = null)
+ public BaseItem ResolvePath(FileSystemInfo fileInfo, Folder parent = null)
{
- if (string.IsNullOrEmpty(path))
+ if (fileInfo == null)
{
- throw new ArgumentNullException();
+ throw new ArgumentNullException("fileInfo");
}
- fileInfo = fileInfo ?? FileSystem.GetFileSystemInfo(path);
-
var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths)
{
Parent = parent,
- Path = path,
+ Path = fileInfo.FullName,
FileInfo = fileInfo
};
@@ -534,7 +531,7 @@ namespace MediaBrowser.Server.Implementations.Library
{
try
{
- var item = ResolvePath(f.FullName, parent, f) as T;
+ var item = ResolvePath(f, parent) as T;
if (item != null)
{
@@ -567,7 +564,7 @@ namespace MediaBrowser.Server.Implementations.Library
Directory.CreateDirectory(rootFolderPath);
}
- var rootFolder = RetrieveItem(rootFolderPath.GetMBId(typeof(AggregateFolder))) as AggregateFolder ?? (AggregateFolder)ResolvePath(rootFolderPath);
+ var rootFolder = RetrieveItem(rootFolderPath.GetMBId(typeof(AggregateFolder))) as AggregateFolder ?? (AggregateFolder)ResolvePath(new DirectoryInfo(rootFolderPath));
// Add in the plug-in folders
foreach (var child in PluginFolderCreators)
@@ -585,7 +582,7 @@ namespace MediaBrowser.Server.Implementations.Library
/// UserRootFolder.
public UserRootFolder GetUserRootFolder(string userRootPath)
{
- return _userRootFolders.GetOrAdd(userRootPath, key => RetrieveItem(userRootPath.GetMBId(typeof(UserRootFolder))) as UserRootFolder ?? (UserRootFolder)ResolvePath(userRootPath));
+ return _userRootFolders.GetOrAdd(userRootPath, key => RetrieveItem(userRootPath.GetMBId(typeof(UserRootFolder))) as UserRootFolder ?? (UserRootFolder)ResolvePath(new DirectoryInfo(userRootPath)));
}
///
diff --git a/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs b/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs
index ef303008de..5a4e27108c 100644
--- a/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs
+++ b/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs
@@ -56,7 +56,7 @@ namespace MediaBrowser.Server.Implementations.Library
if (string.IsNullOrEmpty(item.Name) && !string.IsNullOrEmpty(item.Path))
{
//we use our resolve args name here to get the name of the containg folder, not actual video file
- item.Name = GetMBName(item.ResolveArgs.FileInfo.Name, item.ResolveArgs.FileInfo.Attributes.HasFlag(FileAttributes.Directory));
+ item.Name = GetMBName(item.ResolveArgs.FileInfo.Name, (item.ResolveArgs.FileInfo.Attributes & FileAttributes.Directory) == FileAttributes.Directory);
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs
index 60a262fabf..fa34a6a2e8 100644
--- a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs
+++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs
@@ -40,7 +40,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
}
// If we contain an album assume we are an artist folder
- return args.FileSystemChildren.Where(i => i.Attributes.HasFlag(FileAttributes.Directory)).Any(i => MusicAlbumResolver.IsMusicAlbum(i.FullName)) ? new MusicArtist() : null;
+ return args.FileSystemChildren.Where(i => (i.Attributes & FileAttributes.Directory) == FileAttributes.Directory).Any(i => MusicAlbumResolver.IsMusicAlbum(i.FullName)) ? new MusicArtist() : null;
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
index f54c78f356..a21c15f4f7 100644
--- a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
+++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
@@ -135,7 +135,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
// Loop through each child file/folder and see if we find a video
foreach (var child in args.FileSystemChildren)
{
- if (child.Attributes.HasFlag(FileAttributes.Directory))
+ if ((child.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
{
if (IsDvdDirectory(child.Name))
{