111
|
1 |
"{ Package: 'stx:goodies/monticello' }"
|
|
2 |
|
|
3 |
MCFileBasedRepository subclass:#MCFtpRepository
|
|
4 |
instanceVariableNames:'host directory user password connection'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Monticello-Repositories'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!MCFtpRepository class methodsFor:'as yet unclassified'!
|
|
12 |
|
|
13 |
creationTemplate
|
|
14 |
^
|
|
15 |
'MCFtpRepository
|
|
16 |
host: ''modules.squeakfoundation.org''
|
|
17 |
directory: ''mc''
|
|
18 |
user: ''squeak''
|
|
19 |
password: ''squeak'''
|
|
20 |
|
|
21 |
!
|
|
22 |
|
|
23 |
description
|
|
24 |
^ 'FTP'
|
|
25 |
!
|
|
26 |
|
|
27 |
host: host directory: directory user: user password: password
|
|
28 |
^ self new
|
|
29 |
host: host;
|
|
30 |
directory: directory;
|
|
31 |
user: user;
|
|
32 |
password: password
|
|
33 |
!
|
|
34 |
|
|
35 |
templateCreationSelector
|
|
36 |
^ #host:directory:user:password:
|
|
37 |
! !
|
|
38 |
|
|
39 |
!MCFtpRepository methodsFor:'as yet unclassified'!
|
|
40 |
|
|
41 |
clientDo: aBlock
|
|
42 |
| client |
|
233
|
43 |
client := FTPClient openOnHostNamed: host.
|
111
|
44 |
client loginUser: user password: password.
|
|
45 |
directory isEmpty ifFalse: [client changeDirectoryTo: directory].
|
|
46 |
^ [aBlock value: client] ensure: [client close]
|
|
47 |
!
|
|
48 |
|
|
49 |
directory: dirPath
|
233
|
50 |
directory := dirPath
|
111
|
51 |
!
|
|
52 |
|
|
53 |
host: hostname
|
233
|
54 |
host := hostname
|
111
|
55 |
!
|
|
56 |
|
|
57 |
parseDirectoryListing: aString
|
|
58 |
| stream files line tokens |
|
233
|
59 |
stream := aString readStream.
|
|
60 |
files := OrderedCollection new.
|
111
|
61 |
[stream atEnd] whileFalse:
|
233
|
62 |
[line := stream nextLine.
|
|
63 |
tokens := line findTokens: ' '.
|
111
|
64 |
tokens size > 2 ifTrue: [files add: tokens last]].
|
|
65 |
^ files
|
|
66 |
!
|
|
67 |
|
|
68 |
password: passwordString
|
233
|
69 |
password := passwordString
|
111
|
70 |
!
|
|
71 |
|
|
72 |
user: userString
|
233
|
73 |
user := userString
|
111
|
74 |
! !
|
|
75 |
|
|
76 |
!MCFtpRepository methodsFor:'required'!
|
|
77 |
|
|
78 |
allFileNames
|
|
79 |
^ self clientDo:
|
|
80 |
[:client |
|
|
81 |
self parseDirectoryListing: client getDirectory]
|
|
82 |
!
|
|
83 |
|
|
84 |
description
|
|
85 |
^ 'ftp://', user, '@', host, '/', directory
|
|
86 |
!
|
|
87 |
|
|
88 |
readStreamForFileNamed: aString do: aBlock
|
|
89 |
| stream |
|
|
90 |
^ self clientDo:
|
|
91 |
[:client |
|
|
92 |
client binary.
|
233
|
93 |
stream := RWBinaryOrTextStream on: String new.
|
111
|
94 |
stream nextPutAll: (client getFileNamed: aString).
|
|
95 |
aBlock value: stream reset]
|
|
96 |
!
|
|
97 |
|
|
98 |
writeStreamForFileNamed: aString replace: ignoreBoolean do: aBlock
|
|
99 |
| stream |
|
233
|
100 |
stream := RWBinaryOrTextStream on: String new.
|
111
|
101 |
aBlock value: stream.
|
|
102 |
self clientDo:
|
|
103 |
[:client |
|
|
104 |
client binary.
|
|
105 |
client putFileStreamContents: stream reset as: aString]
|
|
106 |
! !
|
|
107 |
|
|
108 |
!MCFtpRepository class methodsFor:'documentation'!
|
|
109 |
|
|
110 |
version
|
233
|
111 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCFtpRepository.st,v 1.2 2011-08-20 11:45:39 cg Exp $'
|
|
112 |
!
|
|
113 |
|
|
114 |
version_CVS
|
|
115 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCFtpRepository.st,v 1.2 2011-08-20 11:45:39 cg Exp $'
|
|
116 |
!
|
|
117 |
|
|
118 |
version_SVN
|
|
119 |
^ '§Id: MCFtpRepository.st 5 2010-08-29 07:30:29Z vranyj1 §'
|
111
|
120 |
! !
|