I just had to commit a small change to this method to prevent it mangling filenames inappropriately but in the process it struck me that this is a bit of a weird bit of code.
For a start there isn’t any point to the split around byte or wide string for the filename extension since the same result is used now - from the commented out bits we can see what used to happen. It makes it pretty clear that the FileStream>multiCs & multiSt are pointless anyway. Nobody sends them.
Then the explicit playing with the text convertor appears pointless too, since the MultiByteFileStream code handles that.
And so far as I can work out nobody actually does anything with the whole html flag part - the sole effect seems to be the file extension and no conversion to html formatted contents is even attempted.
Does anyone remember why this rather complicated method was needed, and if it really still is? A much simpler version of the code seems to do the right thing but I’m no expert in the i18n arena (the middle-finger emoji is deliberately in that comment to try to trigger the multibyte handling) -
writeSourceCodeFrom: aStream baseName: baseName isSt: stOrCsFlag useHtml: useHtml
"Write the source code from aStream into a file.'foo $🖕'"
| extension fileName |
stOrCsFlag ifTrue: [
extension := (FileDirectory dot, FileStream st).
] ifFalse: [
extension := (FileDirectory dot, FileStream cs).
].
useHtml ifTrue: [extension := FileDirectory dot, 'html'].
fileName := (self class baseNameFor: baseName) , extension. "oh, for a decent file name system"
self newFileNamed: fileName do:[:f|
f nextPutAll: aStream contents]
tim
--
tim Rowledge;
[hidden email];
http://www.rowledge.org/timI'm so skeptical that I'm not sure I'm really a skeptic