[BUG][FIX] FileStreamException (fix default actions)

David T. Lewis lewis at mail.msen.com
Sun Jan 14 17:38:15 UTC 2001


This change set modifies the fileStream exception default actions
to refer to the context of the method which generated the exception,
rather than to assume that the exception was raised by an instance
of StandardFileStream. Specifically, instances of FileStreamException
will send messages to initialContext>>receiver rather than to class
StandardFileStream.

For VM builders and plugin hackers, this corrects the annoying
tendency of CCodeGenerator to use unintended line feed conventions
in the generated code when overwriting existing files.

To reproduce the problem addressed by this change set, first modify
FileStream>>concreteStream to answer CrLfFileStream, then:

  FileStream newFileNamed: 'myNewFile'
    ==> CrLfFileStream throws an exception if 'myNewFile' already
        exists.
    ==> User responds to dialog from a FileExistsException, and requests
        that the file be overwritten.
    ==> An instance of StandardFileStream is created, instead of the
        intended CrLfFileStream.

-Dave

-------------- next part --------------
'From Squeak2.9alpha of 13 June 2000 [latest update: #3125] on 14 January 2001 at 12:29:38 pm'!
"Change Set:		FileStreamExceptionsFix
Date:			14 January 2001
Author:			David T. Lewis

Changes fileStream exception default actions to refer to the context
of the method which generated the exception, rather than to assume
that the exception was raised by an instance of StandardFileStream.
Specifically, instances of FileStreamException send messages to
initialContext>>receiver rather than to class StandardFileStream.

For VM builders and plugin hackers, this corrects the annoying
tendency of CCodeGenerator to use unintended line feed conventions
in the generated code when overwriting existing files.

To reproduce the problem addressed by this change set, first modify
FileStream>>concreteStream to answer CrLfFileStream, then:

  FileStream newFileNamed: 'myNewFile'
    ==> CrLfFileStream throws an exception if 'myNewFile' already
        exists.
    ==> User responds to dialog fro!
 m a FileExistsException, and requests
        that the file be overwritten.
    ==> An instance of StandardFileStream is created, instead of the
        intended CrLfFileStream."!


!FileDoesNotExistException methodsFor: 'exceptionDescription' stamp: 'dtl 1/14/2001 10:14'!
defaultAction
	"The default action taken if the exception is signaled."


	^self readOnly
		ifTrue: [initialContext receiver readOnlyFileDoesNotExistUserHandling: self fileName]
		ifFalse: [initialContext receiver fileDoesNotExistUserHandling: self fileName]
! !


!FileExistsException methodsFor: 'exceptionDescription' stamp: 'dtl 1/14/2001 10:13'!
defaultAction
	"The default action taken if the exception is signaled."

	^initialContext receiver fileExistsUserHandling: self fileName
! !


More information about the Squeak-dev mailing list