summaryrefslogtreecommitdiff
path: root/include/SDL_rwops.h
diff options
context:
space:
mode:
authorSam Lantinga <slouken@libsdl.org>2017-08-09 11:58:38 -0700
committerSam Lantinga <slouken@libsdl.org>2017-08-09 11:58:38 -0700
commit8adb12e5ebb0c2bad5e0eb7bac29a27e0ba8cffd (patch)
treef40b236192c12d35d0f97c1f3b24433d3f985bd7 /include/SDL_rwops.h
parentc65cae94fc30ec6cb297227633efc3368703fa63 (diff)
Added an API SDL_LoadFile_RW() to load all the data from an SDL data stream, and a convenience macro SDL_LoadFile() to load all the data from a file.
Diffstat (limited to 'include/SDL_rwops.h')
-rw-r--r--include/SDL_rwops.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/SDL_rwops.h b/include/SDL_rwops.h
index 00d82a6d02..7f0cbdfd55 100644
--- a/include/SDL_rwops.h
+++ b/include/SDL_rwops.h
@@ -191,6 +191,29 @@ extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area);
/**
+ * 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.