From 734daf362b8518df5ca85707876e65800ccbab57 Mon Sep 17 00:00:00 2001 From: luigi2us Date: Thu, 17 Dec 2009 19:11:40 +0000 Subject: [PATCH] FileIO: update m_FileLength upon writes, so that MKWii doesn't end up seeking in rksys.dat at incredibly huge offsets. MKWii still fails to create a new save file. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4704 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp index 9288769245..2aed0a62fd 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp @@ -130,7 +130,7 @@ bool CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress) s32 SeekPosition = Memory::Read_U32(_CommandAddress + 0xC); s32 Mode = Memory::Read_U32(_CommandAddress + 0x10); - INFO_LOG(WII_IPC_FILEIO, "FileIO: Old Seek Pos: 0x%08x, Mode: %i (%s, Length=0x%08x)", SeekPosition, Mode, m_Name.c_str(), m_FileLength); + INFO_LOG(WII_IPC_FILEIO, "FileIO: Old Seek Pos: 0x%08x, Mode: %i (%s, Length=0x%08x)", SeekPosition, Mode, m_Name.c_str(), m_FileLength); // TODO : The following hack smells bad /* Zelda - TP Fix: It doesn't make much sense but it works in Zelda - TP and @@ -208,6 +208,10 @@ bool CWII_IPC_HLE_Device_FileIO::Write(u32 _CommandAddress) size_t Result = fwrite(Memory::GetPointer(Address), Size, 1, m_pFileHandle); _dbg_assert_msg_(WII_IPC_FILEIO, Result == 1, "fwrite failed"); ReturnValue = Size; + + u32 NewPosition = (u32)ftell(m_pFileHandle); + if (NewPosition > m_FileLength) // Oops, we made the file longer... let's update m_FileLength then + m_FileLength = NewPosition; } Memory::Write_U32(ReturnValue, _CommandAddress + 0x4);