ack/util/int/test/prtime.c

40 lines
551 B
C
Raw Normal View History

1988-06-24 15:40:41 +00:00
/* $Header$ */
/*
Test access to fields in struct stat
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
extern char * ctime();
main(argc, argv) char *argv[]; {
while (argc > 1) {
prfiltime(argv[1]);
if (argc > 2)
printf("\n");
argc--;
argv++;
}
exit(0);
}
prfiltime(name) char *name; {
struct stat buf;
printf("%s: ", name);
if (stat(name, &buf) != 0)
printf(" not found\n");
else
prtime(&buf);
}
prtime(buf)
struct stat *buf;
{
printf("%lu ", buf->st_mtime);
printf("%s\n", ctime(&buf->st_mtime));
}