void CEeprom::LoadEeprom() { CPath FileName; DWORD dwRead; memset(m_EEPROM,0xFF,sizeof(m_EEPROM)); FileName.SetDriveDirectory( g_Settings->LoadStringVal(Directory_NativeSave).c_str()); FileName.SetName(g_Settings->LoadStringVal(Game_GameName).c_str()); FileName.SetExtension("eep"); if (!FileName.DirectoryExists()) { FileName.DirectoryCreate(); } m_hFile = CreateFile(FileName,m_ReadOnly ? GENERIC_READ : GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); if (m_hFile == INVALID_HANDLE_VALUE) { WriteTraceF(TraceError,__FUNCTION__ ": Failed to open (%s), ReadOnly = %d, LastError = %X",(LPCTSTR)FileName, m_ReadOnly, GetLastError()); g_Notify->DisplayError(GS(MSG_FAIL_OPEN_EEPROM)); return; } SetFilePointer(m_hFile,0,NULL,FILE_BEGIN); ReadFile(m_hFile,m_EEPROM,sizeof(m_EEPROM),&dwRead,NULL); }
bool CSram::LoadSram() { CPath FileName; FileName.SetDriveDirectory( g_Settings->LoadStringVal(Directory_NativeSave).c_str()); FileName.SetName(g_Settings->LoadStringVal(Game_GameName).c_str()); FileName.SetExtension("sra"); if (!FileName.DirectoryExists()) { FileName.DirectoryCreate(); } m_hFile = CreateFile(FileName,m_ReadOnly ? GENERIC_READ : GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); if (m_hFile == INVALID_HANDLE_VALUE) { WriteTraceF(TraceError,__FUNCTION__ ": Failed to open (%s), ReadOnly = %d, LastError = %X",(LPCTSTR)FileName, m_ReadOnly, GetLastError()); return false; } SetFilePointer(m_hFile,0,NULL,FILE_BEGIN); return true; }