Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fopen failing for binary file

I have a huge binary file which is 2148181087 bytes (> 2gb)

I am trying to do fopen (file, "r") and it failed with

Can not open: xyz file (Value too large to be stored in data type)

I read on the man page EOVERFLOW error is received when the file size > 2gb.

The weird thing is, I use a different input file which is also "almost" as big as the first file 2142884400 bytes (also >2gb), fopen works fine with this.

Is there any cutoff on the file size for fopen or is there any alternate way to solve this?

like image 794
Jitesh Dani Avatar asked Mar 28 '26 08:03

Jitesh Dani


1 Answers

The cutoff is 2GB which, contrary to what you may think, is not 2,000,000,000 (2x10003).

It's 2,147,483,648 (2x10243). So your second file, which works, is actually less than 2GB in size).

2GB, in the computer world, is only 2,000,000,000 in the minds of hard drive manufacturers so they can say their disks are bigger than they really are :-) - it lets them say their disks are actually 2.1GB.

like image 81
paxdiablo Avatar answered Mar 29 '26 22:03

paxdiablo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!