// Also used by restore.c. // FIX THIS: This stuff is very similar to make_rev_delta, can maybe share // some code. int do_patch(struct asfd *asfd, const char *dst, const char *del, const char *upd, bool gzupd, int compression) { struct fzp *dstp=NULL; struct fzp *delfzp=NULL; struct fzp *upfzp=NULL; rs_result result=RS_IO_ERROR; if(!(dstp=fzp_open(dst, "rb"))) goto end; if(!(delfzp=fzp_gzopen(del, "rb"))) goto end; if(gzupd) upfzp=fzp_gzopen(upd, comp_level(compression)); else upfzp=fzp_open(upd, "wb"); if(!upfzp) goto end; result=rs_patch_gzfile(dstp, delfzp, upfzp); end: fzp_close(&dstp); fzp_close(&delfzp); if(fzp_close(&upfzp)) { logp("error closing %s in %s\n", upd, __func__); result=RS_IO_ERROR; } return result; }
// Also used by backup_phase4_server.c int do_patch(const char *dst, const char *del, const char *upd, bool gzupd, struct cntr *cntr, struct config *cconf) { FILE *dstp=NULL; FILE *delfp=NULL; gzFile delzp=NULL; gzFile updp=NULL; FILE *updfp=NULL; rs_result result; //logp("patching...\n"); if(!(dstp=fopen(dst, "rb"))) { logp("could not open %s for reading\n", dst); return -1; } if(dpth_is_compressed(del)) delzp=gzopen(del, "rb"); else delfp=fopen(del, "rb"); if(!delzp && !delfp) { logp("could not open %s for reading\n", del); close_fp(&dstp); return -1; } if(gzupd) updp=gzopen(upd, comp_level(cconf)); else updfp=fopen(upd, "wb"); if(!updp && !updfp) { logp("could not open %s for writing\n", upd); close_fp(&dstp); gzclose_fp(&delzp); close_fp(&delfp); return -1; } result=rs_patch_gzfile(dstp, delfp, delzp, updfp, updp, NULL, cntr); fclose(dstp); gzclose_fp(&delzp); close_fp(&delfp); if(updp) gzclose_fp(&updp); if(updfp) fclose(updfp); return result; }
// Also used by restore.c. // FIX THIS: This stuff is very similar to make_rev_delta, can maybe share // some code. int do_patch(struct asfd *asfd, const char *dst, const char *del, const char *upd, bool gzupd, int compression, struct conf *cconf) { FILE *dstp=NULL; FILE *delfp=NULL; gzFile delzp=NULL; gzFile updp=NULL; FILE *updfp=NULL; rs_result result=RS_IO_ERROR; //logp("patching...\n"); if(!(dstp=open_file(dst, "rb"))) goto end; if(dpthl_is_compressed(compression, del)) delzp=gzopen_file(del, "rb"); else delfp=open_file(del, "rb"); if(!delzp && !delfp) goto end; if(gzupd) updp=gzopen(upd, comp_level(cconf)); else updfp=fopen(upd, "wb"); if(!updp && !updfp) goto end; result=rs_patch_gzfile(asfd, dstp, delfp, delzp, updfp, updp, NULL, cconf->cntr); end: close_fp(&dstp); gzclose_fp(&delzp); close_fp(&delfp); if(close_fp(&updfp)) { logp("error closing %s in %s\n", upd, __func__); result=RS_IO_ERROR; } if(gzclose_fp(&updp)) { logp("error gzclosing %s in %s\n", upd, __func__); result=RS_IO_ERROR; } return result; }