Re: How to deal with big-size files??



هنداوى wrote:
What can i do to open , write and seek in file with size 2 GB or more

I know that you r limited with int type size which is 32-bit but how
programs like gzip , zip read and write from files with big size like
2-GB

how can i break this limit in C or even C++

The size of an int isn't relevant; the relevant functions are fseek()
and ftell(), and they use long, not int.
'long' is only guaranteed to be at least 32 bits; it can be larger
than that, and on many systems it is. On systems where 'long' is a 64-
bit type, there is no problem (for now - wait a few decades and even
64 bits might not be enough).

I'm not very familiar with systems where files can be greater than
2GB, but long is too small to hold a file length, so I'll let others
tell you what to do in that case. However, in principle even when
'long' is only 32 bits, you could handle files longer than 2GB by
using fgetpos() and fsetpos() instead of fseek() and ftell(). The
interface is clumsier, but it's still workable. However, I know that
on at least some systems, the ability to work in that fashion to
handle files larger than 2GB is deliberately disabled; you have to use
special functions that are not defined by the C standard to access the
part of a long file that is after an offset of LONG_MAX.
.



Relevant Pages

  • Re: TR 24731 approved
    ... the file system), or just use intmax_t ... they're tied to a specific type, long int. ... would be to change fseek() and ftell() to use a different type, ...
    (comp.std.c)
  • Re: questions on ftell and fopen
    ... int main(int argc, char *argv) ... the fseek and ftell functions do not necessarily deal in pure ...
    (comp.lang.c)
  • Re: fopen
    ... appending and reading as well. ... Return type for ftell is long. ... fseek returns int (-1 on error, ...
    (comp.lang.c)
  • Re: Compiling .java files
    ... public static native String PE_GetSmartCode(String targetStr, int ... public static native StringPE_GetPhonemes(String targetStr, ... phonemesSize, String targetStr, int type, int mode); ...
    (comp.lang.java.programmer)
  • Re: panic: kmem_map too small
    ... endeavour:~# sysctl hw.busdma ... static void bge_tick; ... int type; ...
    (freebsd-stable)