void dcmd(char *arname, int count, char **files) { Armember *bp; int fd, i; if (!count) return; fd = openar(arname, ORDWR, 0); Binit(&bar, fd, OREAD); Bseek(&bar,seek(fd,0,1), 1); astart = newtempfile(artemp); for (i = 0; bp = getdir(&bar); i++) { if(match(count, files)) { mesg('d', file); skip(&bar, bp->size); if (strcmp(file, symdef) == 0) allobj = 0; } else if (i == 0 && strcmp(file, symdef) == 0) skip(&bar, bp->size); else { scanobj(&bar, astart, bp->size); arcopy(&bar, astart, bp); } } close(fd); install(arname, astart, 0, 0, 0); }
void mcmd(char *arname, int count, char **files) { int fd, i; Arfile *ap; Armember *bp; if (count == 0) return; fd = openar(arname, ORDWR, 0); Binit(&bar, fd, OREAD); Bseek(&bar,seek(fd,0,1), 1); astart = newtempfile(artemp); amiddle = newtempfile(movtemp); aend = 0; ap = astart; for (i = 0; bp = getdir(&bar); i++) { if (bamatch(file, poname)) { aend = newtempfile(tailtemp); ap = aend; } if(match(count, files)) { mesg('m', file); scanobj(&bar, amiddle, bp->size); arcopy(&bar, amiddle, bp); } else /* * pitch the symdef file if it is at the beginning * of the archive and we aren't inserting in front * of it (ap == astart). */ if (ap == astart && i == 0 && strcmp(file, symdef) == 0) skip(&bar, bp->size); else { scanobj(&bar, ap, bp->size); arcopy(&bar, ap, bp); } } close(fd); if (poname[0] && aend == 0) fprint(2, "ar: %s not found - files moved to end.\n", poname); install(arname, astart, amiddle, aend, 0); }
void note_cilk_file (const char *fname, const char *org_fname) { switch (stop_at) { case STOP_AT_M: pushpair(&cilk_files, fname, 0); return; default: { const char *outfname = newtempfile(".cilki", fname); pushpair(&cilk_files, fname, outfname); note_cilki_file(outfname, org_fname); } return; } }
void note_cilkc_file (const char *fname, const char *org_fname) { switch (stop_at) { case STOP_AT_M: /* M files don't have any dependencies. */ case STOP_AT_CILKI: case STOP_AT_CILKC: return; case STOP_AT_I: { const char *outfname = output_name ? output_name : replace_suffix(org_fname, ".i"); pushpair(&cilkc_files, fname, outfname); } break; default: { const char *outfname = newtempfile(".i", fname); pushpair(&cilkc_files, fname, outfname); note_i_file(outfname, org_fname); } break; } }
/* * perform the 'r' and 'u' commands */ void arcmd(char *arname, int count, char **files) { int fd; int i; Arfile *ap; Armember *bp; Dir *d; Biobuf *bfile; fd = openar(arname, ORDWR, 1); if (fd >= 0) { Binit(&bar, fd, OREAD); Bseek(&bar,seek(fd,0,1), 1); } astart = newtempfile(artemp); ap = astart; aend = 0; for(i = 0; fd >= 0; i++) { bp = getdir(&bar); if (!bp) break; if (bamatch(file, poname)) { /* check for pivot */ aend = newtempfile(tailtemp); ap = aend; } /* pitch symdef file */ if (i == 0 && strcmp(file, symdef) == 0) { skip(&bar, bp->size); continue; } if (count && !match(count, files)) { scanobj(&bar, ap, bp->size); arcopy(&bar, ap, bp); continue; } bfile = Bopen(file, OREAD); if (!bfile) { if (count != 0) fprint(2, "ar: cannot open %s\n", file); scanobj(&bar, ap, bp->size); arcopy(&bar, ap, bp); continue; } d = dirfstat(Bfildes(bfile)); if (d == nil) fprint(2, "ar: cannot stat %s: %r\n", file); if (uflag && (d == nil || d->mtime <= bp->date)) { scanobj(&bar, ap, bp->size); arcopy(&bar, ap, bp); Bterm(bfile); free(d); continue; } mesg('r', file); skip(&bar, bp->size); scanobj(bfile, ap, d->length); free(d); armove(bfile, ap, bp); Bterm(bfile); } if(fd >= 0) close(fd); /* copy in remaining files named on command line */ for (i = 0; i < count; i++) { file = files[i]; if(file == 0) continue; files[i] = 0; bfile = Bopen(file, OREAD); if (!bfile) fprint(2, "ar: %s cannot open\n", file); else { mesg('a', file); d = dirfstat(Bfildes(bfile)); if (d == nil) fprint(2, "ar: can't stat %s: %r\n", file); else { scanobj(bfile, astart, d->length); armove(bfile, astart, newmember()); free(d); } Bterm(bfile); } } if(fd < 0 && !cflag) install(arname, astart, 0, aend, 1); /* issue 'creating' msg */ else install(arname, astart, 0, aend, 0); }