[squeak-dev] The Trunk: System-fbs.563.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Jul 12 19:08:19 UTC 2013


Frank Shearar uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-fbs.563.mcz

==================== Summary ====================

Name: System-fbs.563
Author: fbs
Time: 12 July 2013, 8:07:20.531 pm
UUID: 77979621-cebe-5d49-b9ae-244955755030
Ancestors: System-fbs.562

Break File's dependency on System by pushing error handling into System-Files. ReplaceExistingFileException turns a UIManager request into a resumable exception.

Files thus contains the definition of the exceptions, while System decorates these with basic error handling (in the default case).

=============== Diff against System-fbs.562 ===============

Item was added:
+ ----- Method: FileDoesNotExistException>>defaultAction (in category '*System-Files-error handling') -----
+ defaultAction
+ 	"The default action taken if the exception is signaled."
+ 
+ 	^self readOnly
+ 		ifTrue: [StandardFileStream readOnlyFileDoesNotExistUserHandling: self fileName
+ 			ifDebug: [super defaultAction]]
+ 		ifFalse: [StandardFileStream fileDoesNotExistUserHandling: self fileName
+ 			ifDebug: [super defaultAction]]
+ !

Item was added:
+ ----- Method: FileExistsException>>defaultAction (in category '*System-Files-error handling') -----
+ defaultAction
+ 	"The default action taken if the exception is signaled."
+ 
+ 	^ self fileClass fileExistsUserHandling: self fileName ifDebug: [super defaultAction]
+ !

Item was added:
+ ----- Method: ReplaceExistingFileException>>defaultAction (in category '*System-Files-error handling') -----
+ defaultAction
+ 	| selection |
+ 	selection := UIManager default
+ 		chooseFrom: #('delete version in target directory' 'cancel' )
+ 		title: fileName , ' already exists'.
+ 	^ selection = 1.!

Item was added:
+ ----- Method: StandardFileStream class>>fileDoesNotExistUserHandling:ifDebug: (in category '*System-Files-error handling') -----
+ fileDoesNotExistUserHandling: fullFileName ifDebug: debugBlock
+ 
+ 	| selection newName |
+ 	selection := UIManager default chooseFrom: {
+ 		'create a new file' translated.
+ 		'choose another name' translated.
+ 		'debug' translated.
+ 		'cancel' translated
+ 	} title: (FileDirectory localNameFor: fullFileName) , '
+ does not exist.'.
+ 	selection = 1 ifTrue:
+ 		[^ self new open: fullFileName forWrite: true].
+ 	selection = 2 ifTrue:
+ 		[ newName := UIManager default request: 'Enter a new file name'
+ 						initialAnswer:  fullFileName.
+ 		^ self oldFileNamed:
+ 			(self fullName: newName)].
+ 	selection = 3 ifTrue: [^ debugBlock value].
+ 	self halt!

Item was added:
+ ----- Method: StandardFileStream class>>fileExistsUserHandling:ifDebug: (in category '*System-Files-error handling') -----
+ fileExistsUserHandling: fullFileName ifDebug: debugBlock
+ 	| dir localName choice newName newFullFileName |
+ 	dir := FileDirectory forFileName: fullFileName.
+ 	localName := FileDirectory localNameFor: fullFileName.
+ 	choice := (UIManager default 
+ 		chooseFrom: #('overwrite that file' 'append (risky!!!!)' 'choose another name' 'debug' 'cancel')
+ 		title: localName, ' already exists.').
+ 
+ 	choice = 1 ifTrue: [
+ 		dir deleteFileNamed: localName
+ 			ifAbsent: [self error: 'Could not delete the old version of that file'].
+ 		^ self new open: fullFileName forWrite: true].
+ 
+ 	choice = 2 ifTrue: [
+ 		^ (self new open: fullFileName forWrite: true) setToEnd].
+ 
+ 	choice = 3 ifTrue: [
+ 		newName := UIManager default request: 'Enter a new file name' initialAnswer: fullFileName.
+ 		newFullFileName := self fullName: newName.
+ 		^ self newFileNamed: newFullFileName].
+ 
+ 	choice = 4 ifTrue: [^ debugBlock value].
+ 
+ 	self error: 'Please close this to abort file opening'!

Item was added:
+ ----- Method: StandardFileStream class>>readOnlyFileDoesNotExistUserHandling:ifDebug: (in category '*System-Files-error handling') -----
+ readOnlyFileDoesNotExistUserHandling: fullFileName ifDebug: debugBlock
+ 
+ 	| dir files choices selection newName fileName |
+ 	dir := FileDirectory forFileName: fullFileName.
+ 	files := dir fileNames.
+ 	fileName := FileDirectory localNameFor: fullFileName.
+ 	choices := fileName correctAgainst: files.
+ 	choices add: 'Choose another name'.
+ 	choices add: 'Debug'.
+ 	choices add: 'Cancel'.
+ 	selection := UIManager default chooseFrom: choices lines: (Array with: 5)
+ 		title: (FileDirectory localNameFor: fullFileName), '
+ does not exist.'.
+ 	selection = choices size ifTrue:["cancel" ^ nil "should we raise another exception here?"].
+ 	selection < (choices size - 1) ifTrue: [
+ 		newName := (dir pathName , FileDirectory slash , (choices at: selection))].
+ 	selection = (choices size - 2) ifTrue: [
+ 		newName := UIManager default 
+ 							request: 'Enter a new file name' 
+ 							initialAnswer: fileName].
+ 	selection = (choices size - 1) ifTrue: [^ debugBlock value].
+ 	newName = '' ifFalse: [^ self readOnlyFileNamed: (self fullName: newName)].
+ 	^ self error: 'Could not open a file'!



More information about the Squeak-dev mailing list