Edit report at https://bugs.php.net/bug.php?id=41985&edit=1
ID: 41985 Comment by: cmbecker69 at gmx dot de Reported by: marc dot bau at gmx dot net Summary: rename doesn't work Status: Open Type: Feature/Change Request Package: Feature/Change Request Operating System: Windows PHP Version: 5.2.3 Block user comment: N Private report: N New Comment: This issue is solved since PHP 5.3.0 (released 2009-06-30). rename() works atomic on Windows due to the use of MoveFileEx(..., ..., MOVEFILE_REPLACE_EXISTING) (see virtual_rename() in TSRM/tsrm_virtual_cwd.c resp. VCWD_RENAME() in TSRM/tsrm_virtual.cwd.h). So this issue can be closed. Previous Comments: ------------------------------------------------------------------------ [2009-12-08 06:10:18] rainmanhhh at tom dot com rename should be remake to copy + unlink to keep php do the same behavior on windows & *nix ------------------------------------------------------------------------ [2007-07-14 12:58:22] marc dot bau at gmx dot net Well, if this rename is not possible atomically (how bad this ever is), i think PHP should handle the copy/unlink logic in background if i use "rename()". I simply don't like to think about possible platform dependencies (i don't know anything about) and hack around in a bad way that additional produce an error with "E_ALL & ~E_NOTICE" i cannot circumvent. ------------------------------------------------------------------------ [2007-07-14 10:35:16] der...@php.net I actually agree with that... however, it's not possible to do this atomically on windows if the file you're moving to exists. The only option is to unlink() the target and then do the rename() but that leaves a race condition. I don't think that is solvable on Windows. ------------------------------------------------------------------------ [2007-07-13 20:57:49] marc dot bau at gmx dot net Do you know how this works on *nix systems? Well i will tell you - it will *move* the "new file" over the "old file" in an atomic rename. This is what PHP needs to handle on Windows, too. I don't need any extras on *nix to rename. And PHP internal command should work platform independent. This bug should be fixed to make sure the code runs on windows in the *same way* as it does on *nix systems. What is so difficult to understand about this? Writing write code once, *run everywhere* is not possible with this bug. ------------------------------------------------------------------------ [2007-07-13 20:48:09] tony2...@php.net Please open a dictionary and translate the error message: PHP Warning: rename(C:\temp\tmp_file.txt.new,C:\temp\tmp_file.txt): ****File exists**** in C:\Temp\rename-test.php on line 2 It says FILE EXISTS, don't you see it? Please do NOT reopen the report again. Thank you. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=41985 -- Edit this bug report at https://bugs.php.net/bug.php?id=41985&edit=1