(nothing of value, just reindentation and removal of commented out includes. i'm just cleaning my svn client here)
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4808 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
ddcb39d8e3
commit
1bca5e8c86
|
@ -20,121 +20,123 @@
|
||||||
|
|
||||||
namespace DiscIO
|
namespace DiscIO
|
||||||
{
|
{
|
||||||
DriveReader::DriveReader(const char *drive)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
char path[MAX_PATH];
|
|
||||||
strncpy(path, drive, 3);
|
|
||||||
path[2] = 0;
|
|
||||||
sprintf(path, "\\\\.\\%s", drive);
|
|
||||||
SectorReader::SetSectorSize(2048);
|
|
||||||
hDisc = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
|
||||||
NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, NULL);
|
|
||||||
if (hDisc != INVALID_HANDLE_VALUE)
|
|
||||||
{
|
|
||||||
// Do a test read to make sure everything is OK, since it seems you can get
|
|
||||||
// handles to empty drives.
|
|
||||||
DWORD not_used;
|
|
||||||
u8 *buffer = new u8[m_blocksize];
|
|
||||||
if (!ReadFile(hDisc, buffer, m_blocksize, (LPDWORD)¬_used, NULL))
|
|
||||||
{
|
|
||||||
delete [] buffer;
|
|
||||||
// OK, something is wrong.
|
|
||||||
CloseHandle(hDisc);
|
|
||||||
hDisc = INVALID_HANDLE_VALUE;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
delete [] buffer;
|
|
||||||
|
|
||||||
#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;
|
|
||||||
DeviceIoControl(hDisc, IOCTL_CDROM_MEDIA_REMOVAL,
|
|
||||||
&pmrLockCDROM, sizeof(pmrLockCDROM), NULL,
|
|
||||||
0, &dwNotUsed, NULL);
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
file_ = fopen(drive, "rb");
|
|
||||||
if (file_)
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PanicAlert("Load from DVD backup failed or no disc in drive %s", drive);
|
|
||||||
}
|
|
||||||
} // DriveReader::DriveReader
|
|
||||||
|
|
||||||
DriveReader::~DriveReader()
|
DriveReader::DriveReader(const char *drive)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#ifdef _LOCKDRIVE // Do we want to lock the drive?
|
char path[MAX_PATH];
|
||||||
// Unlock the disc in the CD-ROM drive.
|
strncpy(path, drive, 3);
|
||||||
pmrLockCDROM.PreventMediaRemoval = FALSE;
|
path[2] = 0;
|
||||||
DeviceIoControl (hDisc, IOCTL_CDROM_MEDIA_REMOVAL,
|
sprintf(path, "\\\\.\\%s", drive);
|
||||||
&pmrLockCDROM, sizeof(pmrLockCDROM), NULL,
|
SectorReader::SetSectorSize(2048);
|
||||||
0, &dwNotUsed, NULL);
|
hDisc = CreateFile(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||||
#endif
|
NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, NULL);
|
||||||
if (hDisc != INVALID_HANDLE_VALUE)
|
if (hDisc != INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
// Do a test read to make sure everything is OK, since it seems you can get
|
||||||
|
// handles to empty drives.
|
||||||
|
DWORD not_used;
|
||||||
|
u8 *buffer = new u8[m_blocksize];
|
||||||
|
if (!ReadFile(hDisc, buffer, m_blocksize, (LPDWORD)¬_used, NULL))
|
||||||
{
|
{
|
||||||
|
delete [] buffer;
|
||||||
|
// OK, something is wrong.
|
||||||
CloseHandle(hDisc);
|
CloseHandle(hDisc);
|
||||||
hDisc = INVALID_HANDLE_VALUE;
|
hDisc = INVALID_HANDLE_VALUE;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
delete [] buffer;
|
||||||
|
|
||||||
|
#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;
|
||||||
|
DeviceIoControl(hDisc, IOCTL_CDROM_MEDIA_REMOVAL,
|
||||||
|
&pmrLockCDROM, sizeof(pmrLockCDROM), NULL,
|
||||||
|
0, &dwNotUsed, NULL);
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
fclose(file_);
|
file_ = fopen(drive, "rb");
|
||||||
file_ = 0;
|
if (file_)
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PanicAlert("Load from DVD backup failed or no disc in drive %s", drive);
|
||||||
|
}
|
||||||
|
} // DriveReader::DriveReader
|
||||||
|
|
||||||
|
DriveReader::~DriveReader()
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
#ifdef _LOCKDRIVE // Do we want to lock the drive?
|
||||||
|
// Unlock the disc in the CD-ROM drive.
|
||||||
|
pmrLockCDROM.PreventMediaRemoval = FALSE;
|
||||||
|
DeviceIoControl (hDisc, IOCTL_CDROM_MEDIA_REMOVAL,
|
||||||
|
&pmrLockCDROM, sizeof(pmrLockCDROM), NULL,
|
||||||
|
0, &dwNotUsed, NULL);
|
||||||
|
#endif
|
||||||
|
if (hDisc != INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
CloseHandle(hDisc);
|
||||||
|
hDisc = INVALID_HANDLE_VALUE;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
fclose(file_);
|
||||||
|
file_ = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
DriveReader *DriveReader::Create(const char *drive)
|
DriveReader *DriveReader::Create(const char *drive)
|
||||||
|
{
|
||||||
|
DriveReader *reader = new DriveReader(drive);
|
||||||
|
if (!reader->IsOK())
|
||||||
{
|
{
|
||||||
DriveReader *reader = new DriveReader(drive);
|
delete reader;
|
||||||
if (!reader->IsOK())
|
return 0;
|
||||||
{
|
|
||||||
delete reader;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return reader;
|
|
||||||
}
|
}
|
||||||
|
return reader;
|
||||||
|
}
|
||||||
|
|
||||||
void DriveReader::GetBlock(u64 block_num, u8 *out_ptr)
|
void DriveReader::GetBlock(u64 block_num, u8 *out_ptr)
|
||||||
{
|
{
|
||||||
u8 * lpSector = new u8[m_blocksize];
|
u8 * lpSector = new u8[m_blocksize];
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
u32 NotUsed;
|
u32 NotUsed;
|
||||||
u64 offset = m_blocksize * block_num;
|
u64 offset = m_blocksize * block_num;
|
||||||
LONG off_low = (LONG)offset & 0xFFFFFFFF;
|
LONG off_low = (LONG)offset & 0xFFFFFFFF;
|
||||||
LONG off_high = (LONG)(offset >> 32);
|
LONG off_high = (LONG)(offset >> 32);
|
||||||
SetFilePointer(hDisc, off_low, &off_high, FILE_BEGIN);
|
SetFilePointer(hDisc, off_low, &off_high, FILE_BEGIN);
|
||||||
if (!ReadFile(hDisc, lpSector, m_blocksize, (LPDWORD)&NotUsed, NULL))
|
if (!ReadFile(hDisc, lpSector, m_blocksize, (LPDWORD)&NotUsed, NULL))
|
||||||
PanicAlert("Disc Read Error");
|
PanicAlert("Disc Read Error");
|
||||||
#else
|
#else
|
||||||
fseek(file_, m_blocksize*block_num, SEEK_SET);
|
fseek(file_, m_blocksize*block_num, SEEK_SET);
|
||||||
fread(lpSector, 1, m_blocksize, file_);
|
fread(lpSector, 1, m_blocksize, file_);
|
||||||
#endif
|
#endif
|
||||||
memcpy(out_ptr, lpSector, m_blocksize);
|
memcpy(out_ptr, lpSector, m_blocksize);
|
||||||
delete[] lpSector;
|
delete[] lpSector;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DriveReader::ReadMultipleAlignedBlocks(u64 block_num, u64 num_blocks, u8 *out_ptr)
|
bool DriveReader::ReadMultipleAlignedBlocks(u64 block_num, u64 num_blocks, u8 *out_ptr)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
u32 NotUsed;
|
u32 NotUsed;
|
||||||
u64 offset = m_blocksize * block_num;
|
u64 offset = m_blocksize * block_num;
|
||||||
LONG off_low = (LONG)offset & 0xFFFFFFFF;
|
LONG off_low = (LONG)offset & 0xFFFFFFFF;
|
||||||
LONG off_high = (LONG)(offset >> 32);
|
LONG off_high = (LONG)(offset >> 32);
|
||||||
SetFilePointer(hDisc, off_low, &off_high, FILE_BEGIN);
|
SetFilePointer(hDisc, off_low, &off_high, FILE_BEGIN);
|
||||||
if (!ReadFile(hDisc, out_ptr, (DWORD)(m_blocksize * num_blocks), (LPDWORD)&NotUsed, NULL))
|
if (!ReadFile(hDisc, out_ptr, (DWORD)(m_blocksize * num_blocks), (LPDWORD)&NotUsed, NULL))
|
||||||
{
|
{
|
||||||
PanicAlert("Disc Read Error");
|
PanicAlert("Disc Read Error");
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
#else
|
|
||||||
fseek(file_, m_blocksize*block_num, SEEK_SET);
|
|
||||||
if(fread(out_ptr, 1, m_blocksize * num_blocks, file_) != m_blocksize * num_blocks)
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
fseek(file_, m_blocksize*block_num, SEEK_SET);
|
||||||
|
if(fread(out_ptr, 1, m_blocksize * num_blocks, file_) != m_blocksize * num_blocks)
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include "../TextureMngr.h"
|
#include "../TextureMngr.h"
|
||||||
#include "VertexShaderManager.h"
|
#include "VertexShaderManager.h"
|
||||||
#include "../PostProcessing.h"
|
#include "../PostProcessing.h"
|
||||||
//#include "GlobalControl.h"
|
|
||||||
#include "Render.h"
|
#include "Render.h"
|
||||||
|
|
||||||
#include "FileUtil.h"
|
#include "FileUtil.h"
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#include <mmsystem.h>
|
#include <mmsystem.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#include "GlobalControl.h"
|
|
||||||
#include "CommonPaths.h"
|
#include "CommonPaths.h"
|
||||||
#include "VideoConfig.h"
|
#include "VideoConfig.h"
|
||||||
#include "Profiler.h"
|
#include "Profiler.h"
|
||||||
|
|
Loading…
Reference in New Issue