Hi SO,
The 'best practice' (as I see it) to atomically create a new file, is to open a temporary file (using tmpfile()), and then moving the file to it's final location.
However, this won't work well if the temporary file is on a different mountpoint, as this will result in the file gradually building up and additionally result in unneeded IO overhead.
Another option is to create a temporary file in the same directory as the final destination, but this has the disadvantage of creating a unusual file for a user (Apps such as MS Word and ViM do this, but I also consider this bad behaviour).
Is there a similar method as tmpfile() that will allow me to specify the mountpoint? I realize this probably doesn't exist built-into PHP, so a Posix/C-function or shell-call is also acceptable.