CVS rebase
[nedit-bw.git] / keep_state_for_bck_file.patch
blob051d83b86a86186c155f76652c345c0cf6363f6f
1 ---
3 source/file.c | 18 ++++++++++++++++--
4 1 file changed, 16 insertions(+), 2 deletions(-)
6 diff --quilt old/source/file.c new/source/file.c
7 --- old/source/file.c
8 +++ new/source/file.c
9 @@ -69,6 +69,7 @@ static const char CVSID[] = "$Id: file.c
10 #endif
11 #include <fcntl.h>
12 #endif /*VMS*/
13 +#include <utime.h>
15 #include <Xm/Xm.h>
16 #include <Xm/ToggleB.h>
17 @@ -1361,6 +1362,7 @@ static int writeBckVersion(WindowInfo *w
18 struct stat statbuf;
19 int in_fd, out_fd;
20 char *io_buffer;
21 + struct utimbuf utimbuf;
22 #define IO_BUFFER_SIZE ((size_t)(1024*1024))
24 /* Do only if version backups are turned on */
25 @@ -1390,8 +1392,8 @@ static int writeBckVersion(WindowInfo *w
28 /* Get permissions of the file.
29 - We preserve the normal permissions but not ownership, extended
30 - attributes, et cetera. */
31 + We preserve the normal permissions but not extended attributes,
32 + et cetera. */
33 if (fstat(in_fd, &statbuf) != 0) {
34 return FALSE;
36 @@ -1410,6 +1412,14 @@ static int writeBckVersion(WindowInfo *w
37 return bckError(window, "fchmod() failed", bckname);
40 + /* Set ownership on new file */
41 + if (fchown(out_fd, statbuf.st_uid, statbuf.st_gid) != 0) {
42 + close(in_fd);
43 + close(out_fd);
44 + remove(bckname);
45 + return bckError(window, "fchown() failed", bckname);
46 + }
48 /* Allocate I/O buffer */
49 io_buffer = (char*) malloc(IO_BUFFER_SIZE);
50 if (NULL == io_buffer) {
51 @@ -1454,6 +1464,10 @@ static int writeBckVersion(WindowInfo *w
53 free(io_buffer);
55 + utimbuf.actime = statbuf.st_atime;
56 + utimbuf.modtime = statbuf.st_mtime;
57 + utime(bckname, &utimbuf);
59 #endif /* VMS */
61 return FALSE;