Implement full support fo files larger than 2GB

Locked
soulhunter
getID3() v1 developer
Posts:40
Joined:Mon Jan 11, 2010 5:37 pm
Are you a spambot?:no
Location:Kaliningrad, Russia
Contact:
Implement full support fo files larger than 2GB

Post by soulhunter » Thu Feb 10, 2011 12:01 pm

In GetID3 there are some checks for support of files > 2GB, but such files produce many warnings/errors and many features (line ID3v1 tags) are simply disabled if filesize is > 2GB.
All of this is due to lack of PHP's INT64 support for 32bit mashines, but on 64bit machines PHP's integers are 64bit signed, so there is real posibility to implement 64bit limited file size support.

Simple code to check for 64bit integer:

Code: Select all

define('INT_64', is_int(pow(2, 31)));
Or there other ways, for example making use of PHP_INT_MAX (casting it to string and comparing with predefined string value) constant available since PHP 5.0.5

Also it is important to investigate the behaviour of some PHP's build'in functions, that are used by GetID3 (like filesize(), fseek(), ftell() etc.), to determine that they behave correctly with files larger than 2GB and return LONGINT integers correctly.

And if so, our INT_64 constant may be used everywhere to determine filesize > 2GB support.

I am ready to help you, James, to investigate this problem, to do the required tests and implement this very important in our days feature.

James Heinrich
getID3() v1 developer
Posts:1477
Joined:Fri May 04, 2001 4:00 pm
Are you a spambot?:no
Location:Northern Ontario, Canada
Contact:

Post by James Heinrich » Thu Feb 10, 2011 6:38 pm

I'm working on getting a 64-bit PHP development machine. Side note to the curious: even with the unofficial 64-bit Windows PHP binaries, PHP_INT_MAX is still 2^31, since apparently the underlying C code is still using 32-bit longs.

Nevertheless, I can still write the code to support >2GB operations and rely on user testing for now. I'll advise when a test version is available.

soulhunter
getID3() v1 developer
Posts:40
Joined:Mon Jan 11, 2010 5:37 pm
Are you a spambot?:no
Location:Kaliningrad, Russia
Contact:

Post by soulhunter » Thu Feb 10, 2011 7:27 pm

I'm not using Windows, only for developement (because PHPED IDE, which i prefer, only exists for Windows), but in production am using Linux 64-bit mashines and many users do the same, so they have the posibility to process big files on their production servers. So I think, that the best practice would be (like in JavaScript) to determine the availability of this feature regardless of the software and use if it is available.

James Heinrich
getID3() v1 developer
Posts:1477
Joined:Fri May 04, 2001 4:00 pm
Are you a spambot?:no
Location:Northern Ontario, Canada
Contact:

Post by James Heinrich » Thu Feb 10, 2011 7:43 pm

Agreed. And v1.8.5 will included >2GB support, assuming it detects that 64-bit integers are available.

I installed 64-bit PHP on my Windows development server this morning, only to discover that doesn't help. I'm attempting to get a 64-bit linux installed on a local machine soon (tried already but it didn't like the installer). So, so far the >2GB code is untested, but if you have access to a 64-bit machine and want to test it, send me a PM.

James Heinrich
getID3() v1 developer
Posts:1477
Joined:Fri May 04, 2001 4:00 pm
Are you a spambot?:no
Location:Northern Ontario, Canada
Contact:

Re: Implement full support fo files larger than 2GB

Post by James Heinrich » Sun Feb 13, 2011 12:48 am

Initial testing looks promising. Will release v1.8.5 once 64-bit support has been tested locally by me.

Locked