Re: Open Large Files in C++
looks like you are using 32bit integers to do 'something' with your file (seeks, locks, filesize, ...) but a 32bit int can only hold a value from -2billion to +2billion.
You'll need to change your code to use 64bit integers.
Also, it's posible that whatever API's/ libraries or whatever you're using don't support files above 2Gb in size.
Also, if you use memorymapping, then you can't map a bigger file than the amount of available memory in your process, which is 2gb at best (minus whatever is taken by system dll's, and accounting for memory fragmentation).
Re: Open Large Files in C++
Hi OReubens,
Thanks for your reply. Unfortunately, I can't move to 64-bit system yet. Is it possible to read/write data from/to the file in 32-bit system which is larger than 4GB?
Regards,
Abhishek Madaan
Re: Open Large Files in C++
Using 64 bit integers has no dependance on bitness of your system. Though without seeing your code how you do writing it's not possible for us to make any suggestion on code improvement.
Re: Open Large Files in C++
you can read a file larger than 4gb with Win32 using 32bit code but...
you can't read all the file at once, you'll have to read it in smaller chunks and process each of the smaller chunks.
Win32 only allow you a max of 2gb (3gb with some messing around) per process, and part of that will be already used bb system DLL's and will be fragmented.
If you do seeks, get the file size, try to lock parts of the file, you will need to use 64bit integers, and yes, you can do this in Win32.
Some libraries/api functions/objects don't support files larger than 2gb. (or 4gb if they use unsigned integers) This could be your problem, but we have no way of knowing since you haven't told what you're using/doing.
Re: Open Large Files in C++
The only small piece of advice I can offer is to look at chapter 10 of 'Windows via c/c++ 5th edition' by Jeffrey Richter where he discusses using files greater than 4gb.