예제 #1
0
파일: OsPath.cs 프로젝트: rmangaha/Radarr
        private static string FixSlashes(string path, OsPathKind kind)
        {
            switch (kind)
            {
            case OsPathKind.Windows:
                return(path.Replace('/', '\\'));

            case OsPathKind.Unix:
                return(path.Replace('\\', '/'));
            }

            return(path);
        }
예제 #2
0
파일: OsPath.cs 프로젝트: rmangaha/Radarr
 public OsPath(string path, OsPathKind kind)
 {
     if (path == null)
     {
         _kind = kind;
         _path = string.Empty;
     }
     else
     {
         _kind = kind;
         _path = FixSlashes(path, kind);
     }
 }
예제 #3
0
파일: OsPath.cs 프로젝트: rmangaha/Radarr
 public OsPath(string path)
 {
     if (path == null)
     {
         _kind = OsPathKind.Unknown;
         _path = string.Empty;
     }
     else
     {
         _kind = DetectPathKind(path);
         _path = FixSlashes(path, _kind);
     }
 }
예제 #4
0
파일: OsPath.cs 프로젝트: Macharr/Macharr
        private static string FixSlashes(string path, OsPathKind kind)
        {
            switch (kind)
            {
            case OsPathKind.Windows:
                return(path.Replace('/', '\\'));

            case OsPathKind.Unix:
                path = path.Replace('\\', '/');
                while (path.Contains("//"))
                {
                    path = path.Replace("//", "/");
                }
                return(path);
            }

            return(path);
        }
예제 #5
0
        public void should_auto_detect_kind(string path, OsPathKind kind)
        {
            var result = new OsPath(path);

            result.Kind.Should().Be(kind);

            if (kind == OsPathKind.Windows)
            {
                result.IsWindowsPath.Should().BeTrue();
                result.IsUnixPath.Should().BeFalse();
            }
            else if (kind == OsPathKind.Unix)
            {
                result.IsWindowsPath.Should().BeFalse();
                result.IsUnixPath.Should().BeTrue();
            }
            else
            {
                result.IsWindowsPath.Should().BeFalse();
                result.IsUnixPath.Should().BeFalse();
            }
        }
예제 #6
0
        public void should_auto_detect_kind(String path, OsPathKind kind)
        {
            var result = new OsPath(path);

            result.Kind.Should().Be(kind);

            if (kind == OsPathKind.Windows)
            {
                result.IsWindowsPath.Should().BeTrue();
                result.IsUnixPath.Should().BeFalse();
            }
            else if (kind == OsPathKind.Unix)
            {
                result.IsWindowsPath.Should().BeFalse();
                result.IsUnixPath.Should().BeTrue();
            }
            else
            {
                result.IsWindowsPath.Should().BeFalse();
                result.IsUnixPath.Should().BeFalse();
            }
        }