Wii IPC: Opening nonexistent files for writing now creates them and renaming now returns a proper error code.
Result: Zelda: A link to the past (VC) now runs (needs to be run twice to work), Wii System Menu generates more files. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3344 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
8cbe39dc11
commit
3a4e51b67f
|
@ -70,6 +70,8 @@ CWII_IPC_HLE_Device_FileIO::Close(u32 _CommandAddress)
|
|||
bool
|
||||
CWII_IPC_HLE_Device_FileIO::Open(u32 _CommandAddress, u32 _Mode)
|
||||
{
|
||||
u32 ReturnValue = 0;
|
||||
|
||||
// close the file handle if we get a reopen
|
||||
if (m_pFileHandle != NULL)
|
||||
{
|
||||
|
@ -89,28 +91,29 @@ CWII_IPC_HLE_Device_FileIO::Open(u32 _CommandAddress, u32 _Mode)
|
|||
|
||||
m_Filename = std::string(HLE_IPC_BuildFilename(GetDeviceName().c_str(), 64));
|
||||
|
||||
if (File::Exists(m_Filename.c_str()))
|
||||
{
|
||||
// Reading requires the file to exist
|
||||
if(_Mode == 0x01 && !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 = -106;
|
||||
} else {
|
||||
switch(_Mode)
|
||||
{
|
||||
// Do "r+b" for all writing to avoid truncating the file
|
||||
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;
|
||||
case 0x03: m_pFileHandle = fopen(m_Filename.c_str(), "r+b"); break;
|
||||
default: PanicAlert("CWII_IPC_HLE_Device_FileIO: unknown open mode"); break;
|
||||
}
|
||||
}
|
||||
|
||||
u32 ReturnValue = 0;
|
||||
|
||||
if (m_pFileHandle != NULL)
|
||||
{
|
||||
m_FileLength = File::GetSize(m_Filename.c_str());
|
||||
ReturnValue = GetDeviceID();
|
||||
}
|
||||
else
|
||||
else if(ReturnValue == 0)
|
||||
{
|
||||
ERROR_LOG(WII_IPC_FILEIO, " FileIO failed open: %s - File doesn't exist", m_Filename.c_str());
|
||||
ReturnValue = -106;
|
||||
ERROR_LOG(WII_IPC_FILEIO, " FileIO failed open: %s(%s) - I/O Error", m_Filename.c_str(), Modes[_Mode]);
|
||||
ReturnValue = -101;
|
||||
}
|
||||
|
||||
Memory::Write_U32(ReturnValue, _CommandAddress+4);
|
||||
|
|
|
@ -438,7 +438,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
|
|||
else
|
||||
{
|
||||
ERROR_LOG(WII_IPC_FILEIO, "FS: Rename %s to %s - failed", Filename.c_str(), FilenameRename.c_str());
|
||||
PanicAlert("CWII_IPC_HLE_Device_fs: rename %s to %s failed", Filename.c_str(), FilenameRename.c_str());
|
||||
return FS_FILE_NOT_EXIST;
|
||||
}
|
||||
|
||||
return FS_RESULT_OK;
|
||||
|
|
Loading…
Reference in New Issue