'From Squeak3.2alpha of 7 October 2001 [latest update: #4418] on 24 October 2001 at 10:19:30 pm'! "Change Set: FileExistsFix Date: 24 October 2001 Author: Leandro Caniglia If you try to overwrite a file that already existed (by sending the message #newFileNamed:), then a StandardFileStream will be created. This behavior is observed even when the receiver of the original message were a subclass of SFS. For instance, trying to overwrite a CrLfFileStream will result in a StandardFileStream, and not in a CrLfFileStream."! FileStreamException subclass: #FileExistsException instanceVariableNames: 'fileClass ' classVariableNames: '' poolDictionaries: '' category: 'System-Exceptions Kernel'! !FileExistsException methodsFor: 'accessing' stamp: 'LC 10/24/2001 21:49'! fileClass ^ fileClass ifNil: [StandardFileStream]! ! !FileExistsException methodsFor: 'accessing' stamp: 'LC 10/24/2001 21:42'! fileClass: aClass fileClass _ aClass! ! !FileExistsException methodsFor: 'exceptionDescription' stamp: 'LC 10/24/2001 21:50'! defaultAction "The default action taken if the exception is signaled." ^ self fileClass fileExistsUserHandling: self fileName ! ! !FileExistsException class methodsFor: 'exceptionInstantiator' stamp: 'LC 10/24/2001 21:50'! fileName: aFileName fileClass: aClass ^ self new fileName: aFileName; fileClass: aClass! ! !StandardFileStream class methodsFor: 'file creation' stamp: 'LC 10/24/2001 21:43'! newFileNamed: fileName "Create a new file with the given name, and answer a stream opened for writing on that file. If the file already exists, ask the user what to do." | fullName | fullName _ self fullName: fileName. ^(self isAFileNamed: fullName) ifTrue: ["file already exists:" (FileExistsException fileName: fullName fileClass: self) signal] ifFalse: [self new open: fullName forWrite: true] ! ! !FileExistsException reorganize! ('accessing' fileClass fileClass:) ('exceptionDescription' defaultAction) !