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