From 579b507f7fa322fdf8a746b6e787015d0567e2a6 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 30 Oct 2013 19:15:58 -0400 Subject: use IFileSystem interface to get creation time --- .../IO/CommonFileSystem.cs | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'MediaBrowser.ServerApplication/IO/CommonFileSystem.cs') diff --git a/MediaBrowser.ServerApplication/IO/CommonFileSystem.cs b/MediaBrowser.ServerApplication/IO/CommonFileSystem.cs index b777930f3..dee9bd9d7 100644 --- a/MediaBrowser.ServerApplication/IO/CommonFileSystem.cs +++ b/MediaBrowser.ServerApplication/IO/CommonFileSystem.cs @@ -1,4 +1,5 @@ using MediaBrowser.Controller.IO; +using MediaBrowser.Model.Logging; using System; using System.IO; using System.Text; @@ -10,6 +11,13 @@ namespace MediaBrowser.ServerApplication.IO /// public class CommonFileSystem : IFileSystem { + protected ILogger Logger; + + public CommonFileSystem(ILogger logger) + { + Logger = logger; + } + /// /// Determines whether the specified filename is shortcut. /// @@ -137,6 +145,25 @@ namespace MediaBrowser.ServerApplication.IO return builder.ToString(); } + + /// + /// Gets the creation time UTC. + /// + /// The info. + /// DateTime. + public DateTime GetCreationTimeUtc(FileSystemInfo info) + { + // This could throw an error on some file systems that have dates out of range + try + { + return info.CreationTimeUtc; + } + catch (Exception ex) + { + Logger.ErrorException("Error determining CreationTimeUtc for {0}", ex, info.FullName); + return DateTime.MinValue; + } + } } -- cgit v1.2.3