diff options
author | Richard M. Stallman <rms@gnu.org> | 2005-06-23 21:29:26 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 2005-06-23 21:29:26 +0000 |
commit | de432eaadb3d58781cd68dd6d5d09f8277a6226e (patch) | |
tree | e512338af90b0a0f9e3c819214b248a7e6b1b595 /src | |
parent | ca18655a9b6568ff81eb794156cf308ab9ca527a (diff) | |
download | emacs-de432eaadb3d58781cd68dd6d5d09f8277a6226e.tar.gz |
(Frename_file): Preserve owner and group, if possible.
Diffstat (limited to 'src')
-rw-r--r-- | src/fileio.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/fileio.c b/src/fileio.c index 537b7f4d10d..6bdc030bc6c 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2775,6 +2775,7 @@ This is what happens in interactive use with M-x. */) { if (errno == EXDEV) { + struct stat data; #ifdef S_IFLNK symlink_target = Ffile_symlink_p (file); if (! NILP (symlink_target)) @@ -2787,6 +2788,11 @@ This is what happens in interactive use with M-x. */) so don't have copy-file prompt again. */ NILP (ok_if_already_exists) ? Qnil : Qt, Qt, Qnil); + + /* Preserve owner and group, if possible (if we are root). */ + if (stat (SDATA (encoded_file), &data) >= 0) + chown (SDATA (encoded_file), data.st_uid, data.st_gid); + Fdelete_file (file); } else |