[Project64] Use cfile for looking at an uncompressed file (Rom Browser)

This commit is contained in:
zilmar 2016-04-16 09:08:44 +10:00
parent cad6d7db7b
commit c73d91de92
1 changed files with 20 additions and 11 deletions

View File

@ -404,17 +404,26 @@ bool CRomList::LoadDataFromRomFile(const char * FileName, uint8_t * Data, int32_
} }
else else
{ {
HANDLE hFile = CreateFile(FileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); CFile File;
if (hFile == INVALID_HANDLE_VALUE) { return false; } if (!File.Open(FileName, CFileBase::modeRead))
SetFilePointer(hFile, 0, 0, FILE_BEGIN); {
return false;
DWORD dwRead; }
ReadFile(hFile, Test, 4, &dwRead, NULL); File.SeekToBegin();
if (!CN64Rom::IsValidRomImage(Test)) { CloseHandle(hFile); return false; } if (!File.Read(Test,sizeof(Test)))
SetFilePointer(hFile, 0, 0, FILE_BEGIN); {
if (!ReadFile(hFile, Data, DataLen, &dwRead, NULL)) { CloseHandle(hFile); return false; } return false;
*RomSize = GetFileSize(hFile, NULL); }
CloseHandle(hFile); if (!CN64Rom::IsValidRomImage(Test))
{
return false;
}
File.SeekToBegin();
if (!File.Read(Data,DataLen))
{
return false;
}
*RomSize = File.GetLength();
FileFormat = Format_Uncompressed; FileFormat = Format_Uncompressed;
} }
ByteSwapRomData(Data, DataLen); ByteSwapRomData(Data, DataLen);