Jim Michaels - 2011-03-13

I had to write my own custom 64-bit filesystem support for windows for my Thunderbird Inbox Splitter (after 2GiB, Thunderbird either goes nuts or stops working, and lots of email clients are like that) because stdio.h was 32-bit and thus had 2GiB file size limitations on ftell() and fseek(), but not fread() and fwrite(). 

microsoft overcame these limiations by implementing 64-bit versions of these C lib functions (but of course using their own proprietary 64-bit integer type).
http://msdn.microsoft.com/en-us/library/0ys3hc0b.aspx
http://msdn.microsoft.com/en-us/library/75yw9bf3.aspx

however, _fseeki64 and _ftelli64 are buggy apparently.

LIke I said, I have developed a windows library of functions that are 64bit, work every time, and allow you to read lines, all based on file handles.

   231: bool __IsFrom(char * line) {
   250: bool __IsBlankLine(char * line) {
   255: bool __FileSeek(HANDLE h, uint64_t pos) {
   272: bool __FileTell(HANDLE h, uint64_t& pos) {
   292: bool __FileGetLine(HANDLE h, char * dstLine, int bufsize) {
   344: bool __FileWriteLine(HANDLE h, char * line) {
   357: HANDLE __FileOpenRead(string& filepath) {
   371: HANDLE __FileOpenWriteTruncate(string& filepath) {
   402: bool __FileEOF(HANDLE h) {
   442: void __PrintError(char * str) {
   472: bool __Head(string& filepath) {
   503: bool __CountEmails(string& infilepath, uint64_t& emailCount) {
   559: bool __GetNewUUIDString(string& s) {
   618: bool __SplitFile(string& filepathin, string& filepathout, uint64_t splitPointe, uint64_t& emailCount) {
   887: bool __ExtractDirFromFilepath(string& infilepath, string& outfiledir) {
   897: bool __msfFromFilepath(string& infilepath, string& outfilepath) {
   909: bool __FileExists(string& filepath) {
   939: bool __SplitNTimes(string& infilepath, uint64_t numSplits) {

you can probably rewrite some of these to use string instead of char * if you would like.

the code is GPL3'd.