version 1.27, 2001/07/09 07:04:58 |
version 1.28, 2001/08/25 19:52:05 |
|
|
char backup[MAXPATHLEN]; |
char backup[MAXPATHLEN]; |
(void)snprintf(backup, MAXPATHLEN, "%s%s", to_name, |
(void)snprintf(backup, MAXPATHLEN, "%s%s", to_name, |
suffix); |
suffix); |
if (rename(to_name, backup) < 0) { |
/* It is ok for the target file not to exist. */ |
|
if (rename(to_name, backup) < 0 && errno != ENOENT) { |
serrno = errno; |
serrno = errno; |
unlink(tempfile); |
unlink(tempfile); |
errx(EX_OSERR, "rename: %s to %s: %s", to_name, |
errx(EX_OSERR, "rename: %s to %s: %s", to_name, |
|
|
|
|
if (dobackup) { |
if (dobackup) { |
(void)snprintf(backup, MAXPATHLEN, "%s%s", path, suffix); |
(void)snprintf(backup, MAXPATHLEN, "%s%s", path, suffix); |
if (rename(path, backup) < 0) |
/* It is ok for the target file not to exist. */ |
err(EX_OSERR, "rename: %s to %s", path, backup); |
if (rename(path, backup) < 0 && errno != ENOENT) |
|
err(EX_OSERR, "rename: %s to %s (errno %d)", path, backup, errno); |
} else |
} else |
(void)unlink(path); |
(void)unlink(path); |
|
|