A question about FileStream and Size
by Stefan Lundmark · in Torque Game Engine · 11/22/2004 (12:40 pm) · 1 replies
I've opened a file and I want to echo out how many bytes it contains, ie - the size of the file.
I've written this part of code below, but I'm unable to print out the size, the value which is being sent is apparantly NULL.
This is the code:
I get the filename echo'd in the console so that works, but I just get nothing from the size.
I figured there is something more you need to do to get the size in bytes to show up, but what is it?
I've written this part of code below, but I'm unable to print out the size, the value which is being sent is apparantly NULL.
This is the code:
ConsoleFunction( EchoFile, bool, 3, 3, "")
{
FileStream str;
const char* clientEXE = "client.exe";
if(!str.open(clientEXE, FileStream::Read))
{
char msg[1024];
dSprintf(msg, sizeof(msg), "Failed to open \"%s\".", clientEXE);
Platform::AlertOK("Error", msg);
Platform::postQuitMessage(0);
return false;
}
U32 size = str.getStreamSize();
const char checksize = size;
char *file = new char[size + 1];
str.read(size, file);
str.close();
file[size] = 0;
Con::executef(2, "EchoFileName", clientEXE);
Con::executef(2, "EchoFileSize", size);
delete[] file;
return true;
}I get the filename echo'd in the console so that works, but I just get nothing from the size.
I figured there is something more you need to do to get the size in bytes to show up, but what is it?
About the author
Torque 3D Owner Pat Wilson
(Disclamer, I didn't check that for exact name, it may be something different like 'getIntArgument' or something, but you get the idea)