ZipArchive.st
changeset 4171 1f5976c25a68
parent 4013 a191e524042c
child 4173 fd04c99664fd
child 4174 49c5d5174724
--- a/ZipArchive.st	Fri Oct 14 17:56:32 2016 +0200
+++ b/ZipArchive.st	Tue Oct 18 18:43:00 2016 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1998 by eXept Software AG
               All Rights Reserved
@@ -3268,18 +3270,18 @@
 !ZipArchive methodsFor:'open & close'!
 
 close
-     self closeFile
+    file notNil ifTrue:[
+        self flush.
+        Lobby unregister:self.
+        self closeFile.
+    ]
 !
 
 flush
     "finish the zip archive, but do not close the underlying stream"
 
-    file notNil ifTrue:[
-        Lobby unregister:self.
-        mode == #write ifTrue: [
-            self addCentralZipDirectory
-        ].
-        file := nil.
+    (file notNil and:[mode == #write]) ifTrue: [
+        self addCentralZipDirectory
     ]
 !
 
@@ -3297,7 +3299,7 @@
     ].
 
     file notNil ifTrue: [
-        self closeFile.
+        self close.
     ].
 
     archiveName := filename name.
@@ -3323,7 +3325,7 @@
                 mode := #write.
             ].
         ] ensure:[
-            mustCloseFile ifTrue:[self closeFile].
+            mustCloseFile ifTrue:[self close].
         ].
     ] ifFalse:[
         zipMembersByName := Dictionary new.
@@ -3346,7 +3348,7 @@
 
     file notNil ifTrue: [
         file ~~ aPositionableStream ifTrue: [
-            self closeFile.
+            self close.
         ].
     ].
 
@@ -3380,7 +3382,7 @@
     "initialize the archive to write to aPositionableStream"
 
     file notNil ifTrue: [
-        self closeFile.
+        self close.
     ].
 
     mode := #write.
@@ -3403,7 +3405,7 @@
 
     file notNil ifTrue:[
         savedFile := file.
-        self flush.
+        file := nil.
         savedFile close.
     ]
 !
@@ -3791,7 +3793,7 @@
     [
         isValidArchive := self checkZipArchive.
     ] ensure:[
-        self closeFile.
+        self close.
     ].
     ^ isValidArchive
 !
@@ -3999,7 +4001,6 @@
     ^ false.
 ! !
 
-
 !ZipArchive methodsFor:'reading'!
 
 extract:fileName
@@ -4109,7 +4110,6 @@
     "Created: / 21-11-2010 / 11:51:41 / cg"
 ! !
 
-
 !ZipArchive methodsFor:'reading - stream'!
 
 extract:fileName intoStream: aWriteStream