diff options
Diffstat (limited to 'MediaBrowser.Common.Implementations/IO/CommonFileSystem.cs')
| -rw-r--r-- | MediaBrowser.Common.Implementations/IO/CommonFileSystem.cs | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/MediaBrowser.Common.Implementations/IO/CommonFileSystem.cs b/MediaBrowser.Common.Implementations/IO/CommonFileSystem.cs index 3e02d96f6..98e81981d 100644 --- a/MediaBrowser.Common.Implementations/IO/CommonFileSystem.cs +++ b/MediaBrowser.Common.Implementations/IO/CommonFileSystem.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.IO; +using MediaBrowser.Common.Extensions; +using MediaBrowser.Common.IO; using MediaBrowser.Model.Logging; using System; using System.IO; @@ -332,5 +333,34 @@ namespace MediaBrowser.Common.Implementations.IO return path.TrimEnd(Path.DirectorySeparatorChar); } + + public string SubstitutePath(string path, string from, string to) + { + if (string.IsNullOrWhiteSpace(path)) + { + throw new ArgumentNullException("path"); + } + if (string.IsNullOrWhiteSpace(from)) + { + throw new ArgumentNullException("from"); + } + if (string.IsNullOrWhiteSpace(to)) + { + throw new ArgumentNullException("to"); + } + + path = path.Replace(from, to, StringComparison.OrdinalIgnoreCase); + + if (to.IndexOf('/') != -1) + { + path = path.Replace('\\', '/'); + } + else + { + path = path.Replace('/', '\\'); + } + + return path; + } } } |
