mirror of
https://github.com/irssi/irssi.git
synced 2024-11-03 04:27:19 -05:00
Merge pull request #922 from dequis/fix-new-config-file-write
Fix /save not working if the config didn't previously exist
This commit is contained in:
commit
8261b2a7c8
@ -302,6 +302,7 @@ int config_write(CONFIG_REC *rec, const char *fname, int create_mode)
|
||||
int ret;
|
||||
int fd;
|
||||
int save_errno;
|
||||
const char *base_name;
|
||||
char *tmp_name = NULL;
|
||||
char *dest_name = NULL;
|
||||
|
||||
@ -309,13 +310,21 @@ int config_write(CONFIG_REC *rec, const char *fname, int create_mode)
|
||||
g_return_val_if_fail(fname != NULL || rec->fname != NULL, -1);
|
||||
g_return_val_if_fail(create_mode != -1 || rec->create_mode != -1, -1);
|
||||
|
||||
base_name = fname != NULL ? fname : rec->fname;
|
||||
|
||||
/* expand all symlinks; else we may replace a symlink with a regular file */
|
||||
dest_name = realpath(fname != NULL ? fname : rec->fname, NULL);
|
||||
dest_name = realpath(base_name, NULL);
|
||||
|
||||
if (dest_name == NULL) {
|
||||
if (errno == ENOENT) {
|
||||
dest_name = g_strdup(base_name);
|
||||
errno = 0;
|
||||
} else {
|
||||
config_error(rec, g_strerror(errno));
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
tmp_name = g_strdup_printf("%s.XXXXXX", dest_name);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user