diff options
| author | LPFaint99 <lpfaint99@gmail.com> | 2009-02-24 07:30:10 +0000 |
|---|---|---|
| committer | LPFaint99 <lpfaint99@gmail.com> | 2009-02-24 07:30:10 +0000 |
| commit | 5dfbb9438e2bc205b159d67b97e2d7504de99c80 (patch) | |
| tree | 631da95594d593740ba8647b682b3141dfc0c2aa /Source/Core/DiscIO | |
| parent | 772e37be9a3a0031d12ca9406841ddcee241069a (diff) | |
Attempt at raw drive access for linux / osx, test please :)
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2410 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/DiscIO')
| -rw-r--r-- | Source/Core/DiscIO/Src/DriveBlob.cpp | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/Source/Core/DiscIO/Src/DriveBlob.cpp b/Source/Core/DiscIO/Src/DriveBlob.cpp index 1ebef3af55..7e798e337f 100644 --- a/Source/Core/DiscIO/Src/DriveBlob.cpp +++ b/Source/Core/DiscIO/Src/DriveBlob.cpp @@ -30,14 +30,10 @@ namespace DiscIO hDisc = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, NULL); - if (hDisc == INVALID_HANDLE_VALUE) - { - PanicAlert("Load from DVD backup failed"); - } - else + if (hDisc != INVALID_HANDLE_VALUE) { - SectorReader::SetSectorSize(2048); - #ifdef _LOCKDRIVE + + #ifdef _LOCKDRIVE // Do we want to lock the drive? // Lock the compact disc in the CD-ROM drive to prevent accidental // removal while reading from it. pmrLockCDROM.PreventMediaRemoval = TRUE; @@ -45,14 +41,17 @@ namespace DiscIO &pmrLockCDROM, sizeof(pmrLockCDROM), NULL, 0, &dwNotUsed, NULL); #endif - } #else file_ = fopen(drive, "rb"); - if (!file_) - PanicAlert("Load from DVD backup failed"); - else - SetSectorSize(2048); + if (file_) + { #endif + SectorReader::SetSectorSize(2048); + } + else + { + PanicAlert("Load from DVD backup failed or no disc in drive %s",drive); + } } // DriveReader::DriveReader DriveReader::~DriveReader() @@ -65,7 +64,10 @@ namespace DiscIO &pmrLockCDROM, sizeof(pmrLockCDROM), NULL, 0, &dwNotUsed, NULL); #endif - CloseHandle(hDisc); + if (hDisc != INVALID_HANDLE_VALUE) + { + CloseHandle(hDisc); + } #else fclose(file_); #endif @@ -104,10 +106,14 @@ namespace DiscIO LONG off_high = (LONG)(offset >> 32); SetFilePointer(hDisc, off_low, &off_high, FILE_BEGIN); if (!ReadFile(hDisc, out_ptr, (DWORD)(m_blocksize * num_blocks), (LPDWORD)&NotUsed, NULL)) + { PanicAlert("DRE"); + return false; + } #else fseek(file_, m_blocksize*block_num, SEEK_SET); - fread(out_ptr, 1, m_blocksize * num_blocks, file_); + if(fread(out_ptr, 1, m_blocksize * num_blocks, file_) != m_blocksize * num_blocks) + return false; #endif return true; } |
