fixed new-symbolic link operation
authorClaus Gittinger <cg@exept.de>
Mon, 13 Dec 2004 11:46:46 +0100
changeset 6150 5028485a29c6
parent 6149 e72cc6c35d0e
child 6151 baba7a7d54b6
fixed new-symbolic link operation
FileOperation.st
--- a/FileOperation.st	Fri Dec 10 16:53:54 2004 +0100
+++ b/FileOperation.st	Mon Dec 13 11:46:46 2004 +0100
@@ -643,9 +643,9 @@
 
     string := 'Create ', (symbolic ifTrue:['Symbolic'] ifFalse:['Hard']) ,' Link from:'.
     (box addTextLabel:(resources string:string)) adjust:#left.
-    if1 := box addFilenameInputFieldOn:newPath in:nil tabable:true.
+    if1 := box addFilenameInputFieldOn:oldPath in:nil tabable:true.
     (box addTextLabel:(resources string:'to:')) adjust:#left.
-    if2 := box addFilenameInputFieldOn:oldPath in:nil value tabable:true.
+    if2 := box addFilenameInputFieldOn:newPath in:nil value tabable:true.
 
     box addAbortAndOkButtons.
 
@@ -667,29 +667,39 @@
     self createLinkIn:aFile soft:true.
 !
 
-doCreateLinkFrom:oldPath to:newPath soft:symbolic
+doCreateLinkFrom:oldPath to:newPathArg soft:symbolic
     "actually create a soft or hard link"
 
-    |resources err newPathFile oldPathFile|
+    |resources err newPath newPathFile oldPathFile|
+
+    newPath := newPathArg.
 
     resources := AbstractFileBrowser classResources.
 
     (oldPath size == 0) ifTrue:[
-        self operationError:'no source entered'.
+        self operationError:'Missing source'.
         ^ self.
     ].
     (newPath size == 0) ifTrue:[
-        self operationError:'no link name entered'.
+        self operationError:'Missing link name (target)'.
         ^ self.
     ].
 
     newPathFile := newPath asFilename.
+    oldPathFile := oldPath asFilename.
+
+    newPathFile exists ifTrue:[
+        newPathFile isDirectory ifTrue:[
+            newPathFile := newPathFile construct:(oldPathFile baseName).
+            newPath := newPathFile name.
+        ].
+    ].
+
     newPathFile exists ifTrue:[
         self operationError:(resources string:'%1 already exists' with:newPath allBold).
         ^ self.
     ].
-    oldPathFile := oldPath asFilename.
-    oldPathFile exists not ifTrue:[
+    oldPathFile exists ifFalse:[
         symbolic ifTrue:[
             oldPathFile isAbsolute ifTrue:[
                 self operationError:(resources string:'%1 does not exist' with:oldPath allBold).
@@ -1283,5 +1293,5 @@
 !FileOperation class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/FileOperation.st,v 1.59 2004-10-15 21:00:06 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/FileOperation.st,v 1.60 2004-12-13 10:46:46 cg Exp $'
 ! !