Game Development Community

FileObject::readMemory doesn't accept a "local" file.

by Stefan Lundmark · in Torque Game Engine · 11/04/2004 (4:06 pm) · 6 replies

FileObject::openForWrite accepts files that are placed in the root of the game, ie the bottom folder (example, for instance).

But if you try to use FileObject::readMemory, it ignores the file and doesn't create it's stream, if you assign the same path for the file. Example follows:

Quote:%file.openforWrite("./testfile.file");
- Opens the stream and writes the file to the root.

Quote:%file.openForRead("./testfile.file");
- Doesn't open the file at all.

openForRead is connected to readMemory for anyone that is confused by my post.

#1
11/04/2004 (5:30 pm)
I'm really confused about what you mean by readMemory.

Interesting you can open files that are in the root dir. That shouldn't be allowed at all.
#2
11/04/2004 (5:50 pm)
%file.openforWrite("./testfile.file");
FileObject::openForWrite <- Obvious that the two are connected.

%file.openForRead("./testfile.file");
FileObject::readMemory <- Less obvious, if you don't check the code. :)

No Ben, then everything is in order. I can write to the root, but not read from there. I wanted to read from a file in there though :/ Didn't know about this limitation.

I guess it's somewhere in the ResourceManager? Is it trivial to disable?
#3
11/04/2004 (7:22 pm)
Stefan, I found this doing some T2D stuff, and it has been fixed in SVN.

Good catch.
#4
11/04/2004 (10:21 pm)
Ah, wonderful. Thanks Pat.
#5
11/05/2004 (3:40 am)
Pat Wilson,

I take it SVN is not open to the public yet? :)
If the fix is small, I would love if you could post it. Would help me out alot.
#6
11/05/2004 (6:47 am)
Sure, add:
char buffer[1024];
   if( fileName )
      if( Con::expandScriptFilename( buffer, sizeof(buffer), fileName ) )
         fileName = buffer;
At the start of readMemory and openForWrite