www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - File.seek OS X dmd 2.031 and 2.032

Bug, or (more likely) I'm doing something wrong? 

seek seems to always throw:

std.conv.ConvOverflowError: Error: overflow Conversion underflow

Thanks, Jason

//////////////////////////////////////////////
import std.stdio;

void main(string[] args)
{
    auto f = File("test.txt", "w");

    f.write("Hello, file!\n");
    f.close;

    f = File("test.txt", "r");

    f.seek(0L, SEEK_END); // fails
    f.seek(2L); // fails

    writeln("posn = ", f.tell());
}

// Mac OS X, dmd v2.031 and 2.032

// both seeks give:
// std.conv.ConvOverflowError: Error: overflow Conversion underflow

// seek from Phobos, stdio.d

//     void seek(long offset, int origin = SEEK_SET)
//     {
//         enforce(p && p.handle,
//                 "Attempting to seek() in an unopened file");
//         //     Dubious: why is fseek in std.c.stdio taking an int???
//         errnoEnforce(core.stdc.stdio.fseek(
//                     p.handle, to!int(offset), origin) == 0,
//                 "Could not seek in file `"~p.name~"'");
//     }
Sep 10 2009