Fix issue #6: touch does not update mtime if file exists

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2017-05-19 17:50:44 +02:00
1 parent b7b635a3f4
commit 628c5597b9
1 file changed
+6 -1
+6 -1
View File
@@ -86,10 +86,15 @@ void progress (int percent, int max_width);
void progress_simple(int percent);
#ifndef touch
#include <sys/stat.h> /* utimensat() */
#include <sys/time.h> /* utimensat() on *BSD */
static inline int touch(const char *path)
{
if (mknod((path), S_IFREG|0644, 0) && errno != EEXIST)
if (mknod((path), S_IFREG|0644, 0)) {
if (errno == EEXIST)
return utimensat(0, path, NULL, 0);
return -1;
}
return 0;
}
#endif