Use slightly different Windows file functions.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3910 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
8ab4814d73
commit
48365b5daa
|
@ -32,9 +32,7 @@ namespace DiscIO
|
||||||
PlainFileReader::PlainFileReader(HANDLE hFile_)
|
PlainFileReader::PlainFileReader(HANDLE hFile_)
|
||||||
{
|
{
|
||||||
hFile = hFile_;
|
hFile = hFile_;
|
||||||
DWORD size_low, size_high;
|
GetFileSizeEx(hFile, (PLARGE_INTEGER)&size);
|
||||||
size_low = GetFileSize(hFile, &size_high);
|
|
||||||
size = ((u64)size_low) | ((u64)size_high << 32);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PlainFileReader* PlainFileReader::Create(const char* filename)
|
PlainFileReader* PlainFileReader::Create(const char* filename)
|
||||||
|
@ -55,16 +53,15 @@ PlainFileReader::~PlainFileReader()
|
||||||
|
|
||||||
bool PlainFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr)
|
bool PlainFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr)
|
||||||
{
|
{
|
||||||
LONG offset_high = (LONG)(offset >> 32);
|
if (!SetFilePointerEx(hFile, *(LARGE_INTEGER*)&offset, NULL, FILE_BEGIN))
|
||||||
SetFilePointer(hFile, (DWORD)(offset & 0xFFFFFFFF), &offset_high, FILE_BEGIN);
|
|
||||||
|
|
||||||
if (nbytes >= 0x100000000ULL)
|
|
||||||
return false; // WTF, does windows really have this limitation?
|
|
||||||
|
|
||||||
DWORD unused = 0;
|
|
||||||
if (!ReadFile(hFile, out_ptr, DWORD(nbytes & 0xFFFFFFFF), &unused, NULL))
|
|
||||||
return false;
|
return false;
|
||||||
else
|
|
||||||
|
DWORD bytesRead = 0;
|
||||||
|
if (!ReadFile(hFile, out_ptr, (DWORD)nbytes, &bytesRead, NULL))
|
||||||
|
return false;
|
||||||
|
if (bytesRead != nbytes)
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue