Handle openErrorSignal in preparition for change openErrorSignal
authorStefan Vogel <sv@exept.de>
Sun, 02 Mar 2003 19:46:52 +0100
changeset 2701 b77cc7cf3818
parent 2700 d6bc43ddc80f
child 2702 1c385145ab46
Handle openErrorSignal in preparition for change openErrorSignal to be a real exception (this is currently a Notification)
EnterBox2.st
TextView.st
--- a/EnterBox2.st	Fri Feb 28 18:03:17 2003 +0100
+++ b/EnterBox2.st	Sun Mar 02 19:46:52 2003 +0100
@@ -134,7 +134,7 @@
 !EnterBox2 methodsFor:'user interaction'!
 
 keyPress:aKey x:x y:y
-    "return-key dublicates ok-function if acceptReturnAsOK is true"
+    "return-key duplicates ok-function if acceptReturnAsOK is true"
 
     <resource: #keyboard (#Return)>
 
@@ -156,5 +156,5 @@
 !EnterBox2 class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/EnterBox2.st,v 1.24 2003-02-25 14:58:23 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EnterBox2.st,v 1.25 2003-03-02 18:46:52 stefan Exp $'
 ! !
--- a/TextView.st	Fri Feb 28 18:03:17 2003 +0100
+++ b/TextView.st	Sun Mar 02 19:46:52 2003 +0100
@@ -1475,28 +1475,29 @@
 
 !TextView methodsFor:'menu actions'!
 
-appendTo:fileName
+appendTo:aFileName
     "append contents to a file named fileName"
 
-    |aStream msg|
-
-    (FileStream userInitiatedFileSaveQuerySignal queryWith:fileName asFilename) ifFalse:[
-        msg := resources string:'Refused to append to file ''%1'' !!' with:fileName.
+    |aStream msg filename|
+
+    filename := aFileName asFilename.
+
+    (FileStream userInitiatedFileSaveQuerySignal queryWith:filename) ifFalse:[
+        msg := resources string:'Refused to append to file ''%1'' !!' with:filename name.
         self warn:(msg , '\\(ST/X internal permission check)' ) withCRs.
         ^ self
     ].
 
-    aStream := FileStream appendingOldFileNamed:fileName.
-    aStream isNil ifTrue:[
-        msg := resources string:'cannot append to file %1 !!' with:fileName.
-        self warn:(msg , '\\(' , FileStream lastErrorString , ')' ) withCRs
-    ] ifFalse:[
-        self 
-            fileOutContentsOn:aStream 
-            compressTabs:true 
-            encoding:externalEncoding.
+    [
+        aStream := filename appendingWriteStream.
+        self fileOutContentsOn:aStream 
+             compressTabs:true 
+             encoding:externalEncoding.
         aStream close.
         contentsWasSaved := true
+    ] on:FileStream openErrorSignal do:[:ex|
+        msg := resources string:'cannot append to file %1 !!' with:filename name.
+        self warn:(msg , '\\(' , FileStream lastErrorString , ')' ) withCRs
     ]
 !
 
@@ -1706,38 +1707,39 @@
     ^ self saveAs:fileName doAppend:false
 !
 
-saveAs:fileName doAppend:doAppend
+saveAs:aFilename doAppend:doAppend
     "save the contents into a file named fileName;
      if doAppend is true, the views contents is appended to the existing
      contents - otherwise, it overwrites any previous file contents."
- 
+
+    |filename|
+
+    filename := aFilename asFilename.
+
     self withCursor:Cursor write do:[
         |aStream msg|
 
-        (FileStream userInitiatedFileSaveQuerySignal queryWith:fileName asFilename) ifFalse:[
-            msg := resources string:'Refused to write file ''%1'' !!' with:fileName.
+        (FileStream userInitiatedFileSaveQuerySignal queryWith:filename) ifFalse:[
+            msg := resources string:'Refused to write file ''%1'' !!' with:filename name.
             self warn:(msg , '\\(ST/X internal permission check)' ) withCRs.
             ^ self
         ].
 
-        FileStream openErrorSignal catch:[
+        [
             doAppend ifTrue:[
-                aStream := FileStream appendingOldFileNamed:fileName
+                aStream := filename appendingWriteStream.
             ] ifFalse:[
-                aStream := FileStream newFileNamed:fileName.
-            ]
-        ].
-        aStream isNil ifTrue:[
-            msg := resources string:'cannot write file ''%1'' !!' with:fileName.
-            self warn:(msg , '\\(' , FileStream lastErrorString , ')' ) withCRs
-        ] ifFalse:[
-            self
-                fileOutContentsOn:aStream 
-                compressTabs:true 
-                encoding:externalEncoding.
+                aStream := filename newReadWriteStream.
+            ].
+            self fileOutContentsOn:aStream 
+                 compressTabs:true 
+                 encoding:externalEncoding.
             aStream close.
             contentsWasSaved := true
-        ]
+        ] on:FileStream openErrorSignal do:[:ex|
+            msg := resources string:'cannot write file ''%1'' !!' with:filename name.
+            self warn:(msg , '\\(' , FileStream lastErrorString , ')' ) withCRs
+        ].
     ]
 
     "Modified: 22.10.1997 / 12:32:51 / cg"
@@ -3616,7 +3618,7 @@
 !TextView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.193 2003-02-25 14:43:24 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.194 2003-03-02 18:46:28 stefan Exp $'
 ! !
 
 TextView initialize!