ID:               44805
 User updated by:  rasmus at mindplay dot dk
 Reported By:      rasmus at mindplay dot dk
 Status:           Open
 Bug Type:         Filesystem function related
 Operating System: WindowsXP/DebianLinux
 PHP Version:      5.2.5
 New Comment:

File rename with overwrite code for Windows here:

http://rikkus.info/rename-with-overwrite-on-windows.html


Previous Comments:
------------------------------------------------------------------------

[2008-04-23 06:53:09] rasmus at mindplay dot dk

Description:
------------
The behavior of rename() is inconsistent between Linux and Windows.

On Linux, the rename() function is atomic - you can rename() one file
over an existing file, and the replacement is atomic.

On Windows, you cannot rename over an existing file.

Reproduce code:
---------------
<?php

file_put_contents("file1.txt", "this is file 1");
file_put_contents("file2.txt", "this is file 2");

rename("file1.txt", "file2.txt");

echo "reading file 2: ";
readfile("file2.txt");

?>

Expected result:
----------------
reading file 2: this is file 1


Actual result:
--------------
On Linux: (CORRECT)

reading file 2: this is file 1

On Windows: (INCORRECT)

Warning: rename(file1.txt,file2.txt) [function.rename]: File exists in
C:\Web3\test\rename\test.php on line 6
reading file 2: this is file 2



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44805&edit=1

Reply via email to