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