Blame SOURCES/unzip-6.0-close.patch

6c1878
diff -up unzip60/extract.c.close unzip60/extract.c
6c1878
--- unzip60/extract.c.close	2009-03-14 02:32:52.000000000 +0100
6c1878
+++ unzip60/extract.c	2009-11-19 08:17:23.481263496 +0100
6c1878
@@ -1924,24 +1924,21 @@ static int extract_or_test_member(__G)  
6c1878
 
6c1878
 #ifdef VMS                  /* VMS:  required even for stdout! (final flush) */
6c1878
     if (!uO.tflag)           /* don't close NULL file */
6c1878
-        close_outfile(__G);
6c1878
+        error = close_outfile(__G);
6c1878
 #else
6c1878
 #ifdef DLL
6c1878
     if (!uO.tflag && (!uO.cflag || G.redirect_data)) {
6c1878
         if (G.redirect_data)
6c1878
             FINISH_REDIRECT();
6c1878
         else
6c1878
-            close_outfile(__G);
6c1878
+            error = close_outfile(__G);
6c1878
     }
6c1878
 #else
6c1878
     if (!uO.tflag && !uO.cflag)   /* don't close NULL file or stdout */
6c1878
-        close_outfile(__G);
6c1878
+        error = close_outfile(__G);
6c1878
 #endif
6c1878
 #endif /* VMS */
6c1878
 
6c1878
-            /* GRR: CONVERT close_outfile() TO NON-VOID:  CHECK FOR ERRORS! */
6c1878
-
6c1878
-
6c1878
     if (G.disk_full) {            /* set by flush() */
6c1878
         if (G.disk_full > 1) {
6c1878
 #if (defined(DELETE_IF_FULL) && defined(HAVE_UNLINK))
6c1878
diff -up unzip60/unix/unix.c.close unzip60/unix/unix.c
6c1878
--- unzip60/unix/unix.c.close	2009-01-24 00:31:26.000000000 +0100
6c1878
+++ unzip60/unix/unix.c	2009-11-19 08:33:25.568389171 +0100
6c1878
@@ -1096,10 +1096,41 @@ static int get_extattribs(__G__ pzt, z_u
6c1878
 #ifndef MTS
6c1878
 
6c1878
 /****************************/
6c1878
+/* Function CloseError()    */
6c1878
+/***************************/
6c1878
+
6c1878
+int CloseError(__G)
6c1878
+    __GDEF
6c1878
+{
6c1878
+    int errval = PK_OK;
6c1878
+    
6c1878
+    if (fclose(G.outfile) < 0) {
6c1878
+          switch (errno) {
6c1878
+                case ENOSPC:
6c1878
+                    /* Do we need this on fileio.c? */
6c1878
+                    Info(slide, 0x4a1, ((char *)slide, "%s: write error (disk full?).   Continue? (y/n/^C) ",
6c1878
+                          FnFilter1(G.filename)));
6c1878
+                    fgets(G.answerbuf, 9, stdin);
6c1878
+                    if (*G.answerbuf == 'y')     /* stop writing to this file */
6c1878
+                        G.disk_full = 1;         /* pass to next */
6c1878
+                    else
6c1878
+                        G.disk_full = 2;         /* no: exit program */
6c1878
+          
6c1878
+                    errval = PK_DISK;
6c1878
+                    break;
6c1878
+
6c1878
+                default:
6c1878
+                    errval = PK_WARN;
6c1878
+          }
6c1878
+     }
6c1878
+     return errval;
6c1878
+} /* End of CloseError() */
6c1878
+
6c1878
+/****************************/
6c1878
 /* Function close_outfile() */
6c1878
 /****************************/
6c1878
 
6c1878
-void close_outfile(__G)    /* GRR: change to return PK-style warning level */
6c1878
+int close_outfile(__G) 
6c1878
     __GDEF
6c1878
 {
6c1878
     union {
6c1878
@@ -1108,6 +1139,7 @@ void close_outfile(__G)    /* GRR: chang
6c1878
     } zt;
6c1878
     ulg z_uidgid[2];
6c1878
     int have_uidgid_flg;
6c1878
+    int errval = PK_OK;
6c1878
 
6c1878
     have_uidgid_flg = get_extattribs(__G__ &(zt.t3), z_uidgid);
6c1878
 
6c1878
@@ -1141,16 +1173,16 @@ void close_outfile(__G)    /* GRR: chang
6c1878
             Info(slide, 0x201, ((char *)slide,
6c1878
               "warning:  symbolic link (%s) failed: mem alloc overflow\n",
6c1878
               FnFilter1(G.filename)));
6c1878
-            fclose(G.outfile);
6c1878
-            return;
6c1878
+            errval = CloseError(G.outfile, G.filename);
6c1878
+            return errval ? errval : PK_WARN;
6c1878
         }
6c1878
 
6c1878
         if ((slnk_entry = (slinkentry *)malloc(slnk_entrysize)) == NULL) {
6c1878
             Info(slide, 0x201, ((char *)slide,
6c1878
               "warning:  symbolic link (%s) failed: no mem\n",
6c1878
               FnFilter1(G.filename)));
6c1878
-            fclose(G.outfile);
6c1878
-            return;
6c1878
+            errval = CloseError(G.outfile, G.filename);
6c1878
+            return errval ? errval : PK_WARN;
6c1878
         }
6c1878
         slnk_entry->next = NULL;
6c1878
         slnk_entry->targetlen = ucsize;
6c1878
@@ -1174,10 +1206,10 @@ void close_outfile(__G)    /* GRR: chang
6c1878
               "warning:  symbolic link (%s) failed\n",
6c1878
               FnFilter1(G.filename)));
6c1878
             free(slnk_entry);
6c1878
-            fclose(G.outfile);
6c1878
-            return;
6c1878
+            errval = CloseError(G.outfile, G.filename);
6c1878
+            return errval ? errval : PK_WARN;
6c1878
         }
6c1878
-        fclose(G.outfile);                  /* close "link" file for good... */
6c1878
+        errval = CloseError(G.outfile, G.filename); /* close "link" file for good... */
6c1878
         slnk_entry->target[ucsize] = '\0';
6c1878
         if (QCOND2)
6c1878
             Info(slide, 0, ((char *)slide, "-> %s ",
6c1878
@@ -1188,7 +1220,7 @@ void close_outfile(__G)    /* GRR: chang
6c1878
         else
6c1878
             G.slink_head = slnk_entry;
6c1878
         G.slink_last = slnk_entry;
6c1878
-        return;
6c1878
+        return errval;
6c1878
     }
6c1878
 #endif /* SYMLINKS */
6c1878
 
6c1878
@@ -1201,7 +1233,7 @@ void close_outfile(__G)    /* GRR: chang
6c1878
 #endif
6c1878
 
6c1878
 #if (defined(NO_FCHOWN))
6c1878
-    fclose(G.outfile);
6c1878
+    errval = CloseError(G.outfile, G.filename);
6c1878
 #endif
6c1878
 
6c1878
     /* if -X option was specified and we have UID/GID info, restore it */
6c1878
@@ -1227,7 +1259,7 @@ void close_outfile(__G)    /* GRR: chang
6c1878
     }
6c1878
 
6c1878
 #if (!defined(NO_FCHOWN) && defined(NO_FCHMOD))
6c1878
-    fclose(G.outfile);
6c1878
+    errval = CloseError(G.outfile, G.filename);
6c1878
 #endif
6c1878
 
6c1878
 #if (!defined(NO_FCHOWN) && !defined(NO_FCHMOD))
6c1878
@@ -1239,7 +1271,7 @@ void close_outfile(__G)    /* GRR: chang
6c1878
     if (fchmod(fileno(G.outfile), filtattr(__G__ G.pInfo->file_attr)))
6c1878
         perror("fchmod (file attributes) error");
6c1878
 
6c1878
-    fclose(G.outfile);
6c1878
+    errval = CloseError(G.outfile, G.filename);
6c1878
 #endif /* !NO_FCHOWN && !NO_FCHMOD */
6c1878
 
6c1878
     /* skip restoring time stamps on user's request */
6c1878
@@ -1267,6 +1299,7 @@ void close_outfile(__G)    /* GRR: chang
6c1878
 #endif
6c1878
 #endif /* NO_FCHOWN || NO_FCHMOD */
6c1878
 
6c1878
+    return errval;
6c1878
 } /* end function close_outfile() */
6c1878
 
6c1878
 #endif /* !MTS */
6c1878
diff -up unzip60/unzpriv.h.close unzip60/unzpriv.h
6c1878
--- unzip60/unzpriv.h.close	2009-04-20 01:59:26.000000000 +0200
6c1878
+++ unzip60/unzpriv.h	2009-11-19 08:19:08.610388618 +0100
6c1878
@@ -2604,7 +2604,7 @@ char    *GetLoadPath     OF((__GPRO));  
6c1878
    int   SetFileSize     OF((FILE *file, zusz_t filesize));         /* local */
6c1878
 #endif
6c1878
 #ifndef MTS /* macro in MTS */
6c1878
-   void  close_outfile   OF((__GPRO));                              /* local */
6c1878
+   int  close_outfile   OF((__GPRO));                              /* local */
6c1878
 #endif
6c1878
 #ifdef SET_SYMLINK_ATTRIBS
6c1878
    int  set_symlnk_attribs  OF((__GPRO__ slinkentry *slnk_entry));  /* local */