unsigned long filesize(char *filename){
unsigned long fsize=0;
unsigned char dummy;
fstream rfile;//vars
rfile.open(filename,0x81);
while(!rfile.eof()){
fsize++;
rfile.read(&dummy,1);
};
rfile.close();
return(fsize);
};
But in visual C++ it doesn''t work properly.
Should I use another method?
Retrieving the size of a file
I always used this function to retrieve the size of a file:
I always just use:
ifstream fip;
fip.open(fname);
//: seek to the end of file
fip.seekg(0, ios::end);
//: get the position (will be size of file)
unsigned long bytes = fip.tellg();
HTH,
-mordell
__________________________________________
Yeah, sure... we are laughing WITH you ...
Yeah, sure... we are laughing WITH you ...
you definitely should!
u32 FileLength (FILE *f)
{
return (filelength(fileno(f)));
}
It should be straight-forward to make it accept a filename instead of a file stream (just requires more code).
u32 FileLength (FILE *f)
{
return (filelength(fileno(f)));
}
It should be straight-forward to make it accept a filename instead of a file stream (just requires more code).
Darn! It was just my graphics write function. It displayed the numbers in the wrong order.
But thanks anyway mordell, your function is faster than mine (especially in big files).
Foofightr: Your function generates a lot of compiler errors in VC++, just to let you know.
But thanks anyway mordell, your function is faster than mine (especially in big files).
Foofightr: Your function generates a lot of compiler errors in VC++, just to let you know.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement