9base

revived minimalist port of Plan 9 userland to Unix
git clone git://git.suckless.org/9base
Log | Files | Refs | README | LICENSE

mtime.c (450B)


      1 #include <u.h>
      2 #include <libc.h>
      3 
      4 void
      5 usage(void)
      6 {
      7 	fprint(2, "usage: mtime file...\n");
      8 	exits("usage");
      9 }
     10 
     11 void
     12 main(int argc, char **argv)
     13 {
     14 	int errors, i;
     15 	Dir *d;
     16 
     17 	ARGBEGIN{
     18 	default:
     19 		usage();
     20 	}ARGEND
     21 
     22 	errors = 0;
     23 	for(i=0; i<argc; i++){
     24 		if((d = dirstat(argv[i])) == nil){
     25 			fprint(2, "stat %s: %r\n", argv[i]);
     26 			errors = 1;
     27 		}else{
     28 			print("%11lud %s\n", d->mtime, argv[i]);
     29 			free(d);
     30 		}
     31 	}
     32 	exits(errors ? "errors" : nil);
     33 }