www.digitalmars.com         C & C++   DMDScript  

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

reply Jason <jraddison gmail.com> writes:
I originally posted this in the bug group, but then realized that that was
probably  the wrong place. So ... sorry for cross-posting ... I hope I'm not
making my original mistake worse! Anyway ...

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
parent Michel Fortin <michel.fortin michelf.com> writes:
On 2009-09-10 21:02:05 -0400, Jason <jraddison gmail.com> said:

 I originally posted this in the bug group, but then realized that that 
 was probably  the wrong place. So ... sorry for cross-posting ... I 
 hope I'm not making my original mistake worse! Anyway ...
 
 Bug, or (more likely) I'm doing something wrong?
 
 seek seems to always throw:
 
 std.conv.ConvOverflowError: Error: overflow Conversion underflow
That's probably the same thing as this bug I reported a few days ago: <http://d.puremagic.com/issues/show_bug.cgi?id=3298> The bug is about std.file.read, but the resolution is in fstat64 on which half os std.file depends. -- Michel Fortin michel.fortin michelf.com http://michelf.com/
Sep 10 2009