std.stdio.File.seek error
stunaep via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Mar 13 17:12:46 PDT 2016
On Sunday, 13 March 2016 at 12:21:11 UTC, Nicholas Wilson wrote:
> On Sunday, 13 March 2016 at 10:32:41 UTC, stunaep wrote:
>> I have a very large file I need to read data from at certain
>> positions, but I have run into this error
>>> std.conv.ConvOverflowException at std\conv.d(1328): Conversion
>>> positive overflow
>> when seeking to 6346890680. Seeking to smaller values such as
>> 3580720 work with no problem. The file is well over 8GB, so it
>> must be able to read data at positions that high.
>
> are you on a 32 or 64 bit system?
> You could try 2 or more consecutive relative seeks in place of
> an absolute seek.
> i.e.
> File f = ... ;
> f.seek(173445340 , SEEK_SET);
> f.seek(173445340 , SEEK_REL);
> also what does
> f.seek(0,SEEK_END);
> writeln(f.tell());
> print?
I'm on 64 bit but it needs to work on both. It works for anything
between 0 and 2147483647.
> f.seek(0,SEEK_END);
> writeln(f.tell());
that throws an error before reaching f.tell()
> std.exception.ErrnoException at std\stdio.d(920): Could not seek
> in file `./file.dat' (Invalid argument)
> ----------------
> 0x000000013FE67868 in @safe bool
> std.exception.errnoEnforce!(bool, "std\stdio.d",
> 920uL).errnoEnforce(bool, lazy immutable(char)[])
> 0x000000013FE4E7D3 in @trusted void std.stdio.File.seek(long,
> int)
Also, seeking relative to the current position throws the same
error as in the original post if it's over max signed int.
> f.seek(2147483647, SEEK_SET);
> writeln(f.tell()); // prints 2147483647
> f.seek(4, SEEK_CUR); // throws error
More information about the Digitalmars-d-learn
mailing list