| | |
| | | /* |
| | | Simple DirectMedia Layer |
| | | Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> |
| | | Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> |
| | | |
| | | This software is provided 'as-is', without any express or implied |
| | | warranty. In no event will the authors be held liable for any damages |
| | |
| | | * data streams. It can easily be extended to files, memory, etc. |
| | | */ |
| | | |
| | | #ifndef _SDL_rwops_h |
| | | #define _SDL_rwops_h |
| | | #ifndef SDL_rwops_h_ |
| | | #define SDL_rwops_h_ |
| | | |
| | | #include "SDL_stdinc.h" |
| | | #include "SDL_error.h" |
| | |
| | | #endif |
| | | |
| | | /* RWops Types */ |
| | | #define SDL_RWOPS_UNKNOWN 0U /* Unknown stream type */ |
| | | #define SDL_RWOPS_WINFILE 1U /* Win32 file */ |
| | | #define SDL_RWOPS_STDFILE 2U /* Stdio file */ |
| | | #define SDL_RWOPS_JNIFILE 3U /* Android asset */ |
| | | #define SDL_RWOPS_MEMORY 4U /* Memory stream */ |
| | | #define SDL_RWOPS_MEMORY_RO 5U /* Read-Only memory stream */ |
| | | #define SDL_RWOPS_UNKNOWN 0U /**< Unknown stream type */ |
| | | #define SDL_RWOPS_WINFILE 1U /**< Win32 file */ |
| | | #define SDL_RWOPS_STDFILE 2U /**< Stdio file */ |
| | | #define SDL_RWOPS_JNIFILE 3U /**< Android asset */ |
| | | #define SDL_RWOPS_MEMORY 4U /**< Memory stream */ |
| | | #define SDL_RWOPS_MEMORY_RO 5U /**< Read-Only memory stream */ |
| | | |
| | | /** |
| | | * This is the read/write operation structure -- very basic. |
| | |
| | | |
| | | |
| | | /** |
| | | * Load all the data from an SDL data stream. |
| | | * |
| | | * The data is allocated with a zero byte at the end (null terminated) |
| | | * |
| | | * If \c datasize is not NULL, it is filled with the size of the data read. |
| | | * |
| | | * If \c freesrc is non-zero, the stream will be closed after being read. |
| | | * |
| | | * The data should be freed with SDL_free(). |
| | | * |
| | | * \return the data, or NULL if there was an error. |
| | | */ |
| | | extern DECLSPEC void *SDLCALL SDL_LoadFile_RW(SDL_RWops * src, size_t *datasize, |
| | | int freesrc); |
| | | |
| | | /** |
| | | * Load an entire file. |
| | | * |
| | | * Convenience macro. |
| | | */ |
| | | #define SDL_LoadFile(file, datasize) SDL_LoadFile_RW(SDL_RWFromFile(file, "rb"), datasize, 1) |
| | | |
| | | /** |
| | | * \name Read endian functions |
| | | * |
| | | * Read an item of the specified endianness and return in native format. |
| | |
| | | #endif |
| | | #include "close_code.h" |
| | | |
| | | #endif /* _SDL_rwops_h */ |
| | | #endif /* SDL_rwops_h_ */ |
| | | |
| | | /* vi: set ts=4 sw=4 expandtab: */ |