SDL  2.0
SDL_rwops.c File Reference
#include "../SDL_internal.h"
#include "SDL_endian.h"
#include "SDL_rwops.h"
+ Include dependency graph for SDL_rwops.c:

Go to the source code of this file.

Macros

#define _LARGEFILE64_SOURCE
 

Functions

static Sint64 mem_size (SDL_RWops *context)
 
static Sint64 mem_seek (SDL_RWops *context, Sint64 offset, int whence)
 
static size_t mem_read (SDL_RWops *context, void *ptr, size_t size, size_t maxnum)
 
static size_t mem_write (SDL_RWops *context, const void *ptr, size_t size, size_t num)
 
static size_t mem_writeconst (SDL_RWops *context, const void *ptr, size_t size, size_t num)
 
static int mem_close (SDL_RWops *context)
 
SDL_RWopsSDL_RWFromFile (const char *file, const char *mode)
 
SDL_RWopsSDL_RWFromFP (void *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)
 
voidSDL_LoadFile_RW (SDL_RWops *src, size_t *datasize, int freesrc)
 
voidSDL_LoadFile (const char *file, size_t *datasize)
 
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)
 
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)
 
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)
 

Macro Definition Documentation

◆ _LARGEFILE64_SOURCE

#define _LARGEFILE64_SOURCE

Definition at line 26 of file SDL_rwops.c.

Function Documentation

◆ mem_close()

static int mem_close ( SDL_RWops context)
static

Definition at line 499 of file SDL_rwops.c.

500 {
501  if (context) {
503  }
504  return 0;
505 }

References context, and SDL_FreeRW().

Referenced by SDL_RWFromConstMem(), and SDL_RWFromMem().

◆ mem_read()

static size_t mem_read ( SDL_RWops context,
void ptr,
size_t  size,
size_t  maxnum 
)
static

Definition at line 458 of file SDL_rwops.c.

459 {
460  size_t total_bytes;
461  size_t mem_available;
462 
463  total_bytes = (maxnum * size);
464  if ((maxnum <= 0) || (size <= 0)
465  || ((total_bytes / maxnum) != (size_t) size)) {
466  return 0;
467  }
468 
469  mem_available = (context->hidden.mem.stop - context->hidden.mem.here);
470  if (total_bytes > mem_available) {
471  total_bytes = mem_available;
472  }
473 
474  SDL_memcpy(ptr, context->hidden.mem.here, total_bytes);
475  context->hidden.mem.here += total_bytes;
476 
477  return (total_bytes / size);
478 }

References context, and SDL_memcpy.

Referenced by SDL_RWFromConstMem(), and SDL_RWFromMem().

◆ mem_seek()

static Sint64 mem_seek ( SDL_RWops context,
Sint64  offset,
int  whence 
)
static

Definition at line 430 of file SDL_rwops.c.

431 {
432  Uint8 *newpos;
433 
434  switch (whence) {
435  case RW_SEEK_SET:
436  newpos = context->hidden.mem.base + offset;
437  break;
438  case RW_SEEK_CUR:
439  newpos = context->hidden.mem.here + offset;
440  break;
441  case RW_SEEK_END:
442  newpos = context->hidden.mem.stop + offset;
443  break;
444  default:
445  return SDL_SetError("Unknown value for 'whence'");
446  }
447  if (newpos < context->hidden.mem.base) {
448  newpos = context->hidden.mem.base;
449  }
450  if (newpos > context->hidden.mem.stop) {
451  newpos = context->hidden.mem.stop;
452  }
453  context->hidden.mem.here = newpos;
454  return (Sint64)(context->hidden.mem.here - context->hidden.mem.base);
455 }

References context, RW_SEEK_CUR, RW_SEEK_END, RW_SEEK_SET, and SDL_SetError.

Referenced by SDL_RWFromConstMem(), and SDL_RWFromMem().

◆ mem_size()

static Sint64 mem_size ( SDL_RWops context)
static

Definition at line 424 of file SDL_rwops.c.

425 {
426  return (Sint64)(context->hidden.mem.stop - context->hidden.mem.base);
427 }

References context.

Referenced by SDL_RWFromConstMem(), and SDL_RWFromMem().

◆ mem_write()

static size_t mem_write ( SDL_RWops context,
const void ptr,
size_t  size,
size_t  num 
)
static

Definition at line 481 of file SDL_rwops.c.

482 {
483  if ((context->hidden.mem.here + (num * size)) > context->hidden.mem.stop) {
484  num = (context->hidden.mem.stop - context->hidden.mem.here) / size;
485  }
486  SDL_memcpy(context->hidden.mem.here, ptr, num * size);
487  context->hidden.mem.here += num * size;
488  return num;
489 }

References context, and SDL_memcpy.

Referenced by SDL_RWFromMem().

◆ mem_writeconst()

static size_t mem_writeconst ( SDL_RWops context,
const void ptr,
size_t  size,
size_t  num 
)
static

Definition at line 492 of file SDL_rwops.c.

493 {
494  SDL_SetError("Can't write to read-only memory");
495  return 0;
496 }

References SDL_SetError.

Referenced by SDL_RWFromConstMem().

◆ SDL_AllocRW()

SDL_RWops* SDL_AllocRW ( void  )

Definition at line 683 of file SDL_rwops.c.

684 {
685  SDL_RWops *area;
686 
687  area = (SDL_RWops *) SDL_malloc(sizeof *area);
688  if (area == NULL) {
689  SDL_OutOfMemory();
690  } else {
691  area->type = SDL_RWOPS_UNKNOWN;
692  }
693  return area;
694 }

References NULL, SDL_malloc, SDL_OutOfMemory, SDL_RWOPS_UNKNOWN, and SDL_RWops::type.

Referenced by SDL_RWFromConstMem(), SDL_RWFromFile(), and SDL_RWFromMem().

◆ SDL_FreeRW()

void SDL_FreeRW ( SDL_RWops area)

Definition at line 697 of file SDL_rwops.c.

698 {
699  SDL_free(area);
700 }

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 756 of file SDL_rwops.c.

757 {
758  return SDL_LoadFile_RW(SDL_RWFromFile(file, "rb"), datasize, 1);
759 }

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 704 of file SDL_rwops.c.

705 {
706  const int FILE_CHUNK_SIZE = 1024;
707  Sint64 size;
708  size_t size_read, size_total;
709  void *data = NULL, *newdata;
710 
711  if (!src) {
712  SDL_InvalidParamError("src");
713  return NULL;
714  }
715 
716  size = SDL_RWsize(src);
717  if (size < 0) {
718  size = FILE_CHUNK_SIZE;
719  }
720  data = SDL_malloc((size_t)(size + 1));
721 
722  size_total = 0;
723  for (;;) {
724  if ((((Sint64)size_total) + FILE_CHUNK_SIZE) > size) {
725  size = (size_total + FILE_CHUNK_SIZE);
726  newdata = SDL_realloc(data, (size_t)(size + 1));
727  if (!newdata) {
728  SDL_free(data);
729  data = NULL;
730  SDL_OutOfMemory();
731  goto done;
732  }
733  data = newdata;
734  }
735 
736  size_read = SDL_RWread(src, (char *)data+size_total, 1, (size_t)(size-size_total));
737  if (size_read == 0) {
738  break;
739  }
740  size_total += size_read;
741  }
742 
743  if (datasize) {
744  *datasize = size_total;
745  }
746  ((char *)data)[size_total] = '\0';
747 
748 done:
749  if (freesrc && src) {
750  SDL_RWclose(src);
751  }
752  return data;
753 }

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 818 of file SDL_rwops.c.

819 {
820  Uint16 value = 0;
821 
822  SDL_RWread(src, &value, sizeof (value), 1);
823  return SDL_SwapBE16(value);
824 }

References SDL_RWread(), and SDL_SwapBE16.

◆ SDL_ReadBE32()

Uint32 SDL_ReadBE32 ( SDL_RWops src)

Definition at line 836 of file SDL_rwops.c.

837 {
838  Uint32 value = 0;
839 
840  SDL_RWread(src, &value, sizeof (value), 1);
841  return SDL_SwapBE32(value);
842 }

References SDL_RWread(), and SDL_SwapBE32.

◆ SDL_ReadBE64()

Uint64 SDL_ReadBE64 ( SDL_RWops src)

Definition at line 854 of file SDL_rwops.c.

855 {
856  Uint64 value = 0;
857 
858  SDL_RWread(src, &value, sizeof (value), 1);
859  return SDL_SwapBE64(value);
860 }

References SDL_RWread(), and SDL_SwapBE64.

◆ SDL_ReadLE16()

Uint16 SDL_ReadLE16 ( SDL_RWops src)

Definition at line 809 of file SDL_rwops.c.

810 {
811  Uint16 value = 0;
812 
813  SDL_RWread(src, &value, sizeof (value), 1);
814  return SDL_SwapLE16(value);
815 }

References SDL_RWread(), and SDL_SwapLE16.

◆ SDL_ReadLE32()

Uint32 SDL_ReadLE32 ( SDL_RWops src)

Definition at line 827 of file SDL_rwops.c.

828 {
829  Uint32 value = 0;
830 
831  SDL_RWread(src, &value, sizeof (value), 1);
832  return SDL_SwapLE32(value);
833 }

References SDL_RWread(), and SDL_SwapLE32.

◆ SDL_ReadLE64()

Uint64 SDL_ReadLE64 ( SDL_RWops src)

Definition at line 845 of file SDL_rwops.c.

846 {
847  Uint64 value = 0;
848 
849  SDL_RWread(src, &value, sizeof (value), 1);
850  return SDL_SwapLE64(value);
851 }

References SDL_RWread(), and SDL_SwapLE64.

◆ SDL_ReadU8()

Uint8 SDL_ReadU8 ( SDL_RWops src)

Definition at line 800 of file SDL_rwops.c.

801 {
802  Uint8 value = 0;
803 
804  SDL_RWread(src, &value, sizeof (value), 1);
805  return value;
806 }

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 792 of file SDL_rwops.c.

793 {
794  return context->close(context);
795 }

References context.

Referenced by SDL_LoadFile_RW().

◆ SDL_RWFromConstMem()

SDL_RWops* SDL_RWFromConstMem ( const void mem,
int  size 
)

Definition at line 655 of file SDL_rwops.c.

656 {
657  SDL_RWops *rwops = NULL;
658  if (!mem) {
659  SDL_InvalidParamError("mem");
660  return rwops;
661  }
662  if (!size) {
663  SDL_InvalidParamError("size");
664  return rwops;
665  }
666 
667  rwops = SDL_AllocRW();
668  if (rwops != NULL) {
669  rwops->size = mem_size;
670  rwops->seek = mem_seek;
671  rwops->read = mem_read;
672  rwops->write = mem_writeconst;
673  rwops->close = mem_close;
674  rwops->hidden.mem.base = (Uint8 *) mem;
675  rwops->hidden.mem.here = rwops->hidden.mem.base;
676  rwops->hidden.mem.stop = rwops->hidden.mem.base + size;
677  rwops->type = SDL_RWOPS_MEMORY_RO;
678  }
679  return rwops;
680 }

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 511 of file SDL_rwops.c.

512 {
513  SDL_RWops *rwops = NULL;
514  if (!file || !*file || !mode || !*mode) {
515  SDL_SetError("SDL_RWFromFile(): No file or no mode specified");
516  return NULL;
517  }
518 #if defined(__ANDROID__)
519 #ifdef HAVE_STDIO_H
520  /* Try to open the file on the filesystem first */
521  if (*file == '/') {
522  FILE *fp = fopen(file, mode);
523  if (fp) {
524  return SDL_RWFromFP(fp, 1);
525  }
526  } else {
527  /* Try opening it from internal storage if it's a relative path */
528  char *path;
529  FILE *fp;
530 
531  /* !!! FIXME: why not just "char path[PATH_MAX];" ? */
532  path = SDL_stack_alloc(char, PATH_MAX);
533  if (path) {
534  SDL_snprintf(path, PATH_MAX, "%s/%s",
536  fp = fopen(path, mode);
538  if (fp) {
539  return SDL_RWFromFP(fp, 1);
540  }
541  }
542  }
543 #endif /* HAVE_STDIO_H */
544 
545  /* Try to open the file from the asset system */
546  rwops = SDL_AllocRW();
547  if (!rwops)
548  return NULL; /* SDL_SetError already setup by SDL_AllocRW() */
549  if (Android_JNI_FileOpen(rwops, file, mode) < 0) {
550  SDL_FreeRW(rwops);
551  return NULL;
552  }
553  rwops->size = Android_JNI_FileSize;
554  rwops->seek = Android_JNI_FileSeek;
555  rwops->read = Android_JNI_FileRead;
556  rwops->write = Android_JNI_FileWrite;
557  rwops->close = Android_JNI_FileClose;
558  rwops->type = SDL_RWOPS_JNIFILE;
559 
560 #elif defined(__WIN32__)
561  rwops = SDL_AllocRW();
562  if (!rwops)
563  return NULL; /* SDL_SetError already setup by SDL_AllocRW() */
564  if (windows_file_open(rwops, file, mode) < 0) {
565  SDL_FreeRW(rwops);
566  return NULL;
567  }
568  rwops->size = windows_file_size;
569  rwops->seek = windows_file_seek;
570  rwops->read = windows_file_read;
571  rwops->write = windows_file_write;
572  rwops->close = windows_file_close;
573  rwops->type = SDL_RWOPS_WINFILE;
574 
575 #elif HAVE_STDIO_H
576  {
577  #ifdef __APPLE__
578  FILE *fp = SDL_OpenFPFromBundleOrFallback(file, mode);
579  #elif __WINRT__
580  FILE *fp = NULL;
581  fopen_s(&fp, file, mode);
582  #else
583  FILE *fp = fopen(file, mode);
584  #endif
585  if (fp == NULL) {
586  SDL_SetError("Couldn't open %s", file);
587  } else {
588  rwops = SDL_RWFromFP(fp, 1);
589  }
590  }
591 #else
592  SDL_SetError("SDL not compiled with stdio support");
593 #endif /* !HAVE_STDIO_H */
594 
595  return rwops;
596 }

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_RWops::seek, SDL_RWops::size, SDL_RWops::type, and SDL_RWops::write.

Referenced by SDL_LoadFile().

◆ SDL_RWFromFP()

SDL_RWops* SDL_RWFromFP ( void fp,
SDL_bool  autoclose 
)

Definition at line 619 of file SDL_rwops.c.

620 {
621  SDL_SetError("SDL not compiled with stdio support");
622  return NULL;
623 }

References NULL, and SDL_SetError.

Referenced by SDL_RWFromFile().

◆ SDL_RWFromMem()

SDL_RWops* SDL_RWFromMem ( void mem,
int  size 
)

Definition at line 627 of file SDL_rwops.c.

628 {
629  SDL_RWops *rwops = NULL;
630  if (!mem) {
631  SDL_InvalidParamError("mem");
632  return rwops;
633  }
634  if (!size) {
635  SDL_InvalidParamError("size");
636  return rwops;
637  }
638 
639  rwops = SDL_AllocRW();
640  if (rwops != NULL) {
641  rwops->size = mem_size;
642  rwops->seek = mem_seek;
643  rwops->read = mem_read;
644  rwops->write = mem_write;
645  rwops->close = mem_close;
646  rwops->hidden.mem.base = (Uint8 *) mem;
647  rwops->hidden.mem.here = rwops->hidden.mem.base;
648  rwops->hidden.mem.stop = rwops->hidden.mem.base + size;
649  rwops->type = SDL_RWOPS_MEMORY;
650  }
651  return rwops;
652 }

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 780 of file SDL_rwops.c.

781 {
782  return context->read(context, ptr, size, maxnum);
783 }

References context.

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 768 of file SDL_rwops.c.

769 {
770  return context->seek(context, offset, whence);
771 }

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 762 of file SDL_rwops.c.

763 {
764  return context->size(context);
765 }

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 774 of file SDL_rwops.c.

775 {
776  return context->seek(context, 0, RW_SEEK_CUR);
777 }

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 786 of file SDL_rwops.c.

787 {
788  return context->write(context, ptr, size, num);
789 }

References context.

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 876 of file SDL_rwops.c.

877 {
878  const Uint16 swapped = SDL_SwapBE16(value);
879  return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
880 }

References SDL_RWwrite(), and SDL_SwapBE16.

◆ SDL_WriteBE32()

size_t SDL_WriteBE32 ( SDL_RWops dst,
Uint32  value 
)

Definition at line 890 of file SDL_rwops.c.

891 {
892  const Uint32 swapped = SDL_SwapBE32(value);
893  return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
894 }

References SDL_RWwrite(), and SDL_SwapBE32.

◆ SDL_WriteBE64()

size_t SDL_WriteBE64 ( SDL_RWops dst,
Uint64  value 
)

Definition at line 904 of file SDL_rwops.c.

905 {
906  const Uint64 swapped = SDL_SwapBE64(value);
907  return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
908 }

References SDL_RWwrite(), and SDL_SwapBE64.

◆ SDL_WriteLE16()

size_t SDL_WriteLE16 ( SDL_RWops dst,
Uint16  value 
)

Definition at line 869 of file SDL_rwops.c.

870 {
871  const Uint16 swapped = SDL_SwapLE16(value);
872  return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
873 }

References SDL_RWwrite(), and SDL_SwapLE16.

◆ SDL_WriteLE32()

size_t SDL_WriteLE32 ( SDL_RWops dst,
Uint32  value 
)

Definition at line 883 of file SDL_rwops.c.

884 {
885  const Uint32 swapped = SDL_SwapLE32(value);
886  return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
887 }

References SDL_RWwrite(), and SDL_SwapLE32.

◆ SDL_WriteLE64()

size_t SDL_WriteLE64 ( SDL_RWops dst,
Uint64  value 
)

Definition at line 897 of file SDL_rwops.c.

898 {
899  const Uint64 swapped = SDL_SwapLE64(value);
900  return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
901 }

References SDL_RWwrite(), and SDL_SwapLE64.

◆ SDL_WriteU8()

size_t SDL_WriteU8 ( SDL_RWops dst,
Uint8  value 
)

Definition at line 863 of file SDL_rwops.c.

864 {
865  return SDL_RWwrite(dst, &value, sizeof (value), 1);
866 }

References SDL_RWwrite().

SDL_FreeRW
void SDL_FreeRW(SDL_RWops *area)
Definition: SDL_rwops.c:697
SDL_RWOPS_JNIFILE
#define SDL_RWOPS_JNIFILE
Definition: SDL_rwops.h:45
offset
GLintptr offset
Definition: SDL_opengl_glext.h:538
SDL_RWclose
int SDL_RWclose(SDL_RWops *context)
Definition: SDL_rwops.c:792
NULL
#define NULL
Definition: begin_code.h:167
SDL_SwapBE16
#define SDL_SwapBE16(X)
Definition: SDL_endian.h:236
mode
GLenum mode
Definition: SDL_opengl_glext.h:1122
SDL_RWOPS_WINFILE
#define SDL_RWOPS_WINFILE
Definition: SDL_rwops.h:43
Android_JNI_FileSeek
Sint64 Android_JNI_FileSeek(SDL_RWops *ctx, Sint64 offset, int whence)
RW_SEEK_END
#define RW_SEEK_END
Definition: SDL_rwops.h:176
SDL_realloc
#define SDL_realloc
Definition: SDL_dynapi_overrides.h:376
SDL_InvalidParamError
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
mem_writeconst
static size_t mem_writeconst(SDL_RWops *context, const void *ptr, size_t size, size_t num)
Definition: SDL_rwops.c:492
num
GLuint num
Definition: SDL_opengl_glext.h:4956
path
GLsizei const GLchar *const * path
Definition: SDL_opengl_glext.h:3730
mem_size
static Sint64 mem_size(SDL_RWops *context)
Definition: SDL_rwops.c:424
SDL_RWOPS_UNKNOWN
#define SDL_RWOPS_UNKNOWN
Definition: SDL_rwops.h:42
SDL_SwapLE16
#define SDL_SwapLE16(X)
Definition: SDL_endian.h:232
SDL_AllocRW
SDL_RWops * SDL_AllocRW(void)
Definition: SDL_rwops.c:683
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1973
SDL_stack_alloc
#define SDL_stack_alloc(type, count)
Definition: SDL_stdinc.h:354
SDL_LoadFile_RW
void * SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, int freesrc)
Definition: SDL_rwops.c:704
dst
GLenum GLenum dst
Definition: SDL_opengl_glext.h:1737
SDL_RWsize
Sint64 SDL_RWsize(SDL_RWops *context)
Definition: SDL_rwops.c:762
SDL_RWops::seek
Sint64(* seek)(struct SDL_RWops *context, Sint64 offset, int whence)
Definition: SDL_rwops.h:65
SDL_memcpy
#define SDL_memcpy
Definition: SDL_dynapi_overrides.h:387
Uint8
uint8_t Uint8
Definition: SDL_stdinc.h:179
SDL_RWFromFile
SDL_RWops * SDL_RWFromFile(const char *file, const char *mode)
Definition: SDL_rwops.c:511
done
int done
Definition: checkkeys.c:28
context
static screen_context_t context
Definition: video.c:25
mem_write
static size_t mem_write(SDL_RWops *context, const void *ptr, size_t size, size_t num)
Definition: SDL_rwops.c:481
SDL_RWFromFP
SDL_RWops * SDL_RWFromFP(void *fp, SDL_bool autoclose)
Definition: SDL_rwops.c:619
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
SDL_RWops::type
Uint32 type
Definition: SDL_rwops.h:93
Android_JNI_FileRead
size_t Android_JNI_FileRead(SDL_RWops *ctx, void *buffer, size_t size, size_t maxnum)
mem_close
static int mem_close(SDL_RWops *context)
Definition: SDL_rwops.c:499
Android_JNI_FileSize
Sint64 Android_JNI_FileSize(SDL_RWops *ctx)
Android_JNI_FileOpen
int Android_JNI_FileOpen(SDL_RWops *ctx, const char *fileName, const char *mode)
mem_seek
static Sint64 mem_seek(SDL_RWops *context, Sint64 offset, int whence)
Definition: SDL_rwops.c:430
Android_JNI_FileClose
int Android_JNI_FileClose(SDL_RWops *ctx)
SDL_RWops::hidden
union SDL_RWops::@9 hidden
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
size
GLsizeiptr size
Definition: SDL_opengl_glext.h:537
SDL_RWOPS_MEMORY
#define SDL_RWOPS_MEMORY
Definition: SDL_rwops.h:46
SDL_RWOPS_MEMORY_RO
#define SDL_RWOPS_MEMORY_RO
Definition: SDL_rwops.h:47
SDL_RWwrite
size_t SDL_RWwrite(SDL_RWops *context, const void *ptr, size_t size, size_t num)
Definition: SDL_rwops.c:786
SDL_RWops::close
int(* close)(struct SDL_RWops *context)
Definition: SDL_rwops.h:91
src
GLenum src
Definition: SDL_opengl_glext.h:1737
SDL_SwapBE64
#define SDL_SwapBE64(X)
Definition: SDL_endian.h:238
SDL_stack_free
#define SDL_stack_free(data)
Definition: SDL_stdinc.h:355
SDL_RWops::mem
struct SDL_RWops::@9::@12 mem
RW_SEEK_SET
#define RW_SEEK_SET
Definition: SDL_rwops.h:174
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:698
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
SDL_snprintf
#define SDL_snprintf
Definition: SDL_dynapi_overrides.h:40
Uint64
uint64_t Uint64
Definition: SDL_stdinc.h:216
SDL_RWread
size_t SDL_RWread(SDL_RWops *context, void *ptr, size_t size, size_t maxnum)
Definition: SDL_rwops.c:780
Android_JNI_FileWrite
size_t Android_JNI_FileWrite(SDL_RWops *ctx, const void *buffer, size_t size, size_t num)
RW_SEEK_CUR
#define RW_SEEK_CUR
Definition: SDL_rwops.h:175
Uint32
uint32_t Uint32
Definition: SDL_stdinc.h:203
SDL_RWops::size
Sint64(* size)(struct SDL_RWops *context)
Definition: SDL_rwops.h:57
SDL_RWops::read
size_t(* read)(struct SDL_RWops *context, void *ptr, size_t size, size_t maxnum)
Definition: SDL_rwops.h:74
SDL_SwapBE32
#define SDL_SwapBE32(X)
Definition: SDL_endian.h:237
SDL_malloc
#define SDL_malloc
Definition: SDL_dynapi_overrides.h:374
SDL_RWops
Definition: SDL_rwops.h:52
size_t
unsigned int size_t
Definition: SDL_config_windows.h:68
SDL_SwapLE64
#define SDL_SwapLE64(X)
Definition: SDL_endian.h:234
SDL_SwapLE32
#define SDL_SwapLE32(X)
Definition: SDL_endian.h:233
Sint64
int64_t Sint64
Definition: SDL_stdinc.h:210
SDL_RWops::write
size_t(* write)(struct SDL_RWops *context, const void *ptr, size_t size, size_t num)
Definition: SDL_rwops.h:83
mem_read
static size_t mem_read(SDL_RWops *context, void *ptr, size_t size, size_t maxnum)
Definition: SDL_rwops.c:458
SDL_AndroidGetInternalStoragePath
#define SDL_AndroidGetInternalStoragePath
Definition: SDL_dynapi_overrides.h:51
Uint16
uint16_t Uint16
Definition: SDL_stdinc.h:191