Archived

This topic is now archived and is closed to further replies.

neurokaotix

Help regarding the FILE struct and creating a resource manager

Recommended Posts

neurokaotix    100
Hello everyone, I''m having some trouble here and I wasn''t exactly sure what to search for so I figured I''d give you guys a shot. My problem is that I''m trying to create a resource manager for my project but I''m completely unsure as to how I must go about loading a file from the hdd into memory, and being able to store it to a format that other classes can draw from. I''ve gotten the notion that I could somehow store it all to a void* but I''m not sure if this is the best route. Perhaps I should just load it as a FILE struct and keep it as such since most loaders seem to use that anyway? Any suggestions or war stories would be apprectiated, thanks! MindEngine Development http://medev.sourceforge.net

Share this post


Link to post
Share on other sites
CodeMunkie    805
I'm not clear on the problem. You have the data saved but you don't know how to load it? Or are you having trouble coming up with a format for the data?

[edited by - CodeMunkie on March 30, 2004 1:36:07 PM]

Share this post


Link to post
Share on other sites
BriTeg    168
Your question is kind of vague, but I''m guessing you want to, at runtime (as opposed to compile/link time), load/manage stuff like bitmaps, sounds, player data, etc. from files. Is this what you mean?



Share this post


Link to post
Share on other sites
neurokaotix    100
My new question is this: If I were to save all the files I load into memory as the _iobuf FILE* without using fclose on them so that I can access it later, is that going to cause big memory problems (keeping non-closed FILE pointers stored in memory)?

MindEngine Development
http://medev.sourceforge.net

Share this post


Link to post
Share on other sites
Evil Steve    2017
From the CRT source (Stream.c):

/*
* Loop through the __piob table looking for a free stream, or the
* first NULL entry.
*/

for ( i = 0 ; i < _nstream ; i++ ) {

_nstream is 512. So, if you try to open more than 512 files, you'll run out of file pointers. Also, under windows, fopen calls OpenFile(), and uses an OS handle. So you'll use up a lot of handles.

I'm not entirely sure what performance impact this will have, but i doubt it'll be severe.

Edit: You can open 509 files (3 are reserved for stdin, stdout, stderr) - I just tried it.

[edited by - Evil Steve on March 31, 2004 11:53:20 AM]

Share this post


Link to post
Share on other sites