~ft/npe

7a8cd4cb0b312e13a88d4d3175a839a2536ee4e3 — Jacob Moody 4 months ago 9e05fc7
npe: add utime.h
3 files changed, 30 insertions(+), 0 deletions(-)

A include/npe/utime.h
M libnpe/mkfile
A libnpe/utime.c
A include/npe/utime.h => include/npe/utime.h +13 -0
@@ 0,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

M libnpe/mkfile => libnpe/mkfile +1 -0
@@ 50,6 50,7 @@ OFILES=\
	trunc.$O\
	unlink.$O\
	usleep.$O\
	utime.$O\

UPDATE=\
	mkfile\

A libnpe/utime.c => libnpe/utime.c +16 -0
@@ 0,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);
}