#include #include #include #include int main(int argc, char *argv[]) { FILE *f; int wr = 1; int v = 0; int c; while ((c = getopt(argc, argv, "cv")) != -1) { switch (c) { case 'c': wr = 0; break; case 'v': v = 1; break; } } for (int i = 1; i < argc; i++) { while (strncmp(argv[i], "-", 1) == 0) /* ignore args that start with - */ i++; if (wr) { if (access (argv[i], F_OK) && v) { printf("Making new file '%s'.\n", argv[i]); } else if (v) { printf("File '%s' already exists, updating time.\n", argv[i]); } f = fopen(argv[i], "w"); fclose(f); } if (access (argv[i], F_OK) && !wr && v) { printf("File '%s' doesn't exist, Can't update time.\n", argv[i]); } else if (!wr && v) { printf("File '%s' exist's, updating time.\n", argv[i]); } utime(argv[i], NULL); } }