File:  [Research Unix] / researchv10no / cmd / efl / efixsrc / cpt.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:35 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Norman

/* Set time of second argument to that of first. */
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
main(argc, argv)
int argc;
char **argv;
{
	struct stat buf;
	time_t timep[2];
	char *progname = argv[0], *s;
	int rc = 0;

	if (argc < 3) {
		fprintf(stderr,
	"usage: %s f1 f2 [f3 ...]\n\tto copy times from f1 to f2 [f3 ...]\n",
			progname);
		exit(1);
		}
	s = *++argv;
	if (stat(s, &buf) != 0) {
		fprintf(stderr, "%s: can't stat %s!\n", progname, s);
		exit(1);
		}
	timep[0] = buf.st_atime;
	timep[1] = buf.st_mtime;
	while(s = *++argv)
		if (utime(s, timep) != 0) {
			fprintf(stderr, "%s: can't set time of %s!\n",
				progname, s);
			++rc;
			}
	exit(rc);
	}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.