@@ -15,6 +15,8 @@ public static class DirectoryHelper
15
15
{ "gitmodules" , ".gitmodules" } ,
16
16
} ;
17
17
18
+ private static readonly Type [ ] whitelist = { typeof ( IOException ) , typeof ( UnauthorizedAccessException ) } ;
19
+
18
20
public static void CopyFilesRecursively ( DirectoryInfo source , DirectoryInfo target )
19
21
{
20
22
// From http://stackoverflow.com/questions/58744/best-way-to-copy-the-entire-contents-of-a-directory-in-c/58779#58779
@@ -34,15 +36,6 @@ private static string Rename(string name)
34
36
return toRename . ContainsKey ( name ) ? toRename [ name ] : name ;
35
37
}
36
38
37
- public static void DeleteSubdirectories ( string parentPath )
38
- {
39
- string [ ] dirs = Directory . GetDirectories ( parentPath ) ;
40
- foreach ( string dir in dirs )
41
- {
42
- DeleteDirectory ( dir ) ;
43
- }
44
- }
45
-
46
39
public static void DeleteDirectory ( string directoryPath )
47
40
{
48
41
// From http://stackoverflow.com/questions/329355/cannot-delete-directory-with-directory-deletepath-true/329502#329502
@@ -53,28 +46,26 @@ public static void DeleteDirectory(string directoryPath)
53
46
return ;
54
47
}
55
48
NormalizeAttributes ( directoryPath ) ;
56
- TryDeleteDirectory ( directoryPath , maxAttempts : 5 , initialTimeout : 16 , timeoutFactor : 2 ) ;
49
+ DeleteDirectory ( directoryPath , maxAttempts : 5 , initialTimeout : 16 , timeoutFactor : 2 ) ;
57
50
}
58
51
59
52
private static void NormalizeAttributes ( string directoryPath )
60
53
{
61
- string [ ] files = Directory . GetFiles ( directoryPath ) ;
62
- string [ ] dirs = Directory . GetDirectories ( directoryPath ) ;
54
+ string [ ] filePaths = Directory . GetFiles ( directoryPath ) ;
55
+ string [ ] subdirectoryPaths = Directory . GetDirectories ( directoryPath ) ;
63
56
64
- foreach ( string file in files )
57
+ foreach ( string filePath in filePaths )
65
58
{
66
- File . SetAttributes ( file , FileAttributes . Normal ) ;
59
+ File . SetAttributes ( filePath , FileAttributes . Normal ) ;
67
60
}
68
- foreach ( string dir in dirs )
61
+ foreach ( string subdirectoryPath in subdirectoryPaths )
69
62
{
70
- NormalizeAttributes ( dir ) ;
63
+ NormalizeAttributes ( subdirectoryPath ) ;
71
64
}
72
65
File . SetAttributes ( directoryPath , FileAttributes . Normal ) ;
73
66
}
74
67
75
- private static readonly Type [ ] whitelist = { typeof ( IOException ) , typeof ( UnauthorizedAccessException ) } ;
76
-
77
- private static void TryDeleteDirectory ( string directoryPath , int maxAttempts , int initialTimeout , int timeoutFactor )
68
+ private static void DeleteDirectory ( string directoryPath , int maxAttempts , int initialTimeout , int timeoutFactor )
78
69
{
79
70
for ( int attempt = 1 ; attempt <= maxAttempts ; attempt ++ )
80
71
{
0 commit comments