I use PHP's copy() function to copy files. To my horror, I have discovered that it only copied 2 588 396 096 bytes of my 15 473 297 984 bytes large .7z file.
It's being copied between two local disks. Both use NTFS. PHP 7.4.11. Windows 10 Pro 2004.
Please don't tell me to use exec('xcopy blabla') or something like that since this breaks cross-platformness which is a must for me to retain. I'd like to understand why copy(), like so many other built-in PHP functions, has some serious, undocumented limitation. This was unexpected because I didn't think that something like copying a file could possibly be broken.
I did read a user-submitted comment saying something relevant to this, but he claims it stops at 4 GB (which is not the case for me), and he doesn't explain why.
This is an important task and I can't have it just silently "cut off" files like this. It's especially worrying that it didn't even hit the rumored 4 GB limit.
My Windows is 64-bit and so is all my other software, BTW, so it cannot be explained by me using a 32-bit legacy OS.
Minimal code example:
var_dump(copy('C:\test\big.7z', 'D:\test\big.7z'));
Result (after a few seconds):
bool(true)
The target file is 2.41 GB -- a fraction of the actual file. It falsely returns "true" even though it was not successful? It apparently thinks that it was successful.
No error whatsoever is logged. Yes, error logging is turned on.