diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-10-31 10:03:23 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-10-31 10:03:23 -0400 |
| commit | 6c8d9192985036acb3d1fe626ed57980bb862d6a (patch) | |
| tree | 94d59b266b877bf0b073c5e3291cb2822dc055f7 /MediaBrowser.Controller/IO | |
| parent | 579b507f7fa322fdf8a746b6e787015d0567e2a6 (diff) | |
replace file system calls with IFileSystem when needed
Diffstat (limited to 'MediaBrowser.Controller/IO')
| -rw-r--r-- | MediaBrowser.Controller/IO/FileData.cs | 3 | ||||
| -rw-r--r-- | MediaBrowser.Controller/IO/FileSystem.cs | 71 | ||||
| -rw-r--r-- | MediaBrowser.Controller/IO/IFileSystem.cs | 53 |
3 files changed, 2 insertions, 125 deletions
diff --git a/MediaBrowser.Controller/IO/FileData.cs b/MediaBrowser.Controller/IO/FileData.cs index 726467fa6..270afd89a 100644 --- a/MediaBrowser.Controller/IO/FileData.cs +++ b/MediaBrowser.Controller/IO/FileData.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Controller.Library; +using MediaBrowser.Common.IO; +using MediaBrowser.Controller.Library; using MediaBrowser.Model.Logging; using System; using System.Collections.Generic; diff --git a/MediaBrowser.Controller/IO/FileSystem.cs b/MediaBrowser.Controller/IO/FileSystem.cs deleted file mode 100644 index b08e8da27..000000000 --- a/MediaBrowser.Controller/IO/FileSystem.cs +++ /dev/null @@ -1,71 +0,0 @@ -using MediaBrowser.Model.Logging; -using System; -using System.IO; - -namespace MediaBrowser.Controller.IO -{ - /// <summary> - /// Class FileSystem - /// </summary> - public static class FileSystem - { - /// <summary> - /// Gets the creation time UTC. - /// </summary> - /// <param name="info">The info.</param> - /// <param name="logger">The logger.</param> - /// <returns>DateTime.</returns> - public static DateTime GetLastWriteTimeUtc(FileSystemInfo info, ILogger logger) - { - // This could throw an error on some file systems that have dates out of range - - try - { - return info.LastWriteTimeUtc; - } - catch (Exception ex) - { - logger.ErrorException("Error determining LastAccessTimeUtc for {0}", ex, info.FullName); - return DateTime.MinValue; - } - } - - /// <summary> - /// Copies all. - /// </summary> - /// <param name="source">The source.</param> - /// <param name="target">The target.</param> - /// <exception cref="System.ArgumentNullException">source</exception> - /// <exception cref="System.ArgumentException">The source and target directories are the same</exception> - public static void CopyAll(string source, string target) - { - if (string.IsNullOrEmpty(source)) - { - throw new ArgumentNullException("source"); - } - if (string.IsNullOrEmpty(target)) - { - throw new ArgumentNullException("target"); - } - - if (source.Equals(target, StringComparison.OrdinalIgnoreCase)) - { - throw new ArgumentException("The source and target directories are the same"); - } - - // Check if the target directory exists, if not, create it. - Directory.CreateDirectory(target); - - foreach (var file in Directory.EnumerateFiles(source)) - { - File.Copy(file, Path.Combine(target, Path.GetFileName(file)), true); - } - - // Copy each subdirectory using recursion. - foreach (var dir in Directory.EnumerateDirectories(source)) - { - CopyAll(dir, Path.Combine(target, Path.GetFileName(dir))); - } - } - } -} diff --git a/MediaBrowser.Controller/IO/IFileSystem.cs b/MediaBrowser.Controller/IO/IFileSystem.cs deleted file mode 100644 index cbc5c7bf3..000000000 --- a/MediaBrowser.Controller/IO/IFileSystem.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.IO; - -namespace MediaBrowser.Controller.IO -{ - /// <summary> - /// Interface IFileSystem - /// </summary> - public interface IFileSystem - { - /// <summary> - /// Determines whether the specified filename is shortcut. - /// </summary> - /// <param name="filename">The filename.</param> - /// <returns><c>true</c> if the specified filename is shortcut; otherwise, <c>false</c>.</returns> - bool IsShortcut(string filename); - - /// <summary> - /// Resolves the shortcut. - /// </summary> - /// <param name="filename">The filename.</param> - /// <returns>System.String.</returns> - string ResolveShortcut(string filename); - - /// <summary> - /// Creates the shortcut. - /// </summary> - /// <param name="shortcutPath">The shortcut path.</param> - /// <param name="target">The target.</param> - void CreateShortcut(string shortcutPath, string target); - - /// <summary> - /// Gets the file system info. - /// </summary> - /// <param name="path">The path.</param> - /// <returns>FileSystemInfo.</returns> - FileSystemInfo GetFileSystemInfo(string path); - - /// <summary> - /// Gets the valid filename. - /// </summary> - /// <param name="filename">The filename.</param> - /// <returns>System.String.</returns> - string GetValidFilename(string filename); - - /// <summary> - /// Gets the creation time UTC. - /// </summary> - /// <param name="info">The info.</param> - /// <returns>DateTime.</returns> - DateTime GetCreationTimeUtc(FileSystemInfo info); - } -} |
