Re: fopen - File too large
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: fopen - File too large

From: Malcolm Dew-Jones <yf110@vtn1.victoria.tc.ca>
Date: Thu Jul 14 2005 - 05:17:47 CEST

Kasper Johansen (kasper@johansen.tdcadsl.dk) wrote:
: Hello group.

: I am trying to open a filepointer to a file which is above 2 gb. Because of
: PHP's integer type (or something like that) PHP cant handle files which
: filesize is above 2gb?

: As a workaround I have used this line of code:

: popen("cat /filenpathanddir", "r");

: My problem is that I want to jump around in the file (like fseek()), and I
: havent figured out how to do this while using popen() (and "cat"). I only
: have to read the last 5 mb of total 2,4 gb.

: Can anyone point me in the direction of how to solve this problem?

Your copy of php does not appear to be compiled with the 64 bit integer
sizes, which are required for files larger than 2 gb. That is required
since the library routines use integers in the file manipulations. This
is not php's fault, by the way.

A problem with 64 bit integers is that many applications make assumptions
about integer sizes, and so simply compiling an application to use larger
integer sizes can break things. There can also be some performance
aspects I believe (larger size data chunks can be slower to manipulate).
Therefore many applications are not compiled as 64 bit apps unless you do
that yourself, since very few tasks require access to such large files.

As with many applications that have this problem, you need to recompile
the application to natively use the necessary 64 bit integer sizes and
libraries. In this case you need to recompile php itself. I assume that
php will work with no problem when you do that, but have never tried it to
find out myself.

I notice that "http://ca.php.net/fopen", has a comment on this topic.
Search for "2gb" to find it on that page. That person describes how to
compile php with the compile options to allow large files to be accessed.

There are probably other references to this at the php site, I would look
in the install/compile readme files with the php source code.

--
This space not for rent.
Received on Mon Oct 17 21:06:49 2005