extend-for-key-in-array-syntax: update to key=val syntax
[nedit-bw.git] / keep_state_for_bck_file.patch
blobfd96756165d92e75fb084a6167074e866f67f317
1 ---
3 source/file.c | 18 ++++++++++++++++--
4 1 files 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,10 +69,11 @@ static const char CVSID[] = "$Id: file.c
10 #ifndef __MVS__
11 #include <sys/param.h>
12 #endif
13 #include <fcntl.h>
14 #endif /*VMS*/
15 +#include <utime.h>
17 #include <Xm/Xm.h>
18 #include <Xm/ToggleB.h>
19 #include <Xm/FileSB.h>
20 #include <Xm/RowColumn.h>
21 @@ -1338,10 +1339,11 @@ static int writeBckVersion(WindowInfo *w
22 char* backname;
23 struct stat statbuf;
24 int in_fd, out_fd;
25 char *io_buffer;
26 off_t fileLen;
27 + struct utimbuf utimbuf;
28 #define IO_BUFFER_SIZE ((size_t)(1024*1024))
30 /* Do only if version backups are turned on */
31 if (!window->saveOldVersion) {
32 return False;
33 @@ -1379,12 +1381,12 @@ static int writeBckVersion(WindowInfo *w
34 perror("nedit: Error reading edited file");
35 return FALSE;
38 /* Get permissions of the file.
39 - We preserve the normal permissions but not ownership, extended
40 - attributes, et cetera. */
41 + We preserve the normal permissions but not extended attributes,
42 + et cetera. */
43 if (fstat(in_fd, &statbuf) != 0) {
44 return FALSE;
47 /* open the destination file exclusive and with restrictive permissions. */
48 @@ -1399,10 +1401,18 @@ static int writeBckVersion(WindowInfo *w
49 close(out_fd);
50 remove(bckname);
51 return bckError(window, "fchmod() failed", bckname);
54 + /* Set ownership on new file */
55 + if (fchown(out_fd, statbuf.st_uid, statbuf.st_gid) != 0) {
56 + close(in_fd);
57 + close(out_fd);
58 + remove(bckname);
59 + return bckError(window, "fchown() failed", bckname);
60 + }
62 /* Allocate I/O buffer */
63 io_buffer = (char*) malloc(IO_BUFFER_SIZE);
64 if (NULL == io_buffer) {
65 close(in_fd);
66 close(out_fd);
67 @@ -1443,10 +1453,14 @@ static int writeBckVersion(WindowInfo *w
68 close(in_fd);
69 close(out_fd);
71 free(io_buffer);
73 + utimbuf.actime = statbuf.st_atime;
74 + utimbuf.modtime = statbuf.st_mtime;
75 + utime(bckname, &utimbuf);
77 #endif /* VMS */
79 return FALSE;