Add touch_file() utility function

This commit is contained in:
Andrew Ayer
2014-06-22 15:14:19 -07:00
parent 38b43a4415
commit e6bb66b93a
3 changed files with 29 additions and 0 deletions

View File

@@ -31,7 +31,9 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <errno.h>
#include <utime.h>
#include <unistd.h>
#include <stdio.h>
#include <limits.h>
@@ -274,6 +276,13 @@ bool successful_exit (int status)
return status != -1 && WIFEXITED(status) && WEXITSTATUS(status) == 0;
}
void touch_file (const std::string& filename)
{
if (utimes(filename.c_str(), NULL) == -1) {
throw System_error("utimes", "", errno);
}
}
static void init_std_streams_platform ()
{
}