Here a quick hack, in case anyone cares:
'From Pharo1.2a of ''11 June 2010'' [Latest update: #12261] on 1 December 2010
at 10:42:06 pm'!
!FileStream class methodsFor: 'file reader services' stamp: 'StefanMarr
12/1/2010 22:42'!
writeSourceCodeFrom: aStream baseName: baseName isSt: stOrCsFlag
| extension converter fileName lineEndConvention |
lineEndConvention := MultiByteFileStream guessDefaultLineEndConvention.
lineEndConvention := MultiByteFileStream lineEndConventionAsString:
lineEndConvention.
extension := stOrCsFlag ifTrue: ['.st'] ifFalse: ['.cs'].
converter := aStream contents isAsciiString
ifTrue: [MacRomanTextConverter new]
ifFalse: [UTF8TextConverter new].
converter installLineEndConvention: lineEndConvention.
fileName := baseName, extension.
fileName := FileDirectory default checkName: fileName fixErrors: true.
[FileStream newFileNamed: fileName do: [:fileStream |
(converter isMemberOf: UTF8TextConverter)
ifTrue: [fileStream binary.
UTF8TextConverter writeBOMOn:
fileStream].
fileStream
text;
converter: converter;
nextPutAll: aStream contents;
close]] on: Abort do: [:e | ]! !
!MultiByteFileStream class methodsFor: 'class initialization' stamp:
'StefanMarr 12/1/2010 22:39'!
defaultToCR
"MultiByteFileStream defaultToCR"
LineEndDefault := #cr.
^ LineEndDefault! !
!MultiByteFileStream class methodsFor: 'class initialization' stamp:
'StefanMarr 12/1/2010 22:39'!
defaultToCRLF
"MultiByteFileStream defaultToCRLF"
LineEndDefault := #crlf.
^ LineEndDefault! !
!MultiByteFileStream class methodsFor: 'class initialization' stamp:
'StefanMarr 12/1/2010 22:39'!
defaultToLF
"MultiByteFileStream defaultToLF"
LineEndDefault := #lf.
^ LineEndDefault
! !
!MultiByteFileStream class methodsFor: 'class initialization' stamp:
'StefanMarr 12/1/2010 22:36'!
lineEndConventionAsString: conventionSymbol
^ LineEndStrings at: conventionSymbol
! !
On 30 Nov 2010, at 14:06, Stefan Marr wrote:
> Hi:
>
> On 30 Nov 2010, at 13:56, Schwab,Wilhelm K wrote:
>
>> A possible wrinkle: what about using Linux to write a file for a Windows
>> user?
> That is why I proposed to use MultiByteFileStream LineEndDefault.
>
> There are methods in MultiByteFileStream to set it explicitly. So, it could
> be either set in a save dialog, or a user preference somewhere, I guess.
>
> Best regards
> Stefan
>
> PS: The file stream should be initialized on creation with
> MultiByteFileStream LineEndDefault, otherwise it is not thread/RoarVM-safe...
>
>>
>>
>> ________________________________________
>> From: [email protected]
>> [[email protected]] On Behalf Of Stefan Marr
>> [[email protected]]
>> Sent: Tuesday, November 30, 2010 7:13 AM
>> To: [email protected]
>> Subject: Re: [Pharo-project] Changesets with LF/CRLF instead of CR?
>>
>> Hello:
>>
>> On 30 Nov 2010, at 09:20, Stéphane Ducasse wrote:
>>
>>> as a general principle, I'm open to change for the better :)
>>> Now how much?
>>> - cost to do
>> Cleaning it up completely does not looks like a simple/localized change to a
>> single method.
>>
>> There are 'aFileStream cr' message sends all over the place, which from my
>> perspective are wrong in the sense that they are not platform independent. I
>> guess the best way would be to have something like 'aFileStream nl' or
>> 'lineEnd' instead. Where nl/lineEnd uses MultiByteFileStream LineEndDefault.
>>
>> Best regards
>> Stefan
>>
>> --
>> Stefan Marr
>> Software Languages Lab
>> Vrije Universiteit Brussel
>> Pleinlaan 2 / B-1050 Brussels / Belgium
>> http://soft.vub.ac.be/~smarr
>> Phone: +32 2 629 2974
>> Fax: +32 2 629 3525
>>
>>
>>
>
> --
> Stefan Marr
> Software Languages Lab
> Vrije Universiteit Brussel
> Pleinlaan 2 / B-1050 Brussels / Belgium
> http://soft.vub.ac.be/~smarr
> Phone: +32 2 629 2974
> Fax: +32 2 629 3525
>
>
--
Stefan Marr
Software Languages Lab
Vrije Universiteit Brussel
Pleinlaan 2 / B-1050 Brussels / Belgium
http://soft.vub.ac.be/~smarr
Phone: +32 2 629 2974
Fax: +32 2 629 3525