*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Fri, 12 Mar 2004 20:06:42 +0100
changeset 4093 24b16c9d3d82
parent 4092 9a7cf8cf8329
child 4094 af931a8b005b
*** empty log message ***
ResourcePack.st
--- a/ResourcePack.st	Fri Mar 12 15:44:01 2004 +0100
+++ b/ResourcePack.st	Fri Mar 12 20:06:42 2004 +0100
@@ -180,15 +180,19 @@
     Packs := nil.
     self initialize
 
-    "ResourcePack flushCachedResourcePacks"
+    "
+     ResourcePack flushCachedResourcePacks
+    "
 !
 
 initialize
     Packs isNil ifTrue:[
-	Packs := WeakArray new:30
+        Packs := WeakArray new:30
     ].
 
-    "ResourcePack initialize"
+    "
+     ResourcePack initialize
+    "
 ! !
 
 !ResourcePack class methodsFor:'instance creation'!
@@ -235,7 +239,7 @@
     aClass == Object ifFalse:[
         pack superPack:(self for:(aClass superclass)).
     ].
-    pack packsClassName:nm.
+    pack packsClassOrFileName:nm.
     cached ifTrue:[
         self addToCache:pack.
     ].
@@ -283,7 +287,7 @@
     rsrcDir exists ifFalse:[^ nil].
 
     pack := self fromFile:'resources.rs' directory:rsrcDir.
-    pack packsClassName:fullName.
+    pack packsClassOrFileName:fullName.
     cached ifTrue:[
         self addToCache:pack.
     ].
@@ -343,30 +347,31 @@
     Packs at:idx put:aPack
 !
 
-searchCacheFor:aClassname
+searchCacheFor:aClassOrFileName
     |sz "{ Class: SmallInteger }" |
 
     Packs isNil ifTrue:[
-	self initialize.
-	^ nil
+        self initialize.
+        ^ nil
     ].
 
     sz := Packs size.
     1 to:sz do:[:idx |
-	|aPack|
+        |aPack|
 
-	aPack := Packs at:idx.
-	(aPack notNil 
-	and:[aPack ~~ 0]) ifTrue:[
-	    aClassname = aPack packsClassName ifTrue:[
-		"
-		 bring to end for LRU
-		"
-		Packs replaceFrom:idx to:sz-1 with:Packs startingAt:idx+1.
-		Packs at:sz put:aPack.
-		^ aPack
-	    ]
-	]
+        aPack := Packs at:idx.
+        (aPack notNil and:[aPack ~~ 0]) ifTrue:[
+            aClassOrFileName = aPack packsClassOrFileName ifTrue:[
+                "
+                 bring to front for LRU
+                "
+                idx ~~ 1 ifTrue:[
+                    Packs replaceFrom:2 to:idx with:Packs startingAt:1.
+                    Packs at:1 put:aPack.
+                ].
+                ^ aPack
+            ]
+        ]
     ].
     ^ nil
 
@@ -682,6 +687,14 @@
     packsClassName := aString
 !
 
+packsClassOrFileName
+    ^ packsClassName
+!
+
+packsClassOrFileName:aString
+    packsClassName := aString
+!
+
 projectPack:anotherResourcePack
     projectPack := anotherResourcePack
 
@@ -863,7 +876,7 @@
         ^ self nonexistingFileRead
     ].
 
-    ok := self readFromResourceStream:inStream in:dirName.
+    ok := self readFromResourceStream:inStream in:(inStream pathName asFilename directoryName).
     inStream close.
 
     ok ifFalse:[
@@ -1039,10 +1052,21 @@
     "Modified: / 30.8.1998 / 12:35:24 / cg"
 ! !
 
+!ResourcePack methodsFor:'printing & storing'!
+
+displayString
+    ^ String 
+        streamContents:
+            [:s | 
+                s nextPutAll:'ResourcePack for: '.
+                packsClassName printOn:s
+            ]
+! !
+
 !ResourcePack class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.95 2004-03-09 21:34:09 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.96 2004-03-12 19:06:42 cg Exp $'
 ! !
 
 ResourcePack initialize!