Fix calls to functions moved from PathInternal to Path
authorStephen Toub <stoub@microsoft.com>
Fri, 31 May 2019 02:54:01 +0000 (22:54 -0400)
committerStephen Toub <stoub@microsoft.com>
Fri, 7 Jun 2019 03:11:50 +0000 (23:11 -0400)
Commit migrated from https://github.com/dotnet/corefx/commit/b60e3c347d0af66dc7f7788b736be7f5315c3ad1

src/libraries/System.IO.FileSystem/src/System/IO/DirectoryInfo.cs
src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEntry.cs
src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Unix.cs
src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Windows.cs
src/libraries/System.IO.FileSystem/src/System/IO/FileStatus.Unix.cs
src/libraries/System.IO.FileSystem/src/System/IO/FileSystem.Exists.Unix.cs
src/libraries/System.IO.FileSystem/src/System/IO/FileSystem.Unix.cs
src/libraries/System.IO.FileSystem/src/System/IO/FileSystem.Windows.cs
src/libraries/System.IO.FileSystem/src/System/IO/FileSystemInfo.Unix.cs

index ee2a6bf..a71556d 100644 (file)
@@ -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<char> trimmedNewPath = PathInternal.TrimEndingDirectorySeparator(newPath.AsSpan());
-            ReadOnlySpan<char> trimmedCurrentPath = PathInternal.TrimEndingDirectorySeparator(FullPath.AsSpan());
+            ReadOnlySpan<char> trimmedNewPath = Path.TrimEndingDirectorySeparator(newPath.AsSpan());
+            ReadOnlySpan<char> trimmedCurrentPath = Path.TrimEndingDirectorySeparator(FullPath.AsSpan());
 
             // We want to make sure the requested directory is actually under the subdirectory.
             if (trimmedNewPath.StartsWith(trimmedCurrentPath, PathInternal.StringComparison)
index e071aa5..bfb3491 100644 (file)
@@ -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<char> 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);
index 9983329..b8b115f 100644 (file)
@@ -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
index f0fbb3f..b996a98 100644 (file)
@@ -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
index e2a8a88..562beaa 100644 (file)
@@ -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)
             {
index 93f4e38..c02b8e5 100644 (file)
@@ -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<char> fullPath, int fileType, out Interop.ErrorInfo errorInfo)
index cba6fb5..20442eb 100644 (file)
@@ -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))
index 91756c0..acf3dab 100644 (file)
@@ -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)
                 {
index aac479e..60618fb 100644 (file)
@@ -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);
         }