Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ucbvax!decwrl!pyramid!prls!philabs!ttidca!quad1!few From: few@quad1.quad.com (Frank Whaley) Newsgroups: comp.sys.ibm.pc Subject: Re: Shell command question (touch.c) Keywords: shell msdos Message-ID: <1576@quad1.quad.com> Date: 9 Jun 88 06:34:23 GMT References: <1102@cod.NOSC.MIL> <9301@iuvax.cs.indiana.edu> <22243@tis.llnl.gov> <10555@ism780c.isc.com> <1561@hoqax.UUCP> Reply-To: few@quad1.quad.com (Frank Whaley) Organization: Quadratron Systems Inc, Westlake Village, CA Lines: 86 I couldn't stand it any more. A 30 byte batch file eats 2K of my hard disk, my version of touch.com comes in at 4016 bytes. It doesn't need a shell around it, and it understands the "-c" option. I once had a version that used the GET/SET TIMESTAMP function, but this version was just too crudely simple for me to ignore. Frank Whaley Senior Programmer Quadratron Systems Incorporated sdcrdcf! scgvaxd! bellcore! ttidca! ihnp4!psivax!quad1!few Water separates the people of the world; Wine unites them. ---------------------------------------- /* * touch.c -> update time/date stamp of files */ #include void main(ac, av) int ac; char **av; { char r; /* character read */ int arg, /* argument counter */ fd, /* file descriptor */ make; /* create file if not found ?? */ make = arg = 1; /* check for 'create' option */ if ((av[1][0] == '-') && (av[1][1] == 'c')) { make--; arg++; } /* touch each file */ for (; arg < ac; arg++) if ((fd = open(av[arg], 2)) != ERROR) { read(fd, &r, 1); lseek(fd, 0L, 0); write(fd, &r, 1); close(fd); } else if (make) if ((fd = creat(av[arg], 0)) == ERROR) { fputs("touch: cannot create ", stderr); fputs(av[arg], stderr); fputs("\r\n", stderr); } else close(fd); else { fputs("touch: cannot open ", stderr); fputs(av[arg], stderr); fputs("\r\n", stderr); } } /* * END of touch.c */ -- Frank Whaley Senior Programmer Quadratron Systems Incorporated sdcrdcf! scgvaxd! bellcore! ttidca! ihnp4!psivax!quad1!few Water separates the people of the world; Wine unites them.