]> err.no Git - dpkg/commitdiff
Move "skip a file forward" into its own function
authorTollef Fog Heen <tfheen@err.no>
Sat, 28 Jun 2008 09:43:22 +0000 (12:43 +0300)
committerGuillem Jover <guillem@debian.org>
Sat, 28 Jun 2008 09:43:22 +0000 (12:43 +0300)
ChangeLog
src/archives.c

index 0f86deae767443deae1da183a0bb90f6cda51346..979cc1494498332dccfc6500019c14bff4938d68 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-06-28  Tollef Fog Heen  <tfheen@err.no>
+
+       * src/archives.c (tarobject): Refactor tarfile object skipping to ...
+       (tarfile_skip_one_forward): ... here. New function.
+
 2008-06-28  Guillem Jover  <guillem@debian.org>
 
        * lib/dpkg-db.h (skip_slash_dotslash): Move declaration ...
index 921d60e1e51b6f9406977ee212c4c210537ca741..70080fa2330adb08b8cf164b93edae11df37668b 100644 (file)
@@ -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;
   }