static void gcf_list(){ char *gcf_name=HREnextArg(); if (gcf_name==NULL) { Abort("missing <gcf archive> argument"); } if (HREnextArg()){ Abort("too many arguments"); } raf_t raf=raf_unistd(gcf_name); archive_t gcf=arch_gcf_read(raf); struct arch_enum_callbacks cb={.stat=list_item}; struct list_count totals={0,0,0}; Printf(infoShort,"Archive %s contains:\n",gcf_name); Printf(infoShort," stream size compressed stream name (compression)\n"); arch_enum_t e=arch_enum(gcf,NULL); if (arch_enumerate(e,&cb,&totals)){ Abort("unexpected non-zero return"); } Printf(infoShort,"totals:\n"); Printf(infoShort,"%12zd %12zd files: %d (%3.2f%%)\n", (ssize_t)totals.total_orig,(ssize_t)totals.total_compressed,totals.files, 100.0*((float)(totals.total_orig-totals.total_compressed))/((float)totals.total_orig)); arch_enum_free(&e); uint64_t gcf_size=raf_size(raf); Printf(infoShort,"gcf file size%12zu (%3.2f%% overhead, %3.2f%% compression)\n",(size_t)gcf_size, 100.0*((float)(gcf_size-totals.total_compressed))/((float)totals.total_compressed), 100.0*(((float)totals.total_orig)-((float)gcf_size))/((float)totals.total_orig)); arch_close(&gcf); }
static void archive_copy(archive_t src,archive_t dst,string_map_t encode,int blocksize,char*pattern){ struct arch_enum_callbacks cb={.new_item=copy_item}; struct copy_context ctx; ctx.encode=encode; ctx.src=src; ctx.dst=dst; ctx.bs=blocksize; arch_enum_t e=arch_enum(src,pattern); if (arch_enumerate(e,&cb,&ctx)){ Abort("unexpected non-zero return"); } arch_enum_free(&e); }
static void archive_copy(archive_t src,char*decode,archive_t dst,char*(*encode)(char*),int blocksize){ struct arch_enum_callbacks cb; cb.new_item=copy_item; cb.end_item=NULL; cb.data=NULL; struct copy_context ctx; ctx.decode=decode; ctx.encode=encode; ctx.src=src; ctx.dst=dst; ctx.bs=blocksize; arch_enum_t e=arch_enum(src,NULL); if (arch_enumerate(e,&cb,&ctx)){ Fatal(1,error,"unexpected non-zero return"); } arch_enum_free(&e); }