Sign in to follow this  
sakky

Using Buffered Files

Recommended Posts

sakky    100
Okay, I have a quick question about buffering files. I’m loading a 3D model from file. I read the header information first, then allocate a BYTE array equal to the size of the remaining file. I then user one read command to read in the file’s contents. So after this, I run through setting various pointers to point into the buffer. I use the offsets from the file header to offset into the BYTE array. I have figured that the offsets given in the file header pertain to file position from the beginning of the file. So I have subtracted sizeof( FILE_HEADER ) from the offset value into the BYTE array. This should work, right!? I only have to reconfigure the offsets into the file to match with those in the buffer. The header’s offsets are from the beginning of the file. So I figured that they would be valid if I subtracted the header’s size from the index. My main concern is that an offset had a negative or irregular value. This can happen, can’t it? For instance, the file in question is fragmented. How much can I trust file offsets? By the way, the file in question is an MD2. The header contains the EOF offset, so I though it would be quick and easy to load an MD2 into memory this way. Then later converting the data as needed, for example, a vertex buffer. Am I incorrect in my assumptions?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Fragmentation isn't something to worry about. The operating system usually just presents the file as a sequence of bytes. The way the file is actually stored on disk doesn't affect the way your program works with it (unless you use platform dependent methods to mess with that stuff).

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