#44870 [Opn->Fbk]: rename() on directory deletes same named file

From: Date: Wed, 30 Apr 2008 14:17:26 +0000
Subject: #44870 [Opn->Fbk]: rename() on directory deletes same named file
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-124610@lists.php.net to get a copy of this message
ID: 44870 Updated by: pajoye@php.net Reported By: ant@php.net -Status: Open +Status: Feedback Bug Type: Streams related Operating System: Windows/XP PHP Version: 5.3CVS-2008-04-30 (snap) -Assigned To: +Assigned To: pajoye New Comment: "Calling rename() on a directory where there is already a file with the new name does something odd, it renames the directory but also deletes the file." Can you test it with 5.2.x please? I know that rename on windows will not rename a file when a directory already exists with the same (new) name. I'm not sure about renaming a directory. But the general idea is to replace a file if it is named using the new name (all platforms). Previous Comments: ------------------------------------------------------------------------ [2008-04-30 14:09:56] ant@php.net Description: ------------ Calling rename() on a directory where there is already a file with the new name does something odd, it renames the directory but also deletes the file. If this is in fact a bug then the test case rename_variation3.phpt will need to be fixed up. Reproduce code: --------------- <?php $file_path = dirname(__FILE__); $filename = "$file_path/rename_variation3.tmp"; $dirname = "$file_path/rename_variation3_dir"; mkdir($dirname); $fp = fopen($filename, "w"); fclose($fp); var_dump( rename($dirname, $filename) ); echo "Done\n"; ?> Expected result: ---------------- A directory called rename_variation3.tmp and also a file called rename_variation3.tmp Actual result: -------------- A directory called rename_variation3.tmp and no file..! ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44870&edit=1

« previous php.bugs (#124610) next »