From 422b82f22032536a0ec6cb7a2578be5e41510532 Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Mon, 29 Apr 2013 17:39:54 -0700 Subject: [PATCH] added path casing extension methods. --- NzbDrone.Common/PathExtensions.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/NzbDrone.Common/PathExtensions.cs b/NzbDrone.Common/PathExtensions.cs index 8cc02afc3..bfdde9b80 100644 --- a/NzbDrone.Common/PathExtensions.cs +++ b/NzbDrone.Common/PathExtensions.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; using NzbDrone.Common.EnsureThat; namespace NzbDrone.Common @@ -32,6 +31,24 @@ public static string CleanPath(this string path) return info.FullName.Trim('/', '\\', ' '); } + static string GetProperDirectoryCapitalization(DirectoryInfo dirInfo) + { + var parentDirInfo = dirInfo.Parent; + if (null == parentDirInfo) + return dirInfo.Name; + return Path.Combine(GetProperDirectoryCapitalization(parentDirInfo), + parentDirInfo.GetDirectories(dirInfo.Name)[0].Name); + } + + static string GetProperFilePathCapitalization(string filename) + { + var fileInfo = new FileInfo(filename); + DirectoryInfo dirInfo = fileInfo.Directory; + return Path.Combine(GetProperDirectoryCapitalization(dirInfo), + dirInfo.GetFiles(fileInfo.Name)[0].Name); + } + + public static string GetAppDataPath(this EnvironmentProvider environmentProvider) { return Path.Combine(environmentProvider.WorkingDirectory, APP_DATA);