Changeset 2162
- Timestamp:
- 6/13/2010 3:33:06 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/eraser/Eraser.DefaultPlugins/FileSystems/Ntfs.cs
r2157 r2162 51 51 FileSystemEntriesEraseProgress callback) 52 52 { 53 //Squeeze files smaller than one MFT record until the volume and the MFT is full. 54 long MFTRecordSize = NtfsApi.GetMftRecordSegmentSize(volume); 55 long lastFileSize = MFTRecordSize; 56 53 57 try 54 58 { 55 //Squeeze one-byte files until the volume or the MFT is full.56 long oldMFTSize = NtfsApi.GetMftValidSize(volume);57 58 59 for ( ; ; ) 59 60 { 60 61 //Open this stream 61 using (FileStream strm = new FileStream( 62 GenerateRandomFileName(tempDirectory, 18), FileMode.CreateNew, 63 FileAccess.Write, FileShare.None, 8, FileOptions.WriteThrough)) 64 { 65 long streamSize = 0; 66 try 67 { 68 while (true) 69 { 70 //Stretch the file size to use up some of the resident space. 71 strm.SetLength(++streamSize); 72 73 //Then run the erase task 74 method.Erase(strm, long.MaxValue, 75 ManagerLibrary.Instance.PrngRegistrar[ManagerLibrary.Settings.ActivePrng], 76 null); 77 78 //Call the callback function if one is provided. We'll provide a dummy 79 //value since we really have no idea how much of the MFT we can clean. 80 if (callback != null) 81 callback(0, 1); 82 } 83 } 84 catch (IOException) 85 { 86 if (streamSize == 1) 87 return; 88 } 89 } 90 91 //We can stop when the MFT has grown. 92 if (NtfsApi.GetMftValidSize(volume) > oldMFTSize) 93 break; 62 string fileName = GenerateRandomFileName(tempDirectory, 18); 63 FileStream strm = new FileStream(fileName, FileMode.CreateNew, FileAccess.Write, 64 FileShare.None, 8, FileOptions.WriteThrough); 65 try 66 { 67 //Stretch the file size to use up some of the resident space. 68 strm.SetLength(lastFileSize); 69 70 //Then run the erase task 71 method.Erase(strm, long.MaxValue, ManagerLibrary.Instance.PrngRegistrar[ 72 ManagerLibrary.Settings.ActivePrng], null); 73 74 //Call the callback function if one is provided. We'll provide a dummy 75 //value since we really have no idea how much of the MFT we can clean. 76 if (callback != null) 77 callback((int)(MFTRecordSize - lastFileSize), (int)MFTRecordSize); 78 } 79 catch (IOException) 80 { 81 if (lastFileSize-- == 0) 82 break; 83 } 84 finally 85 { 86 //Close the stream handle 87 strm.Close(); 88 89 //Then reset the time the file was created. 90 ResetFileTimes(new FileInfo(fileName)); 91 } 94 92 } 95 93 } … … 120 118 { 121 119 ++filesCreated; 122 using (FileStream strm = new FileStream(FileSystem.GenerateRandomFileName( 123 tempDir, 220), FileMode.CreateNew, FileAccess.Write)) 124 { 125 } 120 string fileName = GenerateRandomFileName(tempDir, 220); 121 File.Create(fileName).Close(); 122 ResetFileTimes(new FileInfo(fileName)); 126 123 127 124 if (filesCreated % pollingInterval == 0) … … 152 149 if (callback != null && i % 50 == 0) 153 150 callback(files.Length + i, files.Length * 2); 154 DeleteFile(files[i]);151 files[i].Delete(); 155 152 } 156 153
Note: See TracChangeset
for help on using the changeset viewer.
