|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-03-29 12:28 UTC] dianerrr at hotmail dot com
Description:
------------
I've noticed the following (cornercase of usage), but still faulty behavior of rename:
I mount a WindowsXP full control share
This share contains directories and all directories contain files and directories (otherwise reproduction will fail)
I created a piece of code that mounts a samba share and then I try to move the non-empty directory "EXAMPLE" to "EXAMPLE_OLD" so to have some form of rotation.
However the rename-function fails right after it created a directory named "EXAMPLE_OLD". So now I have two directories, the original (still non-empty) and the 'copy' (i didn't want) without any files.
It seems like the internals of rename are incompatible with WindowsXP + Samba share.
BTW: I tried the same items in normal bash and that worked flawlessly. I ran the PHP script as root on my bash and the WinXP share is fullcontrol to everyone.
Reproduce code:
---------------
---
From manual page: function.rename
---
#!/bin/php
<?php
shell_exec( "mount -t smbfs -o password=\"\" ". $this->url ." ". TEMP_MOUNT_TARGET );
$files = scandir( $inboxDir );
for( $i=0; $i<count( $files ); $i++ )
{
$file = $files[$i];
if( $file != "." && $file != ".." )
{
rename( $Dir ."/$file", $Dir ."/$file_old" );
//ERROR!
//Warning: rename(######,#######): Permission denied in ....
}
}
?>
Expected result:
----------------
Renamed directory on WinXP-share
Actual result:
--------------
Warning and a empty copy of directory on WinXP share
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 16:00:01 2025 UTC |
Does it work if you only call rename() in CLI, like this: # php -r 'rename("foo", "bar");'