--- a/FtpURI.st Sat Mar 20 16:33:16 2004 +0100
+++ b/FtpURI.st Sat Mar 20 16:36:05 2004 +0100
@@ -191,115 +191,115 @@
path := self path.
"kludge"
(path startsWith:'/~') ifTrue:[
- path := path copyFrom:2.
+ path := path copyFrom:2.
].
attributes := self class attributes.
list := OrderedCollection new.
self connectThenDo:[:ftp| |baseName|
- "try to change directory to path.
- If we get a file error, we know that the directory does not exist"
- baseName := self baseName.
- (baseName includesAny:'*?[]') ifTrue:[
- requestDirectory := true.
- dirUri := self directory.
- dirPath := dirUri path.
- "kludge"
- (dirPath startsWith:'/~') ifTrue:[
- dirPath := dirPath copyFrom:2.
- ].
- ftp cd:dirPath.
- FTPClient fileNotFoundErrorSignal handle:[:ex|]
- "skip error about an empty directory"
- do:[
- list addAll:
- (ftp nlist select:[:filenameString| filenameString matches:baseName]).
- ].
- ] ifFalse:[
- [
- dirUri := self.
- dirPath := path.
- ftp cd:dirPath.
- requestDirectory := true.
- FTPClient fileNotFoundErrorSignal handle:[:ex|]
- "skip error about an empty directory"
- do:[
- list addAll:ftp nlist.
- ].
- ] on:FTPClient fileErrorSignal do:[:ex|
- "no directory, fetch path istSelf"
- ].
- ].
- requestDirectory ifFalse:[
- dirUri := self directory.
- dirPath := dirUri path.
- "kludge"
- (dirPath startsWith:'/~') ifTrue:[
- dirPath := dirPath copyFrom:2.
- ].
- ftp cd:dirPath.
- list add:self baseName.
- ].
+ "try to change directory to path.
+ If we get a file error, we know that the directory does not exist"
+ baseName := self baseName.
+ (baseName includesAny:'*?[]') ifTrue:[
+ requestDirectory := true.
+ dirUri := self directory.
+ dirPath := dirUri path.
+ "kludge"
+ (dirPath startsWith:'/~') ifTrue:[
+ dirPath := dirPath copyFrom:2.
+ ].
+ ftp cd:dirPath.
+ FTPClient fileNotFoundErrorSignal handle:[:ex|]
+ "skip error about an empty directory"
+ do:[
+ list addAll:
+ (ftp nlist select:[:filenameString| filenameString matches:baseName]).
+ ].
+ ] ifFalse:[
+ [
+ dirUri := self.
+ dirPath := path.
+ ftp cd:dirPath.
+ requestDirectory := true.
+ FTPClient fileNotFoundErrorSignal handle:[:ex|]
+ "skip error about an empty directory"
+ do:[
+ list addAll:ftp nlist.
+ ].
+ ] on:FTPClient fileErrorSignal do:[:ex|
+ "no directory, fetch path istSelf"
+ ].
+ ].
+ requestDirectory ifFalse:[
+ dirUri := self directory.
+ dirPath := dirUri path.
+ "kludge"
+ (dirPath startsWith:'/~') ifTrue:[
+ dirPath := dirPath copyFrom:2.
+ ].
+ ftp cd:dirPath.
+ list add:self baseName.
+ ].
- attributes at:#requestDirectory put:requestDirectory.
+ attributes at:#requestDirectory put:requestDirectory.
- "skip all files with skipSuffix aka 'file.old'"
- skipSuffix size == 0 ifFalse:[
- list := list select:[:baseName| (baseName endsWith:skipSuffix) not]
- ].
+ "skip all files with skipSuffix aka 'file.old'"
+ skipSuffix size == 0 ifFalse:[
+ list := list select:[:baseName| (baseName endsWith:skipSuffix) not]
+ ].
- list do:[:eachBaseName| |stream|
- "get a stream for the contents of the file"
- FTPClient fileErrorSignal handle:[:ex|
- "ignore errors -- skip subdirectories"
- ] do:[
- stream := ftp getStreamFor:eachBaseName.
- attributes at:#fileSize put:(ftp sizeOf:eachBaseName).
- attributes at:#baseName put:eachBaseName.
- ].
+ list do:[:eachBaseName| |stream|
+ "get a stream for the contents of the file"
+ FTPClient fileErrorSignal handle:[:ex|
+ "ignore errors -- skip subdirectories"
+ ] do:[
+ stream := ftp getStreamFor:eachBaseName.
+ attributes at:#fileSize put:(ftp sizeOf:eachBaseName).
+ attributes at:#baseName put:eachBaseName.
+ ].
- stream notNil ifTrue:[ |srcUri srcPath|
- requestDirectory ifTrue:[
- "accessing the contents of a directory"
- srcUri := dirUri construct:eachBaseName.
- ] ifFalse:[ |pathSegments|
- "accessing a single file"
- srcUri := self.
- ].
- attributes at:#uriInfo put:srcUri.
+ stream notNil ifTrue:[ |srcUri srcPath|
+ requestDirectory ifTrue:[
+ "accessing the contents of a directory"
+ srcUri := dirUri construct:eachBaseName.
+ ] ifFalse:[ |pathSegments|
+ "accessing a single file"
+ srcUri := self.
+ ].
+ attributes at:#uriInfo put:srcUri.
- [
- aBlock value:stream value:attributes
- ] ensure:[stream close].
+ [
+ aBlock value:stream value:attributes
+ ] ensure:[stream close].
- renameBlock notNil ifTrue:[ |renameFilenameString|
- renameFilenameString := renameBlock value:eachBaseName.
+ renameBlock notNil ifTrue:[ |renameFilenameString|
+ renameFilenameString := renameBlock value:eachBaseName.
"/ [
- ftp rename:eachBaseName to:renameFilenameString.
+ ftp rename:eachBaseName to:renameFilenameString.
"/ ] on:FTPClient fileErrorSignal do:[:ex|
"/ "rename failed, maybe file already exists"
"/ renameFilenameString := renameFilenameString, '.',
-"/ (AbsoluteTime now printStringFormat:'%(year)%(mon)%(day)%h%m%s').
+"/ (Timestamp now printStringFormat:'%(year)%(mon)%(day)%h%m%s').
"/ ftp rename:eachBaseName to:renameFilenameString.
"/ ].
- ].
- ].
- ].
+ ].
+ ].
+ ].
].
"
- |pwd|
+ |pwd|
- pwd := Dialog requestPassword:''.
- (URI fromString:('ftp://tm:%1@exept/~/tmp' bindWith:pwd) )
- readStreamsDo:[:stream :attributes |
- Transcript showCR:(attributes at:#baseName).
- Transcript showCR:(attributes at:#fileSize).
- Transcript showCR:(attributes at:#requestDirectory).
- Transcript showCR:(attributes at:#uriInfo).
- ].
+ pwd := Dialog requestPassword:''.
+ (URI fromString:('ftp://tm:%1@exept/~/tmp' bindWith:pwd) )
+ readStreamsDo:[:stream :attributes |
+ Transcript showCR:(attributes at:#baseName).
+ Transcript showCR:(attributes at:#fileSize).
+ Transcript showCR:(attributes at:#requestDirectory).
+ Transcript showCR:(attributes at:#uriInfo).
+ ].
"
!
@@ -410,5 +410,5 @@
!FtpURI class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic2/FtpURI.st,v 1.15 2003-08-29 19:33:45 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/FtpURI.st,v 1.16 2004-03-20 15:36:05 stefan Exp $'
! !