version 1.52, 2012/09/14 00:00:29 |
version 1.53, 2013/02/18 22:15:11 |
|
|
/* It is ok for the target file not to exist. */ |
/* It is ok for the target file not to exist. */ |
if (rename(path, backup) < 0 && errno != ENOENT) |
if (rename(path, backup) < 0 && errno != ENOENT) |
err(EX_OSERR, "rename: %s to %s (errno %d)", path, backup, errno); |
err(EX_OSERR, "rename: %s to %s (errno %d)", path, backup, errno); |
} else |
} else { |
(void)unlink(path); |
if (unlink(path) < 0 && errno != ENOENT) |
|
err(EX_OSERR, "%s", path); |
|
} |
|
|
return(open(path, O_CREAT | O_RDWR | O_EXCL, S_IRUSR | S_IWUSR)); |
return(open(path, O_CREAT | O_RDWR | O_EXCL, S_IRUSR | S_IWUSR)); |
} |
} |