Changeset 1219


Ignore:
Timestamp:
09/29/09 13:46:48 (5 years ago)
Author:
lowjoel
Message:

-Instead of passing the clumsy handles, just pass streams to the FatApi? constructor.
-Load the FAT regardless of constructor, since other code depends on it being initialised.

Location:
trunk/eraser6/Eraser.Util.FileSystem
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser6/Eraser.Util.FileSystem/Fat32Api.cpp

    r1215 r1219  
    3838    } 
    3939 
    40     Fat32Api::Fat32Api(VolumeInfo^ info, Microsoft::Win32::SafeHandles::SafeFileHandle^ handle, 
    41         IO::FileAccess access) : FatApi(info, handle, access) 
     40    Fat32Api::Fat32Api(VolumeInfo^ info, Stream^ stream) : FatApi(info, stream) 
    4241    { 
    4342        //Sanity checks: check that this volume is FAT32! 
  • trunk/eraser6/Eraser.Util.FileSystem/FatApi.cpp

    r1215 r1219  
    2929using namespace System::IO; 
    3030using namespace System::Runtime::InteropServices; 
    31 using namespace Microsoft::Win32::SafeHandles; 
    3231 
    3332namespace Eraser { 
     
    4544        CString volumeName(info->VolumeId); 
    4645        volumeName.Truncate(volumeName.GetLength() - 1); 
    47         VolumeHandle = gcnew SafeFileHandle(static_cast<IntPtr>(CreateFile(volumeName, 
    48                     GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 
    49                     FILE_FLAG_RANDOM_ACCESS, NULL)), 
    50             true); 
    51         VolumeStream = gcnew FileStream(VolumeHandle, FileAccess::Read); 
     46        VolumeStream = info->Open(FileAccess::Read); 
    5247 
    5348        //Then read the boot sector for information 
     
    6156    } 
    6257 
    63     FatApi::FatApi(VolumeInfo^ info, Microsoft::Win32::SafeHandles::SafeFileHandle^ handle, 
    64         IO::FileAccess access) 
     58    FatApi::FatApi(VolumeInfo^ info, Stream^ stream) 
    6559    { 
    6660        SectorSize = info->SectorSize; 
     
    7266 
    7367        //Open the handle to the drive 
    74         VolumeHandle = handle; 
    75         VolumeStream = gcnew FileStream(VolumeHandle, access); 
     68        VolumeStream = stream; 
    7669 
    7770        //Then read the boot sector for information 
     
    8073        VolumeStream->Read(bootSector, 0, sizeof(*BootSector)); 
    8174        Marshal::Copy(bootSector, 0, static_cast<IntPtr>(BootSector), bootSector->Length); 
     75 
     76        //Then load the FAT 
     77        LoadFat(); 
    8278    } 
    8379 
  • trunk/eraser6/Eraser.Util.FileSystem/FatApi.h

    r1215 r1219  
    4242        ///  
    4343        /// \param[in] info   The volume to create the FAT API for. 
    44         /// \param[in] handle A handle to the volume for read/write requests. 
    45         /// \param[in] access The access required for the volume. 
    46         FatApi(VolumeInfo^ info, Microsoft::Win32::SafeHandles::SafeFileHandle^ handle, 
    47              IO::FileAccess access); 
     44        /// \param[in] stream The stream to use to read/write to the disk. 
     45        FatApi(VolumeInfo^ info, IO::Stream^ stream); 
    4846 
    4947    public: 
     
    111109 
    112110    protected: 
    113         Microsoft::Win32::SafeHandles::SafeFileHandle^ VolumeHandle; 
    114         IO::FileStream^ VolumeStream; 
     111        IO::Stream^ VolumeStream; 
    115112 
    116113        unsigned SectorSize;                 // Size of one sector, in bytes 
     
    221218    public: 
    222219        Fat32Api(VolumeInfo^ info); 
    223         Fat32Api(VolumeInfo^ info, Microsoft::Win32::SafeHandles::SafeFileHandle^ handle, 
    224              IO::FileAccess access); 
     220        Fat32Api(VolumeInfo^ info, IO::Stream^ stream); 
    225221 
    226222    public: 
Note: See TracChangeset for help on using the changeset viewer.