SDL 3.0
SDL_iostream.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22/* WIKI CATEGORY: IOStream */
23
24/**
25 * # CategoryIOStream
26 *
27 * SDL provides an abstract interface for reading and writing data streams. It
28 * offers implementations for files, memory, etc, and the app can provideo
29 * their own implementations, too.
30 *
31 * SDL_IOStream is not related to the standard C++ iostream class, other than
32 * both are abstract interfaces to read/write data.
33 */
34
35#ifndef SDL_iostream_h_
36#define SDL_iostream_h_
37
38#include <SDL3/SDL_stdinc.h>
39#include <SDL3/SDL_error.h>
40#include <SDL3/SDL_properties.h>
41
42#include <SDL3/SDL_begin_code.h>
43/* Set up for C function definitions, even when using C++ */
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48/**
49 * SDL_IOStream status, set by a read or write operation.
50 *
51 * \since This enum is available since SDL 3.0.0.
52 */
53typedef enum SDL_IOStatus
54{
55 SDL_IO_STATUS_READY, /**< Everything is ready (no errors and not EOF). */
56 SDL_IO_STATUS_ERROR, /**< Read or write I/O error */
57 SDL_IO_STATUS_EOF, /**< End of file */
58 SDL_IO_STATUS_NOT_READY, /**< Non blocking I/O, not ready */
59 SDL_IO_STATUS_READONLY, /**< Tried to write a read-only buffer */
60 SDL_IO_STATUS_WRITEONLY /**< Tried to read a write-only buffer */
62
63/**
64 * Possible `whence` values for SDL_IOStream seeking.
65 *
66 * These map to the same "whence" concept that `fseek` or `lseek` use in the
67 * standard C runtime.
68 *
69 * \since This enum is available since SDL 3.0.0.
70 */
71typedef enum SDL_IOWhence
72{
73 SDL_IO_SEEK_SET, /**< Seek from the beginning of data */
74 SDL_IO_SEEK_CUR, /**< Seek relative to current read point */
75 SDL_IO_SEEK_END /**< Seek relative to the end of data */
77
78/**
79 * The function pointers that drive an SDL_IOStream.
80 *
81 * Applications can provide this struct to SDL_OpenIO() to create their own
82 * implementation of SDL_IOStream. This is not necessarily required, as SDL
83 * already offers several common types of I/O streams, via functions like
84 * SDL_IOFromFile() and SDL_IOFromMem().
85 *
86 * This structure should be initialized using SDL_INIT_INTERFACE()
87 *
88 * \since This struct is available since SDL 3.0.0.
89 *
90 * \sa SDL_INIT_INTERFACE
91 */
93{
94 /* The version of this interface */
96
97 /**
98 * Return the number of bytes in this SDL_IOStream
99 *
100 * \return the total size of the data stream, or -1 on error.
101 */
102 Sint64 (SDLCALL *size)(void *userdata);
103
104 /**
105 * Seek to `offset` relative to `whence`, one of stdio's whence values:
106 * SDL_IO_SEEK_SET, SDL_IO_SEEK_CUR, SDL_IO_SEEK_END
107 *
108 * \return the final offset in the data stream, or -1 on error.
109 */
110 Sint64 (SDLCALL *seek)(void *userdata, Sint64 offset, SDL_IOWhence whence);
111
112 /**
113 * Read up to `size` bytes from the data stream to the area pointed
114 * at by `ptr`.
115 *
116 * On an incomplete read, you should set `*status` to a value from the
117 * SDL_IOStatus enum. You do not have to explicitly set this on
118 * a complete, successful read.
119 *
120 * \return the number of bytes read
121 */
122 size_t (SDLCALL *read)(void *userdata, void *ptr, size_t size, SDL_IOStatus *status);
123
124 /**
125 * Write exactly `size` bytes from the area pointed at by `ptr`
126 * to data stream.
127 *
128 * On an incomplete write, you should set `*status` to a value from the
129 * SDL_IOStatus enum. You do not have to explicitly set this on
130 * a complete, successful write.
131 *
132 * \return the number of bytes written
133 */
134 size_t (SDLCALL *write)(void *userdata, const void *ptr, size_t size, SDL_IOStatus *status);
135
136 /**
137 * If the stream is buffering, make sure the data is written out.
138 *
139 * On failure, you should set `*status` to a value from the
140 * SDL_IOStatus enum. You do not have to explicitly set this on
141 * a successful flush.
142 *
143 * \return true if successful or false on write error when flushing data.
144 */
145 bool (SDLCALL *flush)(void *userdata, SDL_IOStatus *status);
146
147 /**
148 * Close and free any allocated resources.
149 *
150 * This does not guarantee file writes will sync to physical media; they
151 * can be in the system's file cache, waiting to go to disk.
152 *
153 * The SDL_IOStream is still destroyed even if this fails, so clean up anything
154 * even if flushing buffers, etc, returns an error.
155 *
156 * \return true if successful or false on write error when flushing data.
157 */
158 bool (SDLCALL *close)(void *userdata);
159
161
162/* Check the size of SDL_IOStreamInterface
163 *
164 * If this assert fails, either the compiler is padding to an unexpected size,
165 * or the interface has been updated and this should be updated to match and
166 * the code using this interface should be updated to handle the old version.
167 */
168SDL_COMPILE_TIME_ASSERT(SDL_IOStreamInterface_SIZE,
169 (sizeof(void *) == 4 && sizeof(SDL_IOStreamInterface) == 28) ||
170 (sizeof(void *) == 8 && sizeof(SDL_IOStreamInterface) == 56));
171
172/**
173 * The read/write operation structure.
174 *
175 * This operates as an opaque handle. There are several APIs to create various
176 * types of I/O streams, or an app can supply an SDL_IOStreamInterface to
177 * SDL_OpenIO() to provide their own stream implementation behind this
178 * struct's abstract interface.
179 *
180 * \since This struct is available since SDL 3.0.0.
181 */
183
184
185/**
186 * \name IOFrom functions
187 *
188 * Functions to create SDL_IOStream structures from various data streams.
189 */
190/* @{ */
191
192/**
193 * Use this function to create a new SDL_IOStream structure for reading from
194 * and/or writing to a named file.
195 *
196 * The `mode` string is treated roughly the same as in a call to the C
197 * library's fopen(), even if SDL doesn't happen to use fopen() behind the
198 * scenes.
199 *
200 * Available `mode` strings:
201 *
202 * - "r": Open a file for reading. The file must exist.
203 * - "w": Create an empty file for writing. If a file with the same name
204 * already exists its content is erased and the file is treated as a new
205 * empty file.
206 * - "a": Append to a file. Writing operations append data at the end of the
207 * file. The file is created if it does not exist.
208 * - "r+": Open a file for update both reading and writing. The file must
209 * exist.
210 * - "w+": Create an empty file for both reading and writing. If a file with
211 * the same name already exists its content is erased and the file is
212 * treated as a new empty file.
213 * - "a+": Open a file for reading and appending. All writing operations are
214 * performed at the end of the file, protecting the previous content to be
215 * overwritten. You can reposition (fseek, rewind) the internal pointer to
216 * anywhere in the file for reading, but writing operations will move it
217 * back to the end of file. The file is created if it does not exist.
218 *
219 * **NOTE**: In order to open a file as a binary file, a "b" character has to
220 * be included in the `mode` string. This additional "b" character can either
221 * be appended at the end of the string (thus making the following compound
222 * modes: "rb", "wb", "ab", "r+b", "w+b", "a+b") or be inserted between the
223 * letter and the "+" sign for the mixed modes ("rb+", "wb+", "ab+").
224 * Additional characters may follow the sequence, although they should have no
225 * effect. For example, "t" is sometimes appended to make explicit the file is
226 * a text file.
227 *
228 * This function supports Unicode filenames, but they must be encoded in UTF-8
229 * format, regardless of the underlying operating system.
230 *
231 * In Android, SDL_IOFromFile() can be used to open content:// URIs. As a
232 * fallback, SDL_IOFromFile() will transparently open a matching filename in
233 * the app's `assets`.
234 *
235 * Closing the SDL_IOStream will close SDL's internal file handle.
236 *
237 * The following properties may be set at creation time by SDL:
238 *
239 * - `SDL_PROP_IOSTREAM_WINDOWS_HANDLE_POINTER`: a pointer, that can be cast
240 * to a win32 `HANDLE`, that this SDL_IOStream is using to access the
241 * filesystem. If the program isn't running on Windows, or SDL used some
242 * other method to access the filesystem, this property will not be set.
243 * - `SDL_PROP_IOSTREAM_STDIO_FILE_POINTER`: a pointer, that can be cast to a
244 * stdio `FILE *`, that this SDL_IOStream is using to access the filesystem.
245 * If SDL used some other method to access the filesystem, this property
246 * will not be set. PLEASE NOTE that if SDL is using a different C runtime
247 * than your app, trying to use this pointer will almost certainly result in
248 * a crash! This is mostly a problem on Windows; make sure you build SDL and
249 * your app with the same compiler and settings to avoid it.
250 * - `SDL_PROP_IOSTREAM_FILE_DESCRIPTOR_NUMBER`: a file descriptor that this
251 * SDL_IOStream is using to access the filesystem.
252 * - `SDL_PROP_IOSTREAM_ANDROID_AASSET_POINTER`: a pointer, that can be cast
253 * to an Android NDK `AAsset *`, that this SDL_IOStream is using to access
254 * the filesystem. If SDL used some other method to access the filesystem,
255 * this property will not be set.
256 *
257 * \param file a UTF-8 string representing the filename to open.
258 * \param mode an ASCII string representing the mode to be used for opening
259 * the file.
260 * \returns a pointer to the SDL_IOStream structure that is created or NULL on
261 * failure; call SDL_GetError() for more information.
262 *
263 * \since This function is available since SDL 3.0.0.
264 *
265 * \sa SDL_CloseIO
266 * \sa SDL_FlushIO
267 * \sa SDL_ReadIO
268 * \sa SDL_SeekIO
269 * \sa SDL_TellIO
270 * \sa SDL_WriteIO
271 */
272extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromFile(const char *file, const char *mode);
273
274#define SDL_PROP_IOSTREAM_WINDOWS_HANDLE_POINTER "SDL.iostream.windows.handle"
275#define SDL_PROP_IOSTREAM_STDIO_FILE_POINTER "SDL.iostream.stdio.file"
276#define SDL_PROP_IOSTREAM_FILE_DESCRIPTOR_NUMBER "SDL.iostream.file_descriptor"
277#define SDL_PROP_IOSTREAM_ANDROID_AASSET_POINTER "SDL.iostream.android.aasset"
278
279/**
280 * Use this function to prepare a read-write memory buffer for use with
281 * SDL_IOStream.
282 *
283 * This function sets up an SDL_IOStream struct based on a memory area of a
284 * certain size, for both read and write access.
285 *
286 * This memory buffer is not copied by the SDL_IOStream; the pointer you
287 * provide must remain valid until you close the stream. Closing the stream
288 * will not free the original buffer.
289 *
290 * If you need to make sure the SDL_IOStream never writes to the memory
291 * buffer, you should use SDL_IOFromConstMem() with a read-only buffer of
292 * memory instead.
293 *
294 * The following properties will be set at creation time by SDL:
295 *
296 * - `SDL_PROP_IOSTREAM_MEMORY_POINTER`: this will be the `mem` parameter that
297 * was passed to this function.
298 * - `SDL_PROP_IOSTREAM_MEMORY_SIZE_NUMBER`: this will be the `size` parameter
299 * that was passed to this function.
300 *
301 * \param mem a pointer to a buffer to feed an SDL_IOStream stream.
302 * \param size the buffer size, in bytes.
303 * \returns a pointer to a new SDL_IOStream structure or NULL on failure; call
304 * SDL_GetError() for more information.
305 *
306 * \since This function is available since SDL 3.0.0.
307 *
308 * \sa SDL_IOFromConstMem
309 * \sa SDL_CloseIO
310 * \sa SDL_FlushIO
311 * \sa SDL_ReadIO
312 * \sa SDL_SeekIO
313 * \sa SDL_TellIO
314 * \sa SDL_WriteIO
315 */
316extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromMem(void *mem, size_t size);
317
318#define SDL_PROP_IOSTREAM_MEMORY_POINTER "SDL.iostream.memory.base"
319#define SDL_PROP_IOSTREAM_MEMORY_SIZE_NUMBER "SDL.iostream.memory.size"
320
321/**
322 * Use this function to prepare a read-only memory buffer for use with
323 * SDL_IOStream.
324 *
325 * This function sets up an SDL_IOStream struct based on a memory area of a
326 * certain size. It assumes the memory area is not writable.
327 *
328 * Attempting to write to this SDL_IOStream stream will report an error
329 * without writing to the memory buffer.
330 *
331 * This memory buffer is not copied by the SDL_IOStream; the pointer you
332 * provide must remain valid until you close the stream. Closing the stream
333 * will not free the original buffer.
334 *
335 * If you need to write to a memory buffer, you should use SDL_IOFromMem()
336 * with a writable buffer of memory instead.
337 *
338 * The following properties will be set at creation time by SDL:
339 *
340 * - `SDL_PROP_IOSTREAM_MEMORY_POINTER`: this will be the `mem` parameter that
341 * was passed to this function.
342 * - `SDL_PROP_IOSTREAM_MEMORY_SIZE_NUMBER`: this will be the `size` parameter
343 * that was passed to this function.
344 *
345 * \param mem a pointer to a read-only buffer to feed an SDL_IOStream stream.
346 * \param size the buffer size, in bytes.
347 * \returns a pointer to a new SDL_IOStream structure or NULL on failure; call
348 * SDL_GetError() for more information.
349 *
350 * \since This function is available since SDL 3.0.0.
351 *
352 * \sa SDL_IOFromMem
353 * \sa SDL_CloseIO
354 * \sa SDL_ReadIO
355 * \sa SDL_SeekIO
356 * \sa SDL_TellIO
357 */
358extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromConstMem(const void *mem, size_t size);
359
360/**
361 * Use this function to create an SDL_IOStream that is backed by dynamically
362 * allocated memory.
363 *
364 * This supports the following properties to provide access to the memory and
365 * control over allocations:
366 *
367 * - `SDL_PROP_IOSTREAM_DYNAMIC_MEMORY_POINTER`: a pointer to the internal
368 * memory of the stream. This can be set to NULL to transfer ownership of
369 * the memory to the application, which should free the memory with
370 * SDL_free(). If this is done, the next operation on the stream must be
371 * SDL_CloseIO().
372 * - `SDL_PROP_IOSTREAM_DYNAMIC_CHUNKSIZE_NUMBER`: memory will be allocated in
373 * multiples of this size, defaulting to 1024.
374 *
375 * \returns a pointer to a new SDL_IOStream structure or NULL on failure; call
376 * SDL_GetError() for more information.
377 *
378 * \since This function is available since SDL 3.0.0.
379 *
380 * \sa SDL_CloseIO
381 * \sa SDL_ReadIO
382 * \sa SDL_SeekIO
383 * \sa SDL_TellIO
384 * \sa SDL_WriteIO
385 */
386extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromDynamicMem(void);
387
388#define SDL_PROP_IOSTREAM_DYNAMIC_MEMORY_POINTER "SDL.iostream.dynamic.memory"
389#define SDL_PROP_IOSTREAM_DYNAMIC_CHUNKSIZE_NUMBER "SDL.iostream.dynamic.chunksize"
390
391/* @} *//* IOFrom functions */
392
393
394/**
395 * Create a custom SDL_IOStream.
396 *
397 * Applications do not need to use this function unless they are providing
398 * their own SDL_IOStream implementation. If you just need an SDL_IOStream to
399 * read/write a common data source, you should use the built-in
400 * implementations in SDL, like SDL_IOFromFile() or SDL_IOFromMem(), etc.
401 *
402 * This function makes a copy of `iface` and the caller does not need to keep
403 * it around after this call.
404 *
405 * \param iface the interface that implements this SDL_IOStream, initialized
406 * using SDL_INIT_INTERFACE().
407 * \param userdata the pointer that will be passed to the interface functions.
408 * \returns a pointer to the allocated memory on success or NULL on failure;
409 * call SDL_GetError() for more information.
410 *
411 * \since This function is available since SDL 3.0.0.
412 *
413 * \sa SDL_CloseIO
414 * \sa SDL_INIT_INTERFACE
415 * \sa SDL_IOFromConstMem
416 * \sa SDL_IOFromFile
417 * \sa SDL_IOFromMem
418 */
419extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_OpenIO(const SDL_IOStreamInterface *iface, void *userdata);
420
421/**
422 * Close and free an allocated SDL_IOStream structure.
423 *
424 * SDL_CloseIO() closes and cleans up the SDL_IOStream stream. It releases any
425 * resources used by the stream and frees the SDL_IOStream itself. This
426 * returns true on success, or false if the stream failed to flush to its
427 * output (e.g. to disk).
428 *
429 * Note that if this fails to flush the stream for any reason, this function
430 * reports an error, but the SDL_IOStream is still invalid once this function
431 * returns.
432 *
433 * This call flushes any buffered writes to the operating system, but there
434 * are no guarantees that those writes have gone to physical media; they might
435 * be in the OS's file cache, waiting to go to disk later. If it's absolutely
436 * crucial that writes go to disk immediately, so they are definitely stored
437 * even if the power fails before the file cache would have caught up, one
438 * should call SDL_FlushIO() before closing. Note that flushing takes time and
439 * makes the system and your app operate less efficiently, so do so sparingly.
440 *
441 * \param context SDL_IOStream structure to close.
442 * \returns true on success or false on failure; call SDL_GetError() for more
443 * information.
444 *
445 * \since This function is available since SDL 3.0.0.
446 *
447 * \sa SDL_OpenIO
448 */
449extern SDL_DECLSPEC bool SDLCALL SDL_CloseIO(SDL_IOStream *context);
450
451/**
452 * Get the properties associated with an SDL_IOStream.
453 *
454 * \param context a pointer to an SDL_IOStream structure.
455 * \returns a valid property ID on success or 0 on failure; call
456 * SDL_GetError() for more information.
457 *
458 * \since This function is available since SDL 3.0.0.
459 */
460extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetIOProperties(SDL_IOStream *context);
461
462/**
463 * Query the stream status of an SDL_IOStream.
464 *
465 * This information can be useful to decide if a short read or write was due
466 * to an error, an EOF, or a non-blocking operation that isn't yet ready to
467 * complete.
468 *
469 * An SDL_IOStream's status is only expected to change after a SDL_ReadIO or
470 * SDL_WriteIO call; don't expect it to change if you just call this query
471 * function in a tight loop.
472 *
473 * \param context the SDL_IOStream to query.
474 * \returns an SDL_IOStatus enum with the current state.
475 *
476 * \threadsafety This function should not be called at the same time that
477 * another thread is operating on the same SDL_IOStream.
478 *
479 * \since This function is available since SDL 3.0.0.
480 */
481extern SDL_DECLSPEC SDL_IOStatus SDLCALL SDL_GetIOStatus(SDL_IOStream *context);
482
483/**
484 * Use this function to get the size of the data stream in an SDL_IOStream.
485 *
486 * \param context the SDL_IOStream to get the size of the data stream from.
487 * \returns the size of the data stream in the SDL_IOStream on success or a
488 * negative error code on failure; call SDL_GetError() for more
489 * information.
490 *
491 * \since This function is available since SDL 3.0.0.
492 */
493extern SDL_DECLSPEC Sint64 SDLCALL SDL_GetIOSize(SDL_IOStream *context);
494
495/**
496 * Seek within an SDL_IOStream data stream.
497 *
498 * This function seeks to byte `offset`, relative to `whence`.
499 *
500 * `whence` may be any of the following values:
501 *
502 * - `SDL_IO_SEEK_SET`: seek from the beginning of data
503 * - `SDL_IO_SEEK_CUR`: seek relative to current read point
504 * - `SDL_IO_SEEK_END`: seek relative to the end of data
505 *
506 * If this stream can not seek, it will return -1.
507 *
508 * \param context a pointer to an SDL_IOStream structure.
509 * \param offset an offset in bytes, relative to `whence` location; can be
510 * negative.
511 * \param whence any of `SDL_IO_SEEK_SET`, `SDL_IO_SEEK_CUR`,
512 * `SDL_IO_SEEK_END`.
513 * \returns the final offset in the data stream after the seek or -1 on
514 * failure; call SDL_GetError() for more information.
515 *
516 * \since This function is available since SDL 3.0.0.
517 *
518 * \sa SDL_TellIO
519 */
520extern SDL_DECLSPEC Sint64 SDLCALL SDL_SeekIO(SDL_IOStream *context, Sint64 offset, SDL_IOWhence whence);
521
522/**
523 * Determine the current read/write offset in an SDL_IOStream data stream.
524 *
525 * SDL_TellIO is actually a wrapper function that calls the SDL_IOStream's
526 * `seek` method, with an offset of 0 bytes from `SDL_IO_SEEK_CUR`, to
527 * simplify application development.
528 *
529 * \param context an SDL_IOStream data stream object from which to get the
530 * current offset.
531 * \returns the current offset in the stream, or -1 if the information can not
532 * be determined.
533 *
534 * \since This function is available since SDL 3.0.0.
535 *
536 * \sa SDL_SeekIO
537 */
538extern SDL_DECLSPEC Sint64 SDLCALL SDL_TellIO(SDL_IOStream *context);
539
540/**
541 * Read from a data source.
542 *
543 * This function reads up `size` bytes from the data source to the area
544 * pointed at by `ptr`. This function may read less bytes than requested. It
545 * will return zero when the data stream is completely read, and
546 * SDL_GetIOStatus() will return SDL_IO_STATUS_EOF, or on error, and
547 * SDL_GetIOStatus() will return SDL_IO_STATUS_ERROR.
548 *
549 * \param context a pointer to an SDL_IOStream structure.
550 * \param ptr a pointer to a buffer to read data into.
551 * \param size the number of bytes to read from the data source.
552 * \returns the number of bytes read, or 0 on end of file or other failure;
553 * call SDL_GetError() for more information.
554 *
555 * \since This function is available since SDL 3.0.0.
556 *
557 * \sa SDL_WriteIO
558 * \sa SDL_GetIOStatus
559 */
560extern SDL_DECLSPEC size_t SDLCALL SDL_ReadIO(SDL_IOStream *context, void *ptr, size_t size);
561
562/**
563 * Write to an SDL_IOStream data stream.
564 *
565 * This function writes exactly `size` bytes from the area pointed at by `ptr`
566 * to the stream. If this fails for any reason, it'll return less than `size`
567 * to demonstrate how far the write progressed. On success, it returns `size`.
568 *
569 * On error, this function still attempts to write as much as possible, so it
570 * might return a positive value less than the requested write size.
571 *
572 * The caller can use SDL_GetIOStatus() to determine if the problem is
573 * recoverable, such as a non-blocking write that can simply be retried later,
574 * or a fatal error.
575 *
576 * \param context a pointer to an SDL_IOStream structure.
577 * \param ptr a pointer to a buffer containing data to write.
578 * \param size the number of bytes to write.
579 * \returns the number of bytes written, which will be less than `size` on
580 * failure; call SDL_GetError() for more information.
581 *
582 * \since This function is available since SDL 3.0.0.
583 *
584 * \sa SDL_IOprintf
585 * \sa SDL_ReadIO
586 * \sa SDL_SeekIO
587 * \sa SDL_FlushIO
588 * \sa SDL_GetIOStatus
589 */
590extern SDL_DECLSPEC size_t SDLCALL SDL_WriteIO(SDL_IOStream *context, const void *ptr, size_t size);
591
592/**
593 * Print to an SDL_IOStream data stream.
594 *
595 * This function does formatted printing to the stream.
596 *
597 * \param context a pointer to an SDL_IOStream structure.
598 * \param fmt a printf() style format string.
599 * \param ... additional parameters matching % tokens in the `fmt` string, if
600 * any.
601 * \returns the number of bytes written or 0 on failure; call SDL_GetError()
602 * for more information.
603 *
604 * \since This function is available since SDL 3.0.0.
605 *
606 * \sa SDL_IOvprintf
607 * \sa SDL_WriteIO
608 */
609extern SDL_DECLSPEC size_t SDLCALL SDL_IOprintf(SDL_IOStream *context, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
610
611/**
612 * Print to an SDL_IOStream data stream.
613 *
614 * This function does formatted printing to the stream.
615 *
616 * \param context a pointer to an SDL_IOStream structure.
617 * \param fmt a printf() style format string.
618 * \param ap a variable argument list.
619 * \returns the number of bytes written or 0 on failure; call SDL_GetError()
620 * for more information.
621 *
622 * \since This function is available since SDL 3.0.0.
623 *
624 * \sa SDL_IOprintf
625 * \sa SDL_WriteIO
626 */
627extern SDL_DECLSPEC size_t SDLCALL SDL_IOvprintf(SDL_IOStream *context, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2);
628
629/**
630 * Flush any buffered data in the stream.
631 *
632 * This function makes sure that any buffered data is written to the stream.
633 * Normally this isn't necessary but if the stream is a pipe or socket it
634 * guarantees that any pending data is sent.
635 *
636 * \param context SDL_IOStream structure to flush.
637 * \returns true on success or false on failure; call SDL_GetError() for more
638 * information.
639 *
640 * \since This function is available since SDL 3.0.0.
641 *
642 * \sa SDL_OpenIO
643 * \sa SDL_WriteIO
644 */
645extern SDL_DECLSPEC bool SDLCALL SDL_FlushIO(SDL_IOStream *context);
646
647/**
648 * Load all the data from an SDL data stream.
649 *
650 * The data is allocated with a zero byte at the end (null terminated) for
651 * convenience. This extra byte is not included in the value reported via
652 * `datasize`.
653 *
654 * The data should be freed with SDL_free().
655 *
656 * \param src the SDL_IOStream to read all available data from.
657 * \param datasize a pointer filled in with the number of bytes read, may be
658 * NULL.
659 * \param closeio if true, calls SDL_CloseIO() on `src` before returning, even
660 * in the case of an error.
661 * \returns the data or NULL on failure; call SDL_GetError() for more
662 * information.
663 *
664 * \since This function is available since SDL 3.0.0.
665 *
666 * \sa SDL_LoadFile
667 */
668extern SDL_DECLSPEC void * SDLCALL SDL_LoadFile_IO(SDL_IOStream *src, size_t *datasize, bool closeio);
669
670/**
671 * Load all the data from a file path.
672 *
673 * The data is allocated with a zero byte at the end (null terminated) for
674 * convenience. This extra byte is not included in the value reported via
675 * `datasize`.
676 *
677 * The data should be freed with SDL_free().
678 *
679 * \param file the path to read all available data from.
680 * \param datasize if not NULL, will store the number of bytes read.
681 * \returns the data or NULL on failure; call SDL_GetError() for more
682 * information.
683 *
684 * \since This function is available since SDL 3.0.0.
685 *
686 * \sa SDL_LoadFile_IO
687 */
688extern SDL_DECLSPEC void * SDLCALL SDL_LoadFile(const char *file, size_t *datasize);
689
690/**
691 * \name Read endian functions
692 *
693 * Read an item of the specified endianness and return in native format.
694 */
695/* @{ */
696
697/**
698 * Use this function to read a byte from an SDL_IOStream.
699 *
700 * \param src the SDL_IOStream to read from.
701 * \param value a pointer filled in with the data read.
702 * \returns true on success or false on failure; call SDL_GetError() for more
703 * information.
704 *
705 * \since This function is available since SDL 3.0.0.
706 */
707extern SDL_DECLSPEC bool SDLCALL SDL_ReadU8(SDL_IOStream *src, Uint8 *value);
708
709/**
710 * Use this function to read a signed byte from an SDL_IOStream.
711 *
712 * \param src the SDL_IOStream to read from.
713 * \param value a pointer filled in with the data read.
714 * \returns true on success or false on failure; call SDL_GetError() for more
715 * information.
716 *
717 * \since This function is available since SDL 3.0.0.
718 */
719extern SDL_DECLSPEC bool SDLCALL SDL_ReadS8(SDL_IOStream *src, Sint8 *value);
720
721/**
722 * Use this function to read 16 bits of little-endian data from an
723 * SDL_IOStream and return in native format.
724 *
725 * SDL byteswaps the data only if necessary, so the data returned will be in
726 * the native byte order.
727 *
728 * \param src the stream from which to read data.
729 * \param value a pointer filled in with the data read.
730 * \returns true on successful write or false on failure; call SDL_GetError()
731 * for more information.
732 *
733 * \since This function is available since SDL 3.0.0.
734 */
735extern SDL_DECLSPEC bool SDLCALL SDL_ReadU16LE(SDL_IOStream *src, Uint16 *value);
736
737/**
738 * Use this function to read 16 bits of little-endian data from an
739 * SDL_IOStream and return in native format.
740 *
741 * SDL byteswaps the data only if necessary, so the data returned will be in
742 * the native byte order.
743 *
744 * \param src the stream from which to read data.
745 * \param value a pointer filled in with the data read.
746 * \returns true on successful write or false on failure; call SDL_GetError()
747 * for more information.
748 *
749 * \since This function is available since SDL 3.0.0.
750 */
751extern SDL_DECLSPEC bool SDLCALL SDL_ReadS16LE(SDL_IOStream *src, Sint16 *value);
752
753/**
754 * Use this function to read 16 bits of big-endian data from an SDL_IOStream
755 * and return in native format.
756 *
757 * SDL byteswaps the data only if necessary, so the data returned will be in
758 * the native byte order.
759 *
760 * \param src the stream from which to read data.
761 * \param value a pointer filled in with the data read.
762 * \returns true on successful write or false on failure; call SDL_GetError()
763 * for more information.
764 *
765 * \since This function is available since SDL 3.0.0.
766 */
767extern SDL_DECLSPEC bool SDLCALL SDL_ReadU16BE(SDL_IOStream *src, Uint16 *value);
768
769/**
770 * Use this function to read 16 bits of big-endian data from an SDL_IOStream
771 * and return in native format.
772 *
773 * SDL byteswaps the data only if necessary, so the data returned will be in
774 * the native byte order.
775 *
776 * \param src the stream from which to read data.
777 * \param value a pointer filled in with the data read.
778 * \returns true on successful write or false on failure; call SDL_GetError()
779 * for more information.
780 *
781 * \since This function is available since SDL 3.0.0.
782 */
783extern SDL_DECLSPEC bool SDLCALL SDL_ReadS16BE(SDL_IOStream *src, Sint16 *value);
784
785/**
786 * Use this function to read 32 bits of little-endian data from an
787 * SDL_IOStream and return in native format.
788 *
789 * SDL byteswaps the data only if necessary, so the data returned will be in
790 * the native byte order.
791 *
792 * \param src the stream from which to read data.
793 * \param value a pointer filled in with the data read.
794 * \returns true on successful write or false on failure; call SDL_GetError()
795 * for more information.
796 *
797 * \since This function is available since SDL 3.0.0.
798 */
799extern SDL_DECLSPEC bool SDLCALL SDL_ReadU32LE(SDL_IOStream *src, Uint32 *value);
800
801/**
802 * Use this function to read 32 bits of little-endian data from an
803 * SDL_IOStream and return in native format.
804 *
805 * SDL byteswaps the data only if necessary, so the data returned will be in
806 * the native byte order.
807 *
808 * \param src the stream from which to read data.
809 * \param value a pointer filled in with the data read.
810 * \returns true on successful write or false on failure; call SDL_GetError()
811 * for more information.
812 *
813 * \since This function is available since SDL 3.0.0.
814 */
815extern SDL_DECLSPEC bool SDLCALL SDL_ReadS32LE(SDL_IOStream *src, Sint32 *value);
816
817/**
818 * Use this function to read 32 bits of big-endian data from an SDL_IOStream
819 * and return in native format.
820 *
821 * SDL byteswaps the data only if necessary, so the data returned will be in
822 * the native byte order.
823 *
824 * \param src the stream from which to read data.
825 * \param value a pointer filled in with the data read.
826 * \returns true on successful write or false on failure; call SDL_GetError()
827 * for more information.
828 *
829 * \since This function is available since SDL 3.0.0.
830 */
831extern SDL_DECLSPEC bool SDLCALL SDL_ReadU32BE(SDL_IOStream *src, Uint32 *value);
832
833/**
834 * Use this function to read 32 bits of big-endian data from an SDL_IOStream
835 * and return in native format.
836 *
837 * SDL byteswaps the data only if necessary, so the data returned will be in
838 * the native byte order.
839 *
840 * \param src the stream from which to read data.
841 * \param value a pointer filled in with the data read.
842 * \returns true on successful write or false on failure; call SDL_GetError()
843 * for more information.
844 *
845 * \since This function is available since SDL 3.0.0.
846 */
847extern SDL_DECLSPEC bool SDLCALL SDL_ReadS32BE(SDL_IOStream *src, Sint32 *value);
848
849/**
850 * Use this function to read 64 bits of little-endian data from an
851 * SDL_IOStream and return in native format.
852 *
853 * SDL byteswaps the data only if necessary, so the data returned will be in
854 * the native byte order.
855 *
856 * \param src the stream from which to read data.
857 * \param value a pointer filled in with the data read.
858 * \returns true on successful write or false on failure; call SDL_GetError()
859 * for more information.
860 *
861 * \since This function is available since SDL 3.0.0.
862 */
863extern SDL_DECLSPEC bool SDLCALL SDL_ReadU64LE(SDL_IOStream *src, Uint64 *value);
864
865/**
866 * Use this function to read 64 bits of little-endian data from an
867 * SDL_IOStream and return in native format.
868 *
869 * SDL byteswaps the data only if necessary, so the data returned will be in
870 * the native byte order.
871 *
872 * \param src the stream from which to read data.
873 * \param value a pointer filled in with the data read.
874 * \returns true on successful write or false on failure; call SDL_GetError()
875 * for more information.
876 *
877 * \since This function is available since SDL 3.0.0.
878 */
879extern SDL_DECLSPEC bool SDLCALL SDL_ReadS64LE(SDL_IOStream *src, Sint64 *value);
880
881/**
882 * Use this function to read 64 bits of big-endian data from an SDL_IOStream
883 * and return in native format.
884 *
885 * SDL byteswaps the data only if necessary, so the data returned will be in
886 * the native byte order.
887 *
888 * \param src the stream from which to read data.
889 * \param value a pointer filled in with the data read.
890 * \returns true on successful write or false on failure; call SDL_GetError()
891 * for more information.
892 *
893 * \since This function is available since SDL 3.0.0.
894 */
895extern SDL_DECLSPEC bool SDLCALL SDL_ReadU64BE(SDL_IOStream *src, Uint64 *value);
896
897/**
898 * Use this function to read 64 bits of big-endian data from an SDL_IOStream
899 * and return in native format.
900 *
901 * SDL byteswaps the data only if necessary, so the data returned will be in
902 * the native byte order.
903 *
904 * \param src the stream from which to read data.
905 * \param value a pointer filled in with the data read.
906 * \returns true on successful write or false on failure; call SDL_GetError()
907 * for more information.
908 *
909 * \since This function is available since SDL 3.0.0.
910 */
911extern SDL_DECLSPEC bool SDLCALL SDL_ReadS64BE(SDL_IOStream *src, Sint64 *value);
912/* @} *//* Read endian functions */
913
914/**
915 * \name Write endian functions
916 *
917 * Write an item of native format to the specified endianness.
918 */
919/* @{ */
920
921/**
922 * Use this function to write a byte to an SDL_IOStream.
923 *
924 * \param dst the SDL_IOStream to write to.
925 * \param value the byte value to write.
926 * \returns true on successful write or false on failure; call SDL_GetError()
927 * for more information.
928 *
929 * \since This function is available since SDL 3.0.0.
930 */
931extern SDL_DECLSPEC bool SDLCALL SDL_WriteU8(SDL_IOStream *dst, Uint8 value);
932
933/**
934 * Use this function to write a signed byte to an SDL_IOStream.
935 *
936 * \param dst the SDL_IOStream to write to.
937 * \param value the byte value to write.
938 * \returns true on successful write or false on failure; call SDL_GetError()
939 * for more information.
940 *
941 * \since This function is available since SDL 3.0.0.
942 */
943extern SDL_DECLSPEC bool SDLCALL SDL_WriteS8(SDL_IOStream *dst, Sint8 value);
944
945/**
946 * Use this function to write 16 bits in native format to an SDL_IOStream as
947 * little-endian data.
948 *
949 * SDL byteswaps the data only if necessary, so the application always
950 * specifies native format, and the data written will be in little-endian
951 * format.
952 *
953 * \param dst the stream to which data will be written.
954 * \param value the data to be written, in native format.
955 * \returns true on successful write or false on failure; call SDL_GetError()
956 * for more information.
957 *
958 * \since This function is available since SDL 3.0.0.
959 */
960extern SDL_DECLSPEC bool SDLCALL SDL_WriteU16LE(SDL_IOStream *dst, Uint16 value);
961
962/**
963 * Use this function to write 16 bits in native format to an SDL_IOStream as
964 * little-endian data.
965 *
966 * SDL byteswaps the data only if necessary, so the application always
967 * specifies native format, and the data written will be in little-endian
968 * format.
969 *
970 * \param dst the stream to which data will be written.
971 * \param value the data to be written, in native format.
972 * \returns true on successful write or false on failure; call SDL_GetError()
973 * for more information.
974 *
975 * \since This function is available since SDL 3.0.0.
976 */
977extern SDL_DECLSPEC bool SDLCALL SDL_WriteS16LE(SDL_IOStream *dst, Sint16 value);
978
979/**
980 * Use this function to write 16 bits in native format to an SDL_IOStream as
981 * big-endian data.
982 *
983 * SDL byteswaps the data only if necessary, so the application always
984 * specifies native format, and the data written will be in big-endian format.
985 *
986 * \param dst the stream to which data will be written.
987 * \param value the data to be written, in native format.
988 * \returns true on successful write or false on failure; call SDL_GetError()
989 * for more information.
990 *
991 * \since This function is available since SDL 3.0.0.
992 */
993extern SDL_DECLSPEC bool SDLCALL SDL_WriteU16BE(SDL_IOStream *dst, Uint16 value);
994
995/**
996 * Use this function to write 16 bits in native format to an SDL_IOStream as
997 * big-endian data.
998 *
999 * SDL byteswaps the data only if necessary, so the application always
1000 * specifies native format, and the data written will be in big-endian format.
1001 *
1002 * \param dst the stream to which data will be written.
1003 * \param value the data to be written, in native format.
1004 * \returns true on successful write or false on failure; call SDL_GetError()
1005 * for more information.
1006 *
1007 * \since This function is available since SDL 3.0.0.
1008 */
1009extern SDL_DECLSPEC bool SDLCALL SDL_WriteS16BE(SDL_IOStream *dst, Sint16 value);
1010
1011/**
1012 * Use this function to write 32 bits in native format to an SDL_IOStream as
1013 * little-endian data.
1014 *
1015 * SDL byteswaps the data only if necessary, so the application always
1016 * specifies native format, and the data written will be in little-endian
1017 * format.
1018 *
1019 * \param dst the stream to which data will be written.
1020 * \param value the data to be written, in native format.
1021 * \returns true on successful write or false on failure; call SDL_GetError()
1022 * for more information.
1023 *
1024 * \since This function is available since SDL 3.0.0.
1025 */
1026extern SDL_DECLSPEC bool SDLCALL SDL_WriteU32LE(SDL_IOStream *dst, Uint32 value);
1027
1028/**
1029 * Use this function to write 32 bits in native format to an SDL_IOStream as
1030 * little-endian data.
1031 *
1032 * SDL byteswaps the data only if necessary, so the application always
1033 * specifies native format, and the data written will be in little-endian
1034 * format.
1035 *
1036 * \param dst the stream to which data will be written.
1037 * \param value the data to be written, in native format.
1038 * \returns true on successful write or false on failure; call SDL_GetError()
1039 * for more information.
1040 *
1041 * \since This function is available since SDL 3.0.0.
1042 */
1043extern SDL_DECLSPEC bool SDLCALL SDL_WriteS32LE(SDL_IOStream *dst, Sint32 value);
1044
1045/**
1046 * Use this function to write 32 bits in native format to an SDL_IOStream as
1047 * big-endian data.
1048 *
1049 * SDL byteswaps the data only if necessary, so the application always
1050 * specifies native format, and the data written will be in big-endian format.
1051 *
1052 * \param dst the stream to which data will be written.
1053 * \param value the data to be written, in native format.
1054 * \returns true on successful write or false on failure; call SDL_GetError()
1055 * for more information.
1056 *
1057 * \since This function is available since SDL 3.0.0.
1058 */
1059extern SDL_DECLSPEC bool SDLCALL SDL_WriteU32BE(SDL_IOStream *dst, Uint32 value);
1060
1061/**
1062 * Use this function to write 32 bits in native format to an SDL_IOStream as
1063 * big-endian data.
1064 *
1065 * SDL byteswaps the data only if necessary, so the application always
1066 * specifies native format, and the data written will be in big-endian format.
1067 *
1068 * \param dst the stream to which data will be written.
1069 * \param value the data to be written, in native format.
1070 * \returns true on successful write or false on failure; call SDL_GetError()
1071 * for more information.
1072 *
1073 * \since This function is available since SDL 3.0.0.
1074 */
1075extern SDL_DECLSPEC bool SDLCALL SDL_WriteS32BE(SDL_IOStream *dst, Sint32 value);
1076
1077/**
1078 * Use this function to write 64 bits in native format to an SDL_IOStream as
1079 * little-endian data.
1080 *
1081 * SDL byteswaps the data only if necessary, so the application always
1082 * specifies native format, and the data written will be in little-endian
1083 * format.
1084 *
1085 * \param dst the stream to which data will be written.
1086 * \param value the data to be written, in native format.
1087 * \returns true on successful write or false on failure; call SDL_GetError()
1088 * for more information.
1089 *
1090 * \since This function is available since SDL 3.0.0.
1091 */
1092extern SDL_DECLSPEC bool SDLCALL SDL_WriteU64LE(SDL_IOStream *dst, Uint64 value);
1093
1094/**
1095 * Use this function to write 64 bits in native format to an SDL_IOStream as
1096 * little-endian data.
1097 *
1098 * SDL byteswaps the data only if necessary, so the application always
1099 * specifies native format, and the data written will be in little-endian
1100 * format.
1101 *
1102 * \param dst the stream to which data will be written.
1103 * \param value the data to be written, in native format.
1104 * \returns true on successful write or false on failure; call SDL_GetError()
1105 * for more information.
1106 *
1107 * \since This function is available since SDL 3.0.0.
1108 */
1109extern SDL_DECLSPEC bool SDLCALL SDL_WriteS64LE(SDL_IOStream *dst, Sint64 value);
1110
1111/**
1112 * Use this function to write 64 bits in native format to an SDL_IOStream as
1113 * big-endian data.
1114 *
1115 * SDL byteswaps the data only if necessary, so the application always
1116 * specifies native format, and the data written will be in big-endian format.
1117 *
1118 * \param dst the stream to which data will be written.
1119 * \param value the data to be written, in native format.
1120 * \returns true on successful write or false on failure; call SDL_GetError()
1121 * for more information.
1122 *
1123 * \since This function is available since SDL 3.0.0.
1124 */
1125extern SDL_DECLSPEC bool SDLCALL SDL_WriteU64BE(SDL_IOStream *dst, Uint64 value);
1126
1127/**
1128 * Use this function to write 64 bits in native format to an SDL_IOStream as
1129 * big-endian data.
1130 *
1131 * SDL byteswaps the data only if necessary, so the application always
1132 * specifies native format, and the data written will be in big-endian format.
1133 *
1134 * \param dst the stream to which data will be written.
1135 * \param value the data to be written, in native format.
1136 * \returns true on successful write or false on failure; call SDL_GetError()
1137 * for more information.
1138 *
1139 * \since This function is available since SDL 3.0.0.
1140 */
1141extern SDL_DECLSPEC bool SDLCALL SDL_WriteS64BE(SDL_IOStream *dst, Sint64 value);
1142
1143/* @} *//* Write endian functions */
1144
1145/* Ends C function definitions when using C++ */
1146#ifdef __cplusplus
1147}
1148#endif
1149#include <SDL3/SDL_close_code.h>
1150
1151#endif /* SDL_iostream_h_ */
bool SDL_WriteS64LE(SDL_IOStream *dst, Sint64 value)
SDL_IOStream * SDL_IOFromConstMem(const void *mem, size_t size)
SDL_IOStream * SDL_OpenIO(const SDL_IOStreamInterface *iface, void *userdata)
SDL_IOStatus
@ SDL_IO_STATUS_ERROR
@ SDL_IO_STATUS_EOF
@ SDL_IO_STATUS_NOT_READY
@ SDL_IO_STATUS_READY
@ SDL_IO_STATUS_WRITEONLY
@ SDL_IO_STATUS_READONLY
bool SDL_ReadU32LE(SDL_IOStream *src, Uint32 *value)
bool SDL_WriteS64BE(SDL_IOStream *dst, Sint64 value)
bool SDL_ReadS32LE(SDL_IOStream *src, Sint32 *value)
bool SDL_ReadU32BE(SDL_IOStream *src, Uint32 *value)
size_t SDL_WriteIO(SDL_IOStream *context, const void *ptr, size_t size)
bool SDL_WriteS32BE(SDL_IOStream *dst, Sint32 value)
bool SDL_WriteU16BE(SDL_IOStream *dst, Uint16 value)
bool SDL_ReadS64LE(SDL_IOStream *src, Sint64 *value)
bool SDL_ReadS8(SDL_IOStream *src, Sint8 *value)
bool SDL_ReadU16LE(SDL_IOStream *src, Uint16 *value)
Sint64 SDL_SeekIO(SDL_IOStream *context, Sint64 offset, SDL_IOWhence whence)
size_t SDL_IOvprintf(SDL_IOStream *context, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2)
SDL_IOStream * SDL_IOFromFile(const char *file, const char *mode)
bool SDL_WriteU16LE(SDL_IOStream *dst, Uint16 value)
Sint64 SDL_TellIO(SDL_IOStream *context)
bool SDL_WriteS32LE(SDL_IOStream *dst, Sint32 value)
bool SDL_WriteS8(SDL_IOStream *dst, Sint8 value)
bool SDL_WriteS16BE(SDL_IOStream *dst, Sint16 value)
size_t SDL_IOprintf(SDL_IOStream *context, SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(2)
bool SDL_ReadS32BE(SDL_IOStream *src, Sint32 *value)
bool SDL_ReadU64BE(SDL_IOStream *src, Uint64 *value)
bool SDL_ReadU8(SDL_IOStream *src, Uint8 *value)
bool SDL_ReadS64BE(SDL_IOStream *src, Sint64 *value)
SDL_IOStream * SDL_IOFromDynamicMem(void)
void * SDL_LoadFile_IO(SDL_IOStream *src, size_t *datasize, bool closeio)
bool SDL_ReadS16LE(SDL_IOStream *src, Sint16 *value)
struct SDL_IOStream SDL_IOStream
bool SDL_ReadU16BE(SDL_IOStream *src, Uint16 *value)
bool SDL_WriteS16LE(SDL_IOStream *dst, Sint16 value)
bool SDL_WriteU64BE(SDL_IOStream *dst, Uint64 value)
bool SDL_WriteU32BE(SDL_IOStream *dst, Uint32 value)
Sint64 SDL_GetIOSize(SDL_IOStream *context)
bool SDL_ReadS16BE(SDL_IOStream *src, Sint16 *value)
bool SDL_WriteU32LE(SDL_IOStream *dst, Uint32 value)
bool SDL_WriteU8(SDL_IOStream *dst, Uint8 value)
SDL_IOStatus SDL_GetIOStatus(SDL_IOStream *context)
SDL_IOStream * SDL_IOFromMem(void *mem, size_t size)
bool SDL_CloseIO(SDL_IOStream *context)
bool SDL_FlushIO(SDL_IOStream *context)
bool SDL_WriteU64LE(SDL_IOStream *dst, Uint64 value)
SDL_PropertiesID SDL_GetIOProperties(SDL_IOStream *context)
size_t SDL_ReadIO(SDL_IOStream *context, void *ptr, size_t size)
void * SDL_LoadFile(const char *file, size_t *datasize)
bool SDL_ReadU64LE(SDL_IOStream *src, Uint64 *value)
SDL_IOWhence
@ SDL_IO_SEEK_CUR
@ SDL_IO_SEEK_SET
@ SDL_IO_SEEK_END
Uint32 SDL_PropertiesID
uint8_t Uint8
Definition SDL_stdinc.h:320
int64_t Sint64
Definition SDL_stdinc.h:367
uint16_t Uint16
Definition SDL_stdinc.h:338
#define SDL_PRINTF_VARARG_FUNCV(fmtargnumber)
Definition SDL_stdinc.h:566
int8_t Sint8
Definition SDL_stdinc.h:311
int32_t Sint32
Definition SDL_stdinc.h:347
SDL_MALLOC size_t size
Definition SDL_stdinc.h:720
int16_t Sint16
Definition SDL_stdinc.h:329
#define SDL_PRINTF_FORMAT_STRING
Definition SDL_stdinc.h:554
#define SDL_PRINTF_VARARG_FUNC(fmtargnumber)
Definition SDL_stdinc.h:565
#define SDL_COMPILE_TIME_ASSERT(name, x)
Definition SDL_stdinc.h:112
#define bool
Definition SDL_stdinc.h:53
uint64_t Uint64
Definition SDL_stdinc.h:378
uint32_t Uint32
Definition SDL_stdinc.h:356
bool(* flush)(void *userdata, SDL_IOStatus *status)
Sint64(* size)(void *userdata)
size_t(* read)(void *userdata, void *ptr, size_t size, SDL_IOStatus *status)
Sint64(* seek)(void *userdata, Sint64 offset, SDL_IOWhence whence)
size_t(* write)(void *userdata, const void *ptr, size_t size, SDL_IOStatus *status)
bool(* close)(void *userdata)