Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <sys/stat.h>
- int main (int argc, char** argv)
- {
- int i;
- struct stat stat_data;
- int num_iterations;
- int print;
- int use_filetime;
- int use_time;
- char const* filename;
- if (argc != 5)
- {
- fprintf (stderr, "Usage: %s num_iterations print|noprint filetime|time|nothing filename\n", argv[0]);
- return EXIT_FAILURE;
- }
- num_iterations= atoi (argv[1]);
- print= argv[2][0] == 'p';
- use_filetime= argv[3][0] == 'f';
- use_time= argv[3][0] == 't';
- filename= argv[4];
- for (i=0; i<num_iterations; ++i)
- {
- if (use_filetime)
- {
- stat (filename, &stat_data);
- }
- else if (use_time)
- {
- time (&(stat_data.st_mtime));
- }
- else
- {
- stat_data.st_mtime= 100;
- }
- if (print)
- {
- printf ("%u\n", (unsigned int)stat_data.st_mtime);
- }
- }
- return EXIT_SUCCESS;
- }
Add Comment
Please, Sign In to add comment