FtpURI.st
changeset 1267 5e7f102e094d
parent 1266 4522fd38deef
child 1268 48b43aebf125
--- a/FtpURI.st	Thu Jul 10 14:07:39 2003 +0200
+++ b/FtpURI.st	Thu Jul 10 16:33:01 2003 +0200
@@ -208,6 +208,7 @@
                 [ aBlock value:stream value:attributes ] 
                     ensure:[ stream close ].
                 doRemoveSource == true ifTrue:[ 
+                    (srcPath startsWith:'/') ifFalse:[ srcPath := '/', srcPath ].
                     ftp delete:srcPath.
                 ].
             ].
@@ -269,9 +270,13 @@
 writeStreamDo:aBlock create:doCreate
     "use FTPClient for now"
 
-    |path|
+    |path absDir absPath|
 
     path := self path.
+    (path startsWith:'/') 
+        ifTrue:[  absPath := path] 
+        ifFalse:[ absPath := '/', path ].
+    absDir := absPath asFilename directory.
     self connectThenDo:[:ftp| |stream|
         [
             ftp connectTo:self host 
@@ -279,14 +284,17 @@
                 user:(self user ? self defaultUser)
                 password:(self password ? self defaultPassword).
 
-            Stream streamErrorSignal handle:[:ex|
+            FTPClient filePutErrorSignal handle:[:ex| |str|
                 doCreate ifFalse:[
                     ex reject
                 ]. 
-                ftp mkdir:path asFilename directory pathName.
-                stream := ftp putStreamFor:path.
+                FTPClient fileNotFoundErrorSignal handle:[:ex| ] do:[
+                    ftp mkdir:absDir.
+                ].
+                ftp cd:absDir.
+                stream := ftp putStreamFor:absPath.
             ] do:[
-                stream := ftp putStreamFor:path.
+                stream := ftp putStreamFor:absPath.
             ].
 
             aBlock value:stream value:self class attributes.
@@ -307,5 +315,5 @@
 !FtpURI class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/FtpURI.st,v 1.6 2003-07-10 12:07:39 tm Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/FtpURI.st,v 1.7 2003-07-10 14:32:44 tm Exp $'
 ! !