This repository was archived by the owner on Jan 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-21
lines changed
System.IO.Compression.ZipFile/src
System.Runtime/tests/System/IO Expand file tree Collapse file tree 2 files changed +14
-21
lines changed Original file line number Diff line number Diff line change 24
24
</ItemGroup >
25
25
<!-- Windows -->
26
26
<ItemGroup Condition =" '$(TargetsWindows)' == 'true'" >
27
- <Compile Include =" $(CommonPath)\System\IO\PathInternal.Windows.cs" >
28
- <Link >Common\System\IO\PathInternal.Windows.cs</Link >
29
- </Compile >
30
27
<Compile Include =" $(CommonPath)\System\IO\PathInternal.CaseInsensitive.cs" >
31
28
<Link >Common\System\IO\PathInternal.CaseInsensitive.cs</Link >
32
29
</Compile >
33
30
</ItemGroup >
34
- <!-- Unix -->
35
- <ItemGroup Condition =" '$(TargetsUnix)' == 'true'" >
36
- <Compile Include =" $(CommonPath)\System\IO\PathInternal.Unix.cs" >
37
- <Link >Common\System\IO\PathInternal.Unix.cs</Link >
38
- </Compile >
39
- </ItemGroup >
40
31
<!-- FreeBSD -->
41
32
<ItemGroup Condition =" '$(TargetsFreeBSD)' == 'true'" >
42
33
<Compile Include =" $(CommonPath)\System\IO\PathInternal.CaseSensitive.cs" >
Original file line number Diff line number Diff line change @@ -38,18 +38,20 @@ public static void PathTooLongException_From_Path()
38
38
// This test case ensures that the PathTooLongException defined in System.IO.Primitives is the same that
39
39
// is thrown by Path. The S.IO.FS.P implementation forwards to the core assembly to ensure this is true.
40
40
41
- string subPath = "subdir\\ " ;
42
- const int MAX_PATH = 260 ;
43
-
44
- // Create a relative path that is longer than maxpath.
45
- StringBuilder path = new StringBuilder ( ) ;
46
- while ( path . Length <= MAX_PATH )
41
+ // Build up a path until GetFullPath throws, and verify that the right exception type
42
+ // emerges from it and related APIs.
43
+ var sb = new StringBuilder ( "directoryNameHere" + Path . DirectorySeparatorChar ) ;
44
+ string path = null ;
45
+ Assert . Throws < PathTooLongException > ( new Action ( ( ) =>
47
46
{
48
- path . Append ( subPath ) ;
49
- }
50
-
51
- // Not available in N: Assert.Throws<PathTooLongException>(() => Path.GetFullPath(path.ToString()));
52
- Assert . Throws < PathTooLongException > ( ( ) => Path . GetPathRoot ( path . ToString ( ) ) ) ;
53
- Assert . Throws < PathTooLongException > ( ( ) => Path . GetDirectoryName ( path . ToString ( ) ) ) ;
47
+ while ( true )
48
+ {
49
+ path = sb . ToString ( ) ;
50
+ Path . GetPathRoot ( path ) ; // will eventually throw when path is too long
51
+ sb . Append ( path ) ; // double the number of directories for the next time
52
+ }
53
+ } ) ) ;
54
+ Assert . Throws < PathTooLongException > ( ( ) => Path . GetFullPath ( path ) ) ;
55
+ Assert . Throws < PathTooLongException > ( ( ) => Path . GetDirectoryName ( path ) ) ;
54
56
}
55
57
}
You can’t perform that action at this time.
0 commit comments