mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-26 12:35:27 +00:00
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,17 +53,16 @@ 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
|
|
||||||
return true;
|
DWORD bytesRead = 0;
|
||||||
|
if (!ReadFile(hFile, out_ptr, (DWORD)nbytes, &bytesRead, NULL))
|
||||||
|
return false;
|
||||||
|
if (bytesRead != nbytes)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // POSIX
|
#else // POSIX
|
||||||
|
Loading…
x
Reference in New Issue
Block a user