main(int argc, char** argv) { Ardir_t* dir; Ardirent_t* ent; long touch; char* file; touch = 0; while (file = *++argv) { if (!strcmp(file, "-t") && *(argv + 1)) touch = strtol(*++argv, NiL, 0); else if (dir = ardiropen(file, NiL, touch ? ARDIR_UPDATE : 0)) { sfprintf(sfstdout, "%s: type=%s truncate=%d%s\n", file, dir->meth->name, dir->truncate, (dir->flags & ARDIR_RANLIB) ? " ranlib" : ""); while (ent = ardirnext(dir)) { if (touch) { ent->mtime = touch; ardirchange(dir, ent); sfprintf(sfstdout, "touch %s\n", ent->name); } else sfprintf(sfstdout, "%s %8u %8u %8llu %8llu %s %s\n", fmtmode(ent->mode, 1), ent->uid, ent->gid, ent->size, ent->offset, fmttime("%k", ent->mtime), ent->name); } if (ardirclose(dir)) error(2, "%s: archive read error", file); } else error(ERROR_SYSTEM|2, "%s: not an archive", file); } return 0; }
static int ar_getprologue(Pax_t* pax, Format_t* fp, register Archive_t* ap, register File_t* f, unsigned char* buf, size_t size) { Ar_t* ar; Ardir_t* dir; if (!(dir = ardiropen(ap->name, NiL, 0))) return 0; if (!(ar = newof(0, Ar_t, 1, 0))) { ardirclose(dir); nospace(); return -1; } ap->data = ar; ar->dir = dir; ap->type = (char*)dir->meth->name; return 1; }