From: Tollef Fog Heen Date: Sat, 28 Jun 2008 09:43:22 +0000 (+0300) Subject: Move "skip a file forward" into its own function X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61ed7dc39310c13d767b7c894c42f64c42e715c2;p=dpkg Move "skip a file forward" into its own function --- diff --git a/ChangeLog b/ChangeLog index 0f86deae..979cc149 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-06-28 Tollef Fog Heen + + * src/archives.c (tarobject): Refactor tarfile object skipping to ... + (tarfile_skip_one_forward): ... here. New function. + 2008-06-28 Guillem Jover * lib/dpkg-db.h (skip_slash_dotslash): Move declaration ... diff --git a/src/archives.c b/src/archives.c index 921d60e1..70080fa2 100644 --- a/src/archives.c +++ b/src/archives.c @@ -230,6 +230,34 @@ int tarfileread(void *ud, char *buf, int len) { return r; } +void +tarfile_skip_one_forward(struct TarInfo *ti, + struct fileinlist **oldnifd, + struct fileinlist *nifd) +{ + struct tarcontext *tc = (struct tarcontext *)ti->UserData; + size_t r; + char databuf[TARBLKSZ]; + + obstack_free(&tar_obs, nifd); + tc->newfilesp = oldnifd; + *oldnifd = NULL; + + /* We need to advance the tar file to the next object, so read the + * file data and set it to oblivion. + */ + if ((ti->Type == NormalFile0) || (ti->Type == NormalFile1)) { + char fnamebuf[256]; + + fd_null_copy(tc->backendpipe, ti->Size, + _("skipped unpacking file '%.255s' (replaced or excluded?)"), + quote_filename(fnamebuf, 256, ti->Name)); + r = ti->Size % TARBLKSZ; + if (r > 0) + r = safe_read(tc->backendpipe, databuf, TARBLKSZ - r); + } +} + int fnameidlu; struct varbuf fnamevb; struct varbuf fnametmpvb; @@ -584,20 +612,7 @@ int tarobject(struct TarInfo *ti) { if (existingdirectory) return 0; if (keepexisting) { - obstack_free(&tar_obs, nifd); - tc->newfilesp= oldnifd; - *oldnifd = NULL; - - /* We need to advance the tar file to the next object, so read the - * file data and set it to oblivion. - */ - if ((ti->Type == NormalFile0) || (ti->Type == NormalFile1)) { - char fnamebuf[256]; - fd_null_copy(tc->backendpipe, ti->Size, _("gobble replaced file `%.255s'"),quote_filename(fnamebuf,256,ti->Name)); - r= ti->Size % TARBLKSZ; - if (r > 0) r= safe_read(tc->backendpipe,databuf,TARBLKSZ - r); - } - + tarfile_skip_one_forward(ti, oldnifd, nifd); return 0; }