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

DataFileInput: Tango Issue 0.9.8

Moderators: kris

Posted: 03/20/09 18:44:42

Hi Everybody

latetely I upgraded to the recent trunk version of Tango. No I'm struggling with the new DataFileInput? module in order to set a buffer size I need. In Tango v0.9.7 you could set the buffer size of a seekable stream with the second parameter.

1. Tango 0.9.7
auto data = new DataFileInput?(file, buffer_size);

2. Tango Trunk
auto data = new DataFileInput?(file);

In the latest trunk version this isnt possible anymore. Now I'm receiving this error indicating that the buffer is too small:

BufferedInput?.next :: input buffer is full
tango.core.Exception.IOException: BufferedInput?.next :: input buffer is full


Does anybody knows how to increase the buffer size of DataFileInput? with the latest version of tango from the trunk (0.9.8)?

Cheers.

Author Message

Posted: 03/20/09 20:15:52

You can explicitly insert a BufferedInput instance between the DataFileInput and the file conduit. For example:

auto input = new DataFileInput(new BufferedInput(file, myBufferSize));

The creation of an input buffer is done behind the scenes if you don't provide one, using the default buffersize for the input source (typically 16K for a file). By explicitly wrapping the stream source in a buffer (with a size of your choosing) you inhibit that default behavior.

Posted: 03/21/09 13:44:35

Hey Kris, awesome. Thx for the help!

Posted: 03/22/09 14:31:09 -- Modified: 03/22/09 16:21:14 by
tomni -- Modified 4 Times

Well sorry again, but Kris this doesnt works. DataFileInput? just provides two constructor options

1. this (File file)
2. this (char[] path, File.Style style = File.ReadExisting?)

Using

auto input = new DataFileInput?(new BufferedInput?(file, buffer_size));

produces

/workspace/dproject/src/test.d(95): constructor tango.io.stream.DataFile?.DataFileInput?.this (char[],Style) does not match parameter types (BufferedInput?)
/workspace/dproject/src/test.d(95): Error: cannot implicitly convert expression (new BufferedInput?(cast(InputStream?)(file),buffer_size)) of type tango.io.stream.Buffered.BufferedInput? to tango.io.device.File.File

I think its just not yet moved from the old tango 0.99.7 code base to tango trunk right? Shouldn't there be a constructor like:

this (BufferInput? buf)

Any help appreciated! Thx, Tom.

Posted: 03/22/09 16:09:52 -- Modified: 03/22/09 16:37:28 by
tomni -- Modified 3 Times

OK, I think it got lost. I'm writing a ticket.

---

Tango 0.99.7 [tango.io.stream.DataFile?]:

this (FileConduit? file, uint buffer=uint.max, bool flip=false) {

super (conduit = file, buffer, flip);

}

---

Tango 0.99.8 [tango.io.stream.DataFileStream?]:

this (File file) {

super (conduit = file);

}

---

What it should be I guess into Tango 0.99.8

this (File file, uint buffer=uint.max) {

super (conduit = file, buffer);

}

---

Any Ideas?

Posted: 03/22/09 21:42:30

Whoops, sorry. This is what I should have written:

auto input = new DataInput (new BufferedInput(new File("myfile"), myBufferSize));

Posted: 03/23/09 11:19:25 -- Modified: 03/23/09 11:33:23 by
tomni -- Modified 2 Times

OK! Looks like you can do a seek on DataInput?! Thx. That was the missing point.