Help regarding the FILE struct and creating a resource manager

Started by
6 comments, last by neurokaotix 20 years ago
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
Advertisement
*bump*

MindEngine Development
http://medev.sourceforge.net
you''re not using c++?
I am using C++

MindEngine Development
http://medev.sourceforge.net
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]
"When you die, if you get a choice between going to regular heaven or pie heaven, choose pie heaven. It might be a trick, but if it's not, mmmmmmm, boy."
How to Ask Questions the Smart Way.
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?



Brianmiserere nostri Domine miserere nostri
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
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]

This topic is closed to new replies.

Advertisement