finally break-up Patch Collection
[nedit-bw.git] / keep_state_for_bck_file.patch
blobf0b943354275902b2598962c10475d263293f1de
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 @@ -67,10 +67,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 @@ -1337,10 +1338,11 @@ static int writeBckVersion(WindowInfo *w
22 #ifndef VMS
23 char fullname[MAXPATHLEN], bckname[MAXPATHLEN];
24 struct stat statbuf;
25 int in_fd, out_fd;
26 char *io_buffer;
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 @@ -1366,12 +1368,12 @@ static int writeBckVersion(WindowInfo *w
34 if (in_fd<0) {
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 @@ -1386,10 +1388,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 @@ -1430,10 +1440,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;