Sign in to follow this  
Palidor

Setting a FILE* to a raw character array, instead of a file?

Recommended Posts

I know the subject sounds strange, but here's how i found myself in this predicament lol I decided to write a FileArchive class that allows you to open a .PAK file, and leave it open throughout the duration of a program and read data from it when you need to load a certain file into the the game. I originally decided on this method because iPhone doesn't seem to support relative paths very well, and I needed to add a single .PAK file as a resource, and treat it as a bundle and then get the absolute path with regards to the current system and open it in the FileArchive object i created. So, with all that aside, here's my problem: I have succeeded in getting OpenAL working on the iPhone, using the ogg vorbis libraries. However, now when i read out a vector<char*> buffer from the archive that contains all the raw data for the .ogg file i want to load into the sound manager, I cannot open it with a FILE*, which the ov_open function needs to fill out the ogg_FileInfo object, along with subsequent ogg vorbis data structures. So, my question is, is it possible for me to "trick" the FILE* into thinking that the vector<char*> is actually an open file, or am i essentially screwed with this approach? Thanks in advance! Sean

Share this post


Link to post
Share on other sites
FILE* does not actually point to any data, but merely to a structure that's used for file access bookkeeping. So that won't work at all.

However, most somewhat decent libraries that need data from files either provide a mean to set custom file access functions or accept the data from memory. You'd have to consult the documentation of the ogg/vorbis library, or maybe someone here knows.

Share this post


Link to post
Share on other sites
Thank you very much, sir! After mentioning that the ogg vorbis library might be able to do that, I did a quick google and found the following website explaining how to load an ogg file from memory :-) Here it is in case anyone else is interested:

http://www.devmaster.net/articles/openal-ogg-file/

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this