1051
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
111
|
3 |
"{ Package: 'stx:goodies/monticello' }"
|
|
4 |
|
1051
|
5 |
"{ NameSpace: Smalltalk }"
|
|
6 |
|
111
|
7 |
MCFileBasedRepository subclass:#MCFtpRepository
|
|
8 |
instanceVariableNames:'host directory user password connection'
|
|
9 |
classVariableNames:''
|
|
10 |
poolDictionaries:''
|
1051
|
11 |
category:'SCM-Monticello-RemoteRepositories'
|
111
|
12 |
!
|
|
13 |
|
1051
|
14 |
!MCFtpRepository class methodsFor:'documentation'!
|
|
15 |
|
|
16 |
documentation
|
|
17 |
"
|
|
18 |
I am an monticello repository implementation for the FTP protocol.
|
|
19 |
"
|
|
20 |
! !
|
111
|
21 |
|
904
|
22 |
!MCFtpRepository class methodsFor:'instance creation'!
|
|
23 |
|
1051
|
24 |
basicFromUrl: aZnUrl
|
|
25 |
^ self
|
|
26 |
host: (aZnUrl hasPort ifTrue: [ aZnUrl host, ':', aZnUrl port asString ] ifFalse: [ aZnUrl host ])
|
|
27 |
directory: aZnUrl path "MCFtpRepository assumes NO prefixed / in the path"
|
|
28 |
user: (aZnUrl username ifNil: [ '' ])
|
|
29 |
password: (aZnUrl password ifNil: [ '' ])
|
|
30 |
!
|
|
31 |
|
904
|
32 |
host: host directory: directory user: user password: password
|
|
33 |
^ self new
|
|
34 |
host: host;
|
|
35 |
directory: directory;
|
|
36 |
user: user;
|
|
37 |
password: password
|
|
38 |
! !
|
|
39 |
|
1051
|
40 |
!MCFtpRepository class methodsFor:'*MonticelloGUI'!
|
|
41 |
|
|
42 |
fillInTheBlankRequest
|
|
43 |
^ 'FTP Repository:'
|
|
44 |
|
|
45 |
|
|
46 |
!
|
|
47 |
|
|
48 |
morphicConfigure
|
|
49 |
^ self fillInTheBlankConfigure
|
|
50 |
! !
|
|
51 |
|
|
52 |
!MCFtpRepository class methodsFor:'accessing'!
|
|
53 |
|
|
54 |
urlSchemes
|
|
55 |
^ #(ftp)
|
|
56 |
! !
|
|
57 |
|
904
|
58 |
!MCFtpRepository class methodsFor:'queries'!
|
111
|
59 |
|
|
60 |
creationTemplate
|
|
61 |
^
|
|
62 |
'MCFtpRepository
|
|
63 |
host: ''modules.squeakfoundation.org''
|
|
64 |
directory: ''mc''
|
|
65 |
user: ''squeak''
|
|
66 |
password: ''squeak'''
|
|
67 |
|
|
68 |
!
|
|
69 |
|
|
70 |
description
|
|
71 |
^ 'FTP'
|
|
72 |
!
|
|
73 |
|
904
|
74 |
templateCreationSelector
|
|
75 |
^ #host:directory:user:password:
|
|
76 |
! !
|
|
77 |
|
1051
|
78 |
!MCFtpRepository methodsFor:'*Komitter-Models'!
|
|
79 |
|
|
80 |
isRemote
|
|
81 |
^ true
|
|
82 |
!
|
|
83 |
|
|
84 |
koRemote
|
|
85 |
|
|
86 |
^ KomitFtpRemote new
|
|
87 |
remote: self;
|
|
88 |
yourself
|
|
89 |
! !
|
|
90 |
|
|
91 |
!MCFtpRepository methodsFor:'*metacello-pharocommonplatform'!
|
|
92 |
|
|
93 |
asRepositorySpecFor: aMetacelloMCProject
|
|
94 |
| dir |
|
|
95 |
dir := directory.
|
|
96 |
(directory at: 1) = $/
|
|
97 |
ifFalse: [ dir := '/', dir ].
|
|
98 |
^(aMetacelloMCProject repositorySpec)
|
|
99 |
description: 'ftp://', host, dir;
|
|
100 |
type: 'ftp';
|
|
101 |
username: user;
|
|
102 |
password: password;
|
|
103 |
yourself
|
|
104 |
! !
|
|
105 |
|
|
106 |
!MCFtpRepository methodsFor:'*metacello-testsplatform'!
|
|
107 |
|
|
108 |
directory
|
|
109 |
|
|
110 |
^directory
|
|
111 |
!
|
|
112 |
|
|
113 |
host
|
|
114 |
|
|
115 |
^host
|
|
116 |
! !
|
|
117 |
|
904
|
118 |
!MCFtpRepository methodsFor:'accessing'!
|
|
119 |
|
|
120 |
directory: dirPath
|
|
121 |
directory := dirPath
|
111
|
122 |
!
|
|
123 |
|
904
|
124 |
host: hostname
|
|
125 |
host := hostname
|
|
126 |
!
|
|
127 |
|
|
128 |
password: passwordString
|
|
129 |
password := passwordString
|
|
130 |
!
|
|
131 |
|
|
132 |
user: userString
|
|
133 |
user := userString
|
111
|
134 |
! !
|
|
135 |
|
|
136 |
!MCFtpRepository methodsFor:'as yet unclassified'!
|
|
137 |
|
|
138 |
clientDo: aBlock
|
912
|
139 |
| client |
|
|
140 |
|
|
141 |
NVTClient loginFailedSignal handle:[:ex |
|
|
142 |
| answer |
|
|
143 |
|
|
144 |
answer := Dialog
|
|
145 |
requestPassword:('FTP-Login failed (',ex description,'\\Try again with password:') withCRs
|
|
146 |
initialAnswer:password.
|
|
147 |
answer isEmptyOrNil ifTrue:[ AbortOperationRequest raise].
|
|
148 |
password := answer.
|
|
149 |
ex restart
|
|
150 |
] do:[
|
|
151 |
client := FTPClient openOnHostNamed: host.
|
|
152 |
client loginUser: user password: password.
|
|
153 |
directory isEmpty ifFalse: [client changeDirectoryTo: directory].
|
|
154 |
].
|
|
155 |
^ [aBlock value: client] ensure: [client close]
|
111
|
156 |
!
|
|
157 |
|
|
158 |
parseDirectoryListing: aString
|
|
159 |
| stream files line tokens |
|
233
|
160 |
stream := aString readStream.
|
|
161 |
files := OrderedCollection new.
|
111
|
162 |
[stream atEnd] whileFalse:
|
233
|
163 |
[line := stream nextLine.
|
|
164 |
tokens := line findTokens: ' '.
|
111
|
165 |
tokens size > 2 ifTrue: [files add: tokens last]].
|
|
166 |
^ files
|
|
167 |
! !
|
|
168 |
|
515
|
169 |
!MCFtpRepository methodsFor:'displaying'!
|
|
170 |
|
|
171 |
displayString
|
|
172 |
^ self description
|
|
173 |
|
|
174 |
"Created: / 14-09-2010 / 23:20:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
175 |
"Created: / 25-11-2011 / 11:29:31 / cg"
|
|
176 |
! !
|
|
177 |
|
1051
|
178 |
!MCFtpRepository methodsFor:'interface'!
|
|
179 |
|
|
180 |
loadAllFileNames
|
|
181 |
^ self clientDo:
|
|
182 |
[:client |
|
|
183 |
self parseDirectoryListing: client getDirectory]
|
|
184 |
! !
|
|
185 |
|
111
|
186 |
!MCFtpRepository methodsFor:'required'!
|
|
187 |
|
|
188 |
allFileNames
|
|
189 |
^ self clientDo:
|
|
190 |
[:client |
|
|
191 |
self parseDirectoryListing: client getDirectory]
|
|
192 |
!
|
|
193 |
|
|
194 |
description
|
1051
|
195 |
user notNil ifTrue:[
|
|
196 |
^ 'ftp://', user, '@', host, '/', directory
|
|
197 |
].
|
|
198 |
^ 'ftp://', host, '/', directory
|
|
199 |
|
|
200 |
"Modified: / 26-08-2018 / 12:35:25 / Claus Gittinger"
|
111
|
201 |
!
|
|
202 |
|
|
203 |
readStreamForFileNamed: aString do: aBlock
|
1051
|
204 |
|
111
|
205 |
^ self clientDo:
|
1051
|
206 |
[:client | | stream |
|
111
|
207 |
client binary.
|
233
|
208 |
stream := RWBinaryOrTextStream on: String new.
|
111
|
209 |
stream nextPutAll: (client getFileNamed: aString).
|
|
210 |
aBlock value: stream reset]
|
|
211 |
!
|
|
212 |
|
|
213 |
writeStreamForFileNamed: aString replace: ignoreBoolean do: aBlock
|
|
214 |
| stream |
|
233
|
215 |
stream := RWBinaryOrTextStream on: String new.
|
111
|
216 |
aBlock value: stream.
|
|
217 |
self clientDo:
|
|
218 |
[:client |
|
|
219 |
client binary.
|
|
220 |
client putFileStreamContents: stream reset as: aString]
|
|
221 |
! !
|
|
222 |
|
|
223 |
!MCFtpRepository class methodsFor:'documentation'!
|
|
224 |
|
|
225 |
version
|
1051
|
226 |
^ '$Header$'
|
233
|
227 |
!
|
|
228 |
|
|
229 |
version_CVS
|
1051
|
230 |
^ '$Header$'
|
233
|
231 |
!
|
|
232 |
|
|
233 |
version_SVN
|
1051
|
234 |
^ '$Id$'
|
111
|
235 |
! !
|
904
|
236 |
|