[vlc-commits] commit: Win32: vlc_rename() needs to erase target file first, fixes #3521 ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Fri Apr 16 19:02:56 CEST 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Apr 16 20:02:06 2010 +0300| [5581a1ec59bde33d52713f232620777b3c62628d] | committer: Rémi Denis-Courmont 

Win32: vlc_rename() needs to erase target file first, fixes #3521

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5581a1ec59bde33d52713f232620777b3c62628d
---

 src/text/filesystem.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/src/text/filesystem.c b/src/text/filesystem.c
index c270c86..34d03f4 100644
--- a/src/text/filesystem.c
+++ b/src/text/filesystem.c
@@ -520,7 +520,17 @@ int vlc_rename (const char *oldpath, const char *newpath)
     else
         return -1;
 #else
-    return _wrename (wold, wnew);
+    if (_wrename (wold, wnew) && errno == EACCES)
+    {   /* Windows does not allow atomic file replacement */
+        if (_wremove (wnew))
+        {
+            errno = EACCES; /* restore errno */
+            return -1;
+        }
+        if (_wrename (wold, wnew))
+            return -1;
+    }
+    return 0;
 #endif
 
 #endif



More information about the vlc-commits mailing list