mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-08-29 18:11:38 +00:00
Updated source to match SDL function prototype style
This commit is contained in:
@@ -522,8 +522,7 @@ static int SDLCALL mem_close(SDL_RWops *context)
|
||||
|
||||
/* Functions to create SDL_RWops structures from various data sources */
|
||||
|
||||
SDL_RWops *
|
||||
SDL_RWFromFile(const char *file, const char *mode)
|
||||
SDL_RWops *SDL_RWFromFile(const char *file, const char *mode)
|
||||
{
|
||||
SDL_RWops *rwops = NULL;
|
||||
if (file == NULL || !*file || mode == NULL || !*mode) {
|
||||
@@ -616,8 +615,7 @@ SDL_RWFromFile(const char *file, const char *mode)
|
||||
}
|
||||
|
||||
#ifdef HAVE_STDIO_H
|
||||
SDL_RWops *
|
||||
SDL_RWFromFP(FILE * fp, SDL_bool autoclose)
|
||||
SDL_RWops *SDL_RWFromFP(FILE * fp, SDL_bool autoclose)
|
||||
{
|
||||
SDL_RWops *rwops = NULL;
|
||||
|
||||
@@ -635,16 +633,14 @@ SDL_RWFromFP(FILE * fp, SDL_bool autoclose)
|
||||
return rwops;
|
||||
}
|
||||
#else
|
||||
SDL_RWops *
|
||||
SDL_RWFromFP(void * fp, SDL_bool autoclose)
|
||||
SDL_RWops *SDL_RWFromFP(void * fp, SDL_bool autoclose)
|
||||
{
|
||||
SDL_SetError("SDL not compiled with stdio support");
|
||||
return NULL;
|
||||
}
|
||||
#endif /* HAVE_STDIO_H */
|
||||
|
||||
SDL_RWops *
|
||||
SDL_RWFromMem(void *mem, int size)
|
||||
SDL_RWops *SDL_RWFromMem(void *mem, int size)
|
||||
{
|
||||
SDL_RWops *rwops = NULL;
|
||||
if (mem == NULL) {
|
||||
@@ -671,8 +667,7 @@ SDL_RWFromMem(void *mem, int size)
|
||||
return rwops;
|
||||
}
|
||||
|
||||
SDL_RWops *
|
||||
SDL_RWFromConstMem(const void *mem, int size)
|
||||
SDL_RWops *SDL_RWFromConstMem(const void *mem, int size)
|
||||
{
|
||||
SDL_RWops *rwops = NULL;
|
||||
if (mem == NULL) {
|
||||
@@ -699,8 +694,7 @@ SDL_RWFromConstMem(const void *mem, int size)
|
||||
return rwops;
|
||||
}
|
||||
|
||||
SDL_RWops *
|
||||
SDL_AllocRW(void)
|
||||
SDL_RWops *SDL_AllocRW(void)
|
||||
{
|
||||
SDL_RWops *area;
|
||||
|
||||
@@ -719,8 +713,7 @@ void SDL_FreeRW(SDL_RWops *area)
|
||||
}
|
||||
|
||||
/* Load all the data from an SDL data stream */
|
||||
void *
|
||||
SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, int freesrc)
|
||||
void *SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, int freesrc)
|
||||
{
|
||||
static const Sint64 FILE_CHUNK_SIZE = 1024;
|
||||
Sint64 size;
|
||||
@@ -771,26 +764,22 @@ done:
|
||||
return data;
|
||||
}
|
||||
|
||||
void *
|
||||
SDL_LoadFile(const char *file, size_t *datasize)
|
||||
void *SDL_LoadFile(const char *file, size_t *datasize)
|
||||
{
|
||||
return SDL_LoadFile_RW(SDL_RWFromFile(file, "rb"), datasize, 1);
|
||||
}
|
||||
|
||||
Sint64
|
||||
SDL_RWsize(SDL_RWops *context)
|
||||
Sint64 SDL_RWsize(SDL_RWops *context)
|
||||
{
|
||||
return context->size(context);
|
||||
}
|
||||
|
||||
Sint64
|
||||
SDL_RWseek(SDL_RWops *context, Sint64 offset, int whence)
|
||||
Sint64 SDL_RWseek(SDL_RWops *context, Sint64 offset, int whence)
|
||||
{
|
||||
return context->seek(context, offset, whence);
|
||||
}
|
||||
|
||||
Sint64
|
||||
SDL_RWtell(SDL_RWops *context)
|
||||
Sint64 SDL_RWtell(SDL_RWops *context)
|
||||
{
|
||||
return context->seek(context, 0, RW_SEEK_CUR);
|
||||
}
|
||||
@@ -822,8 +811,7 @@ Uint8 SDL_ReadU8(SDL_RWops *src)
|
||||
return value;
|
||||
}
|
||||
|
||||
Uint16
|
||||
SDL_ReadLE16(SDL_RWops *src)
|
||||
Uint16 SDL_ReadLE16(SDL_RWops *src)
|
||||
{
|
||||
Uint16 value = 0;
|
||||
|
||||
@@ -831,8 +819,7 @@ SDL_ReadLE16(SDL_RWops *src)
|
||||
return SDL_SwapLE16(value);
|
||||
}
|
||||
|
||||
Uint16
|
||||
SDL_ReadBE16(SDL_RWops *src)
|
||||
Uint16 SDL_ReadBE16(SDL_RWops *src)
|
||||
{
|
||||
Uint16 value = 0;
|
||||
|
||||
@@ -840,8 +827,7 @@ SDL_ReadBE16(SDL_RWops *src)
|
||||
return SDL_SwapBE16(value);
|
||||
}
|
||||
|
||||
Uint32
|
||||
SDL_ReadLE32(SDL_RWops *src)
|
||||
Uint32 SDL_ReadLE32(SDL_RWops *src)
|
||||
{
|
||||
Uint32 value = 0;
|
||||
|
||||
@@ -849,8 +835,7 @@ SDL_ReadLE32(SDL_RWops *src)
|
||||
return SDL_SwapLE32(value);
|
||||
}
|
||||
|
||||
Uint32
|
||||
SDL_ReadBE32(SDL_RWops *src)
|
||||
Uint32 SDL_ReadBE32(SDL_RWops *src)
|
||||
{
|
||||
Uint32 value = 0;
|
||||
|
||||
@@ -858,8 +843,7 @@ SDL_ReadBE32(SDL_RWops *src)
|
||||
return SDL_SwapBE32(value);
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_ReadLE64(SDL_RWops *src)
|
||||
Uint64 SDL_ReadLE64(SDL_RWops *src)
|
||||
{
|
||||
Uint64 value = 0;
|
||||
|
||||
@@ -867,8 +851,7 @@ SDL_ReadLE64(SDL_RWops *src)
|
||||
return SDL_SwapLE64(value);
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_ReadBE64(SDL_RWops *src)
|
||||
Uint64 SDL_ReadBE64(SDL_RWops *src)
|
||||
{
|
||||
Uint64 value = 0;
|
||||
|
||||
|
||||
@@ -23,21 +23,20 @@
|
||||
#include "SDL_error.h"
|
||||
|
||||
/* Checks if the mode is a kind of reading */
|
||||
SDL_FORCE_INLINE SDL_bool IsReadMode(const char *mode);
|
||||
static SDL_bool IsReadMode(const char *mode);
|
||||
|
||||
/* Checks if the file starts with the given prefix */
|
||||
SDL_FORCE_INLINE SDL_bool HasPrefix(const char *file, const char *prefix);
|
||||
static SDL_bool HasPrefix(const char *file, const char *prefix);
|
||||
|
||||
SDL_FORCE_INLINE FILE *TryOpenFile(const char *file, const char *mode);
|
||||
SDL_FORCE_INLINE FILE *TryOpenInRomfs(const char *file, const char *mode);
|
||||
static FILE *TryOpenFile(const char *file, const char *mode);
|
||||
static FILE *TryOpenInRomfs(const char *file, const char *mode);
|
||||
|
||||
/* Nintendo 3DS applications may embed resources in the executable. The
|
||||
resources are stored in a special read-only partition prefixed with
|
||||
'romfs:/'. As such, when opening a file, we should first try the romfs
|
||||
unless sdmc is specifically mentionned.
|
||||
*/
|
||||
FILE *
|
||||
N3DS_FileOpen(const char *file, const char *mode)
|
||||
FILE *N3DS_FileOpen(const char *file, const char *mode)
|
||||
{
|
||||
/* romfs are read-only */
|
||||
if (!IsReadMode(mode)) {
|
||||
@@ -52,20 +51,17 @@ N3DS_FileOpen(const char *file, const char *mode)
|
||||
return TryOpenFile(file, mode);
|
||||
}
|
||||
|
||||
SDL_FORCE_INLINE SDL_bool
|
||||
IsReadMode(const char *mode)
|
||||
static SDL_bool IsReadMode(const char *mode)
|
||||
{
|
||||
return SDL_strchr(mode, 'r') != NULL;
|
||||
}
|
||||
|
||||
SDL_FORCE_INLINE SDL_bool
|
||||
HasPrefix(const char *file, const char *prefix)
|
||||
static SDL_bool HasPrefix(const char *file, const char *prefix)
|
||||
{
|
||||
return SDL_strncmp(prefix, file, SDL_strlen(prefix)) == 0;
|
||||
}
|
||||
|
||||
SDL_FORCE_INLINE FILE *
|
||||
TryOpenFile(const char *file, const char *mode)
|
||||
static FILE *TryOpenFile(const char *file, const char *mode)
|
||||
{
|
||||
FILE *fp = NULL;
|
||||
|
||||
@@ -77,8 +73,7 @@ TryOpenFile(const char *file, const char *mode)
|
||||
return fp;
|
||||
}
|
||||
|
||||
SDL_FORCE_INLINE FILE *
|
||||
TryOpenInRomfs(const char *file, const char *mode)
|
||||
static FILE *TryOpenInRomfs(const char *file, const char *mode)
|
||||
{
|
||||
FILE *fp = NULL;
|
||||
char *prefixed_filepath = NULL;
|
||||
|
||||
Reference in New Issue
Block a user