Bruno Haible <br...@clisp.org> writes: > Ben Pfaff wrote: >> Here is a gnulib commit that I am proposing. It (cross)compiles >> on Mingw, but I am waiting to hear back from my Windows tester to >> find out whether it actually solves the problem for him. > > How does MoveFileEx with MOVEFILE_REPLACE_EXISTING behave when > the destination file exists and is a hard link [1] to another file? Will > the other file see some changes? I.e. will the hard linked file be > overwritten, or will the hard link be broken (as on POSIX systems)?
The hard link is broken, according to Michel Boaventura: > Done. I've created two files, A and B. Then I create a hardlink to A, called > C. Look: > > C:\DOCUME~1\ADMINI~1\Desktop>more A > lallalla > > C:\DOCUME~1\ADMINI~1\Desktop>more B > conteudo original!!! > > C:\DOCUME~1\ADMINI~1\Desktop>more C > lallalla > > Then I did: > C:\DOCUME~1\ADMINI~1\Desktop>a.exe B C > renaming B as C... success > > Now I get: > C:\DOCUME~1\ADMINI~1\Desktop>more A > lallalla > > C:\DOCUME~1\ADMINI~1\Desktop>more C > conteudo original!!! > > In other words, A keeps it original content. where a.exe was created from the following simple program: #include <stdio.h> #include <stdlib.h> #define WIN32_LEAN_AND_MEAN #include <windows.h> int main(int argc, char *argv[]) { if (argc != 3) { fprintf (stderr, "usage; %s SOURCE DEST\n", argv[0]); return EXIT_FAILURE; } printf ("renaming %s as %s... ", argv[1], argv[2]); if (MoveFileEx (argv[1], argv[2], MOVEFILE_REPLACE_EXISTING)) printf ("success\n"); else printf ("error %d\n", GetLastError ()); return 0; } -- Ben Pfaff http://benpfaff.org