|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-02-25 02:10 UTC] clint at ubuntu dot com
Description:
------------
When a user tries to rename a directory accross filesystems, they are presented
with this warning:
PHP Warning: rename(): The first argument to copy() function cannot be a
directory in Command line code on line 1
PHP Warning: rename(t2,/var/run/test/t2): Invalid cross-device link in Command
line code on line 1
To contrast this, running 'mv t2 /var/run/test/t2' works without any problems.
Test script:
---------------
$ sudo mkdir /var/run/test && sudo chown `whoami` /var/run/test
$ mkdir t2
$ touch t2/a.file
$ php -r "rename('t2','/var/run/test/t2');"
Expected result:
----------------
I would expect the directory to be copied with its contents in their entirety to
the new destination, *OR* at the very least, an error message that specifies that
one cannot rename directories, as its confusing that it mentions copy during a
rename.
Actual result:
--------------
PHP Warning: rename(): The first argument to copy() function cannot be a
directory in Command line code on line 1
PHP Warning: rename(t2,/var/run/test/t2): Invalid cross-device link in Command
line code on line 1
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 15 10:00:01 2025 UTC |
Workaround: exec("mv ".escapeshellarg($strOldPath)." ".escapeshellarg($strNewPath));