touch_file, remove_file: ignore non-existent files

This commit is contained in:
Andrew Ayer
2015-02-07 13:22:30 -08:00
parent 18d3cfeca9
commit 85635ae0b1
3 changed files with 16 additions and 6 deletions

View File

@@ -280,14 +280,14 @@ int exit_status (int wait_status)
void touch_file (const std::string& filename)
{
if (utimes(filename.c_str(), NULL) == -1) {
if (utimes(filename.c_str(), NULL) == -1 && errno != ENOENT) {
throw System_error("utimes", filename, errno);
}
}
void remove_file (const std::string& filename)
{
if (unlink(filename.c_str()) == -1) {
if (unlink(filename.c_str()) == -1 && errno != ENOENT) {
throw System_error("unlink", filename, errno);
}
}