fwrite(buf, 1, MIN(ssizeof(buf), sb.st_size), f);
sb.st_size -= MIN(ssizeof(buf), sb.st_size);
}
- fclose (f);
+ m_fclose(&f);
}
}
}
return fopen(path, mode);
}
-int safe_fclose(FILE **f)
-{
- int r = 0;
-
- if (*f)
- r = fclose (*f);
- *f = NULL;
- return r;
-}
-
/* If rfc1524_expand_command() is used on a recv'd message, then
* the filename doesn't exist yet, but if its used while sending a message,
* then we need to rename the existing file.
nfp = safe_fopen(newfile, "w");
if (!nfp) {
- fclose (ofp);
+ m_fclose(&ofp);
return 3;
}
mutt_copy_stream(ofp, nfp);
- fclose(nfp);
- fclose(ofp);
+ m_fclose(&nfp);
+ m_fclose(&ofp);
mutt_unlink(oldfile);
return 0;
}
m_tempftplize(tpl, sizeof(tpl), fmt, raw);
}
- fd = open(path, O_CREAT | O_EXCL | O_WRONLY | O_NOFOLLOW, 0600);
+ fd = open(path, O_CREAT | O_EXCL | O_RDWR | O_NOFOLLOW, 0600);
if (fd < 0) {
if (errno == EEXIST)