[Q] What is the reason for raise one error trying to save a new file ?

Lic. Edgar J. De Cleene edgardec2001 at yahoo.com.ar
Thu Nov 4 13:15:10 UTC 2004


I copy from image and this code perhaps belongs to Tim Rowledge .
I not could figure why you choose raise one error if file do not exist.
It¹s not what we wish to do using this method ?

forceNewFileNamed: fileName
    "Create a new file with the given name, and answer a stream opened
    for writing on that file. If the file already exists, delete it without
    asking before creating the new file."
    | dir localName fullName f |
    fullName := self fullName: fileName.
    (self isAFileNamed: fullName)
        ifFalse: [f := self new open: fullName forWrite: true.
            ^ f isNil
                ifTrue: ["Failed to open the file"
                    (FileDoesNotExistException fileName: fullName) signal]
                ifFalse: [f]].
    dir := FileDirectory forFileName: fullName.
    localName := FileDirectory localNameFor: fullName.
    dir
        deleteFileNamed: localName
        ifAbsent: [(CannotDeleteFileException new
            messageText: 'Could not delete the old version of file ' ,
fullName) signal].
    f := self new open: fullName forWrite: true.
    ^ f isNil
        ifTrue: ["Failed to open the file"
            (FileDoesNotExistException fileName: fullName) signal]
        ifFalse: [f]

Cheers and continue good work on TK4.

Edgar, Advocatus Diaboli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20041104/b2fc6129/attachment.htm


More information about the Squeak-dev mailing list