- it still returns the FSReference...
what you want is the following I guess:
(wk / 'foo') writeStreamDo: [ :s| s << 'bar' ].
since that will - create also create a new file. - ensure closing the stream
Yes I did the same.
FSReference>>writeStreamDo: doBlock ifPresent: presentBlock "Create a file if not present and execute doBlock (with a stream) as argument, if the file is present execute the presentBlock." ^ self isFile ifTrue: [ presentBlock value ] ifFalse: [ self writeStreamDo: doBlock ]
FSReference>>writeStreamIfPresent: presentBlock "Return a writestream on the receiver if it does not already exist or execute the presentBlock with no argument" ^ self isFile ifTrue: [ presentBlock value ] ifFalse: [ self writeStream ]
I do not get why we do not get as argument to the presentBlock the file itself?
indeed, a [... cull: self] might make sense here :)