]> git.eshelyaron.com Git - emacs.git/commitdiff
* fileio.c (barf_or_query_if_file_exists): Use lstat.
authorJan Djärv <jan.h.d@swipnet.se>
Tue, 4 May 2004 13:54:50 +0000 (13:54 +0000)
committerJan Djärv <jan.h.d@swipnet.se>
Tue, 4 May 2004 13:54:50 +0000 (13:54 +0000)
  (Frename_file): Handle renaming of symlinks across file systems.

src/ChangeLog
src/fileio.c

index fbce94f2ecd88f8974bc59f053b7371f0f3189cf..9ff41a4ccc0e948c74cced2141e22bf8ad4cfccb 100644 (file)
@@ -1,3 +1,8 @@
+2004-05-04  Jan Dj\e,Ad\e(Brv  <jan.h.d@swipnet.se>
+
+       * fileio.c (barf_or_query_if_file_exists): Use lstat.
+       (Frename_file): Handle renaming of symlinks across file systems.
+
 2004-05-04  Kim F. Storm  <storm@cua.dk>
 
        * xdisp.c (Qtotal): New var.
index 1f7fd5753b5193816dd2c2d655cc92b4240fb421..04068e25f8962f8e849cd686dbb5c3711689fe94 100644 (file)
@@ -2349,7 +2349,7 @@ barf_or_query_if_file_exists (absname, querystring, interactive, statptr, quick)
 
   /* stat is a good way to tell whether the file exists,
      regardless of what access permissions it has.  */
-  if (stat (SDATA (encoded_filename), &statbuf) >= 0)
+  if (lstat (SDATA (encoded_filename), &statbuf) >= 0)
     {
       if (! interactive)
        Fsignal (Qfile_already_exists,
@@ -2684,11 +2684,11 @@ This is what happens in interactive use with M-x.  */)
   Lisp_Object args[2];
 #endif
   Lisp_Object handler;
-  struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
-  Lisp_Object encoded_file, encoded_newname;
+  struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
+  Lisp_Object encoded_file, encoded_newname, symlink_target;
 
-  encoded_file = encoded_newname = Qnil;
-  GCPRO4 (file, newname, encoded_file, encoded_newname);
+  symlink_target = encoded_file = encoded_newname = Qnil;
+  GCPRO5 (file, newname, encoded_file, encoded_newname, symlink_target);
   CHECK_STRING (file);
   CHECK_STRING (newname);
   file = Fexpand_file_name (file, Qnil);
@@ -2725,10 +2725,15 @@ This is what happens in interactive use with M-x.  */)
     {
       if (errno == EXDEV)
        {
-         Fcopy_file (file, newname,
-                     /* We have already prompted if it was an integer,
-                        so don't have copy-file prompt again.  */
-                     NILP (ok_if_already_exists) ? Qnil : Qt, Qt);
+          symlink_target = Ffile_symlink_p (file);
+          if (NILP (symlink_target))
+            Fcopy_file (file, newname,
+                        /* We have already prompted if it was an integer,
+                           so don't have copy-file prompt again.  */
+                        NILP (ok_if_already_exists) ? Qnil : Qt, Qt);
+          else
+            Fmake_symbolic_link (symlink_target, newname,
+                                 NILP (ok_if_already_exists) ? Qnil : Qt, Qt);
          Fdelete_file (file);
        }
       else