diff options
author | Mitchell Stokes <mogurijin@gmail.com> | 2010-08-28 06:07:55 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2010-08-28 06:07:55 +0400 |
commit | 5c23537daa5c669b672528b0ed2bcaef2038f766 (patch) | |
tree | d8dafae80815cdd6d05e23ededc87df0098b2eb3 /source/blender/blenloader/BLO_readfile.h | |
parent | 5729b991fa06734a7a7d58b4ff0f2feab5db8bca (diff) |
Committing patch [#23278] (by me)
This patch allows a user to pass binary data to LibLoad() to load a blend file from memory instead of a file path. I don't know how useful this will be for others, but I've used it so far for:
* Decrypting .blend files and loading them without having to store the .blend on the hard drive
* Pulling .blend data out of an archive and loading it (again skipping the hard drive)
So, it seems the biggest use for this is skipping a bit of file IO (and possibly some security problems).
Example usage:
import bge
with f as open('myfile.blend', 'rb'):
data = f.read()
bge.logic.LibLoad('Name', 'Scene', data)
Diffstat (limited to 'source/blender/blenloader/BLO_readfile.h')
-rw-r--r-- | source/blender/blenloader/BLO_readfile.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index eeced13b57b..719a3c065ae 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -123,6 +123,19 @@ BLO_blendhandle_from_file( char *file); /** + * Open a blendhandle from memory. + * + * @param mem The data to load from. + * @param memsize The size of the data. + * @return A handle on success, or NULL on failure. + */ + + BlendHandle* +BLO_blendhandle_from_memory( + void *mem, + int memsize); + +/** * Gets the names of all the datablocks in a file * of a certain type (ie. All the scene names in * a file). |