7 inclusion of the above copyright notice. This software may not |
7 inclusion of the above copyright notice. This software may not |
8 be provided or otherwise made available to, or used by, any |
8 be provided or otherwise made available to, or used by, any |
9 other person. No title to or ownership of the software is |
9 other person. No title to or ownership of the software is |
10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 |
|
13 "{ Package: 'stx:libbasic' }" |
12 "{ Package: 'stx:libbasic' }" |
14 |
13 |
15 Stream subclass:#PeekableStream |
14 Stream subclass:#PeekableStream |
16 instanceVariableNames:'' |
15 instanceVariableNames:'' |
17 classVariableNames:'ErrorDuringFileInSignal CurrentFileInDirectoryQuerySignal |
16 classVariableNames:'ErrorDuringFileInSignal CurrentFileInDirectoryQuerySignal |
54 |
53 |
55 ErrorDuringFileInSignal isNil ifTrue:[ |
54 ErrorDuringFileInSignal isNil ifTrue:[ |
56 ErrorDuringFileInSignal := Error newSignalMayProceed:true. |
55 ErrorDuringFileInSignal := Error newSignalMayProceed:true. |
57 ErrorDuringFileInSignal nameClass:self message:#errorDuringFileInSignal. |
56 ErrorDuringFileInSignal nameClass:self message:#errorDuringFileInSignal. |
58 ErrorDuringFileInSignal notifierString:'error during fileIn'. |
57 ErrorDuringFileInSignal notifierString:'error during fileIn'. |
59 |
|
60 CurrentFileInDirectoryQuerySignal := QuerySignal new. |
|
61 CurrentFileInDirectoryQuerySignal nameClass:self message:#currentFileInDirectoryQuerySignal. |
|
62 CurrentFileInDirectoryQuerySignal notifierString:'query for current directory when filing in'. |
|
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]. |
|
69 ] |
58 ] |
70 |
59 |
71 " |
60 " |
72 self initialize |
61 self initialize |
73 " |
62 " |
|
63 |
|
64 "Modified: / 23-10-2006 / 16:34:41 / cg" |
74 ! ! |
65 ! ! |
75 |
66 |
76 !PeekableStream class methodsFor:'Signal constants'! |
67 !PeekableStream class methodsFor:'Signal constants'! |
77 |
68 |
78 currentFileInDirectoryQuerySignal |
69 currentFileInDirectoryQuerySignal |
80 during a fileIn (that is the directory where the filed-in file resides), |
71 during a fileIn (that is the directory where the filed-in file resides), |
81 and in a fileBrowsers doIt. |
72 and in a fileBrowsers doIt. |
82 Using this, allows for the loaded code or doIts to ask for the fileBrowsers |
73 Using this, allows for the loaded code or doIts to ask for the fileBrowsers |
83 current directory, by asking this querySignal (which is nice sometimes)." |
74 current directory, by asking this querySignal (which is nice sometimes)." |
84 |
75 |
|
76 CurrentFileInDirectoryQuerySignal isNil ifTrue:[ |
|
77 CurrentFileInDirectoryQuerySignal := QuerySignal new. |
|
78 CurrentFileInDirectoryQuerySignal nameClass:self message:#currentFileInDirectoryQuerySignal. |
|
79 CurrentFileInDirectoryQuerySignal notifierString:'query for current directory when filing in'. |
|
80 CurrentFileInDirectoryQuerySignal handlerBlock:[:ex | ex proceedWith:Filename currentDirectory]. |
|
81 ]. |
85 ^ CurrentFileInDirectoryQuerySignal |
82 ^ CurrentFileInDirectoryQuerySignal |
|
83 |
|
84 "Modified: / 23-10-2006 / 16:34:37 / cg" |
86 ! |
85 ! |
87 |
86 |
88 currentSourceContainerQuery |
87 currentSourceContainerQuery |
89 "return the querySignal, which can be used to ask for the current source container filename |
88 "return the querySignal, which can be used to ask for the current source container filename |
90 during a fileIn |
89 during a fileIn |
91 Using this, allows for the loaded code to remember the classes file name." |
90 Using this, allows for the loaded code to remember the classes file name." |
92 |
91 |
|
92 CurrentSourceContainerQuery isNil ifTrue:[ |
|
93 CurrentSourceContainerQuery := QuerySignal new. |
|
94 CurrentSourceContainerQuery nameClass:self message:#currentClassFilenameQuery. |
|
95 CurrentSourceContainerQuery notifierString:'query for current sorce container name when filing in'. |
|
96 CurrentSourceContainerQuery handlerBlock:[:ex | ex proceedWith:nil]. |
|
97 ]. |
93 ^ CurrentSourceContainerQuery |
98 ^ CurrentSourceContainerQuery |
|
99 |
|
100 "Modified: / 23-10-2006 / 16:32:49 / cg" |
94 ! ! |
101 ! ! |
95 |
102 |
96 !PeekableStream class methodsFor:'queries'! |
103 !PeekableStream class methodsFor:'queries'! |
97 |
104 |
98 currentFileInDirectory |
105 currentFileInDirectory |
99 "during a fileIn (if a script), the script can ask for the current directory" |
106 "during a fileIn (if a script), the script can ask for the current directory" |
100 |
107 |
101 ^ CurrentFileInDirectoryQuerySignal query |
108 ^ self currentFileInDirectoryQuerySignal query |
|
109 |
|
110 "Modified: / 23-10-2006 / 16:34:47 / cg" |
102 ! |
111 ! |
103 |
112 |
104 currentSourceContainer |
113 currentSourceContainer |
105 "during a fileIn (if a script), the script can ask for the current filename" |
114 "during a fileIn (if a script), the script can ask for the current filename" |
106 |
115 |
107 ^ CurrentSourceContainerQuery query |
116 ^ self currentSourceContainerQuery query |
|
117 |
|
118 "Modified: / 23-10-2006 / 16:33:40 / cg" |
108 ! ! |
119 ! ! |
109 |
120 |
110 !PeekableStream methodsFor:'chunk input/output'! |
121 !PeekableStream methodsFor:'chunk input/output'! |
111 |
122 |
112 nextChunk |
123 nextChunk |
590 thisDirectoryPathName := thisDirectory pathName. |
601 thisDirectoryPathName := thisDirectory pathName. |
591 oldPath := Smalltalk systemPath. |
602 oldPath := Smalltalk systemPath. |
592 |
603 |
593 [ |
604 [ |
594 Smalltalk systemPath:(oldPath copy addFirst:thisDirectoryPathName; yourself). |
605 Smalltalk systemPath:(oldPath copy addFirst:thisDirectoryPathName; yourself). |
595 CurrentFileInDirectoryQuerySignal answer:thisDirectory do:[ |
606 self class currentFileInDirectoryQuerySignal answer:thisDirectory do:[ |
596 CurrentSourceContainerQuery answer:self do:[ |
607 self class currentSourceContainerQuery answer:self do:[ |
597 val := self basicFileInNotifying:notifiedLoader passChunk:passChunk. |
608 val := self basicFileInNotifying:notifiedLoader passChunk:passChunk. |
598 ]. |
609 ]. |
599 ] |
610 ] |
600 ] ensure:[ |
611 ] ensure:[ |
601 "take care, someone could have changed SystemPath during fileIn!!" |
612 "take care, someone could have changed SystemPath during fileIn!!" |