comparison src/fileio.c @ 63719:c3da886cec72

(Frename_file): Preserve owner and group, if possible.
author Richard M. Stallman <rms@gnu.org>
date Thu, 23 Jun 2005 21:29:26 +0000
parents 23f332ae21c8
children f529a14158f8 d07fdd5d7d4e b7da78284d4c
comparison
equal deleted inserted replaced
63718:47f9bb41d144 63719:c3da886cec72
2773 || 0 > unlink (SDATA (encoded_file))) 2773 || 0 > unlink (SDATA (encoded_file)))
2774 #endif 2774 #endif
2775 { 2775 {
2776 if (errno == EXDEV) 2776 if (errno == EXDEV)
2777 { 2777 {
2778 struct stat data;
2778 #ifdef S_IFLNK 2779 #ifdef S_IFLNK
2779 symlink_target = Ffile_symlink_p (file); 2780 symlink_target = Ffile_symlink_p (file);
2780 if (! NILP (symlink_target)) 2781 if (! NILP (symlink_target))
2781 Fmake_symbolic_link (symlink_target, newname, 2782 Fmake_symbolic_link (symlink_target, newname,
2782 NILP (ok_if_already_exists) ? Qnil : Qt); 2783 NILP (ok_if_already_exists) ? Qnil : Qt);
2785 Fcopy_file (file, newname, 2786 Fcopy_file (file, newname,
2786 /* We have already prompted if it was an integer, 2787 /* We have already prompted if it was an integer,
2787 so don't have copy-file prompt again. */ 2788 so don't have copy-file prompt again. */
2788 NILP (ok_if_already_exists) ? Qnil : Qt, 2789 NILP (ok_if_already_exists) ? Qnil : Qt,
2789 Qt, Qnil); 2790 Qt, Qnil);
2791
2792 /* Preserve owner and group, if possible (if we are root). */
2793 if (stat (SDATA (encoded_file), &data) >= 0)
2794 chown (SDATA (encoded_file), data.st_uid, data.st_gid);
2795
2790 Fdelete_file (file); 2796 Fdelete_file (file);
2791 } 2797 }
2792 else 2798 else
2793 #ifdef NO_ARG_ARRAY 2799 #ifdef NO_ARG_ARRAY
2794 { 2800 {