--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MCFtpRepository.st Wed Nov 22 14:22:28 2006 +0100
@@ -0,0 +1,122 @@
+"{ Package: 'stx:goodies/monticello' }"
+
+MCFileBasedRepository subclass:#MCFtpRepository
+ instanceVariableNames:'host directory user password connection'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Monticello-Repositories'
+!
+
+
+!MCFtpRepository class methodsFor:'as yet unclassified'!
+
+creationTemplate
+ ^
+'MCFtpRepository
+ host: ''modules.squeakfoundation.org''
+ directory: ''mc''
+ user: ''squeak''
+ password: ''squeak'''
+
+!
+
+description
+ ^ 'FTP'
+!
+
+fillInTheBlankRequest
+ ^ 'FTP Repository:'
+
+
+!
+
+host: host directory: directory user: user password: password
+ ^ self new
+ host: host;
+ directory: directory;
+ user: user;
+ password: password
+!
+
+morphicConfigure
+ ^ self fillInTheBlankConfigure
+!
+
+templateCreationSelector
+ ^ #host:directory:user:password:
+! !
+
+!MCFtpRepository methodsFor:'as yet unclassified'!
+
+clientDo: aBlock
+ | client |
+ client _ FTPClient openOnHostNamed: host.
+ client loginUser: user password: password.
+ directory isEmpty ifFalse: [client changeDirectoryTo: directory].
+ ^ [aBlock value: client] ensure: [client close]
+!
+
+directory: dirPath
+ directory _ dirPath
+!
+
+host: hostname
+ host _ hostname
+!
+
+parseDirectoryListing: aString
+ | stream files line tokens |
+ stream _ aString readStream.
+ files _ OrderedCollection new.
+ [stream atEnd] whileFalse:
+ [line _ stream nextLine.
+ tokens _ line findTokens: ' '.
+ tokens size > 2 ifTrue: [files add: tokens last]].
+ ^ files
+!
+
+password: passwordString
+ password _ passwordString
+!
+
+user: userString
+ user _ userString
+! !
+
+!MCFtpRepository methodsFor:'required'!
+
+allFileNames
+ ^ self clientDo:
+ [:client |
+ self parseDirectoryListing: client getDirectory]
+!
+
+description
+ ^ 'ftp://', user, '@', host, '/', directory
+!
+
+readStreamForFileNamed: aString do: aBlock
+ | stream |
+ ^ self clientDo:
+ [:client |
+ client binary.
+ stream _ RWBinaryOrTextStream on: String new.
+ stream nextPutAll: (client getFileNamed: aString).
+ aBlock value: stream reset]
+!
+
+writeStreamForFileNamed: aString replace: ignoreBoolean do: aBlock
+ | stream |
+ stream _ RWBinaryOrTextStream on: String new.
+ aBlock value: stream.
+ self clientDo:
+ [:client |
+ client binary.
+ client putFileStreamContents: stream reset as: aString]
+! !
+
+!MCFtpRepository class methodsFor:'documentation'!
+
+version
+ ^ '$Header: /cvs/stx/stx/goodies/monticello/MCFtpRepository.st,v 1.1 2006-11-22 13:22:28 cg Exp $'
+! !