[squeak-dev] FileStream purports ascii text to be html

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[squeak-dev] FileStream purports ascii text to be html

Tim Johnson
Hi,

I'll try to file this on Mantis but I don't know if it's a bug, design
flaw, deliberate choice, my ignorance, or what.  I searched the list
archives via Nabble and could not find anything related.

In a Browser, choose "printOut" from the class pane menu.  This will
create a file in your image's directory named className.html.  However,
it is not an HTML file.  It is plaintext.  Safari and Opera display the
file with no linefeeds.

The ultimate method being called by Browser>>printOutClass is
FileStream>>writeSourceCodeFrom:baseName:isSt:useHtml: which responds
to a "true" value for #useHtml: by simply adding .html to a filename,
rather than actually writing out a proper HTML file.  This is
deceptive.  Perhaps the file name should be kept as .txt so a user
opening the file by double-clicking is not presented by a web browser
full of linefeedless code.

- timj

---

Browser>>printOutClass
        "Print a description of the selected class onto a file whose name is
the
        category name followed by .html."

Cursor write showWhile:
                [classListIndex ~= 0 ifTrue: [self selectedClass fileOutAsHtml: true]]

----

FileStream>>writeSourceCodeFrom:baseName:isSt:useHtml:

[...]
        fileName := useHtml ifTrue: [baseName, '.html'] ifFalse: [baseName,
extension].
        f := FileStream newFileNamed: fileName.
        f ifNil: [^ self error: 'Cannot open file'].
        (converter isMemberOf: UTF8TextConverter)
                ifTrue: [f binary.
                        UTF8TextConverter writeBOMOn: f].
        f text.
        f converter: converter.
        f nextPutAll: aStream contents.
        f close.