Class.st
branchjv
changeset 25404 a215a0c88872
parent 25398 b0d020199bd0
child 25410 c91ea94445d1
--- a/Class.st	Thu Nov 12 08:33:36 2020 +0000
+++ b/Class.st	Fri Nov 13 23:55:27 2020 +0000
@@ -4810,7 +4810,7 @@
 localSourceStreamFor:sourceFile
     "return an open stream on a local sourcefile, nil if that is not available"
 
-    |fileName info module dir fn package packageDir zar entry|
+    |fileName info module dir fn package packageDir zar entry sourceFileBase |
 
     "/
     "/ old: look in 'source/<filename>'
@@ -4818,9 +4818,10 @@
     "/ classes in her currentDirectory.
     "/
     fileName := Smalltalk getSourceFileName:sourceFile.
-    fileName notNil ifTrue:[
-	^ fileName asFilename readStreamOrNil.
+    (fileName notNil and:[(fileName := fileName asFilename) exists]) ifTrue:[
+	^ fileName readStreamOrNil.
     ].
+    sourceFileBase := sourceFile copyFrom: (sourceFile lastIndexOf: Filename separator) + 1.
 
     (package := self package) notNil ifTrue:[
 	"/ newest scheme ...
@@ -4828,12 +4829,12 @@
 	packageDir notNil ifTrue:[
 	    "/ present there ?
 	    packageDir := packageDir asFilename.
-	    (fn := packageDir construct:sourceFile) exists ifTrue:[
+	    (fn := packageDir construct:sourceFileBase) exists ifTrue:[
 		^ fn readStreamOrNil.
 	    ].
 
 	    "/ a source subdirectory ?
-	    fn := (packageDir construct:'source') construct:sourceFile.
+	    fn := (packageDir construct:'source') construct:sourceFileBase.
 	    fn exists ifTrue:[
 		^ fn readStreamOrNil.
 	    ].
@@ -4843,7 +4844,7 @@
 	    fn exists ifTrue:[
 		zar := ZipArchive oldFileNamed:fn.
 		zar notNil ifTrue:[
-		    entry := zar extract:sourceFile.
+		    entry := zar extract:sourceFileBase.
 		    entry notNil ifTrue:[
 			^ entry asString readStream
 		    ]
@@ -4857,12 +4858,12 @@
 	] ifFalse:[
 	    package := 'stx/' , package
 	].
-	fileName := Smalltalk getSourceFileName:(package , '/' , sourceFile).
+	fileName := Smalltalk getSourceFileName:(package , '/' , sourceFileBase).
 	fileName notNil ifTrue:[
 	    ^ fileName asFilename readStreamOrNil.
 	].
 	(package startsWith:'stx/') ifTrue:[
-	    fileName := Smalltalk getSourceFileName:((package copyFrom:5) , '/' , sourceFile).
+	    fileName := Smalltalk getSourceFileName:((package copyFrom:5) , '/' , sourceFileBase).
 	    fileName notNil ifTrue:[
 		^ fileName asFilename readStreamOrNil.
 	    ]
@@ -4879,7 +4880,7 @@
 	module notNil ifTrue:[
 	    dir := info at:#directory ifAbsent:nil.
 	    dir notNil ifTrue:[
-		fn := (module asFilename construct:dir) construct:sourceFile.
+		fn := (module asFilename construct:dir) construct:sourceFileBase.
 		fileName := Smalltalk getSourceFileName:(fn name).
 		fileName notNil ifTrue:[
 		    ^ fileName asFilename readStreamOrNil.
@@ -4893,7 +4894,7 @@
 		fileName notNil ifTrue:[
 		    zar := ZipArchive oldFileNamed:fileName.
 		    zar notNil ifTrue:[
-			entry := zar extract:sourceFile.
+			entry := zar extract:sourceFileBase.
 			entry notNil ifTrue:[
 			    ^ entry asString readStream
 			]
@@ -4906,7 +4907,7 @@
 		fileName notNil ifTrue:[
 		    zar := ZipArchive oldFileNamed:fileName.
 		    zar notNil ifTrue:[
-			entry := zar extract:sourceFile.
+			entry := zar extract:sourceFileBase.
 			entry notNil ifTrue:[
 			    ^ entry asString readStream
 			]