JavaNativeMethodImpl_OpenJDK6.st
branchdevelopment
changeset 2057 4c8ec3832206
parent 2051 6372843ecbcf
child 2067 a99e82ecac7e
--- a/JavaNativeMethodImpl_OpenJDK6.st	Mon Feb 11 19:45:42 2013 +0000
+++ b/JavaNativeMethodImpl_OpenJDK6.st	Mon Feb 11 13:02:34 2013 -0800
@@ -927,6 +927,29 @@
     "Modified: / 30-01-2013 / 14:00:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!JavaNativeMethodImpl_OpenJDK6 class methodsFor:'helpers - zip'!
+
+getZipArchiveAt:index
+    | zar |
+
+    "Kludge for BCC 5.5 as it does not allow for more than 50 files to be opened at time Sigh"
+
+    zar := ZipCache at:index.
+    OperatingSystem isUNIXlike ifTrue:[
+        ^zar
+    ].
+    zar == ZipCacheLastAccessed ifFalse:[
+        ZipCacheLastAccessed notNil ifTrue:[
+            ZipCacheLastAccessed closeFile.
+        ].
+        ZipCacheLastAccessed := zar.
+        zar reopenForReading.
+    ].
+    ^zar
+
+    "Created: / 11-02-2013 / 12:32:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !JavaNativeMethodImpl_OpenJDK6 class methodsFor:'native - UNPORTED'!
 
 _AccessController_beginPrivileged: nativeContext
@@ -11780,7 +11803,7 @@
     "
     | zipArchive entries jentries |
 
-    zipArchive := ZipCache at: (this instVarNamed: #jzfile).
+    zipArchive := self getZipArchiveAt:(this instVarNamed:#jzfile).
     entries := (zipArchive entries select:[:entry|entry size > 9 and:[entry startsWith: 'META-INF/']]) asArray.
     jentries := Java java_lang_String javaArrayClass new: entries size.
     1 to: entries size do:[:i|
@@ -12103,7 +12126,7 @@
 
     | jzfile zar |
     jzfile := a1.
-    zar := ZipCache at: jzfile.
+    zar := self getZipArchiveAt:jzfile.
     zar close.
     ZipCache at: jzfile put: nil.
 
@@ -12139,7 +12162,7 @@
 
     | zipArchive  filename  member |
 
-    zipArchive := ZipCache at: a1.
+    zipArchive := self getZipArchiveAt:a1.
     filename := Java as_ST_String: a3.
     member := (zipArchive findMemberAllowForMissingTrailingSlash: filename).
     member isNil ifTrue: [
@@ -12177,7 +12200,7 @@
 
     | zipArchive i |
 
-    zipArchive := ZipCache at: jzfile.
+    zipArchive := self getZipArchiveAt:jzfile.
     i := 0.
     zipArchive zipMembersDo:[:member |
         index == i ifTrue:[
@@ -12212,7 +12235,7 @@
     <javanative: 'java/util/zip/ZipFile' name: 'getTotal(J)I'>
 
     | zar|
-    zar := ZipCache at: a1.
+    zar := self getZipArchiveAt:a1.
     ^ zar entries size.
 
     "Modified: / 23-07-2012 / 23:35:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -12256,6 +12279,10 @@
     result ifNil: [ JavaVM throwZipException ].
     ^[
         | i zar |
+
+        ZipCacheLastAccessed notNil ifTrue:[
+            ZipCacheLastAccessed closeFile.
+        ].
         zar := ZipArchive readingFrom: result readStream.
         i := ZipCache indexOf: nil.
         i ~~ 0 ifTrue:[
@@ -12270,7 +12297,7 @@
     ]
 
     "Modified: / 01-04-2011 / 15:35:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-    "Modified: / 30-01-2013 / 13:55:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 11-02-2013 / 12:36:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_util_zip_ZipFile_read: this _:a1 _: a2 _: a3 _: a4 _: a5 _: a6 _: a7 _: a8 _: a9 
@@ -12286,7 +12313,7 @@
     off := a8.
     len := a9.
 
-    zar := ZipCache at: jzfile.
+    zar := self getZipArchiveAt:jzfile.
     zmember := ZipEntryCache at: jzentry.
 
     bytesToRead := len min: (zmember compressedSize - pos).