mirror of
https://github.com/yawut/SDL.git
synced 2026-07-08 04:36:07 -05:00
wiiu: buffer stdio RWops
This commit is contained in:
parent
ecef835577
commit
7d9be9e2fc
|
|
@ -479,4 +479,10 @@ typedef unsigned int uintptr_t;
|
|||
# endif /* !_STDINT_H_ && !HAVE_STDINT_H */
|
||||
#endif /* __WIN32__ */
|
||||
|
||||
#if defined(__WIIU__)
|
||||
/* buffer files using setvbuf */
|
||||
#define SDL_USE_FILE_BUFFER 1
|
||||
#define SDL_FILE_BUFFER_SIZE (128*1024)
|
||||
#endif
|
||||
|
||||
#endif /* SDL_config_h_ */
|
||||
|
|
|
|||
|
|
@ -125,6 +125,9 @@ typedef struct SDL_RWops
|
|||
{
|
||||
SDL_bool autoclose;
|
||||
FILE *fp;
|
||||
#ifdef SDL_USE_FILE_BUFFER
|
||||
char *buffer;
|
||||
#endif
|
||||
} stdio;
|
||||
#endif
|
||||
struct
|
||||
|
|
|
|||
|
|
@ -60,6 +60,10 @@
|
|||
#include "nacl_io/nacl_io.h"
|
||||
#endif
|
||||
|
||||
#ifdef SDL_USE_FILE_BUFFER
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#ifdef __WIN32__
|
||||
|
||||
/* Functions to read/write Win32 API file pointers */
|
||||
|
|
@ -412,6 +416,9 @@ stdio_close(SDL_RWops * context)
|
|||
status = SDL_Error(SDL_EFWRITE);
|
||||
}
|
||||
}
|
||||
#ifdef SDL_USE_FILE_BUFFER
|
||||
free(context->hidden.stdio.buffer);
|
||||
#endif
|
||||
SDL_FreeRW(context);
|
||||
}
|
||||
return status;
|
||||
|
|
@ -608,6 +615,10 @@ SDL_RWFromFP(FILE * fp, SDL_bool autoclose)
|
|||
rwops->write = stdio_write;
|
||||
rwops->close = stdio_close;
|
||||
rwops->hidden.stdio.fp = fp;
|
||||
#ifdef SDL_USE_FILE_BUFFER
|
||||
rwops->hidden.stdio.buffer = (char *) memalign(0x40, SDL_FILE_BUFFER_SIZE);
|
||||
setvbuf(fp, rwops->hidden.stdio.buffer, _IOFBF, SDL_FILE_BUFFER_SIZE);
|
||||
#endif
|
||||
rwops->hidden.stdio.autoclose = autoclose;
|
||||
rwops->type = SDL_RWOPS_STDFILE;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user