ResourcePack.st
changeset 4078 467a07009140
parent 4062 838a58308021
child 4084 09fce0933fe3
--- a/ResourcePack.st	Fri Mar 05 23:19:45 2004 +0100
+++ b/ResourcePack.st	Mon Mar 08 19:11:44 2004 +0100
@@ -252,6 +252,48 @@
     "
 !
 
+forPackage:package 
+    "get the full resource definitions given a package id (such as stx:libbasic').
+     Also leave the resulting pack in the cache for faster access next time."
+
+    ^ self forPackage:package cached:true
+
+    "
+     ResourcePack forPackage:'stx:libbasic'   
+    "
+!
+
+forPackage:package cached:cached
+    "get the full resource definitions given a package id (such as stx:libbasic').
+     Also optionally leave the resulting pack in the cache for faster access next time."
+
+    |fullName pack rsrcDir|
+
+    fullName := package , '/resources/resources.rs'.
+
+    cached ifTrue:[
+        pack := self searchCacheFor:fullName.
+        pack notNil ifTrue:[^ pack].
+    ].
+
+    rsrcDir := Smalltalk projectDirectoryForPackage:package.
+    rsrcDir isNil ifTrue:[^ nil].
+
+    rsrcDir := rsrcDir asFilename construct:'resources'.
+    rsrcDir exists ifFalse:[^ nil].
+
+    pack := self fromFile:'resources.rs' directory:rsrcDir.
+    pack packsClassName:fullName.
+    cached ifTrue:[
+        self addToCache:pack.
+    ].
+    ^ pack
+
+    "
+     ResourcePack forPackage:'stx:libbasic' cached:false     
+    "
+!
+
 fromFile:aFileName
     "get the resource definitions from a file in the default directory.
      Uncached low-level entry."
@@ -990,7 +1032,7 @@
 !ResourcePack class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.92 2004-03-03 08:59:47 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.93 2004-03-08 18:11:44 cg Exp $'
 ! !
 
 ResourcePack initialize!