D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4060 - Phobos + linux problems with files > 2GB
Summary: Phobos + linux problems with files > 2GB
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86 Linux
: P2 major
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-04 15:50 UTC by Egon Elbre
Modified: 2015-06-09 05:10 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Egon Elbre 2010-04-04 15:50:46 UTC
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 Justin Spahr-Summers 2010-04-05 01:06:44 UTC
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.