Changeset 1843


Ignore:
Timestamp:
2/17/2010 9:38:16 AM (2 years ago)
Author:
lowjoel
Message:

Use VolumeInfo?.OpenHandle? to query a volume for NTFS information instead as that has better error handling.

Location:
trunk/eraser6/Eraser.Util
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser6/Eraser.Util/NtfsApi.cs

    r1841 r1843  
    2525using Microsoft.Win32.SafeHandles; 
    2626using System.Runtime.InteropServices; 
     27using System.IO; 
    2728 
    2829namespace Eraser.Util 
     
    5960        internal static NativeMethods.NTFS_VOLUME_DATA_BUFFER GetNtfsVolumeData(VolumeInfo volume) 
    6061        { 
    61             using (SafeFileHandle volumeHandle = NativeMethods.CreateFile( 
    62                 volume.VolumeId.Remove(volume.VolumeId.Length - 1), 
    63                 NativeMethods.FILE_READ_ATTRIBUTES, NativeMethods.FILE_SHARE_READ | 
    64                 NativeMethods.FILE_SHARE_WRITE, IntPtr.Zero, NativeMethods.OPEN_EXISTING, 
    65                 0, IntPtr.Zero)) 
     62            using (SafeFileHandle volumeHandle = volume.OpenHandle( 
     63                NativeMethods.FILE_READ_ATTRIBUTES, FileShare.ReadWrite, FileOptions.None)) 
    6664            { 
    6765                uint resultSize = 0; 
  • trunk/eraser6/Eraser.Util/VolumeInfo.cs

    r1841 r1843  
    626626        } 
    627627 
    628         private SafeFileHandle OpenHandle(FileAccess access, FileShare share, FileOptions options) 
     628        internal SafeFileHandle OpenHandle(FileAccess access, FileShare share, FileOptions options) 
    629629        { 
    630630            //Access mode 
     
    646646        } 
    647647 
    648         private SafeFileHandle OpenHandle(uint access, FileShare share, FileOptions options) 
     648        internal SafeFileHandle OpenHandle(uint access, FileShare share, FileOptions options) 
    649649        { 
    650650            //Sharing mode 
Note: See TracChangeset for help on using the changeset viewer.