Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #109 from lioncash/file-io-clarifications
Eliminate the magic constants in the switch statement in WII_IPC_HLE_Device_FileIO.cpp's Seek function.
  • Loading branch information
Parlane committed Mar 2, 2014
2 parents 0942bda + 3bc082b commit 70b3749
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp
Expand Up @@ -162,7 +162,7 @@ bool CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress)

switch (Mode)
{
case 0:
case WII_SEEK_SET:
{
if ((SeekPosition >=0) && (SeekPosition <= fileSize))
{
Expand All @@ -171,7 +171,8 @@ bool CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress)
}
break;
}
case 1:

case WII_SEEK_CUR:
{
s32 wantedPos = SeekPosition+m_SeekPos;
if (wantedPos >=0 && wantedPos <= fileSize)
Expand All @@ -181,16 +182,18 @@ bool CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress)
}
break;
}
case 2:

case WII_SEEK_END:
{
s32 wantedPos = fileSize+m_SeekPos;
s32 wantedPos = SeekPosition+fileSize;
if (wantedPos >=0 && wantedPos <= fileSize)
{
m_SeekPos = wantedPos;
ReturnValue = m_SeekPos;
}
break;
}

default:
{
PanicAlert("CWII_IPC_HLE_Device_FileIO Unsupported seek mode %i", Mode);
Expand Down
7 changes: 7 additions & 0 deletions Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.h
Expand Up @@ -35,6 +35,13 @@ class CWII_IPC_HLE_Device_FileIO : public IWII_IPC_HLE_Device
ISFS_OPEN_RW = (ISFS_OPEN_READ | ISFS_OPEN_WRITE)
};

enum
{
WII_SEEK_SET = 0,
WII_SEEK_CUR = 1,
WII_SEEK_END = 2,
};

enum
{
ISFS_FUNCNULL = 0,
Expand Down

0 comments on commit 70b3749

Please sign in to comment.