shithub: npe

Download patch

ref: 7a8cd4cb0b312e13a88d4d3175a839a2536ee4e3
parent: 9e05fc749cb48540ee04371cd578f5fd8898b034
author: Jacob Moody <moody@posixcafe.org>
date: Sun May 7 21:07:46 EDT 2023

npe: add utime.h

--- /dev/null
+++ b/include/npe/utime.h
@@ -1,0 +1,13 @@
+#ifndef _npe_utime_h_
+#define _npe_utime_h_
+
+#include <time.h>
+
+struct utimbuf{
+	time_t actime;
+	time_t modtime;
+};
+
+int utime(const char *path, const struct utimbuf *times);
+
+#endif
--- a/libnpe/mkfile
+++ b/libnpe/mkfile
@@ -50,6 +50,7 @@
 	trunc.$O\
 	unlink.$O\
 	usleep.$O\
+	utime.$O\
 
 UPDATE=\
 	mkfile\
--- /dev/null
+++ b/libnpe/utime.c
@@ -1,0 +1,16 @@
+#include <utime.h>
+
+int
+utime(const char *path, const struct utimbuf *times)
+{
+	Dir d;
+
+	nulldir(&d);
+	if(times == nil)
+		d.atime = d.mtime = time(nil);
+	else{
+		d.atime = times->actime;
+		d.mtime = times->modtime;
+	}
+	return dirwstat(path, &d);
+}