9 other person. No title to or ownership of the software is |
11 other person. No title to or ownership of the software is |
10 hereby transferred. |
12 hereby transferred. |
11 " |
13 " |
12 "{ Package: 'stx:libbasic2' }" |
14 "{ Package: 'stx:libbasic2' }" |
13 |
15 |
|
16 "{ NameSpace: Smalltalk }" |
|
17 |
14 HierarchicalURI subclass:#FtpURI |
18 HierarchicalURI subclass:#FtpURI |
15 instanceVariableNames:'' |
19 instanceVariableNames:'' |
16 classVariableNames:'' |
20 classVariableNames:'' |
17 poolDictionaries:'' |
21 poolDictionaries:'' |
18 category:'Net-Resources' |
22 category:'Net-Resources' |
78 ! ! |
82 ! ! |
79 |
83 |
80 !FtpURI methodsFor:'ftp requests'! |
84 !FtpURI methodsFor:'ftp requests'! |
81 |
85 |
82 connectThenDo:aOneArgBlock |
86 connectThenDo:aOneArgBlock |
83 "setup a ftp connection and call aOneArgBlock with it" |
87 "setup a ftp connection and call aOneArgBlock with it. |
|
88 Ensures that the ftp connection is closed afterwards." |
84 |
89 |
85 |ftp| |
90 |ftp| |
86 |
91 |
87 ftp := FTPClient new. |
92 ftp := FTPClient new. |
88 [ |
93 ^ [ |
89 ftp connectTo:self host |
94 ftp connectTo:self host |
90 port:self port |
95 port:self port |
91 user:(self user ? self defaultUser) |
96 user:(self user ? self defaultUser) |
92 password:(self password ? self defaultPassword). |
97 password:(self password ? self defaultPassword). |
93 aOneArgBlock value:ftp |
98 aOneArgBlock value:ftp |
94 ] ensure:[ |
99 ] ensure:[ |
95 ftp notNil ifTrue:[ |
100 ftp notNil ifTrue:[ |
96 ftp close. |
101 ftp close. |
97 ]. |
102 ]. |
98 ] |
103 ] |
|
104 |
|
105 "Modified: / 18-03-2019 / 10:53:22 / Claus Gittinger" |
99 ! ! |
106 ! ! |
100 |
107 |
101 !FtpURI methodsFor:'stream access'! |
108 !FtpURI methodsFor:'stream access'! |
102 |
109 |
103 readStreamDo:aBlock |
110 readStreamDo:aBlock |
|
111 "evaluate a block with the read stream as first argument |
|
112 and a dictionary containing attributes as second argument. |
|
113 The stream is closed after aBlock has been evaluated." |
|
114 |
104 "use FTPClient for now" |
115 "use FTPClient for now" |
105 |
116 |
106 self connectThenDo:[:ftp| |stream path attributes| |
117 ^ self connectThenDo:[:ftp| |
|
118 |stream| |
107 [ |
119 [ |
|
120 |path attributes| |
|
121 |
108 path := self path. |
122 path := self path. |
109 attributes := self class attributes. |
123 attributes := self class attributes. |
110 attributes at:#fileSize put:(ftp sizeOf:path). |
124 attributes at:#fileSize put:(ftp sizeOf:path). |
111 attributes at:#baseName put:self pathSegments last. |
125 attributes at:#baseName put:self pathSegments last. |
112 attributes at:#uriInfo put:self printString. |
126 attributes at:#uriInfo put:self printString. |