arsa  2.7
Classes | Macros | Typedefs | Functions
SDL_rwops.h File Reference
#include "SDL_stdinc.h"
#include "SDL_error.h"
#include "begin_code.h"
#include "close_code.h"

Go to the source code of this file.

Classes

struct  SDL_RWops
 

Macros

#define SDL_RWOPS_UNKNOWN   0U
 
#define SDL_RWOPS_WINFILE   1U
 
#define SDL_RWOPS_STDFILE   2U
 
#define SDL_RWOPS_JNIFILE   3U
 
#define SDL_RWOPS_MEMORY   4U
 
#define SDL_RWOPS_MEMORY_RO   5U
 
#define RW_SEEK_SET   0
 
#define RW_SEEK_CUR   1
 
#define RW_SEEK_END   2
 

Typedefs

typedef struct SDL_RWops SDL_RWops
 

Functions

DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW (void)
 
DECLSPEC void SDLCALL SDL_FreeRW (SDL_RWops *area)
 
DECLSPEC Sint64 SDLCALL SDL_RWsize (SDL_RWops *context)
 
DECLSPEC Sint64 SDLCALL SDL_RWseek (SDL_RWops *context, Sint64 offset, int whence)
 
DECLSPEC Sint64 SDLCALL SDL_RWtell (SDL_RWops *context)
 
DECLSPEC size_t SDLCALL SDL_RWread (SDL_RWops *context, void *ptr, size_t size, size_t maxnum)
 
DECLSPEC size_t SDLCALL SDL_RWwrite (SDL_RWops *context, const void *ptr, size_t size, size_t num)
 
DECLSPEC int SDLCALL SDL_RWclose (SDL_RWops *context)
 
DECLSPEC void *SDLCALL SDL_LoadFile_RW (SDL_RWops *src, size_t *datasize, int freesrc)
 
DECLSPEC void *SDLCALL SDL_LoadFile (const char *file, size_t *datasize)
 
RWFrom functions

Functions to create SDL_RWops structures from various data streams.

DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile (const char *file, const char *mode)
 
DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP (void *fp, SDL_bool autoclose)
 
DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem (void *mem, int size)
 
DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem (const void *mem, int size)
 
Read endian functions

Read an item of the specified endianness and return in native format.

DECLSPEC Uint8 SDLCALL SDL_ReadU8 (SDL_RWops *src)
 
DECLSPEC Uint16 SDLCALL SDL_ReadLE16 (SDL_RWops *src)
 
DECLSPEC Uint16 SDLCALL SDL_ReadBE16 (SDL_RWops *src)
 
DECLSPEC Uint32 SDLCALL SDL_ReadLE32 (SDL_RWops *src)
 
DECLSPEC Uint32 SDLCALL SDL_ReadBE32 (SDL_RWops *src)
 
DECLSPEC Uint64 SDLCALL SDL_ReadLE64 (SDL_RWops *src)
 
DECLSPEC Uint64 SDLCALL SDL_ReadBE64 (SDL_RWops *src)
 
Write endian functions

Write an item of native format to the specified endianness.

DECLSPEC size_t SDLCALL SDL_WriteU8 (SDL_RWops *dst, Uint8 value)
 
DECLSPEC size_t SDLCALL SDL_WriteLE16 (SDL_RWops *dst, Uint16 value)
 
DECLSPEC size_t SDLCALL SDL_WriteBE16 (SDL_RWops *dst, Uint16 value)
 
DECLSPEC size_t SDLCALL SDL_WriteLE32 (SDL_RWops *dst, Uint32 value)
 
DECLSPEC size_t SDLCALL SDL_WriteBE32 (SDL_RWops *dst, Uint32 value)
 
DECLSPEC size_t SDLCALL SDL_WriteLE64 (SDL_RWops *dst, Uint64 value)
 
DECLSPEC size_t SDLCALL SDL_WriteBE64 (SDL_RWops *dst, Uint64 value)
 

Detailed Description

This file provides a general interface for SDL to read and write data streams. It can easily be extended to files, memory, etc.

Definition in file SDL_rwops.h.

Macro Definition Documentation

◆ RW_SEEK_CUR

#define RW_SEEK_CUR   1

Seek relative to current read point

Definition at line 175 of file SDL_rwops.h.

◆ RW_SEEK_END

#define RW_SEEK_END   2

Seek relative to the end of data

Definition at line 176 of file SDL_rwops.h.

◆ RW_SEEK_SET

#define RW_SEEK_SET   0

Seek from the beginning of data

Definition at line 174 of file SDL_rwops.h.

◆ SDL_RWOPS_JNIFILE

#define SDL_RWOPS_JNIFILE   3U

Android asset

Definition at line 45 of file SDL_rwops.h.

◆ SDL_RWOPS_MEMORY

#define SDL_RWOPS_MEMORY   4U

Memory stream

Definition at line 46 of file SDL_rwops.h.

◆ SDL_RWOPS_MEMORY_RO

#define SDL_RWOPS_MEMORY_RO   5U

Read-Only memory stream

Definition at line 47 of file SDL_rwops.h.

◆ SDL_RWOPS_STDFILE

#define SDL_RWOPS_STDFILE   2U

Stdio file

Definition at line 44 of file SDL_rwops.h.

◆ SDL_RWOPS_UNKNOWN

#define SDL_RWOPS_UNKNOWN   0U

Unknown stream type

Definition at line 42 of file SDL_rwops.h.

◆ SDL_RWOPS_WINFILE

#define SDL_RWOPS_WINFILE   1U

Win32 file

Definition at line 43 of file SDL_rwops.h.

Typedef Documentation

◆ SDL_RWops

typedef struct SDL_RWops SDL_RWops

This is the read/write operation structure – very basic.

Function Documentation

◆ SDL_AllocRW()

DECLSPEC SDL_RWops* SDLCALL SDL_AllocRW ( void  )

◆ SDL_FreeRW()

DECLSPEC void SDLCALL SDL_FreeRW ( SDL_RWops area)

◆ SDL_LoadFile()

DECLSPEC void* SDLCALL SDL_LoadFile ( const char *  file,
size_t datasize 
)

Load an entire file.

The data is allocated with a zero byte at the end (null terminated)

If datasize is not NULL, it is filled with the size of the data read.

If freesrc is non-zero, the stream will be closed after being read.

The data should be freed with SDL_free().

Returns
the data, or NULL if there was an error.

◆ SDL_LoadFile_RW()

DECLSPEC void* SDLCALL SDL_LoadFile_RW ( SDL_RWops src,
size_t datasize,
int  freesrc 
)

Load all the data from an SDL data stream.

The data is allocated with a zero byte at the end (null terminated)

If datasize is not NULL, it is filled with the size of the data read.

If freesrc is non-zero, the stream will be closed after being read.

The data should be freed with SDL_free().

Returns
the data, or NULL if there was an error.

◆ SDL_ReadBE16()

DECLSPEC Uint16 SDLCALL SDL_ReadBE16 ( SDL_RWops src)

◆ SDL_ReadBE32()

DECLSPEC Uint32 SDLCALL SDL_ReadBE32 ( SDL_RWops src)

◆ SDL_ReadBE64()

DECLSPEC Uint64 SDLCALL SDL_ReadBE64 ( SDL_RWops src)

◆ SDL_ReadLE16()

DECLSPEC Uint16 SDLCALL SDL_ReadLE16 ( SDL_RWops src)

◆ SDL_ReadLE32()

DECLSPEC Uint32 SDLCALL SDL_ReadLE32 ( SDL_RWops src)

◆ SDL_ReadLE64()

DECLSPEC Uint64 SDLCALL SDL_ReadLE64 ( SDL_RWops src)

◆ SDL_ReadU8()

DECLSPEC Uint8 SDLCALL SDL_ReadU8 ( SDL_RWops src)

◆ SDL_RWclose()

DECLSPEC int SDLCALL SDL_RWclose ( SDL_RWops context)

Close and free an allocated SDL_RWops structure.

Returns
0 if successful or -1 on write error when flushing data.

◆ SDL_RWFromConstMem()

DECLSPEC SDL_RWops* SDLCALL SDL_RWFromConstMem ( const void mem,
int  size 
)

◆ SDL_RWFromFile()

DECLSPEC SDL_RWops* SDLCALL SDL_RWFromFile ( const char *  file,
const char *  mode 
)

◆ SDL_RWFromFP()

DECLSPEC SDL_RWops* SDLCALL SDL_RWFromFP ( void fp,
SDL_bool  autoclose 
)

◆ SDL_RWFromMem()

DECLSPEC SDL_RWops* SDLCALL SDL_RWFromMem ( void mem,
int  size 
)

◆ SDL_RWread()

DECLSPEC size_t SDLCALL SDL_RWread ( SDL_RWops context,
void ptr,
size_t  size,
size_t  maxnum 
)

Read up to maxnum objects each of size size from the data stream to the area pointed at by ptr.

Returns
the number of objects read, or 0 at error or end of file.

◆ SDL_RWseek()

DECLSPEC Sint64 SDLCALL SDL_RWseek ( SDL_RWops context,
Sint64  offset,
int  whence 
)

Seek to offset relative to whence, one of stdio's whence values: RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END

Returns
the final offset in the data stream, or -1 on error.

◆ SDL_RWsize()

DECLSPEC Sint64 SDLCALL SDL_RWsize ( SDL_RWops context)

Return the size of the file in this rwops, or -1 if unknown

◆ SDL_RWtell()

DECLSPEC Sint64 SDLCALL SDL_RWtell ( SDL_RWops context)

Return the current offset in the data stream, or -1 on error.

◆ SDL_RWwrite()

DECLSPEC size_t SDLCALL SDL_RWwrite ( SDL_RWops context,
const void ptr,
size_t  size,
size_t  num 
)

Write exactly num objects each of size size from the area pointed at by ptr to data stream.

Returns
the number of objects written, or 0 at error or end of file.

◆ SDL_WriteBE16()

DECLSPEC size_t SDLCALL SDL_WriteBE16 ( SDL_RWops dst,
Uint16  value 
)

◆ SDL_WriteBE32()

DECLSPEC size_t SDLCALL SDL_WriteBE32 ( SDL_RWops dst,
Uint32  value 
)

◆ SDL_WriteBE64()

DECLSPEC size_t SDLCALL SDL_WriteBE64 ( SDL_RWops dst,
Uint64  value 
)

◆ SDL_WriteLE16()

DECLSPEC size_t SDLCALL SDL_WriteLE16 ( SDL_RWops dst,
Uint16  value 
)

◆ SDL_WriteLE32()

DECLSPEC size_t SDLCALL SDL_WriteLE32 ( SDL_RWops dst,
Uint32  value 
)

◆ SDL_WriteLE64()

DECLSPEC size_t SDLCALL SDL_WriteLE64 ( SDL_RWops dst,
Uint64  value 
)

◆ SDL_WriteU8()

DECLSPEC size_t SDLCALL SDL_WriteU8 ( SDL_RWops dst,
Uint8  value 
)