Bug 4060 – Phobos + linux problems with files > 2GB
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2010-04-04T15:50:00Z
Last change time
2015-06-09T05:10:39Z
Assigned to
nobody
Creator
egonelbre
Comments
Comment #0 by egonelbre — 2010-04-04T15:50:46Z
Phobos is unable to seek/position positions that are > int.max
---
import std.stdio;
import std.string;
import std.stream;
int main(string[] args){
auto file = new BufferedFile(args[1]);
file.seek(cast(ulong)int.max + cast(ulong) atoi(args[2]), SeekPos.Set);
writefln("%d", file.position);
return 1;
}
---
Problem also happens with trying to use MMFile with files larger than int.max.
Probably related to bug 3409.
Comment #1 by Justin.SpahrSummers — 2010-04-05T01:06:44Z
This strikes me as a mistake in the Phobos declaration of seek(). The underlying stdio fseek() function can only take longs as offsets, and Phobos' seek() is defined the same way; however, a 'long' in C almost always corresponds to an 'int' in D.
It's definitely a bug one way or the other, but to work around it you may want to use offsets from SEEK_CUR instead of SEEK_SET.