Using bytes array as it was a file

Started by
5 comments, last by mightypigeon 13 years, 3 months ago
Assume that I have an array of bytes(100500), how can I use it as it was a file( i.e. Loading model with fbxsdk) ? Or do I have to create a temp file? Any help is welcome.
Advertisement
If you're using Windows check out the CreateFileMapping API.
In C# you could create a memory stream from the bytes which can be use like a file stream (like any other stream really). Does anyone know if there's something similar in the C++ stream library? I'd like to know the answer to this myself actually.

[Edited by - doesnotcompute on December 28, 2010 2:56:43 AM]
What about Boost library?

http://www.boost.org/doc/libs/1_36_0/libs/iostreams/doc/classes/mapped_file.html
Quote:Original post by doesnotcompute
In C# you could create a memory stream from the bytes which can be use like a file stream (like any other stream really). Does anyone know if there's something similar in the C++ stream library? I'd like to know the answer to this myself actually.


If you write your code against the base interface std::iostream, you can interchange file streams, memory-backed streams, network-backed streams, or anything else that conforms to the interface. Pretty handy and basically the exact corresponding concept to doing that in C#.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Um... std::stringstream? Guys? Yeah? It lives in <sstream>.
Quote:Original post by Zahlman
Um... std::stringstream? Guys? Yeah? It lives in <sstream>.


I interpreted the question as being able to have a function like LoadFBX( "c:\model.fbx" ); but instead parse an array from RAM
[size="1"]

This topic is closed to new replies.

Advertisement