This is the mail archive of the cygwin-developers@sourceware.cygnus.com mailing list for the Cygwin project. See the Cygwin home page for more information.
Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: B20: mv deletes files on error (NT)


Chris Faylor wrote:
> 
> Actually, was it even your change, Corinna?  I can't find it in the
> ChangeLog.

It's in the ChangeLog, dated 12-Feb-99.

> Has someone come up with a patch for `mv' yet?  If so, please send it to
> me with a ChangeLog entry and I'll get it into Cygnus's sources and look
> into getting it into the FSF sources as well.

I have a patch, made for me at home. It's not very clean, I fear, but
if you think that it's ok...
It handles the two cases, to rename a file with only changing the
case (first additional line) or changing `foo.exe' to 'foo', including
changing the case (next three lines).
I have patched earlier `ln' and `cp', to eliminate the boring `.exe'
problem with the three line patch. I have attached this patches, too.

Regards,
Corinna

ChangeLog: (Date is a lie)
==========

Tue Mar 30 11:00:00 1999  Corinna Vinschen  <corinna.vinschen@cityweb.de>

	* fileutils/src/mv.c: Handles renaming files to another case.
	* fileutils/src/mv.c: Handles renaming files to same name, but
	without `.exe' suffix.
	* fileutils/src/cp.c: Ditto for copying files.
	* fileutils/src/ln.c: Ditto for linking files.

======= snip =======
--- mv.c.old    Tue Mar 30 10:41:46 1999
+++ mv.c        Tue Mar 30 03:12:56 1999
@@ -248,6 +248,12 @@ do_move (const char *source, const char
     {
       if (source_stats.st_dev == dest_stats.st_dev
          && source_stats.st_ino == dest_stats.st_ino
+#if defined (__CYGWIN__) || defined (__CYGWIN32__)
+          && strcasecmp (source, dest) != 0
+          && (strlen (source) < 5
+             || strncasecmp (source, dest, strlen (dest)) != 0
+             || strcasecmp (source + strlen (source) - 4, ".exe") != 0)
+#endif
         )
        {
          error (0, 0, _("`%s' and `%s' are the same file"), source, dest);

--- cp.c.old    Tue Mar 30 10:56:45 1999
+++ cp.c        Fri Nov 13 00:44:32 1998
@@ -659,6 +659,11 @@ copy (const char *src_path, const char *

          if (src_sb.st_ino == dst_sb.st_ino
              && src_sb.st_dev == dst_sb.st_dev
+#if defined (__CYGWIN__) || defined (__CYGWIN32__)
+             && (strlen (src_path) < 5
+                 || strncasecmp (src_path, dst_path, strlen (dst_path)) != 0
+                 || strcasecmp (src_path + strlen (src_path) - 4, ".exe") != 0)
+#endif
             )
            {
              if (flag_hard_link)
--- ln.c.old    Tue Mar 30 10:56:36 1999
+++ ln.c        Fri Nov 13 00:52:48 1998
@@ -204,6 +204,11 @@ do_link (const char *source, const char
       && (!symlink || stat (source, &source_stats) == 0)
       && source_stats.st_dev == dest_stats.st_dev
       && source_stats.st_ino == dest_stats.st_ino
+#if defined (__CYGWIN__) || defined (__CYGWIN32__)
+      && (strlen (source) < 5
+         || strncasecmp (source, dest, strlen (dest)) != 0
+         || strcasecmp (source + strlen (source) - 4, ".exe") != 0)
+#endif
       /* The following detects whether removing DEST will also remove
         SOURCE.  If the file has only one link then both are surely
         the same link.  Otherwise check whether they point to the same
@@ -250,6 +255,11 @@ do_link (const char *source, const char
            return 0;
        }
       else if (!remove_existing_files
+#if defined (__CYGWIN__) || defined (__CYGWIN32__)
+              && (strlen (source) < 5
+                  || strncasecmp (source, dest, strlen (dest)) != 0
+                  || strcasecmp (source + strlen (source) - 4, ".exe") != 0)
+#endif
              )
        {
          error (0, 0, _("%s: File exists"), dest);