374 |
374 |
375 fileIn |
375 fileIn |
376 "file in from the receiver, i.e. read chunks and evaluate them - |
376 "file in from the receiver, i.e. read chunks and evaluate them - |
377 return the value of the last chunk." |
377 return the value of the last chunk." |
378 |
378 |
379 |oldPath val| |
379 |oldPath val notifiedLoader| |
|
380 |
|
381 SourceFileLoader notNil ifTrue:[ |
|
382 notifiedLoader := SourceFileLoader on:self. |
|
383 ]. |
380 |
384 |
381 self isFileStream ifFalse:[ |
385 self isFileStream ifFalse:[ |
382 ^ self fileInNotifying:(SourceFileLoader on:self) passChunk:true. |
386 ^ self fileInNotifying:notifiedLoader passChunk:true. |
383 ]. |
387 ]. |
384 |
388 |
385 [ |thisDirectory| |
389 [ |thisDirectory| |
386 |
390 |
387 oldPath := Smalltalk systemPath. |
391 oldPath := Smalltalk systemPath. |
388 thisDirectory := self pathName asFilename directory. |
392 thisDirectory := self pathName asFilename directory. |
389 Smalltalk systemPath:(oldPath copy addFirst:thisDirectory pathName; yourself). |
393 Smalltalk systemPath:(oldPath copy addFirst:thisDirectory pathName; yourself). |
390 CurrentFileInDirectoryQuerySignal answer:thisDirectory do:[ |
394 CurrentFileInDirectoryQuerySignal answer:thisDirectory do:[ |
391 SourceFileLoader isNil ifTrue:[ |
395 val := self fileInNotifying:notifiedLoader passChunk:true. |
392 val := self fileInNotifying:nil passChunk:true. |
|
393 ] ifFalse:[ |
|
394 val := self fileInNotifying:(SourceFileLoader on:self) passChunk:true. |
|
395 ] |
|
396 ] |
396 ] |
397 ] ensure:[ |
397 ] ensure:[ |
398 Smalltalk systemPath:oldPath. |
398 Smalltalk systemPath:oldPath. |
399 ]. |
399 ]. |
400 ^ val |
400 ^ val |
467 However, other than methodsFor expressions are possible - you can |
467 However, other than methodsFor expressions are possible - you can |
468 (in theory) create readers for any syntax. |
468 (in theory) create readers for any syntax. |
469 " |
469 " |
470 |
470 |
471 |aString sawExcla rslt done| |
471 |aString sawExcla rslt done| |
|
472 |
|
473 Smalltalk::Compiler isNil ifTrue:[ |
|
474 self isFileStream ifTrue:[ |
|
475 Transcript show:('[' , self pathName , '] '). |
|
476 ]. |
|
477 Transcript showCR:'cannot fileIn (no compiler).'. |
|
478 ^ nil. |
|
479 ]. |
472 |
480 |
473 self skipSeparators. |
481 self skipSeparators. |
474 self atEnd ifFalse:[ |
482 self atEnd ifFalse:[ |
475 sawExcla := self peekFor:(self class chunkSeparator). |
483 sawExcla := self peekFor:(self class chunkSeparator). |
476 aString := self nextChunk. |
484 aString := self nextChunk. |