Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
2GB limit
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00273939
Message ID:
00274534
Views:
30
Or, if you have access to Visual C++
'File, New, Projects, Console Application, simple application'

And paste this to the .cpp file. This is a translation of the previous Visual Foxpro code, but this can correctly identify a file size over 2GB.
#include "stdafx.h"
#include <io.h>
#include <fcntl.h>

int main(int argc, char* argv[])
{
    const unsigned long ntablelimit = 2147483647UL;
    int fh1, nretval;
    short nheader, nrecsize;
    unsigned long nnewsize, nmaxrecords;
    __int64 ndbfsize;

    nretval = 0;

    if( (fh1 = _open( argv[1], _O_RDWR | _O_BINARY | _O_RANDOM )) == -1 ) {
      printf("Error opening File!\n");
      nretval = 1;
    }
    else {
      ndbfsize = _filelengthi64(fh1);
      if (ndbfsize > ntablelimit) {
        _lseek(fh1, 8L, SEEK_SET);
        _read(fh1, &nheader, 2);
        _read(fh1, &nrecsize, 2);
        nmaxrecords = (ntablelimit - nheader) / nrecsize;
        nnewsize = nmaxrecords * nrecsize + nheader;
        _chsize(fh1, nnewsize);
        _lseek(fh1, 4L, SEEK_SET);
        _write(fh1, &nnewsize, 4);
        _close(fh1);
      }
    }
    return nretval;
}
>Because you know that the current file size is over the limit, simply comment out this verification, so the part of the routine that shorten the file do its work.
>
>* if lnFileSize > TableLimit
>...
>* endif
>
>>I tried this but the line: lnFileSize=fseek(handle,0,2) returns 0.
>>

Just an opinion... Not a fact.
Previous
Reply
Map
View

Click here to load this message in the networking platform