diff options
| author | blubberdiblub <blubberdiblub@gmail.com> | 2010-12-21 18:03:44 +0000 |
|---|---|---|
| committer | blubberdiblub <blubberdiblub@gmail.com> | 2010-12-21 18:03:44 +0000 |
| commit | 38e80fe094ffea7d51b74960207750d5ae62eba8 (patch) | |
| tree | cc32ddfd87efaf079cb30524a8b0565a7d24df99 /Source/Core/Common/Src/FileUtil.cpp | |
| parent | 6cb78515c64101824d35ee7478d8d30e8dcc6879 (diff) | |
Fixes some file handling in IPC_HLE
* change File::GetSize to fetch the size directly from the open file instead
of stat'ing it when challed with a FILE*
* use changed File::GetSize(FILE *f) instead of calling with file name in two
places
* remove "seek_pos % file_size" hack for ZTP, so one can seek to the end of
file again. Please check Zelda: Twilight Princess for regressions
* return error codes when reading or writing from/to a file
A lot of those changes are from j4ck.fr0st, so kudos to him.
I did not change the file open mode for ISFS_OPEN_WRITE to "wb". While that
would probably be more correct, it says in the comment that it might affect
Mario Kart Wii. I would prefer somebody with that game try that change
locally first.
Please check your games for regressions (or even improvement). Some games that
may be affected are Zelda - Twilight Princess and Metroid Prime 3.
Fixes issue 1749
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6634 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common/Src/FileUtil.cpp')
| -rw-r--r-- | Source/Core/Common/Src/FileUtil.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp index 3c820ef135..90b90a9c35 100644 --- a/Source/Core/Common/Src/FileUtil.cpp +++ b/Source/Core/Common/Src/FileUtil.cpp @@ -362,7 +362,19 @@ u64 GetSize(const int fd) // Overloaded GetSize, accepts FILE* u64 GetSize(FILE *f) { - return GetSize(fileno(f)); + off_t pos = ftello(f); + if (fseeko(f, 0, SEEK_END) != 0) { + ERROR_LOG(COMMON, "GetSize: seek failed %p: %s", + f, GetLastErrorMsg()); + return 0; + } + off_t size = ftello(f); + if ((size != pos) && (fseeko(f, pos, SEEK_SET) != 0)) { + ERROR_LOG(COMMON, "GetSize: seek failed %p: %s", + f, GetLastErrorMsg()); + return 0; + } + return size; } // creates an empty file filename, returns true on success |
