From b3421467add98086223304ca6344d62b15fb5ce3 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Mon, 8 Dec 2008 22:02:06 +0000 Subject: [PATCH] add support for all seek modes (wii nand file i/o) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1451 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) 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 196b08ea64..02b28054a9 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 @@ -125,22 +125,18 @@ CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress) LOG(WII_IPC_FILEIO, "FileIO: Seek Pos: %i, Mode: %i (Device=%s)", SeekPosition, Mode, GetDeviceName().c_str()); - switch(Mode) - { - case 0: - if (fseek(m_pFileHandle, SeekPosition, SEEK_SET) == 0) { - // Seek always return the seek position for success - ReturnValue = SeekPosition; - } else { - LOG(WII_IPC_FILEIO, "FILEIO: Seek failed"); - } - break; + int seek_mode[3] = {SEEK_SET, SEEK_CUR, SEEK_END}; - case 1: // cur - case 2: // end - default: - PanicAlert("CWII_IPC_HLE_Device_FileIO unsupported seek mode"); - break; + if (Mode >= 0 && Mode <= 2) { + if (fseek(m_pFileHandle, SeekPosition, seek_mode[Mode]) == 0) { + // Seek always return the seek position for success + // Not sure if it's right in all modes though. + ReturnValue = SeekPosition; + } else { + LOG(WII_IPC_FILEIO, "FILEIO: Seek failed"); + } + } else { + PanicAlert("CWII_IPC_HLE_Device_FileIO unsupported seek mode %i", Mode); } Memory::Write_U32(ReturnValue, _CommandAddress + 0x4);