mirror of
https://github.com/troglobit/libite.git
synced 2026-11-28 20:48:27 +00:00
Fix issue #6: touch does not update mtime if file exists
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
b7b635a3f4
commit
628c5597b9
1 file changed
+6
-1
@@ -86,10 +86,15 @@ void progress (int percent, int max_width);
|
|||||||
void progress_simple(int percent);
|
void progress_simple(int percent);
|
||||||
|
|
||||||
#ifndef touch
|
#ifndef touch
|
||||||
|
#include <sys/stat.h> /* utimensat() */
|
||||||
|
#include <sys/time.h> /* utimensat() on *BSD */
|
||||||
static inline int touch(const char *path)
|
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 -1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in new issue
Block a user