remember the actual filename from which a pack was read
authorClaus Gittinger <cg@exept.de>
Sun, 04 Nov 2012 22:17:21 +0100
changeset 5951 61a41352ce81
parent 5950 da52b2da9583
child 5952 5a8e9468117a
remember the actual filename from which a pack was read
ResourcePack.st
--- a/ResourcePack.st	Sun Nov 04 21:49:06 2012 +0100
+++ b/ResourcePack.st	Sun Nov 04 22:17:21 2012 +0100
@@ -12,7 +12,7 @@
 "{ Package: 'stx:libview' }"
 
 Dictionary subclass:#ResourcePack
-	instanceVariableNames:'packsClassName fileReadFailed superPack projectPack'
+	instanceVariableNames:'packsClassName packsFileName fileReadFailed superPack projectPack'
 	classVariableNames:'Packs FailedToLoadPacks DebugModifications'
 	poolDictionaries:''
 	category:'Interface-Internationalization'
@@ -1113,13 +1113,21 @@
 !
 
 packsClassOrFileName
+    "old: should no longer be used to access the filename; see packsFileName"
+
     ^ packsClassName
 !
 
 packsClassOrFileName:aString
+    "old: should no longer be used to access the filename; see packsFileName"
+
     packsClassName := aString
 !
 
+packsFileName
+    ^ packsFileName
+!
+
 projectPack
     ^ projectPack
 
@@ -1182,7 +1190,7 @@
 readFromFile:fileName directory:dirName
     "read definitions from a file in a directory"
 
-    |inStream ok|
+    |triedFilename inStream ok|
 
     fileReadFailed := false.
     "/ need to catch errors here, as the handler might itself need resources.
@@ -1208,13 +1216,19 @@
         ^ self nonexistingFileRead
     ].
 
-    ok := self readFromResourceStream:inStream in:(inStream pathName asFilename directoryName).
-    inStream close.
+    triedFilename := inStream pathName.
+    [
+        ok := self readFromResourceStream:inStream in:(triedFilename asFilename directoryName).
+    ] ensure:[
+        inStream close.
+    ].
 
-    ok ifFalse:[
+    ok ifTrue:[
+        packsFileName := triedFilename
+    ] ifFalse:[
         fileReadFailed := true.
 
-        ('ResourcePack [warning]: ''' , inStream pathName , ''' contains error(s) - data may be incomplete.') errorPrintCR.
+        ('ResourcePack [warning]: "' , triedFilename , '" contains error(s) - data may be incomplete.') errorPrintCR.
     ].
 
     "Modified: / 20-08-2011 / 17:10:02 / cg"
@@ -1407,11 +1421,11 @@
 !ResourcePack class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.150 2011-09-28 13:55:53 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.151 2012-11-04 21:17:21 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.150 2011-09-28 13:55:53 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.151 2012-11-04 21:17:21 cg Exp $'
 ! !
 
 ResourcePack initialize!