#REFACTORING by stefan
class: OSProcess
changed:
#setupShufflerForInput:
#setupShufflerForOutput:
Use #on:do:ensure: to save a block.
--- a/OSProcess.st Tue Jan 31 00:20:04 2017 +0100
+++ b/OSProcess.st Tue Jan 31 17:05:47 2017 +0100
@@ -329,22 +329,22 @@
"/ inStream to the pipe (which is connected to the commands input)
shufflerProcess := [
[
- WriteError handle:[:ex |"ignored" ] do:[
- lineWise ifTrue:[
- "shuffle until end-of-input"
- [aStream atEnd] whileFalse:[
- |data|
+ lineWise ifTrue:[
+ "shuffle until end-of-input"
+ [aStream atEnd] whileFalse:[
+ |data|
- data := aStream nextLine.
- data notNil ifTrue:[
- shuffledStream nextPutLine:data.
- shuffledStream flush.
- ].
+ data := aStream nextLine.
+ data notNil ifTrue:[
+ shuffledStream nextPutLine:data.
+ shuffledStream flush.
].
- ] ifFalse:[
- aStream copyToEndInto:shuffledStream.
].
+ ] ifFalse:[
+ aStream copyToEndInto:shuffledStream.
].
+ ] on:WriteError do:[:ex|
+ "ignore"
] ensure:[
shuffledStream close.
]
@@ -357,6 +357,8 @@
streamsToClose add:externalStream.
^ externalStream
+
+ "Modified: / 31-01-2017 / 16:50:39 / stefan"
!
setupShufflerForOutput:aStream
@@ -377,24 +379,24 @@
].
shufflerProcess := [
- WriteError handle:[:ex |"ignored" ] do:[
- [
- "shuffle until the pipe closes"
- lineWise ifTrue:[
- [shuffledStream atEnd] whileFalse:[
- |data|
+ [
+ "shuffle until the pipe closes"
+ lineWise ifTrue:[
+ [shuffledStream atEnd] whileFalse:[
+ |data|
- data := shuffledStream nextLine.
- data notNil ifTrue:[
- aStream nextPutLine:data
- ].
+ data := shuffledStream nextLine.
+ data notNil ifTrue:[
+ aStream nextPutLine:data
].
- ] ifFalse:[
- shuffledStream copyToEndInto:aStream.
].
- ] ensure:[
- shuffledStream close.
+ ] ifFalse:[
+ shuffledStream copyToEndInto:aStream.
].
+ ] on:WriteError do:[:ex |
+ "ignore"
+ ] ensure:[
+ shuffledStream close.
].
] newProcess
priority:(Processor userSchedulingPriority "+ 1");
@@ -406,6 +408,8 @@
streamsToClose add:externalStream.
^ externalStream
+
+ "Modified: / 31-01-2017 / 16:57:25 / stefan"
! !
!OSProcess methodsFor:'queries'!