Page 1 of 1
Read/Write a file
Posted: Wed Jun 22, 2011 9:10 pm
by MisterRose
I see there is a IWriteFile, but there is no method to read it.
Is there a way to open a file once and be able to read and write to it, without going native?
It seems a little silly to have a file you can write to, but then you cannot read back from it without opening the file in a reader.
Posted: Wed Jun 22, 2011 9:15 pm
by RageD
Posted: Thu Jun 23, 2011 12:24 am
by Reiko
To read a file:
Code: Select all
IReadFile *file = device->getFileSystem()->createAndOpenFile("text.txt");
then use file->read() to read the contents
use file->drop() to close the file when youre done
Write a file is almost the same
Code: Select all
IWriteFile *file = device->getFileSystem()->createAndWriteFile("text.txt", false);
then use file->write() to write to it
use file->drop() to close the file when youre done
Posted: Thu Jun 23, 2011 7:53 am
by hybrid
Oh, I thought that it's a question for an IReadWriteFile?!
Posted: Thu Jun 23, 2011 1:55 pm
by MisterRose
I was hoping for a file that I could read and write from at the same time, but I guess that is not part of the framework.
Is there a technical reason that reading from an IWriteFile is not supported?
Posted: Thu Jun 23, 2011 3:05 pm
by hybrid
Well, writing is not a typical task for games, besides several specialized occasions. And these are handled elsewhere, e.g. in the serialization part of the scene. What things are you planning to exchange via files?