use IFileSystem interface to get creation time

This commit is contained in:
Luke Pulverenti
2013-10-30 19:15:58 -04:00
parent d5baaa1f67
commit 579b507f7f
9 changed files with 52 additions and 31 deletions

View File

@@ -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
/// </summary>
public class CommonFileSystem : IFileSystem
{
protected ILogger Logger;
public CommonFileSystem(ILogger logger)
{
Logger = logger;
}
/// <summary>
/// Determines whether the specified filename is shortcut.
/// </summary>
@@ -137,6 +145,25 @@ namespace MediaBrowser.ServerApplication.IO
return builder.ToString();
}
/// <summary>
/// Gets the creation time UTC.
/// </summary>
/// <param name="info">The info.</param>
/// <returns>DateTime.</returns>
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;
}
}
}