3232 ! |
3232 ! |
3233 |
3233 |
3234 localSourceStreamFor:sourceFile |
3234 localSourceStreamFor:sourceFile |
3235 "return an open stream on a local sourcefile, nil if that is not available" |
3235 "return an open stream on a local sourcefile, nil if that is not available" |
3236 |
3236 |
3237 |fileName info module dir fn package zar entry| |
3237 |fileName info module dir fn package packageDir zar entry| |
3238 |
3238 |
3239 "/ |
3239 "/ |
3240 "/ old: look in 'source/<filename>' |
3240 "/ old: look in 'source/<filename>' |
3241 "/ this is still kept in order to find user-private |
3241 "/ this is still kept in order to find user-private |
3242 "/ classes in her currentDirectory. |
3242 "/ classes in her currentDirectory. |
3243 "/ |
3243 "/ |
3244 fileName := Smalltalk getSourceFileName:sourceFile. |
3244 fileName := Smalltalk getSourceFileName:sourceFile. |
3245 fileName notNil ifTrue:[ |
3245 fileName notNil ifTrue:[ |
3246 ^ fileName asFilename readStream. |
3246 ^ fileName asFilename readStream. |
3247 ]. |
3247 ]. |
3248 |
3248 |
3249 (package := self package) notNil ifTrue:[ |
3249 (package := self package) notNil ifTrue:[ |
3250 (package includes:$:) ifTrue:[ |
3250 "/ newest sceme ... |
3251 package := package asString copyReplaceAll:$: with:$/ |
3251 packageDir := package copyReplaceAll:$: with:$/. |
3252 ] ifFalse:[ |
3252 packageDir := Smalltalk getPackageFileName:packageDir. |
3253 package := 'stx/' , package |
3253 packageDir notNil ifTrue:[ |
3254 ]. |
3254 "/ present there ? |
3255 fileName := Smalltalk getSourceFileName:(package , '/' , sourceFile). |
3255 packageDir := packageDir asFilename. |
3256 fileName notNil ifTrue:[ |
3256 (fn := packageDir construct:sourceFile) exists ifTrue:[ |
3257 ^ fileName asFilename readStream. |
3257 ^ fn readStream. |
3258 ]. |
3258 ]. |
3259 (package startsWith:'stx/') ifTrue:[ |
3259 |
3260 fileName := Smalltalk getSourceFileName:((package copyFrom:5) , '/' , sourceFile). |
3260 "/ a source subdirectory ? |
3261 fileName notNil ifTrue:[ |
3261 fn := (packageDir construct:'source') construct:sourceFile. |
3262 ^ fileName asFilename readStream. |
3262 fn exists ifTrue:[ |
3263 ] |
3263 ^ fn readStream. |
3264 ] |
3264 ]. |
|
3265 |
|
3266 "/ a zip-file ? |
|
3267 fn := (packageDir construct:'source.zip'). |
|
3268 fn exists ifTrue:[ |
|
3269 zar := ZipArchive oldFileNamed:fn. |
|
3270 zar notNil ifTrue:[ |
|
3271 entry := zar extract:sourceFile. |
|
3272 entry notNil ifTrue:[ |
|
3273 ^ entry asString readStream |
|
3274 ] |
|
3275 ] |
|
3276 ] |
|
3277 ]. |
|
3278 |
|
3279 "/ will vanish ... |
|
3280 (package includes:$:) ifTrue:[ |
|
3281 package := package asString copyReplaceAll:$: with:$/ |
|
3282 ] ifFalse:[ |
|
3283 package := 'stx/' , package |
|
3284 ]. |
|
3285 fileName := Smalltalk getSourceFileName:(package , '/' , sourceFile). |
|
3286 fileName notNil ifTrue:[ |
|
3287 ^ fileName asFilename readStream. |
|
3288 ]. |
|
3289 (package startsWith:'stx/') ifTrue:[ |
|
3290 fileName := Smalltalk getSourceFileName:((package copyFrom:5) , '/' , sourceFile). |
|
3291 fileName notNil ifTrue:[ |
|
3292 ^ fileName asFilename readStream. |
|
3293 ] |
|
3294 ] |
3265 ]. |
3295 ]. |
3266 |
3296 |
3267 "/ |
3297 "/ |
3268 "/ new: look in 'source/<module>/<package>/<filename> |
3298 "/ new: look in 'source/<module>/<package>/<filename> |
3269 "/ this makes the symbolic links to (or copy of) the source files |
3299 "/ this makes the symbolic links to (or copy of) the source files |
3270 "/ obsolete. |
3300 "/ obsolete. |
3271 info := self packageSourceCodeInfo. |
3301 info := self packageSourceCodeInfo. |
3272 info notNil ifTrue:[ |
3302 info notNil ifTrue:[ |
3273 module := info at:#module ifAbsent:nil. |
3303 module := info at:#module ifAbsent:nil. |
3274 module notNil ifTrue:[ |
3304 module notNil ifTrue:[ |
3275 dir := info at:#directory ifAbsent:nil. |
3305 dir := info at:#directory ifAbsent:nil. |
3276 dir notNil ifTrue:[ |
3306 dir notNil ifTrue:[ |
3277 fn := (module asFilename construct:dir) construct:sourceFile. |
3307 fn := (module asFilename construct:dir) construct:sourceFile. |
3278 fileName := Smalltalk getSourceFileName:(fn name). |
3308 fileName := Smalltalk getSourceFileName:(fn name). |
3279 fileName notNil ifTrue:[ |
3309 fileName notNil ifTrue:[ |
3280 ^ fileName asFilename readStream. |
3310 ^ fileName asFilename readStream. |
3281 ]. |
3311 ]. |
3282 |
3312 |
3283 "/ brand new: look for source/<module>/package.zip |
3313 "/ brand new: look for source/<module>/package.zip |
3284 "/ containing an entry for <filename> |
3314 "/ containing an entry for <filename> |
3285 |
3315 |
3286 fn := (module asFilename construct:dir) withSuffix:'zip'. |
3316 fn := (module asFilename construct:dir) withSuffix:'zip'. |
3287 fileName := Smalltalk getSourceFileName:(fn name). |
3317 fileName := Smalltalk getSourceFileName:(fn name). |
3288 fileName notNil ifTrue:[ |
3318 fileName notNil ifTrue:[ |
3289 zar := ZipArchive oldFileNamed:fileName. |
3319 zar := ZipArchive oldFileNamed:fileName. |
3290 zar notNil ifTrue:[ |
3320 zar notNil ifTrue:[ |
3291 entry := zar extract:sourceFile. |
3321 entry := zar extract:sourceFile. |
3292 entry notNil ifTrue:[ |
3322 entry notNil ifTrue:[ |
3293 ^ entry asString readStream |
3323 ^ entry asString readStream |
3294 ] |
3324 ] |
3295 ] |
3325 ] |
3296 ]. |
3326 ]. |
3297 |
3327 |
3298 "/ and also in source/source.zip ... |
3328 "/ and also in source/source.zip ... |
3299 |
3329 |
3300 fileName := Smalltalk getSourceFileName:'source.zip'. |
3330 fileName := Smalltalk getSourceFileName:'source.zip'. |
3301 fileName notNil ifTrue:[ |
3331 fileName notNil ifTrue:[ |
3302 zar := ZipArchive oldFileNamed:fileName. |
3332 zar := ZipArchive oldFileNamed:fileName. |
3303 zar notNil ifTrue:[ |
3333 zar notNil ifTrue:[ |
3304 entry := zar extract:sourceFile. |
3334 entry := zar extract:sourceFile. |
3305 entry notNil ifTrue:[ |
3335 entry notNil ifTrue:[ |
3306 ^ entry asString readStream |
3336 ^ entry asString readStream |
3307 ] |
3337 ] |
3308 ] |
3338 ] |
3309 ]. |
3339 ]. |
3310 ] |
3340 ] |
3311 ] |
3341 ] |
3312 ]. |
3342 ]. |
3313 ^ nil |
3343 ^ nil |
3314 |
3344 |
3315 "Modified: / 18.7.1998 / 22:53:19 / cg" |
3345 "Modified: / 18.7.1998 / 22:53:19 / cg" |
3316 ! |
3346 ! |