SDL  2.0
SDL_rwops.h File Reference
#include "SDL_stdinc.h"
#include "SDL_error.h"
#include "begin_code.h"
#include "close_code.h"
+ Include dependency graph for SDL_rwops.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

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
 

Functions

Read endian functions

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

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

Write an item of native format to the specified endianness.

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

RWFrom functions

Functions to create SDL_RWops structures from various data streams.

#define RW_SEEK_SET   0
 
#define RW_SEEK_CUR   1
 
#define RW_SEEK_END   2
 
SDL_RWopsSDL_RWFromFile (const char *file, const char *mode)
 
SDL_RWopsSDL_RWFromFP (FILE *fp, SDL_bool autoclose)
 
SDL_RWopsSDL_RWFromMem (void *mem, int size)
 
SDL_RWopsSDL_RWFromConstMem (const void *mem, int size)
 
SDL_RWopsSDL_AllocRW (void)
 
void SDL_FreeRW (SDL_RWops *area)
 
Sint64 SDL_RWsize (SDL_RWops *context)
 
Sint64 SDL_RWseek (SDL_RWops *context, Sint64 offset, int whence)
 
Sint64 SDL_RWtell (SDL_RWops *context)
 
size_t SDL_RWread (SDL_RWops *context, void *ptr, size_t size, size_t maxnum)
 
size_t SDL_RWwrite (SDL_RWops *context, const void *ptr, size_t size, size_t num)
 
int SDL_RWclose (SDL_RWops *context)
 
voidSDL_LoadFile_RW (SDL_RWops *src, size_t *datasize, int freesrc)
 
voidSDL_LoadFile (const char *file, size_t *datasize)
 

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 167 of file SDL_rwops.h.

◆ RW_SEEK_END

#define RW_SEEK_END   2

Seek relative to the end of data

Definition at line 168 of file SDL_rwops.h.

◆ RW_SEEK_SET

#define RW_SEEK_SET   0

Seek from the beginning of data

Definition at line 166 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.

Function Documentation

◆ SDL_AllocRW()

SDL_RWops* SDL_AllocRW ( void  )

◆ SDL_FreeRW()

void SDL_FreeRW ( SDL_RWops area)

Definition at line 715 of file SDL_rwops.c.

716 {
717  SDL_free(area);
718 }
#define SDL_free

References SDL_free.

Referenced by mem_close(), and SDL_RWFromFile().

◆ SDL_LoadFile()

void* 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.

Definition at line 774 of file SDL_rwops.c.

775 {
776  return SDL_LoadFile_RW(SDL_RWFromFile(file, "rb"), datasize, 1);
777 }
SDL_RWops * SDL_RWFromFile(const char *file, const char *mode)
Definition: SDL_rwops.c:529
void * SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, int freesrc)
Definition: SDL_rwops.c:722

References SDL_LoadFile_RW(), and SDL_RWFromFile().

◆ SDL_LoadFile_RW()

void* 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.

Definition at line 722 of file SDL_rwops.c.

723 {
724  const int FILE_CHUNK_SIZE = 1024;
725  Sint64 size;
726  size_t size_read, size_total;
727  void *data = NULL, *newdata;
728 
729  if (!src) {
730  SDL_InvalidParamError("src");
731  return NULL;
732  }
733 
734  size = SDL_RWsize(src);
735  if (size < 0) {
736  size = FILE_CHUNK_SIZE;
737  }
738  data = SDL_malloc((size_t)(size + 1));
739 
740  size_total = 0;
741  for (;;) {
742  if ((((Sint64)size_total) + FILE_CHUNK_SIZE) > size) {
743  size = (size_total + FILE_CHUNK_SIZE);
744  newdata = SDL_realloc(data, (size_t)(size + 1));
745  if (!newdata) {
746  SDL_free(data);
747  data = NULL;
748  SDL_OutOfMemory();
749  goto done;
750  }
751  data = newdata;
752  }
753 
754  size_read = SDL_RWread(src, (char *)data+size_total, 1, (size_t)(size-size_total));
755  if (size_read == 0) {
756  break;
757  }
758  size_total += size_read;
759  }
760 
761  if (datasize) {
762  *datasize = size_total;
763  }
764  ((char *)data)[size_total] = '\0';
765 
766 done:
767  if (freesrc && src) {
768  SDL_RWclose(src);
769  }
770  return data;
771 }
#define SDL_malloc
#define SDL_realloc
#define SDL_OutOfMemory()
Definition: SDL_error.h:88
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:90
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
GLenum src
GLsizeiptr size
size_t SDL_RWread(SDL_RWops *context, void *ptr, size_t size, size_t maxnum)
Definition: SDL_rwops.c:798
Sint64 SDL_RWsize(SDL_RWops *context)
Definition: SDL_rwops.c:780
int SDL_RWclose(SDL_RWops *context)
Definition: SDL_rwops.c:810
int64_t Sint64
Definition: SDL_stdinc.h:216
#define NULL
Definition: begin_code.h:163
int done
Definition: checkkeys.c:28

References done, NULL, SDL_free, SDL_InvalidParamError, SDL_malloc, SDL_OutOfMemory, SDL_realloc, SDL_RWclose(), SDL_RWread(), and SDL_RWsize().

Referenced by SDL_LoadFile().

◆ SDL_ReadBE16()

Uint16 SDL_ReadBE16 ( SDL_RWops src)

Definition at line 836 of file SDL_rwops.c.

837 {
838  Uint16 value = 0;
839 
840  SDL_RWread(src, &value, sizeof (value), 1);
841  return SDL_SwapBE16(value);
842 }
#define SDL_SwapBE16(X)
Definition: SDL_endian.h:239
GLsizei const GLfloat * value
uint16_t Uint16
Definition: SDL_stdinc.h:197

References SDL_RWread(), and SDL_SwapBE16.

◆ SDL_ReadBE32()

Uint32 SDL_ReadBE32 ( SDL_RWops src)

Definition at line 854 of file SDL_rwops.c.

855 {
856  Uint32 value = 0;
857 
858  SDL_RWread(src, &value, sizeof (value), 1);
859  return SDL_SwapBE32(value);
860 }
#define SDL_SwapBE32(X)
Definition: SDL_endian.h:240
uint32_t Uint32
Definition: SDL_stdinc.h:209

References SDL_RWread(), and SDL_SwapBE32.

◆ SDL_ReadBE64()

Uint64 SDL_ReadBE64 ( SDL_RWops src)

Definition at line 872 of file SDL_rwops.c.

873 {
874  Uint64 value = 0;
875 
876  SDL_RWread(src, &value, sizeof (value), 1);
877  return SDL_SwapBE64(value);
878 }
#define SDL_SwapBE64(X)
Definition: SDL_endian.h:241
uint64_t Uint64
Definition: SDL_stdinc.h:222

References SDL_RWread(), and SDL_SwapBE64.

◆ SDL_ReadLE16()

Uint16 SDL_ReadLE16 ( SDL_RWops src)

Definition at line 827 of file SDL_rwops.c.

828 {
829  Uint16 value = 0;
830 
831  SDL_RWread(src, &value, sizeof (value), 1);
832  return SDL_SwapLE16(value);
833 }
#define SDL_SwapLE16(X)
Definition: SDL_endian.h:235

References SDL_RWread(), and SDL_SwapLE16.

◆ SDL_ReadLE32()

Uint32 SDL_ReadLE32 ( SDL_RWops src)

Definition at line 845 of file SDL_rwops.c.

846 {
847  Uint32 value = 0;
848 
849  SDL_RWread(src, &value, sizeof (value), 1);
850  return SDL_SwapLE32(value);
851 }
#define SDL_SwapLE32(X)
Definition: SDL_endian.h:236

References SDL_RWread(), and SDL_SwapLE32.

◆ SDL_ReadLE64()

Uint64 SDL_ReadLE64 ( SDL_RWops src)

Definition at line 863 of file SDL_rwops.c.

864 {
865  Uint64 value = 0;
866 
867  SDL_RWread(src, &value, sizeof (value), 1);
868  return SDL_SwapLE64(value);
869 }
#define SDL_SwapLE64(X)
Definition: SDL_endian.h:237

References SDL_RWread(), and SDL_SwapLE64.

◆ SDL_ReadU8()

Uint8 SDL_ReadU8 ( SDL_RWops src)

Definition at line 818 of file SDL_rwops.c.

819 {
820  Uint8 value = 0;
821 
822  SDL_RWread(src, &value, sizeof (value), 1);
823  return value;
824 }
uint8_t Uint8
Definition: SDL_stdinc.h:185

References SDL_RWread().

◆ SDL_RWclose()

int 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.

Definition at line 810 of file SDL_rwops.c.

811 {
812  return context->close(context);
813 }
static screen_context_t context
Definition: video.c:25

References context.

Referenced by SDL_LoadFile_RW().

◆ SDL_RWFromConstMem()

SDL_RWops* SDL_RWFromConstMem ( const void mem,
int  size 
)

Definition at line 673 of file SDL_rwops.c.

674 {
675  SDL_RWops *rwops = NULL;
676  if (!mem) {
677  SDL_InvalidParamError("mem");
678  return rwops;
679  }
680  if (!size) {
681  SDL_InvalidParamError("size");
682  return rwops;
683  }
684 
685  rwops = SDL_AllocRW();
686  if (rwops != NULL) {
687  rwops->size = mem_size;
688  rwops->seek = mem_seek;
689  rwops->read = mem_read;
690  rwops->write = mem_writeconst;
691  rwops->close = mem_close;
692  rwops->hidden.mem.base = (Uint8 *) mem;
693  rwops->hidden.mem.here = rwops->hidden.mem.base;
694  rwops->hidden.mem.stop = rwops->hidden.mem.base + size;
695  rwops->type = SDL_RWOPS_MEMORY_RO;
696  }
697  return rwops;
698 }
static Sint64 mem_size(SDL_RWops *context)
Definition: SDL_rwops.c:442
static size_t mem_read(SDL_RWops *context, void *ptr, size_t size, size_t maxnum)
Definition: SDL_rwops.c:476
static size_t mem_writeconst(SDL_RWops *context, const void *ptr, size_t size, size_t num)
Definition: SDL_rwops.c:510
SDL_RWops * SDL_AllocRW(void)
Definition: SDL_rwops.c:701
static int mem_close(SDL_RWops *context)
Definition: SDL_rwops.c:517
static Sint64 mem_seek(SDL_RWops *context, Sint64 offset, int whence)
Definition: SDL_rwops.c:448
#define SDL_RWOPS_MEMORY_RO
Definition: SDL_rwops.h:47
size_t(* write)(struct SDL_RWops *context, const void *ptr, size_t size, size_t num)
Definition: SDL_rwops.h:83
Uint32 type
Definition: SDL_rwops.h:93
struct SDL_RWops::@2::@5 mem
int(* close)(struct SDL_RWops *context)
Definition: SDL_rwops.h:91
size_t(* read)(struct SDL_RWops *context, void *ptr, size_t size, size_t maxnum)
Definition: SDL_rwops.h:74
union SDL_RWops::@2 hidden
Sint64(* seek)(struct SDL_RWops *context, Sint64 offset, int whence)
Definition: SDL_rwops.h:65
Sint64(* size)(struct SDL_RWops *context)
Definition: SDL_rwops.h:57

References SDL_RWops::close, SDL_RWops::hidden, SDL_RWops::mem, mem_close(), mem_read(), mem_seek(), mem_size(), mem_writeconst(), NULL, SDL_RWops::read, SDL_AllocRW(), SDL_InvalidParamError, SDL_RWOPS_MEMORY_RO, SDL_RWops::seek, SDL_RWops::size, SDL_RWops::type, and SDL_RWops::write.

◆ SDL_RWFromFile()

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

Definition at line 529 of file SDL_rwops.c.

530 {
531  SDL_RWops *rwops = NULL;
532  if (!file || !*file || !mode || !*mode) {
533  SDL_SetError("SDL_RWFromFile(): No file or no mode specified");
534  return NULL;
535  }
536 #if defined(__ANDROID__)
537 #ifdef HAVE_STDIO_H
538  /* Try to open the file on the filesystem first */
539  if (*file == '/') {
540  FILE *fp = fopen(file, mode);
541  if (fp) {
542  return SDL_RWFromFP(fp, 1);
543  }
544  } else {
545  /* Try opening it from internal storage if it's a relative path */
546  char *path;
547  FILE *fp;
548 
549  /* !!! FIXME: why not just "char path[PATH_MAX];" ? */
550  path = SDL_stack_alloc(char, PATH_MAX);
551  if (path) {
552  SDL_snprintf(path, PATH_MAX, "%s/%s",
554  fp = fopen(path, mode);
556  if (fp) {
557  return SDL_RWFromFP(fp, 1);
558  }
559  }
560  }
561 #endif /* HAVE_STDIO_H */
562 
563  /* Try to open the file from the asset system */
564  rwops = SDL_AllocRW();
565  if (!rwops)
566  return NULL; /* SDL_SetError already setup by SDL_AllocRW() */
567  if (Android_JNI_FileOpen(rwops, file, mode) < 0) {
568  SDL_FreeRW(rwops);
569  return NULL;
570  }
571  rwops->size = Android_JNI_FileSize;
572  rwops->seek = Android_JNI_FileSeek;
573  rwops->read = Android_JNI_FileRead;
574  rwops->write = Android_JNI_FileWrite;
575  rwops->close = Android_JNI_FileClose;
576  rwops->type = SDL_RWOPS_JNIFILE;
577 
578 #elif defined(__WIN32__)
579  rwops = SDL_AllocRW();
580  if (!rwops)
581  return NULL; /* SDL_SetError already setup by SDL_AllocRW() */
582  if (windows_file_open(rwops, file, mode) < 0) {
583  SDL_FreeRW(rwops);
584  return NULL;
585  }
586  rwops->size = windows_file_size;
587  rwops->seek = windows_file_seek;
588  rwops->read = windows_file_read;
589  rwops->write = windows_file_write;
590  rwops->close = windows_file_close;
591  rwops->type = SDL_RWOPS_WINFILE;
592 
593 #elif HAVE_STDIO_H
594  {
595  #ifdef __APPLE__
596  FILE *fp = SDL_OpenFPFromBundleOrFallback(file, mode);
597  #elif __WINRT__
598  FILE *fp = NULL;
599  fopen_s(&fp, file, mode);
600  #else
601  FILE *fp = fopen(file, mode);
602  #endif
603  if (fp == NULL) {
604  SDL_SetError("Couldn't open %s", file);
605  } else {
606  rwops = SDL_RWFromFP(fp, SDL_TRUE);
607  }
608  }
609 #else
610  SDL_SetError("SDL not compiled with stdio support");
611 #endif /* !HAVE_STDIO_H */
612 
613  return rwops;
614 }
size_t Android_JNI_FileRead(SDL_RWops *ctx, void *buffer, size_t size, size_t maxnum)
int Android_JNI_FileOpen(SDL_RWops *ctx, const char *fileName, const char *mode)
size_t Android_JNI_FileWrite(SDL_RWops *ctx, const void *buffer, size_t size, size_t num)
Sint64 Android_JNI_FileSize(SDL_RWops *ctx)
Sint64 Android_JNI_FileSeek(SDL_RWops *ctx, Sint64 offset, int whence)
int Android_JNI_FileClose(SDL_RWops *ctx)
#define SDL_SetError
#define SDL_AndroidGetInternalStoragePath
#define SDL_snprintf
GLenum mode
GLsizei const GLchar *const * path
void SDL_FreeRW(SDL_RWops *area)
Definition: SDL_rwops.c:715
SDL_RWops * SDL_RWFromFP(void *fp, SDL_bool autoclose)
Definition: SDL_rwops.c:637
#define SDL_RWOPS_JNIFILE
Definition: SDL_rwops.h:45
#define SDL_RWOPS_WINFILE
Definition: SDL_rwops.h:43
@ SDL_TRUE
Definition: SDL_stdinc.h:170
#define SDL_stack_alloc(type, count)
Definition: SDL_stdinc.h:360
#define SDL_stack_free(data)
Definition: SDL_stdinc.h:361

References Android_JNI_FileClose(), Android_JNI_FileOpen(), Android_JNI_FileRead(), Android_JNI_FileSeek(), Android_JNI_FileSize(), Android_JNI_FileWrite(), SDL_RWops::close, NULL, SDL_RWops::read, SDL_AllocRW(), SDL_AndroidGetInternalStoragePath, SDL_FreeRW(), SDL_RWFromFP(), SDL_RWOPS_JNIFILE, SDL_RWOPS_WINFILE, SDL_SetError, SDL_snprintf, SDL_stack_alloc, SDL_stack_free, SDL_TRUE, SDL_RWops::seek, SDL_RWops::size, SDL_RWops::type, and SDL_RWops::write.

Referenced by SDL_LoadFile().

◆ SDL_RWFromFP()

SDL_RWops* SDL_RWFromFP ( FILE *  fp,
SDL_bool  autoclose 
)

◆ SDL_RWFromMem()

SDL_RWops* SDL_RWFromMem ( void mem,
int  size 
)

Definition at line 645 of file SDL_rwops.c.

646 {
647  SDL_RWops *rwops = NULL;
648  if (!mem) {
649  SDL_InvalidParamError("mem");
650  return rwops;
651  }
652  if (!size) {
653  SDL_InvalidParamError("size");
654  return rwops;
655  }
656 
657  rwops = SDL_AllocRW();
658  if (rwops != NULL) {
659  rwops->size = mem_size;
660  rwops->seek = mem_seek;
661  rwops->read = mem_read;
662  rwops->write = mem_write;
663  rwops->close = mem_close;
664  rwops->hidden.mem.base = (Uint8 *) mem;
665  rwops->hidden.mem.here = rwops->hidden.mem.base;
666  rwops->hidden.mem.stop = rwops->hidden.mem.base + size;
667  rwops->type = SDL_RWOPS_MEMORY;
668  }
669  return rwops;
670 }
static size_t mem_write(SDL_RWops *context, const void *ptr, size_t size, size_t num)
Definition: SDL_rwops.c:499
#define SDL_RWOPS_MEMORY
Definition: SDL_rwops.h:46

References SDL_RWops::close, SDL_RWops::hidden, SDL_RWops::mem, mem_close(), mem_read(), mem_seek(), mem_size(), mem_write(), NULL, SDL_RWops::read, SDL_AllocRW(), SDL_InvalidParamError, SDL_RWOPS_MEMORY, SDL_RWops::seek, SDL_RWops::size, SDL_RWops::type, and SDL_RWops::write.

◆ SDL_RWread()

size_t 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.

Definition at line 798 of file SDL_rwops.c.

799 {
800  return context->read(context, ptr, size, maxnum);
801 }
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF ptr

References context, and ptr.

Referenced by SDL_LoadFile_RW(), SDL_ReadBE16(), SDL_ReadBE32(), SDL_ReadBE64(), SDL_ReadLE16(), SDL_ReadLE32(), SDL_ReadLE64(), and SDL_ReadU8().

◆ SDL_RWseek()

Sint64 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.

Definition at line 786 of file SDL_rwops.c.

787 {
788  return context->seek(context, offset, whence);
789 }
GLintptr offset

References context.

◆ SDL_RWsize()

Sint64 SDL_RWsize ( SDL_RWops context)

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

Definition at line 780 of file SDL_rwops.c.

781 {
782  return context->size(context);
783 }

References context.

Referenced by SDL_LoadFile_RW().

◆ SDL_RWtell()

Sint64 SDL_RWtell ( SDL_RWops context)

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

Definition at line 792 of file SDL_rwops.c.

793 {
794  return context->seek(context, 0, RW_SEEK_CUR);
795 }
#define RW_SEEK_CUR
Definition: SDL_rwops.h:167

References context, and RW_SEEK_CUR.

◆ SDL_RWwrite()

size_t 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.

Definition at line 804 of file SDL_rwops.c.

805 {
806  return context->write(context, ptr, size, num);
807 }
GLuint num

References context, and ptr.

Referenced by SDL_WriteBE16(), SDL_WriteBE32(), SDL_WriteBE64(), SDL_WriteLE16(), SDL_WriteLE32(), SDL_WriteLE64(), and SDL_WriteU8().

◆ SDL_WriteBE16()

size_t SDL_WriteBE16 ( SDL_RWops dst,
Uint16  value 
)

Definition at line 894 of file SDL_rwops.c.

895 {
896  const Uint16 swapped = SDL_SwapBE16(value);
897  return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
898 }
GLenum GLenum dst
size_t SDL_RWwrite(SDL_RWops *context, const void *ptr, size_t size, size_t num)
Definition: SDL_rwops.c:804

References SDL_RWwrite(), and SDL_SwapBE16.

◆ SDL_WriteBE32()

size_t SDL_WriteBE32 ( SDL_RWops dst,
Uint32  value 
)

Definition at line 908 of file SDL_rwops.c.

909 {
910  const Uint32 swapped = SDL_SwapBE32(value);
911  return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
912 }

References SDL_RWwrite(), and SDL_SwapBE32.

◆ SDL_WriteBE64()

size_t SDL_WriteBE64 ( SDL_RWops dst,
Uint64  value 
)

Definition at line 922 of file SDL_rwops.c.

923 {
924  const Uint64 swapped = SDL_SwapBE64(value);
925  return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
926 }

References SDL_RWwrite(), and SDL_SwapBE64.

◆ SDL_WriteLE16()

size_t SDL_WriteLE16 ( SDL_RWops dst,
Uint16  value 
)

Definition at line 887 of file SDL_rwops.c.

888 {
889  const Uint16 swapped = SDL_SwapLE16(value);
890  return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
891 }

References SDL_RWwrite(), and SDL_SwapLE16.

◆ SDL_WriteLE32()

size_t SDL_WriteLE32 ( SDL_RWops dst,
Uint32  value 
)

Definition at line 901 of file SDL_rwops.c.

902 {
903  const Uint32 swapped = SDL_SwapLE32(value);
904  return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
905 }

References SDL_RWwrite(), and SDL_SwapLE32.

◆ SDL_WriteLE64()

size_t SDL_WriteLE64 ( SDL_RWops dst,
Uint64  value 
)

Definition at line 915 of file SDL_rwops.c.

916 {
917  const Uint64 swapped = SDL_SwapLE64(value);
918  return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
919 }

References SDL_RWwrite(), and SDL_SwapLE64.

◆ SDL_WriteU8()

size_t SDL_WriteU8 ( SDL_RWops dst,
Uint8  value 
)

Definition at line 881 of file SDL_rwops.c.

882 {
883  return SDL_RWwrite(dst, &value, sizeof (value), 1);
884 }

References SDL_RWwrite().