jkuchar/BigFileTools

realpath returns wrong results for files > 2GB

Closed this issue · 6 comments

Env.: PHP 5.3.5, 64bit machine with 32bit Suse linux 11.4
Tried with 670MB, 2.6GB, 4.6GB and 6.8GB files and symlinks to them.

For regular files the behavior is consistently wrong: if file size is over PHP_INT_MAX, realpath return FALSE. Results for symlinks are rather unsure: if you call clearstatcache before realpath, you'll get the same as with regular files. Without clearstatcache however, realpath for first time return FALSE, then after refreshing the page it starts returning resolved symlink (= absolute path to file). If you don't refresh the page for approx 30sec, you're back on the beginning - first FALSE, then correct path.

This affects mainly the sizeCurl method - if realpath (that is, this->$path after calling absolutizePath) returns FALSE, then the address resolves to file:// and the size of current directory is returned.

The same applied for regular files on FAT32 partition (no symlinks of course and only the two smallest).

Found some realpath replacement here: http://stackoverflow.com/questions/4049856/replace-phps-realpath , but didn't try it yet. Personally I'm using absolute paths whenever possible.

I'll check it on Linux Mint. Windows Server 2008/2003 not affected.

This PHP bug seems related (to #3 as well): https://bugs.php.net/bug.php?id=27792

Checking the return value of realpath() would be a good start.

Changed mechanism of setting path. Now throws exception. (branch: master)

Idea: if file:// is resolved to current directory, does it resolve relative paths?

Closed due to innactivity. Reopen anytime if it is still relevant.