prtime.c 547 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* $Id$ */
  2. /*
  3. Test access to fields in struct stat
  4. */
  5. #include <sys/types.h>
  6. #include <sys/stat.h>
  7. #include <time.h>
  8. extern char * ctime();
  9. main(argc, argv) char *argv[]; {
  10. while (argc > 1) {
  11. prfiltime(argv[1]);
  12. if (argc > 2)
  13. printf("\n");
  14. argc--;
  15. argv++;
  16. }
  17. exit(0);
  18. }
  19. prfiltime(name) char *name; {
  20. struct stat buf;
  21. printf("%s: ", name);
  22. if (stat(name, &buf) != 0)
  23. printf(" not found\n");
  24. else
  25. prtime(&buf);
  26. }
  27. prtime(buf)
  28. struct stat *buf;
  29. {
  30. printf("%lu ", buf->st_mtime);
  31. printf("%s\n", ctime(&buf->st_mtime));
  32. }