Thread: Builder C++ large files support for simple C program

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    2

    Question Builder C++ large files support for simple C program

    I had to write a C program and ran it on Solaris server(only command line access). It seemed to me that it was easier to debug program on my notebook under Windows and then with minor modifications copy it to the server and ran.
    I wrote a program at C++Builder 6.

    Hovewer, there some inconsistencies between Borland and Unix <sys/stat.h> library. CC in Solaris offers functions like stat64, fseeko64 etc which designed to work with large files > 2Gb... but in Builder I can find only standard stat, fseek, etc,

    At first, I debugged program on my Windows PC with small files. Hovewer, now I when I run the program on the server, sometimes I get "Core dump" error especially for very large files. It seems a kind of overflow. But I can't test program in a good debugger in Windows because of Builder <sys/stat.h> problem.

    Pleese, give me advise, what is the easiest way to solve this

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    C99 has fsetpos() and fgetpos(), which were introduced to solve this exact problem. The offsets that they use are 64-bit integers, I believe. However, I'm not sure if Borland C++ would support them. You might have to use compiler-specific functions.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    2
    Quote Originally Posted by dwks View Post
    C99 has fsetpos() and fgetpos(), which were introduced to solve this exact problem. The offsets that they use are 64-bit integers, I believe.
    Sorry, in all compilers I saw...f_post from fgetpos is long not 64-bit integer....As I mentioned above ... I just looking for a Windows compiler with good debugger which has functions like fsetpos64() in stdio.h

    I found _stati64() but I can't find Builder peers for Unix fgetpos64(), and fseeko64() functions
    Last edited by Murfury; 11-22-2007 at 12:12 PM.

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    [edit]
    Sorry, in all compilers I saw...f_post from fgetpos is long not 64-bit integer....As I mentioned above ... I just looking for a Windows compiler with good debugger which has functions like fsetpos64() in stdio.h
    Did you try GCC via Code::Blocks? [/edit]

    On the one hand, fgetpos() and fsetpos() definitely have a greater range than fseek() and ftell(): http://publications.gbdirect.co.uk/c...access_io.html:
    Note that for ftell and fseek it must be possible to encode the value of the file position indicator into a long. This may not work for very long files, so the Standard introduces fgetpos and fsetpos which have been specified in a way that removes the problem.
    Perhaps f[gs]etpos() use unsigned variables at least, which would allow 4 GB files. (Several older file systems limit you to this size anyway.)

    On the other hand, it does seem that f[gs]etpos64() have a greater range than ordinary f[gs]etpos(): http://www.mkssoftware.com/docs/man3/fgetpos.3.asp

    It seems that f[gs]etpos64() are part of this library, perhaps you can get it for your intended platforms. http://www.mkssoftware.com/docs/man5/lf64.5.asp
    This also looks like it might have some useful information: http://www.mkssoftware.com/docs/man5/lfcompile.5.asp

    Nowhere is the actual range of f[gs]etpos() mentioned, although I imagine it must be at least 4GB, because it's supposed to be greater range than fseek()/ftell(), which support 2GB (they use longs).
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Deployment and DLL/OCX Files?
    By dfghjk in forum C++ Programming
    Replies: 5
    Last Post: 06-16-2008, 02:47 AM
  2. using mmap for copying large files
    By rohan_ak1 in forum C Programming
    Replies: 6
    Last Post: 05-13-2008, 08:12 AM
  3. Replies: 8
    Last Post: 04-12-2007, 12:42 PM
  4. Help on renaming files using a C program
    By sangken in forum C Programming
    Replies: 21
    Last Post: 08-03-2006, 05:30 PM
  5. large program code ,please help
    By Ash1981 in forum C Programming
    Replies: 14
    Last Post: 01-30-2006, 06:16 AM