This specific file format HATES ME!!! Need help.
Again with the 3ds file format. Really. I do NOT understand why THIS specific format is giving me such a hard time! This shouldn't such a hazzle!
I am trying to load an entire file into a BYTE buffer:
BYTE* memfile = NULL;
unsigned int filesize = 0;
OFSTRUCT of;
hfile = OpenFile(filename,&of,OF_READ);
_lseek(hfile,0L,SEEK_END);
filesize = _tell(hfile);
memfile = new BYTE[filesize];
_lseek(hfile,0L,SEEK_SET);
_lread(hfile,memfile,filesize);
_lclose(hfile);
And when the loader executes, the first thing that goes wrong is that it tells me the "allocation size in invalid" and then spits out a jumble of digits. Now. This is embarrassing and -irritating-. What is wrong with my code that complicates my efforts to load the entire file into a BYTE byffer?
Js
Alright, if I LOWORD(_tell(hfile)) then I get the file's size. and it seems to work out now, but do I get the whole file size or a part of it? I dislike HIWORD:ing and LOWORD:ing. =)
Js
When looking at my win32 SDK, I see that _llseek is only provided for compatibility with 16 bit version of windows. It is recommended in my help file to use SetFilePointer. _lread and _lwrite are also only provided for compatibility only. I also do not find on my Win32 SDK any reference to _tellg. Maybe my own SDK is too old.
I also know that you cannot mix Win32 File functions with stdio.h file functions: they just aren't compatible.
I rather use streams:
Hope that helps.
Ghostly yours,
Red.
I also know that you cannot mix Win32 File functions with stdio.h file functions: they just aren't compatible.
I rather use streams:
#include <fstream>#include <iomanip>char* Buffer;void ReadInBuffer(std::string &pFileName) {int length;ifstream fin(pFilename.c_str());fin.seekg (0, ios::end);length = fin.tellg();fin.seekg (0, ios::beg);Buffer = new char[length];// read data as a block:fin.read (Buffer,length);fin.close();}
Hope that helps.
Ghostly yours,
Red.
Ghostly yours,Red.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement