1
## DP: write ignore.conf.bug463072 and rename to ignore.conf, fixes #463072.
2
--- a/src/common/cfgfiles.c
3
+++ b/src/common/cfgfiles.c
5
return open (buf, flags | OFLAGS);
9
+xchat_rename_file (char *oldpath, char *newpath, int xof_flags)
11
+ char bufoldpath[1024];
12
+ char bufnewpath[1024];
14
+ if (xof_flags & XOF_FULLPATH)
15
+ return rename (oldpath, newpath);
17
+ snprintf (bufoldpath, sizeof (bufoldpath), "%s/%s", get_xdir_fs (), oldpath);
18
+ snprintf (bufnewpath, sizeof (bufnewpath), "%s/%s", get_xdir_fs (), newpath);
19
+ return rename (bufoldpath, bufnewpath);
23
xchat_fopen_file (const char *file, const char *mode, int xof_flags)
25
--- a/src/common/cfgfiles.h
26
+++ b/src/common/cfgfiles.h
28
void list_addentry (GSList ** list, char *cmd, char *name);
29
int cmd_set (session *sess, char *tbuf, char *word[], char *word_eol[]);
30
int xchat_open_file (char *file, int flags, int mode, int xof_flags);
31
+int xchat_rename_file (char *oldpath, char *newpath, int xof_flags);
32
FILE *xchat_fopen_file (const char *file, const char *mode, int xof_flags);
34
#define XOF_FULLPATH 2
35
--- a/src/common/ignore.c
36
+++ b/src/common/ignore.c
44
GSList *temp = ignore_list;
47
- fh = xchat_open_file ("ignore.conf", O_TRUNC | O_WRONLY | O_CREAT, 0600, XOF_DOMODE);
48
+ fh = xchat_open_file ("ignore.conf.bug463072", O_TRUNC | O_WRONLY | O_CREAT, 0600, XOF_DOMODE);
54
snprintf (buf, sizeof (buf), "mask = %s\ntype = %d\n\n",
56
- write (fh, buf, strlen (buf));
57
+ nb = write (fh, buf, strlen (buf));
58
+ if( nb == (ssize_t)-1 )
60
+ perror( "ignore_save: write() failed" );
71
+ perror( "ignore_save: close() failed" );
74
+ rc = xchat_rename_file( "ignore.conf.bug463072", "ignore.conf", XOF_DOMODE );
77
+ perror( "ignore_save: xchat_rename_file() failed" );