Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Binary read/write

Moderators: larsivi kris

Posted: 09/05/09 09:23:59

I can't seem to avoid deprecated files. What I want is some thing like this:

auto file=new File( "animation.fjc", File.ReadWriteCreate ); // or just 'write'
auto write=new File( file );
scope(exit) file.close
write(frames)(width)(height)();

auto file=new File( "animation.fjc", File.ReadWriteCreate ); // or  just 'read'
auto read=new File("animation.fjc",READ);
scope(exit) file.close
read(frames)(width)(height)();

Thanks.

Author Message

Posted: 09/05/09 11:47:56

You don't say what is deprecated. I can only guess that you're importing tango.io.File when you should be importing tango.io.device.File. Or something like that.

Posted: 09/06/09 01:53:54

By the way, if you look at the 'current' version of the docs, all the deprecated I/O modules are gone.

http://www.dsource.org/projects/tango/docs/current/

Posted: 04/16/10 01:44:08

/*
What's wrong with this?
I get:
tango.core.Exception.IOException: DataInput :: unexpected eof while reading
*/
import tango.io.stream.Data;
import tango.io.device.File;

void main() {
	auto output = new DataOutput (new File ("test.dat", File.WriteCreate));
	output.int32   (1024); // this doesn't get on the file at all
	output.close;

	auto input = new DataInput (new File ("test.dat"));
	auto x = input.int32; // dies on this
	input.close;
}

Is this a good way to do binary read write? Maybe it's better for strings.

It's a long time ago, but thanks for your replies torhu.

Posted: 04/16/10 02:04:14

Try flushing the output before closing the file.

Posted: 04/16/10 09:03:47

That did the trick! Thanks torhu. :-)