From: Stephen Toub Date: Fri, 31 May 2019 02:54:01 +0000 (-0400) Subject: Fix calls to functions moved from PathInternal to Path X-Git-Tag: submit/tizen/20210909.063632~11031^2~1366 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ace68b26f52626fa1f228955f29a2f9d4ba0f9a1;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Fix calls to functions moved from PathInternal to Path Commit migrated from https://github.com/dotnet/corefx/commit/b60e3c347d0af66dc7f7788b736be7f5315c3ad1 --- diff --git a/src/libraries/System.IO.FileSystem/src/System/IO/DirectoryInfo.cs b/src/libraries/System.IO.FileSystem/src/System/IO/DirectoryInfo.cs index ee2a6bf..a71556d 100644 --- a/src/libraries/System.IO.FileSystem/src/System/IO/DirectoryInfo.cs +++ b/src/libraries/System.IO.FileSystem/src/System/IO/DirectoryInfo.cs @@ -42,7 +42,7 @@ namespace System.IO _name = fileName ?? (PathInternal.IsRoot(fullPath.AsSpan()) ? fullPath.AsSpan() : - Path.GetFileName(PathInternal.TrimEndingDirectorySeparator(fullPath.AsSpan()))).ToString(); + Path.GetFileName(Path.TrimEndingDirectorySeparator(fullPath.AsSpan()))).ToString(); FullPath = fullPath; } @@ -54,7 +54,7 @@ namespace System.IO // FullPath might end in either "parent\child" or "parent\child\", and in either case we want // the parent of child, not the child. Trim off an ending directory separator if there is one, // but don't mangle the root. - string parentName = Path.GetDirectoryName(PathInternal.IsRoot(FullPath.AsSpan()) ? FullPath : PathInternal.TrimEndingDirectorySeparator(FullPath)); + string parentName = Path.GetDirectoryName(PathInternal.IsRoot(FullPath.AsSpan()) ? FullPath : Path.TrimEndingDirectorySeparator(FullPath)); return parentName != null ? new DirectoryInfo(parentName, isNormalized: true) : null; @@ -72,8 +72,8 @@ namespace System.IO string newPath = Path.GetFullPath(Path.Combine(FullPath, path)); - ReadOnlySpan trimmedNewPath = PathInternal.TrimEndingDirectorySeparator(newPath.AsSpan()); - ReadOnlySpan trimmedCurrentPath = PathInternal.TrimEndingDirectorySeparator(FullPath.AsSpan()); + ReadOnlySpan trimmedNewPath = Path.TrimEndingDirectorySeparator(newPath.AsSpan()); + ReadOnlySpan trimmedCurrentPath = Path.TrimEndingDirectorySeparator(FullPath.AsSpan()); // We want to make sure the requested directory is actually under the subdirectory. if (trimmedNewPath.StartsWith(trimmedCurrentPath, PathInternal.StringComparison) diff --git a/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEntry.cs b/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEntry.cs index e071aa5..bfb3491 100644 --- a/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEntry.cs +++ b/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEntry.cs @@ -41,7 +41,7 @@ namespace System.IO.Enumeration // didn't have a separator. Join() would handle it if we did trim it, not doing so is an optimization. ReadOnlySpan relativePath = Directory.Slice(RootDirectory.Length); - if (PathInternal.EndsInDirectorySeparator(OriginalRootDirectory) && PathInternal.StartsWithDirectorySeparator(relativePath)) + if (Path.EndsInDirectorySeparator(OriginalRootDirectory) && PathInternal.StartsWithDirectorySeparator(relativePath)) relativePath = relativePath.Slice(1); return Path.Join(OriginalRootDirectory, relativePath, FileName); diff --git a/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Unix.cs b/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Unix.cs index 9983329..b8b115f 100644 --- a/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Unix.cs +++ b/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Unix.cs @@ -41,7 +41,7 @@ namespace System.IO.Enumeration public FileSystemEnumerator(string directory, EnumerationOptions options = null) { _originalRootDirectory = directory ?? throw new ArgumentNullException(nameof(directory)); - _rootDirectory = PathInternal.TrimEndingDirectorySeparator(Path.GetFullPath(directory)); + _rootDirectory = Path.TrimEndingDirectorySeparator(Path.GetFullPath(directory)); _options = options ?? EnumerationOptions.Default; // We need to initialize the directory handle up front to ensure diff --git a/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Windows.cs b/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Windows.cs index f0fbb3f..b996a98 100644 --- a/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Windows.cs +++ b/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Windows.cs @@ -49,7 +49,7 @@ namespace System.IO.Enumeration public FileSystemEnumerator(string directory, EnumerationOptions options = null) { _originalRootDirectory = directory ?? throw new ArgumentNullException(nameof(directory)); - _rootDirectory = PathInternal.TrimEndingDirectorySeparator(Path.GetFullPath(directory)); + _rootDirectory = Path.TrimEndingDirectorySeparator(Path.GetFullPath(directory)); _options = options ?? EnumerationOptions.Default; // We'll only suppress the media insertion prompt on the topmost directory as that is the diff --git a/src/libraries/System.IO.FileSystem/src/System/IO/FileStatus.Unix.cs b/src/libraries/System.IO.FileSystem/src/System/IO/FileStatus.Unix.cs index e2a8a88..562beaa 100644 --- a/src/libraries/System.IO.FileSystem/src/System/IO/FileStatus.Unix.cs +++ b/src/libraries/System.IO.FileSystem/src/System/IO/FileStatus.Unix.cs @@ -271,7 +271,7 @@ namespace System.IO // storing those results separately. We only report failure if the initial // lstat fails, as a broken symlink should still report info on exists, attributes, etc. _isDirectory = false; - path = PathInternal.TrimEndingDirectorySeparator(path); + path = Path.TrimEndingDirectorySeparator(path); int result = Interop.Sys.LStat(path, out _fileStatus); if (result < 0) { diff --git a/src/libraries/System.IO.FileSystem/src/System/IO/FileSystem.Exists.Unix.cs b/src/libraries/System.IO.FileSystem/src/System/IO/FileSystem.Exists.Unix.cs index 93f4e38..c02b8e5 100644 --- a/src/libraries/System.IO.FileSystem/src/System/IO/FileSystem.Exists.Unix.cs +++ b/src/libraries/System.IO.FileSystem/src/System/IO/FileSystem.Exists.Unix.cs @@ -30,7 +30,7 @@ namespace System.IO // our historical behavior (outside of File.Exists()), we need to trim. // // See http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html#tag_04_11 for details. - return FileExists(PathInternal.TrimEndingDirectorySeparator(fullPath), Interop.Sys.FileTypes.S_IFREG, out ignored); + return FileExists(Path.TrimEndingDirectorySeparator(fullPath), Interop.Sys.FileTypes.S_IFREG, out ignored); } private static bool FileExists(ReadOnlySpan fullPath, int fileType, out Interop.ErrorInfo errorInfo) diff --git a/src/libraries/System.IO.FileSystem/src/System/IO/FileSystem.Unix.cs b/src/libraries/System.IO.FileSystem/src/System/IO/FileSystem.Unix.cs index cba6fb5..20442eb 100644 --- a/src/libraries/System.IO.FileSystem/src/System/IO/FileSystem.Unix.cs +++ b/src/libraries/System.IO.FileSystem/src/System/IO/FileSystem.Unix.cs @@ -218,7 +218,7 @@ namespace System.IO // Input allows trailing separators in order to match Windows behavior // Unix does not accept trailing separators, so must be trimmed - if (!FileExists(PathInternal.TrimEndingDirectorySeparator(fullPath), + if (!FileExists(Path.TrimEndingDirectorySeparator(fullPath), Interop.Sys.FileTypes.S_IFREG, out fileExistsError) && fileExistsError.Error == Interop.Error.ENOENT) { @@ -241,7 +241,7 @@ namespace System.IO int length = fullPath.Length; // We need to trim the trailing slash or the code will try to create 2 directories of the same name. - if (length >= 2 && PathInternal.EndsInDirectorySeparator(fullPath)) + if (length >= 2 && Path.EndsInDirectorySeparator(fullPath)) { length--; } @@ -348,11 +348,11 @@ namespace System.IO // This surfaces as a IOException, if we let it go beyond here it would // give DirectoryNotFound. - if (PathInternal.EndsInDirectorySeparator(sourceFullPath)) + if (Path.EndsInDirectorySeparator(sourceFullPath)) throw new IOException(SR.Format(SR.IO_PathNotFound_Path, sourceFullPath)); // ... but it doesn't care if the destination has a trailing separator. - destFullPath = PathInternal.TrimEndingDirectorySeparator(destFullPath); + destFullPath = Path.TrimEndingDirectorySeparator(destFullPath); } if (FileExists(destFullPath)) diff --git a/src/libraries/System.IO.FileSystem/src/System/IO/FileSystem.Windows.cs b/src/libraries/System.IO.FileSystem/src/System/IO/FileSystem.Windows.cs index 91756c0..acf3dab 100644 --- a/src/libraries/System.IO.FileSystem/src/System/IO/FileSystem.Windows.cs +++ b/src/libraries/System.IO.FileSystem/src/System/IO/FileSystem.Windows.cs @@ -82,7 +82,7 @@ namespace System.IO int length = fullPath.Length; // We need to trim the trailing slash or the code will try to create 2 directories of the same name. - if (length >= 2 && PathInternal.EndsInDirectorySeparator(fullPath.AsSpan())) + if (length >= 2 && Path.EndsInDirectorySeparator(fullPath.AsSpan())) length--; int lengthRoot = PathInternal.GetRootLength(fullPath.AsSpan()); @@ -200,7 +200,7 @@ namespace System.IO int errorCode = Interop.Errors.ERROR_SUCCESS; // Neither GetFileAttributes or FindFirstFile like trailing separators - path = PathInternal.TrimEndingDirectorySeparator(path); + path = Path.TrimEndingDirectorySeparator(path); using (DisableMediaInsertionPrompt.Create()) { @@ -408,7 +408,7 @@ namespace System.IO private static void GetFindData(string fullPath, ref Interop.Kernel32.WIN32_FIND_DATA findData) { - using (SafeFindHandle handle = Interop.Kernel32.FindFirstFile(PathInternal.TrimEndingDirectorySeparator(fullPath), ref findData)) + using (SafeFindHandle handle = Interop.Kernel32.FindFirstFile(Path.TrimEndingDirectorySeparator(fullPath), ref findData)) { if (handle.IsInvalid) { diff --git a/src/libraries/System.IO.FileSystem/src/System/IO/FileSystemInfo.Unix.cs b/src/libraries/System.IO.FileSystem/src/System/IO/FileSystemInfo.Unix.cs index aac479e..60618fb 100644 --- a/src/libraries/System.IO.FileSystem/src/System/IO/FileSystemInfo.Unix.cs +++ b/src/libraries/System.IO.FileSystem/src/System/IO/FileSystemInfo.Unix.cs @@ -75,7 +75,7 @@ namespace System.IO // being manipulated concurrently with these checks) is that we throw a // FileNotFoundException instead of DirectoryNotFoundException. - bool directoryError = !Directory.Exists(Path.GetDirectoryName(PathInternal.TrimEndingDirectorySeparator(path))); + bool directoryError = !Directory.Exists(Path.GetDirectoryName(Path.TrimEndingDirectorySeparator(path))); throw Interop.GetExceptionForIoErrno(new Interop.ErrorInfo(Interop.Error.ENOENT), path, directoryError); }