From 21b7895b61c134df766be45b00dab35eddfe1e04 Mon Sep 17 00:00:00 2001 From: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com> Date: Sat, 31 Oct 2020 01:54:38 +0100 Subject: [PATCH] wiiu: use buffer for reading files improves loading times --- src/core/FileMgr.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/core/FileMgr.cpp b/src/core/FileMgr.cpp index 38f8c9d3..a6605127 100644 --- a/src/core/FileMgr.cpp +++ b/src/core/FileMgr.cpp @@ -10,6 +10,12 @@ const char *_psGetUserFilesFolder(); +// io is really slow on the Wii U +// so we're buffering files +#ifdef __WIIU__ +#define BUFFER +#endif + /* * Windows FILE is BROKEN for GTA. * @@ -22,6 +28,9 @@ struct myFILE { bool isText; FILE *file; +#ifdef BUFFER + char* buf; +#endif }; #define NUMFILES 20 @@ -80,6 +89,10 @@ found: myfiles[fd].file = fcaseopen(filename, realmode); if(myfiles[fd].file == nil) return 0; +#ifdef BUFFER + myfiles[fd].buf = (char*) malloc(BUFSIZ); + setbuf(myfiles[fd].file, myfiles[fd].buf); +#endif return fd; } @@ -91,6 +104,9 @@ myfclose(int fd) if(myfiles[fd].file){ ret = fclose(myfiles[fd].file); myfiles[fd].file = nil; +#ifdef BUFFER + free(myfiles[fd].buf); +#endif return ret; } return EOF;