PATCH: Fix MoveFileEx() flags in MSVCRT rename()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[ Forwarding to wine-devel because it may be controversial, please 
  see comments below. ]

Patch: rename.diff
Martin Wilck <Martin.Wilck@fujitsu-siemens.com>

Patch against: CVS 2002-09-16

Modified files:
        - wine/dlls/msvcrt: file.c

Log Message:
        * Fix MoveFileEx() flags in MSVCRT rename()/_wrename()

Comment:
From MSDN docs for rename()/_wrename():

"The new name must not be the name of an existing file or directory.
You can use rename to move a file from one directory or device to another
by giving a different path in the newname argument."

This clearly says that MOVEFILE_REPLACE_EXISTING should _not_ be set,
while MOVEFILE_COPY_ALLOWED is necessary to allow moving files between
drives. I have verified that windows actually behaves as stated in the
MSDN excerpt above. Perhaps someone knows why the flags have been set
this way - is it a workaround for some hidden feature in some Windows version?

Index: dlls/msvcrt/file.c
===================================================================
RCS file: /home/wine/wine/dlls/msvcrt/file.c,v
retrieving revision 1.37
diff -u -r1.37 file.c
--- dlls/msvcrt/file.c	12 Sep 2002 22:28:01 -0000	1.37
+++ dlls/msvcrt/file.c	16 Sep 2002 09:16:07 -0000
@@ -2107,7 +2107,7 @@
 int MSVCRT_rename(const char *oldpath,const char *newpath)
 {
   TRACE(":from %s to %s\n",oldpath,newpath);
-  if (MoveFileExA(oldpath, newpath, MOVEFILE_REPLACE_EXISTING))
+  if (MoveFileExA(oldpath, newpath, MOVEFILE_COPY_ALLOWED))
     return 0;
   TRACE(":failed (%ld)\n",GetLastError());
   MSVCRT__set_errno(GetLastError());
@@ -2120,7 +2120,7 @@
 int _wrename(const WCHAR *oldpath,const WCHAR *newpath)
 {
   TRACE(":from %s to %s\n",debugstr_w(oldpath),debugstr_w(newpath));
-  if (MoveFileExW(oldpath, newpath, MOVEFILE_REPLACE_EXISTING))
+  if (MoveFileExW(oldpath, newpath, MOVEFILE_COPY_ALLOWED))
     return 0;
   TRACE(":failed (%ld)\n",GetLastError());
   MSVCRT__set_errno(GetLastError());


-- 
Martin Wilck                Phone: +49 5251 8 15113
Fujitsu Siemens Computers   Fax:   +49 5251 8 20409
Heinz-Nixdorf-Ring 1	    mailto:Martin.Wilck@Fujitsu-Siemens.com
D-33106 Paderborn           http://www.fujitsu-siemens.com/primergy







[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux