Changeset 406 for branches/eraser6/Manager/DirectExecutor.cs
- Timestamp:
- 09/27/08 05:09:24 (5 years ago)
- File:
-
- 1 edited
-
branches/eraser6/Manager/DirectExecutor.cs (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/Manager/DirectExecutor.cs
r405 r406 424 424 //Determine the total amount of data that needs to be written. 425 425 WriteStatistics statistics = new WriteStatistics(); 426 Volume driveInfo = Volume.FromMountpoint(target.Drive);427 long totalSize = method.CalculateEraseDataSize(null, driveInfo.TotalFreeSpace);426 Volume volInfo = Volume.FromMountpoint(target.Drive); 427 long totalSize = method.CalculateEraseDataSize(null, volInfo.TotalFreeSpace); 428 428 429 429 //Continue creating files while there is free space. 430 430 eventArgs.currentItemName = "Unused space"; 431 431 task.OnProgressChanged(eventArgs); 432 while ( driveInfo.AvailableFreeSpace > 0)432 while (volInfo.AvailableFreeSpace > 0) 433 433 { 434 434 //Generate a non-existant file name … … 446 446 //or the maximum size of one of these dumps. 447 447 stream.SetLength(Math.Min(ErasureMethod.FreeSpaceFileUnit, 448 driveInfo.AvailableFreeSpace));448 volInfo.AvailableFreeSpace)); 449 449 450 450 //Then run the erase task … … 622 622 private void EraseFilesystemRecords(DirectoryInfo info, ErasureMethod method) 623 623 { 624 DriveInfo driveInfo = new DriveInfo(info.Root.FullName);625 string driveFormat = driveInfo.DriveFormat;626 if ( driveFormat == "NTFS")624 Volume volInfo = Volume.FromMountpoint(info.FullName); 625 string volFormat = volInfo.VolumeFormat; 626 if (volFormat == "NTFS") 627 627 { 628 628 //If the volume is full, squeeze one-byte files. 629 629 try 630 630 { 631 FileInfo mftInfo = new FileInfo(driveInfo.RootDirectory.FullName + 632 Path.DirectorySeparatorChar + "$MFT"); 631 StreamInfo mftInfo = new StreamInfo(Path.Combine(volInfo.VolumeID, "$MFT")); 633 632 long oldMFTSize = mftInfo.Length; 634 633 for ( ; ; ) 635 634 { 636 635 //Open this stream 637 using (FileStream strm = new FileStream( info.FullName +638 Path.DirectorySeparatorChar + GenerateRandomFileName(18),636 using (FileStream strm = new FileStream(Path.Combine( 637 info.FullName, GenerateRandomFileName(18)), 639 638 FileMode.CreateNew, FileAccess.Write)) 640 639 { … … 650 649 //Determine if we can stop. We will stop if the disk is not 651 650 //full and the MFT has grown in size. 652 if ( driveInfo.TotalFreeSpace != 0 && mftInfo.Length != oldMFTSize)651 if (volInfo.AvailableFreeSpace != 0 && mftInfo.Length != oldMFTSize) 653 652 break; 654 653 }
Note: See TracChangeset
for help on using the changeset viewer.
