php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9499 move() function needed.
Submitted: 2001-02-28 11:32 UTC Modified: 2001-06-03 03:30 UTC
From: jjgignac at opengraphics dot com Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 4.0.4pl1 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jjgignac at opengraphics dot com
New email:
PHP Version: OS:

 

 [2001-02-28 11:32 UTC] jjgignac at opengraphics dot com
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;
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-06-03 03:30 UTC] sniper@php.net
This should be fixed with PHP 4.0.6, please try the 
latest release candidate:

http://www.php.net/~andi/php-4.0.6RC2.tar.gz

-Jani

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC