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/intern/readblenentry.c | |
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/intern/readblenentry.c')
-rw-r--r-- | source/blender/blenloader/intern/readblenentry.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index d66d802c8ee..da441214b37 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -76,6 +76,15 @@ BlendHandle *BLO_blendhandle_from_file(char *file) return bh; } +BlendHandle *BLO_blendhandle_from_memory(void *mem, int memsize) +{ + BlendHandle *bh; + + bh= (BlendHandle*)blo_openblendermemory(mem, memsize, NULL); + + return bh; +} + void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp) { FileData *fd= (FileData*) bh; |