12 |
12 |
13 "{ Package: 'stx:libbasic' }" |
13 "{ Package: 'stx:libbasic' }" |
14 |
14 |
15 Stream subclass:#PeekableStream |
15 Stream subclass:#PeekableStream |
16 instanceVariableNames:'' |
16 instanceVariableNames:'' |
17 classVariableNames:'ErrorDuringFileInSignal CurrentFileInDirectoryQuerySignal' |
17 classVariableNames:'ErrorDuringFileInSignal CurrentFileInDirectoryQuerySignal |
|
18 CurrentSourceContainerQuery' |
18 poolDictionaries:'' |
19 poolDictionaries:'' |
19 category:'Streams' |
20 category:'Streams' |
20 ! |
21 ! |
21 |
22 |
22 !PeekableStream class methodsFor:'documentation'! |
23 !PeekableStream class methodsFor:'documentation'! |
58 |
59 |
59 CurrentFileInDirectoryQuerySignal := QuerySignal new. |
60 CurrentFileInDirectoryQuerySignal := QuerySignal new. |
60 CurrentFileInDirectoryQuerySignal nameClass:self message:#currentFileInDirectoryQuerySignal. |
61 CurrentFileInDirectoryQuerySignal nameClass:self message:#currentFileInDirectoryQuerySignal. |
61 CurrentFileInDirectoryQuerySignal notifierString:'query for current directory when filing in'. |
62 CurrentFileInDirectoryQuerySignal notifierString:'query for current directory when filing in'. |
62 CurrentFileInDirectoryQuerySignal handlerBlock:[:ex | ex proceedWith:Filename currentDirectory]. |
63 CurrentFileInDirectoryQuerySignal handlerBlock:[:ex | ex proceedWith:Filename currentDirectory]. |
|
64 |
|
65 CurrentSourceContainerQuery := QuerySignal new. |
|
66 CurrentSourceContainerQuery nameClass:self message:#currentClassFilenameQuery. |
|
67 CurrentSourceContainerQuery notifierString:'query for current sorce container name when filing in'. |
|
68 CurrentSourceContainerQuery handlerBlock:[:ex | ex proceedWith:nil]. |
63 ] |
69 ] |
64 |
70 |
65 " |
71 " |
66 self initialize |
72 self initialize |
67 " |
73 " |
75 and in a fileBrowsers doIt. |
81 and in a fileBrowsers doIt. |
76 Using this, allows for the loaded code or doIts to ask for the fileBrowsers |
82 Using this, allows for the loaded code or doIts to ask for the fileBrowsers |
77 current directory, by asking this querySignal (which is nice sometimes)." |
83 current directory, by asking this querySignal (which is nice sometimes)." |
78 |
84 |
79 ^ CurrentFileInDirectoryQuerySignal |
85 ^ CurrentFileInDirectoryQuerySignal |
|
86 ! |
|
87 |
|
88 currentSourceContainerQuery |
|
89 "return the querySignal, which can be used to ask for the current source container filename |
|
90 during a fileIn |
|
91 Using this, allows for the loaded code to remember the classes file name." |
|
92 |
|
93 ^ CurrentSourceContainerQuery |
80 ! ! |
94 ! ! |
81 |
95 |
82 !PeekableStream class methodsFor:'queries'! |
96 !PeekableStream class methodsFor:'queries'! |
83 |
97 |
84 currentFileInDirectory |
98 currentFileInDirectory |
85 "during a fileIn (if a script), the script can ask for the current directory" |
99 "during a fileIn (if a script), the script can ask for the current directory" |
86 |
100 |
87 ^ CurrentFileInDirectoryQuerySignal query |
101 ^ CurrentFileInDirectoryQuerySignal query |
|
102 ! |
|
103 |
|
104 currentSourceContainer |
|
105 "during a fileIn (if a script), the script can ask for the current filename" |
|
106 |
|
107 ^ CurrentSourceContainerQuery query |
88 ! ! |
108 ! ! |
89 |
109 |
90 !PeekableStream methodsFor:'chunk input/output'! |
110 !PeekableStream methodsFor:'chunk input/output'! |
91 |
111 |
92 nextChunk |
112 nextChunk |
571 oldPath := Smalltalk systemPath. |
591 oldPath := Smalltalk systemPath. |
572 |
592 |
573 [ |
593 [ |
574 Smalltalk systemPath:(oldPath copy addFirst:thisDirectoryPathName; yourself). |
594 Smalltalk systemPath:(oldPath copy addFirst:thisDirectoryPathName; yourself). |
575 CurrentFileInDirectoryQuerySignal answer:thisDirectory do:[ |
595 CurrentFileInDirectoryQuerySignal answer:thisDirectory do:[ |
576 val := self basicFileInNotifying:notifiedLoader passChunk:passChunk. |
596 CurrentSourceContainerQuery answer:self do:[ |
|
597 val := self basicFileInNotifying:notifiedLoader passChunk:passChunk. |
|
598 ]. |
577 ] |
599 ] |
578 ] ensure:[ |
600 ] ensure:[ |
579 "take care, someone could have changed SystemPath during fileIn!!" |
601 "take care, someone could have changed SystemPath during fileIn!!" |
580 (Smalltalk systemPath copyFrom:2) = oldPath ifTrue:[ |
602 (Smalltalk systemPath copyFrom:2) = oldPath ifTrue:[ |
581 Smalltalk systemPath:oldPath. |
603 Smalltalk systemPath:oldPath. |