diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-12-01 07:43:34 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-12-01 07:43:34 -0500 |
| commit | dc8fb33a1f5ad474fed88d58a19c1098c68b815f (patch) | |
| tree | f25dbe0019c0ee3f872d3c7d57ac70bed2076b33 /MediaBrowser.Common/IO/FileSystemRepository.cs | |
| parent | d7bdb744ca9d4b3955071dfe3c38ed631dbafbfd (diff) | |
updated nuget
Diffstat (limited to 'MediaBrowser.Common/IO/FileSystemRepository.cs')
| -rw-r--r-- | MediaBrowser.Common/IO/FileSystemRepository.cs | 122 |
1 files changed, 0 insertions, 122 deletions
diff --git a/MediaBrowser.Common/IO/FileSystemRepository.cs b/MediaBrowser.Common/IO/FileSystemRepository.cs deleted file mode 100644 index 07328d72d..000000000 --- a/MediaBrowser.Common/IO/FileSystemRepository.cs +++ /dev/null @@ -1,122 +0,0 @@ -using MediaBrowser.Common.Extensions; -using System; -using System.IO; - -namespace MediaBrowser.Common.IO -{ - /// <summary> - /// This is a wrapper for storing large numbers of files within a directory on a file system. - /// Simply pass a filename into GetResourcePath and it will return a full path location of where the file should be stored. - /// </summary> - public class FileSystemRepository - { - /// <summary> - /// Gets or sets the path. - /// </summary> - /// <value>The path.</value> - protected string Path { get; set; } - - /// <summary> - /// Initializes a new instance of the <see cref="FileSystemRepository" /> class. - /// </summary> - /// <param name="path">The path.</param> - /// <exception cref="System.ArgumentNullException"></exception> - public FileSystemRepository(string path) - { - if (string.IsNullOrEmpty(path)) - { - throw new ArgumentNullException(); - } - - Path = path; - } - - /// <summary> - /// Gets the full path of where a resource should be stored within the repository - /// </summary> - /// <param name="uniqueName">Name of the unique.</param> - /// <param name="fileExtension">The file extension.</param> - /// <returns>System.String.</returns> - /// <exception cref="System.ArgumentNullException"> - /// </exception> - public string GetResourcePath(string uniqueName, string fileExtension) - { - if (string.IsNullOrEmpty(uniqueName)) - { - throw new ArgumentNullException("uniqueName"); - } - - if (string.IsNullOrEmpty(fileExtension)) - { - throw new ArgumentNullException("fileExtension"); - } - - var filename = uniqueName.GetMD5() + fileExtension; - - return GetResourcePath(filename); - } - - /// <summary> - /// Gets the resource path. - /// </summary> - /// <param name="filename">The filename.</param> - /// <returns>System.String.</returns> - /// <exception cref="System.ArgumentNullException"></exception> - public string GetResourcePath(string filename) - { - if (string.IsNullOrEmpty(filename)) - { - throw new ArgumentNullException("filename"); - } - - var prefix = filename.Substring(0, 1); - - var path = System.IO.Path.Combine(Path, prefix); - - return System.IO.Path.Combine(path, filename); - } - - /// <summary> - /// Determines if a resource is present in the repository - /// </summary> - /// <param name="uniqueName">Name of the unique.</param> - /// <param name="fileExtension">The file extension.</param> - /// <returns><c>true</c> if the specified unique name contains resource; otherwise, <c>false</c>.</returns> - public bool ContainsResource(string uniqueName, string fileExtension) - { - return ContainsFilePath(GetResourcePath(uniqueName, fileExtension)); - } - - /// <summary> - /// Determines if a file with a given name is present in the repository - /// </summary> - /// <param name="filename">The filename.</param> - /// <returns><c>true</c> if the specified filename contains filename; otherwise, <c>false</c>.</returns> - /// <exception cref="System.ArgumentNullException"></exception> - public bool ContainsFilename(string filename) - { - if (string.IsNullOrEmpty(filename)) - { - throw new ArgumentNullException(); - } - - return ContainsFilePath(GetResourcePath(filename)); - } - - /// <summary> - /// Determines if a file is present in the repository - /// </summary> - /// <param name="path">The path.</param> - /// <returns><c>true</c> if [contains file path] [the specified path]; otherwise, <c>false</c>.</returns> - /// <exception cref="System.ArgumentNullException"></exception> - public bool ContainsFilePath(string path) - { - if (string.IsNullOrEmpty(path)) - { - throw new ArgumentNullException(); - } - - return File.Exists(path); - } - } -} |
