mtime.c 861 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include <u.h>
  10. #include <libc.h>
  11. void
  12. usage(void)
  13. {
  14. fprint(2, "usage: mtime file...\n");
  15. exits("usage");
  16. }
  17. void
  18. main(int argc, char **argv)
  19. {
  20. int errors, i;
  21. Dir *d;
  22. ARGBEGIN{
  23. default:
  24. usage();
  25. }ARGEND
  26. errors = 0;
  27. for(i=0; i<argc; i++){
  28. if((d = dirstat(argv[i])) == nil){
  29. fprint(2, "stat %s: %r\n", argv[i]);
  30. errors = 1;
  31. }else{
  32. print("%11lu %s\n", d->mtime, argv[i]);
  33. free(d);
  34. }
  35. }
  36. exits(errors ? "errors" : nil);
  37. }