Converting from std.file.read's void[]

bearophile bearophileHUGS at lycos.com
Tue Sep 21 17:34:26 PDT 2010


> Take a look at the rawWrite/rawRead methods of std.stdio.File.

I have just tried those a little. Python file object doesn't have a eof() method. This D2 program shows that eof() is false even when the whole file has being read, is this correct?


import std.stdio: File;
void main() {
    double[3] data = [0.5, 1.5, 2.5];
    auto f = File("test.raw", "wb");
    f.rawWrite(data);
    f.close();
    f = File("test.raw", "rb");
    assert(!f.eof());
    f.rawRead(data);
    assert(f.eof()); // Assertion failure
}

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list