111
|
1 |
"{ Package: 'stx:goodies/monticello' }"
|
|
2 |
|
|
3 |
MCFileBasedRepository subclass:#MCFtpRepository
|
|
4 |
instanceVariableNames:'host directory user password connection'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
630
|
7 |
category:'SCM-Monticello-Repositories'
|
111
|
8 |
!
|
|
9 |
|
|
10 |
|
904
|
11 |
!MCFtpRepository class methodsFor:'instance creation'!
|
|
12 |
|
|
13 |
host: host directory: directory user: user password: password
|
|
14 |
^ self new
|
|
15 |
host: host;
|
|
16 |
directory: directory;
|
|
17 |
user: user;
|
|
18 |
password: password
|
|
19 |
! !
|
|
20 |
|
|
21 |
!MCFtpRepository class methodsFor:'queries'!
|
111
|
22 |
|
|
23 |
creationTemplate
|
|
24 |
^
|
|
25 |
'MCFtpRepository
|
|
26 |
host: ''modules.squeakfoundation.org''
|
|
27 |
directory: ''mc''
|
|
28 |
user: ''squeak''
|
|
29 |
password: ''squeak'''
|
|
30 |
|
|
31 |
!
|
|
32 |
|
|
33 |
description
|
|
34 |
^ 'FTP'
|
|
35 |
!
|
|
36 |
|
904
|
37 |
templateCreationSelector
|
|
38 |
^ #host:directory:user:password:
|
|
39 |
! !
|
|
40 |
|
|
41 |
!MCFtpRepository methodsFor:'accessing'!
|
|
42 |
|
|
43 |
directory: dirPath
|
|
44 |
directory := dirPath
|
111
|
45 |
!
|
|
46 |
|
904
|
47 |
host: hostname
|
|
48 |
host := hostname
|
|
49 |
!
|
|
50 |
|
|
51 |
password: passwordString
|
|
52 |
password := passwordString
|
|
53 |
!
|
|
54 |
|
|
55 |
user: userString
|
|
56 |
user := userString
|
111
|
57 |
! !
|
|
58 |
|
|
59 |
!MCFtpRepository methodsFor:'as yet unclassified'!
|
|
60 |
|
|
61 |
clientDo: aBlock
|
912
|
62 |
| client |
|
|
63 |
|
|
64 |
NVTClient loginFailedSignal handle:[:ex |
|
|
65 |
| answer |
|
|
66 |
|
|
67 |
answer := Dialog
|
|
68 |
requestPassword:('FTP-Login failed (',ex description,'\\Try again with password:') withCRs
|
|
69 |
initialAnswer:password.
|
|
70 |
answer isEmptyOrNil ifTrue:[ AbortOperationRequest raise].
|
|
71 |
password := answer.
|
|
72 |
ex restart
|
|
73 |
] do:[
|
|
74 |
client := FTPClient openOnHostNamed: host.
|
|
75 |
client loginUser: user password: password.
|
|
76 |
directory isEmpty ifFalse: [client changeDirectoryTo: directory].
|
|
77 |
].
|
|
78 |
^ [aBlock value: client] ensure: [client close]
|
111
|
79 |
!
|
|
80 |
|
|
81 |
parseDirectoryListing: aString
|
|
82 |
| stream files line tokens |
|
233
|
83 |
stream := aString readStream.
|
|
84 |
files := OrderedCollection new.
|
111
|
85 |
[stream atEnd] whileFalse:
|
233
|
86 |
[line := stream nextLine.
|
|
87 |
tokens := line findTokens: ' '.
|
111
|
88 |
tokens size > 2 ifTrue: [files add: tokens last]].
|
|
89 |
^ files
|
|
90 |
! !
|
|
91 |
|
515
|
92 |
!MCFtpRepository methodsFor:'displaying'!
|
|
93 |
|
|
94 |
displayString
|
|
95 |
^ self description
|
|
96 |
|
|
97 |
"Created: / 14-09-2010 / 23:20:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
98 |
"Created: / 25-11-2011 / 11:29:31 / cg"
|
|
99 |
! !
|
|
100 |
|
111
|
101 |
!MCFtpRepository methodsFor:'required'!
|
|
102 |
|
|
103 |
allFileNames
|
|
104 |
^ self clientDo:
|
|
105 |
[:client |
|
|
106 |
self parseDirectoryListing: client getDirectory]
|
|
107 |
!
|
|
108 |
|
|
109 |
description
|
|
110 |
^ 'ftp://', user, '@', host, '/', directory
|
|
111 |
!
|
|
112 |
|
|
113 |
readStreamForFileNamed: aString do: aBlock
|
|
114 |
| stream |
|
|
115 |
^ self clientDo:
|
|
116 |
[:client |
|
|
117 |
client binary.
|
233
|
118 |
stream := RWBinaryOrTextStream on: String new.
|
111
|
119 |
stream nextPutAll: (client getFileNamed: aString).
|
|
120 |
aBlock value: stream reset]
|
|
121 |
!
|
|
122 |
|
|
123 |
writeStreamForFileNamed: aString replace: ignoreBoolean do: aBlock
|
|
124 |
| stream |
|
233
|
125 |
stream := RWBinaryOrTextStream on: String new.
|
111
|
126 |
aBlock value: stream.
|
|
127 |
self clientDo:
|
|
128 |
[:client |
|
|
129 |
client binary.
|
|
130 |
client putFileStreamContents: stream reset as: aString]
|
|
131 |
! !
|
|
132 |
|
|
133 |
!MCFtpRepository class methodsFor:'documentation'!
|
|
134 |
|
|
135 |
version
|
912
|
136 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCFtpRepository.st,v 1.7 2014-02-12 15:38:13 cg Exp $'
|
233
|
137 |
!
|
|
138 |
|
|
139 |
version_CVS
|
912
|
140 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCFtpRepository.st,v 1.7 2014-02-12 15:38:13 cg Exp $'
|
233
|
141 |
!
|
|
142 |
|
|
143 |
version_SVN
|
912
|
144 |
^ '$Id: MCFtpRepository.st,v 1.7 2014-02-12 15:38:13 cg Exp $'
|
111
|
145 |
! !
|
904
|
146 |
|