Radarr/src/NzbDrone.Test.Common/StringExtensions.cs

25 lines
607 B
C#
Raw Permalink Normal View History

2013-07-26 05:00:57 +00:00
using System.IO;
using NzbDrone.Common.EnvironmentInfo;
namespace NzbDrone.Test.Common
{
public static class StringExtensions
{
public static string AsOsAgnostic(this string path)
{
2014-12-07 20:54:07 +00:00
if (OsInfo.IsNotWindows)
2013-07-26 05:00:57 +00:00
{
if (path.Length > 2 && path[1] == ':')
{
2013-07-26 05:55:19 +00:00
path = path.Replace(":", "");
path = Path.DirectorySeparatorChar + path;
2013-07-26 05:00:57 +00:00
}
2019-12-22 22:08:53 +00:00
2013-07-26 05:00:57 +00:00
path = path.Replace("\\", Path.DirectorySeparatorChar.ToString());
}
return path;
}
}
2019-12-22 21:24:10 +00:00
}