mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
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
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user