Merge jv
authorMerge Script
Tue, 26 Apr 2016 06:50:38 +0200
branchjv
changeset 16323 024140ca45bd
parent 16321 e6a4ab0da993 (current diff)
parent 16322 1953cc62b7a6 (diff)
child 16328 50099c2dbdb5
Merge
FileOperation.st
--- a/FileOperation.st	Mon Apr 25 06:59:02 2016 +0200
+++ b/FileOperation.st	Tue Apr 26 06:50:38 2016 +0200
@@ -879,7 +879,7 @@
 createFileIn:aFile
     "create an empty file"
 
-    |resources aStream msg file directory newName defaultFile|
+    |resources aStream msg file directory newName defaultFile newFile|
 
     resources := AbstractFileBrowser classResources.
 
@@ -903,34 +903,51 @@
                         self result:false.
                         ^ self
                     ].
-    newName isEmpty ifTrue:[
+                    
+    newName isEmptyOrNil ifTrue:[
         self result:false.
-    ] ifFalse:[
-        | newFile |
-        newFile := directory construct:newName.
-        newFile exists ifTrue:[
+        ^ self
+    ].
+        
+    newFile := directory construct:newName.
+
+    (newFile exists) ifTrue:[
+        (newFile isRegularFile) ifTrue:[
+            newFile fileSize == 0 ifTrue:[
+                Dialog
+                    information:(resources stringWithCRs:'An empty "%1" (i.e. with size 0) already existed.' with:newName).
+                self createdFile:newFile.
+                self result:true.
+                ^ self
+            ].    
             (Dialog
-                confirm:(newName, ' already exists truncate ?')
-                yesLabel:('Truncate')
-                noLabel:('Cancel'))
+                confirm:(resources stringWithCRs:'"%1" already exists (with size %2)\\Truncate ?' with:newName with:newFile fileSize)
+                yesLabel:(resources string:'Truncate')
+                noLabel:(resources string:'Cancel'))
             ifFalse:[
                 self result:false.
                 ^ self
             ].
-        ].
-        FileStream openErrorSignal handle:[:ex|
-            msg := 'Cannot create file "', newName,'" (' , (FileStream lastErrorString) , ')'.
-            errorString := msg.
+        ] ifFalse:[
+            Dialog warn:(resources stringWithCRs:'"%1" already exists as a %2' with:newFile fileType).
             self result:false.
-            ^ Dialog warn:errorString
-        ] do:[
-            aStream := newFile newReadWriteStream.
-        ].
-        aStream close.
-        self createdFile:newFile.
-        LastCreatedFile := newFile.
-        self result:true.
+            ^ self
+        ].    
     ].
+    
+    FileStream openErrorSignal handle:[:ex|
+        msg := resources string:'Cannot create file "%1" (%2)' with:newName with:(FileStream lastErrorString).
+        errorString := msg.
+        self result:false.
+        Dialog warn:errorString.
+        ^ self.
+    ] do:[
+        aStream := newFile newReadWriteStream.
+    ].
+    aStream close.
+    self createdFile:newFile.
+    LastCreatedFile := newFile.
+    self result:true.
 !
 
 createLinkIn:aFile soft:symbolic