int m_rand (unsigned char *, size_t);
char *m_mktemp(const char *, int *, FILE **);
char *m_mktemp2(const char *, const char *, int *, FILE **);
-char *m_mktemps(const char *pfx, const char *, int *, FILE **);
+char *m_mktemps(const char *pfx, const char *suffix, int *, FILE **);
char *get_temp_dir();
void m_unknown(m_getfld_state_t *, FILE *);
int makedir (char *);
fd = mkstemp(tmpfil);
{
char *oldfilename = tmpfil;
-
tmpfil = concat(oldfilename, suffix, NULL);
- /* link(2) requires that the new path not exist. And if we
- have to resort to rename(2), at least try to remove a file
- that would be in the way. */
- if (unlink(tmpfil) != 0 && errno != ENOENT) {
- advise("unlink", "Failed to unlink \"%s\"", tmpfil);
- (void) unlink(oldfilename);
- free(oldfilename);
- free(tmpfil);
- return NULL;
- }
-
- /* link() doesn't always work, such as on Windows FAT
- filesystems. If it fails, try rename(). */
- if (link(oldfilename, tmpfil) != 0 &&
- rename(oldfilename, tmpfil) != 0) {
+ if (rename(oldfilename, tmpfil) != 0) {
(void) unlink(oldfilename);
free(oldfilename);
free(tmpfil);
return NULL;
}
- (void) unlink(oldfilename);
free(oldfilename);
}
#endif /* ! HAVE_MKSTEMPS */