Extending FileList with CrLf

Ned Konz ned at bike-nomad.com
Mon Jul 21 15:39:10 UTC 2003


On Monday 21 July 2003 03:33 am, Daniel Vainsencher wrote:
> [Using CrLf by default]
> I strongly disagree. How files are interpreted, at any level,
> should not be a system wide decision made by low level streaming
> classes. It should be an application level decision.

I feel the same way. Plugging CrLfFileStream into the system instead 
of StandardFileStream is not the right thing to do.

At one point I made a rather extensive set of changes that would 
distinguish text streams from binary streams better (different open 
methods), and would make the default text stream reader be something 
very like CrLfFileStream that could do sensible line-end 
translations.

But that didn't handle the cases where someone else opened a stream 
and passed it to a client.

Perhaps a better way to handle this is with stream wrappers that can 
be used after you open a stream for the translations.

In many cases, an open FileStream is being passed around. By then it's 
too late to change it to a CrLfFileStream. However, if we had a 
wrapper, it would be as easy as saying:

readTextFrom: aStream
	| readStream line |
	readStream := aStream asTextStream
		inputLineEndingConversion: #auto;	"this would probably be the 
default"
		outputLineEndingConversion: #cr.	"and this would default to the 
platform standard"
	[ readStream atEnd ] whileFalse: [ line := readStream nextLine. self 
doSomethingWith: line ].




-- 
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE



More information about the Squeak-dev mailing list