Read/Write a file

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
MisterRose
Posts: 18
Joined: Thu Jun 16, 2011 2:46 pm

Read/Write a file

Post 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.
You are unique - just like everyone else.
RageD
Posts: 34
Joined: Mon Jun 13, 2005 2:34 pm

Post by RageD »

DuF = (del)F.u
Microsonic Development
Reiko
Posts: 105
Joined: Sun Aug 16, 2009 7:06 am
Location: Australia

Post 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
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Oh, I thought that it's a question for an IReadWriteFile?!
MisterRose
Posts: 18
Joined: Thu Jun 16, 2011 2:46 pm

Post 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?
You are unique - just like everyone else.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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?
Post Reply