mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
Wrapped fopen/close/read/write functions inside a simple "IOFile" class. Reading, writing, and error checking became simpler in most cases. It should be near impossible to forget to close a file now that the destructor takes care of it. (I hope this fixes Issue 3635) I have tested the functionality of most things, but it is possible I broke something. :p
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7328 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -56,7 +56,7 @@ DriveReader::DriveReader(const char *drive)
|
||||
#endif
|
||||
#else
|
||||
SectorReader::SetSectorSize(2048);
|
||||
file_ = fopen(drive, "rb");
|
||||
file_.Open(drive, "rb");
|
||||
if (file_)
|
||||
{
|
||||
#endif
|
||||
@ -81,9 +81,7 @@ DriveReader::~DriveReader()
|
||||
hDisc = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
#else
|
||||
if (file_)
|
||||
fclose(file_);
|
||||
file_ = 0;
|
||||
file_.Close();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -100,7 +98,7 @@ DriveReader *DriveReader::Create(const char *drive)
|
||||
|
||||
void DriveReader::GetBlock(u64 block_num, u8 *out_ptr)
|
||||
{
|
||||
u8 * lpSector = new u8[m_blocksize];
|
||||
u8* const lpSector = new u8[m_blocksize];
|
||||
#ifdef _WIN32
|
||||
u32 NotUsed;
|
||||
u64 offset = m_blocksize * block_num;
|
||||
@ -110,8 +108,8 @@ void DriveReader::GetBlock(u64 block_num, u8 *out_ptr)
|
||||
if (!ReadFile(hDisc, lpSector, m_blocksize, (LPDWORD)&NotUsed, NULL))
|
||||
PanicAlertT("Disc Read Error");
|
||||
#else
|
||||
fseeko(file_, m_blocksize*block_num, SEEK_SET);
|
||||
fread(lpSector, 1, m_blocksize, file_);
|
||||
file_.Seek(m_blocksize * block_num, SEEK_SET);
|
||||
file_.ReadBytes(lpSector, m_blocksize);
|
||||
#endif
|
||||
memcpy(out_ptr, lpSector, m_blocksize);
|
||||
delete[] lpSector;
|
||||
|
Reference in New Issue
Block a user