# HG changeset patch # User Stefan Vogel # Date 1485878747 -3600 # Node ID 18ca24f32565fb8540cee76ff75775c5c022a5c1 # Parent 9f46467ddc070630b9562e44535b66d8a22eb4a5 #REFACTORING by stefan class: OSProcess changed: #setupShufflerForInput: #setupShufflerForOutput: Use #on:do:ensure: to save a block. diff -r 9f46467ddc07 -r 18ca24f32565 OSProcess.st --- 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'!