|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-06-03 03:30 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 10:00:01 2025 UTC |
We need a move() function that works across filesystems. I don't care if it's thread-safe. Rename() on my system used to do this until version 4.04pl1. Now my scipts are broken. (I'm sure I'm not the only one.) This should work for the simplest case (where both $src and $dest are regular files): function move($src, $dest) { $srcstat = stat($src); $deststat = stat(dirname($dest)); if($srcstat[1] == $deststat[1]) { $rc = rename($src, $dest); } else { $rc = copy($src, $dest); if($rc) { $rc = (unlink($src) == 0); if( !$rc) unlink( $dest); } } return $rc; }