@@ -25,22 +25,7 @@ public static string GetFullPath(string path)
25
25
if ( path . Contains ( '\0 ' ) )
26
26
throw new ArgumentException ( SR . Argument_InvalidPathChars , nameof ( path ) ) ;
27
27
28
- // Expand with current directory if necessary
29
- if ( ! IsPathRooted ( path ) )
30
- {
31
- path = Combine ( Interop . Sys . GetCwd ( ) , path ) ;
32
- }
33
-
34
- // We would ideally use realpath to do this, but it resolves symlinks, requires that the file actually exist,
35
- // and turns it into a full path, which we only want if fullCheck is true.
36
- string collapsedString = PathInternal . RemoveRelativeSegments ( path , PathInternal . GetRootLength ( path ) ) ;
37
-
38
- Debug . Assert ( collapsedString . Length < path . Length || collapsedString . ToString ( ) == path ,
39
- "Either we've removed characters, or the string should be unmodified from the input path." ) ;
40
-
41
- string result = collapsedString . Length == 0 ? PathInternal . DirectorySeparatorCharAsString : collapsedString ;
42
-
43
- return result ;
28
+ return GetFullPathInternal ( path ) ;
44
29
}
45
30
46
31
public static string GetFullPath ( string path , string basePath )
@@ -58,9 +43,33 @@ public static string GetFullPath(string path, string basePath)
58
43
throw new ArgumentException ( SR . Argument_InvalidPathChars ) ;
59
44
60
45
if ( IsPathFullyQualified ( path ) )
61
- return GetFullPath ( path ) ;
46
+ return GetFullPathInternal ( path ) ;
47
+
48
+ return GetFullPathInternal ( CombineInternal ( basePath , path ) ) ;
49
+ }
62
50
63
- return GetFullPath ( CombineInternal ( basePath , path ) ) ;
51
+ // Gets the full path without argument validation
52
+ private static string GetFullPathInternal ( string path )
53
+ {
54
+ Debug . Assert ( ! string . IsNullOrEmpty ( path ) ) ;
55
+ Debug . Assert ( ! path . Contains ( '\0 ' ) ) ;
56
+
57
+ // Expand with current directory if necessary
58
+ if ( ! IsPathRooted ( path ) )
59
+ {
60
+ path = Combine ( Interop . Sys . GetCwd ( ) , path ) ;
61
+ }
62
+
63
+ // We would ideally use realpath to do this, but it resolves symlinks, requires that the file actually exist,
64
+ // and turns it into a full path, which we only want if fullCheck is true.
65
+ string collapsedString = PathInternal . RemoveRelativeSegments ( path , PathInternal . GetRootLength ( path ) ) ;
66
+
67
+ Debug . Assert ( collapsedString . Length < path . Length || collapsedString . ToString ( ) == path ,
68
+ "Either we've removed characters, or the string should be unmodified from the input path." ) ;
69
+
70
+ string result = collapsedString . Length == 0 ? PathInternal . DirectorySeparatorCharAsString : collapsedString ;
71
+
72
+ return result ;
64
73
}
65
74
66
75
private static string RemoveLongPathPrefix ( string path )
0 commit comments