/* * fileage - compare ages of the two files named on the command line. * * Reports the age of each file listed */ #include #include #include #include main( argc, argv) int argc; char *argv[]; { int a; /* index of arguments */ unsigned long age, /* age of file in seconds */ fmt, /* timestamp of file */ now; /* timestamp of this run */ struct stat f_stat; time( &now); /* get current time */ #if defined(BUGGY) fprintf( stderr, "NOW set to %ld\n", now); #endif for ( a = 1 ; a < argc ; a++ ) { if ( stat( argv[a], &f_stat) != 0 ) { fprintf( stderr, "Stat(\"%s\",) returned an error.\n", argv[a]); fflush( stderr); continue; } fmt = f_stat.st_mtime; /* file modification time */ age = now - fmt; /* hope the clock is right */ fprintf( stdout, "%ld %s\n", age, argv[a]); } fflush( stdout); exit( 0); } /* fileage main */