#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Mon, 18 Mar 2019 11:01:52 +0100
changeset 4880 09220005946f
parent 4879 d6b8308d7c51
child 4881 bdff8a3ce9d6
#FEATURE by cg class: FtpURI changed: #connectThenDo: #readStreamDo:
FtpURI.st
--- a/FtpURI.st	Mon Mar 18 11:00:15 2019 +0100
+++ b/FtpURI.st	Mon Mar 18 11:01:52 2019 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 2002 by eXept Software AG
               All Rights Reserved
@@ -11,6 +13,8 @@
 "
 "{ Package: 'stx:libbasic2' }"
 
+"{ NameSpace: Smalltalk }"
+
 HierarchicalURI subclass:#FtpURI
 	instanceVariableNames:''
 	classVariableNames:''
@@ -80,12 +84,13 @@
 !FtpURI methodsFor:'ftp requests'!
 
 connectThenDo:aOneArgBlock
-    "setup a ftp connection and call aOneArgBlock with it"
+    "setup a ftp connection and call aOneArgBlock with it.
+     Ensures that the ftp connection is closed afterwards."
 
     |ftp|
 
     ftp := FTPClient new.
-    [
+    ^ [
         ftp connectTo:self host 
             port:self port 
             user:(self user ? self defaultUser)
@@ -96,15 +101,24 @@
             ftp close.
         ].
     ]
+
+    "Modified: / 18-03-2019 / 10:53:22 / Claus Gittinger"
 ! !
 
 !FtpURI methodsFor:'stream access'!
 
 readStreamDo:aBlock
+    "evaluate a block with the read stream as first argument
+     and a dictionary containing attributes as second argument.
+     The stream is closed after aBlock has been evaluated."
+
     "use FTPClient for now"
 
-    self connectThenDo:[:ftp| |stream path attributes|
+    ^ self connectThenDo:[:ftp| 
+        |stream|
         [
+            |path attributes|
+            
             path := self path.
             attributes := self class attributes.
             attributes at:#fileSize put:(ftp sizeOf:path).
@@ -125,6 +139,8 @@
          self halt
       ].
     "
+
+    "Modified: / 18-03-2019 / 11:00:32 / Claus Gittinger"
 !
 
 readStreamsDo:aBlock
@@ -406,6 +422,6 @@
 !FtpURI class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/FtpURI.st,v 1.20 2014-12-02 14:22:35 stefan Exp $'
+    ^ '$Header$'
 ! !