4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: rename(from, to) deletes the file if "from" and "to" are not equal
12 but still refer to the same file. E.g., on a FAT32 filesystem
14 Solution: Go through another file name.
18 *** ../vim-7.2.075/src/fileio.c Fri Nov 28 21:26:50 2008
19 --- src/fileio.c Tue Dec 30 16:04:44 2008
23 if (mch_stat((char *)from, &st) < 0)
29 + char tempname[MAXPATHL + 1];
31 + /* It's possible for the source and destination to be the same file.
32 + * This happens when "from" and "to" differ in case and are on a FAT32
33 + * filesystem. In that case go through a temp file name. */
34 + if (mch_stat((char *)to, &st_to) >= 0
35 + && st.st_dev == st_to.st_dev
36 + && st.st_ino == st_to.st_ino)
38 + /* Find a name that doesn't exist and is in the same directory.
39 + * Move "from" to "tempname" and then to "to". */
40 + if (STRLEN(from) >= MAXPATHL - 5)
42 + STRCPY(tempname, from);
43 + for (n = 123; n < 99999; ++n)
45 + sprintf(gettail(tempname), "%d", n);
46 + if (mch_stat(tempname, &st_to) < 0)
48 + if (mch_rename((char *)from, tempname) == 0)
50 + if (mch_rename(tempname, (char *)to) == 0)
52 + /* Strange, the second step failed. Try moving the
53 + * file back and return failure. */
54 + mch_rename(tempname, (char *)from);
57 + /* If it fails for one temp name it will most likely fail
58 + * for any temp name, give up. */
68 * Delete the "to" file, this is required on some systems to make the
69 * mch_rename() work, on other systems it makes sure that we don't have
70 *** ../vim-7.2.075/src/version.c Wed Dec 24 14:24:41 2008
71 --- src/version.c Tue Dec 30 16:09:51 2008
75 { /* Add new patch number below this line */
81 FATAL ERROR! SYSTEM HALTED! - Press any key to continue doing nothing.
83 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
84 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
85 \\\ download, build and distribute -- http://www.A-A-P.org ///
86 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///