12 errstr(errbuf, sizeof errbuf);
13 fprint(2, "rm: %s: %s\n", f, errbuf);
18 * f is a non-empty directory. Remove its contents and then it.
24 int fd, i, j, n, ndir, nname;
32 n = dirreadall(fd, &dirbuf);
39 nname = strlen(f)+1+STATMAX+1; /* plenty! */
42 err("memory allocation");
48 snprint(name, nname, "%s/%s", f, dirbuf[i].name);
49 if(remove(name) != -1)
50 dirbuf[i].qid.type = QTFILE; /* so we won't recurse */
52 if(dirbuf[i].qid.type & QTDIR)
60 if(dirbuf[j].qid.type & QTDIR){
61 snprint(name, nname, "%s/%s", f, dirbuf[j].name);
70 main(int argc, char *argv[])
87 fprint(2, "usage: rm [-fr] file ...\n");
90 for(i=0; i<argc; i++){
95 if(recurse && (db=dirstat(f))!=nil && (db->qid.type&QTDIR))