@@ -77,12 +77,7 @@ private static void TestCreateAndDeleteFiles(string path, long size, int count)
7777 disk . ExclusiveLock ( ) ;
7878 NTFSVolume volume = NTFSFormatTests . CreateAndFormatPrimaryPartition ( disk , bytesPerCluster , volumeLabel ) ;
7979 string directoryName = "Directory" ;
80- FileRecord parentDirectoryRecord = volume . CreateFile ( NTFSVolume . RootDirSegmentReference , directoryName , true ) ;
81- for ( int index = 1 ; index <= count ; index ++ )
82- {
83- string fileName = "File" + index . ToString ( "000000" ) ;
84- FileRecord fileRecord = volume . CreateFile ( parentDirectoryRecord . BaseSegmentReference , fileName , false ) ;
85- }
80+ CreateFiles ( volume , directoryName , count ) ;
8681 disk . ReleaseLock ( ) ;
8782
8883 VHDMountHelper . MountVHD ( path ) ;
@@ -103,13 +98,7 @@ private static void TestCreateAndDeleteFiles(string path, long size, int count)
10398 }
10499 VHDMountHelper . UnmountVHD ( path ) ;
105100 disk . ExclusiveLock ( ) ;
106- for ( int index = 1 ; index <= count ; index ++ )
107- {
108- string fileName = "File" + index . ToString ( "000000" ) ;
109- string filePath = "\\ " + directoryName + "\\ " + fileName ;
110- FileRecord fileRecord = volume . GetFileRecord ( filePath ) ;
111- volume . DeleteFile ( fileRecord ) ;
112- }
101+ DeleteFiles ( volume , directoryName , count ) ;
113102 disk . ReleaseLock ( ) ;
114103 VHDMountHelper . MountVHD ( path ) ;
115104 isErrorFree = ChkdskHelper . Chkdsk ( driveName ) ;
@@ -128,5 +117,26 @@ private static void TestCreateAndDeleteFiles(string path, long size, int count)
128117 bytesPerCluster = bytesPerCluster * 2 ;
129118 }
130119 }
120+
121+ private static void CreateFiles ( NTFSVolume volume , string directoryName , int count )
122+ {
123+ FileRecord parentDirectoryRecord = volume . CreateFile ( NTFSVolume . RootDirSegmentReference , directoryName , true ) ;
124+ for ( int index = 1 ; index <= count ; index ++ )
125+ {
126+ string fileName = "File" + index . ToString ( "000000" ) ;
127+ FileRecord fileRecord = volume . CreateFile ( parentDirectoryRecord . BaseSegmentReference , fileName , false ) ;
128+ }
129+ }
130+
131+ private static void DeleteFiles ( NTFSVolume volume , string directoryName , int count )
132+ {
133+ for ( int index = 1 ; index <= count ; index ++ )
134+ {
135+ string fileName = "File" + index . ToString ( "000000" ) ;
136+ string filePath = "\\ " + directoryName + "\\ " + fileName ;
137+ FileRecord fileRecord = volume . GetFileRecord ( filePath ) ;
138+ volume . DeleteFile ( fileRecord ) ;
139+ }
140+ }
131141 }
132142}
0 commit comments