Ejemplo n.º 1
0
        public void NormalizeDirectorySeparatorTests(string path, string expected)
        {
            string result = PathInternal.NormalizeDirectorySeparators(path);

            Assert.Equal(expected, result);
            if (string.Equals(path, expected, StringComparison.Ordinal))
            {
                Assert.Same(path, result);
            }
        }
Ejemplo n.º 2
0
        public static string?GetDirectoryName(string?path)
        {
            if (path == null || PathInternal.IsEffectivelyEmpty(path.AsSpan()))
            {
                return(null);
            }

            int end = GetDirectoryNameOffset(path.AsSpan());

            return(end >= 0 ? PathInternal.NormalizeDirectorySeparators(path.Substring(0, end)) : null);
        }
Ejemplo n.º 3
0
        public static string?GetDirectoryName(string?path)   // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/26761
        {
            if (path == null || PathInternal.IsEffectivelyEmpty(path.AsSpan()))
            {
                return(null);
            }

            int end = GetDirectoryNameOffset(path.AsSpan());

            return(end >= 0 ? PathInternal.NormalizeDirectorySeparators(path.Substring(0, end)) : null);
        }
Ejemplo n.º 4
0
        public static string?GetPathRoot(string?path)
        {
            if (PathInternal.IsEffectivelyEmpty(path.AsSpan()))
            {
                return(null);
            }

            ReadOnlySpan <char> result = GetPathRoot(path.AsSpan());

            if (path !.Length == result.Length)
            {
                return(PathInternal.NormalizeDirectorySeparators(path));
            }

            return(PathInternal.NormalizeDirectorySeparators(result.ToString()));
        }