mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
Trying to fix MK:Wii save corruption (see r3344) while not breaking everything using wb mode...
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3466 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
5b9f26c660
commit
635a1a3a37
@ -90,37 +90,47 @@ CWII_IPC_HLE_Device_FileIO::Open(u32 _CommandAddress, u32 _Mode)
|
||||
{ "Read and Write" }
|
||||
};
|
||||
|
||||
INFO_LOG(WII_IPC_FILEIO, "FileIO: Open %s (%s)", GetDeviceName().c_str(), Modes[_Mode]);
|
||||
|
||||
m_Filename = std::string(HLE_IPC_BuildFilename(GetDeviceName().c_str(), 64));
|
||||
|
||||
// Reading requires the file to exist, but writing doesn't (what a smart thought)
|
||||
if(_Mode != 0x02 && !File::Exists(m_Filename.c_str())) {
|
||||
ERROR_LOG(WII_IPC_FILEIO, " FileIO failed open for reading: %s - File doesn't exist", m_Filename.c_str());
|
||||
ReturnValue = FS_FILE_NOT_EXIST;
|
||||
} else {
|
||||
if(File::Exists(m_Filename.c_str()))
|
||||
{
|
||||
INFO_LOG(WII_IPC_FILEIO, "FileIO: Open %s (%s), File exists", GetDeviceName().c_str(), Modes[_Mode]);
|
||||
switch(_Mode)
|
||||
{
|
||||
case 0x01: m_pFileHandle = fopen(m_Filename.c_str(), "rb"); break;
|
||||
case 0x02: m_pFileHandle = fopen(m_Filename.c_str(), "wb"); break;
|
||||
case 0x02: // m_pFileHandle = fopen(m_Filename.c_str(), "wb"); break;
|
||||
// MK Wii gets here corrupting its saves, however using rb+ mode works fine
|
||||
// TODO : figure it properly...
|
||||
case 0x03: m_pFileHandle = fopen(m_Filename.c_str(), "r+b"); break;
|
||||
default: PanicAlert("CWII_IPC_HLE_Device_FileIO: unknown open mode"); break;
|
||||
default: PanicAlert("CWII_IPC_HLE_Device_FileIO: unknown open mode : 0x%02x", _Mode); break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_Mode == 0x02) {
|
||||
INFO_LOG(WII_IPC_FILEIO, "FileIO: Open %s (%s), File doesn't exist", GetDeviceName().c_str(), Modes[_Mode]);
|
||||
m_pFileHandle = fopen(m_Filename.c_str(), "wb");
|
||||
}
|
||||
else {
|
||||
ERROR_LOG(WII_IPC_FILEIO, " FileIO failed open for reading: %s - File doesn't exist", m_Filename.c_str());
|
||||
ReturnValue = FS_FILE_NOT_EXIST;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_pFileHandle != NULL)
|
||||
{
|
||||
m_FileLength = File::GetSize(m_Filename.c_str());
|
||||
ReturnValue = GetDeviceID();
|
||||
}
|
||||
else if(ReturnValue == 0)
|
||||
{
|
||||
ERROR_LOG(WII_IPC_FILEIO, " FileIO failed open: %s(%s) - I/O Error", m_Filename.c_str(), Modes[_Mode]);
|
||||
ReturnValue = FS_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
Memory::Write_U32(ReturnValue, _CommandAddress+4);
|
||||
return true;
|
||||
if (m_pFileHandle != NULL)
|
||||
{
|
||||
m_FileLength = File::GetSize(m_Filename.c_str());
|
||||
ReturnValue = GetDeviceID();
|
||||
}
|
||||
else if(ReturnValue == 0)
|
||||
{
|
||||
ERROR_LOG(WII_IPC_FILEIO, " FileIO failed open: %s(%s) - I/O Error", m_Filename.c_str(), Modes[_Mode]);
|
||||
ReturnValue = FS_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
Memory::Write_U32(ReturnValue, _CommandAddress+4);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -132,6 +142,7 @@ CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress)
|
||||
|
||||
INFO_LOG(WII_IPC_FILEIO, "FileIO: Old Seek Pos: %s, Mode: %i (Device=%s, FileSize=%s)", ThS(SeekPosition).c_str(), Mode, GetDeviceName().c_str(), ThS((int)m_FileLength).c_str());
|
||||
|
||||
// TODO : The following hack smells bad
|
||||
/* Zelda - TP Fix: It doesn't make much sense but it works in Zelda - TP and
|
||||
it's probably better than trying to read outside the file (it seeks to 0x6000 instead
|
||||
of the correct 0x2000 for the second half of the file). Could this be right
|
||||
|
@ -49,6 +49,7 @@ Core::GetWindowHandle().
|
||||
#include "GameListCtrl.h"
|
||||
#include "BootManager.h"
|
||||
#include "LogWindow.h"
|
||||
#include "WxUtils.h"
|
||||
|
||||
#include "Common.h" // Common
|
||||
#include "FileUtil.h"
|
||||
@ -65,8 +66,6 @@ Core::GetWindowHandle().
|
||||
|
||||
#include <wx/datetime.h> // wxWidgets
|
||||
|
||||
// ugly that this lib included code from the main
|
||||
#include "../../DolphinWX/Src/WxUtils.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Resources
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "IniFile.h"
|
||||
#include "FileUtil.h"
|
||||
#include "CDUtils.h"
|
||||
#include "WxUtils.h"
|
||||
|
||||
#if USE_XPM_BITMAPS
|
||||
#include "../resources/Flag_Europe.xpm"
|
||||
@ -44,9 +45,6 @@
|
||||
#include "../resources/Platform_Gamecube.xpm"
|
||||
#endif // USE_XPM_BITMAPS
|
||||
|
||||
// ugly that this lib included code from the main
|
||||
#include "../../DolphinWX/Src/WxUtils.h"
|
||||
|
||||
size_t CGameListCtrl::m_currentItem = 0;
|
||||
size_t CGameListCtrl::m_numberItem = 0;
|
||||
std::string CGameListCtrl::m_currentFilename;
|
||||
|
Loading…
Reference in New Issue
Block a user