--- a/FileURI.st Wed Jul 09 18:18:48 2003 +0200
+++ b/FileURI.st Thu Jul 10 11:42:47 2003 +0200
@@ -129,11 +129,13 @@
- a collection with a stream on a single file,
- or a collection with streams on a directorie's files, but not recursive"
- |attributes fn files|
+ |attributes fn files list|
fn := self asFilename.
files := OrderedCollection new.
+ list := OrderedCollection new.
attributes := self class attributes.
+
fn isDirectory ifTrue:[
attributes at:#requestDirectory put:true.
(DirectoryContents directoryNamed:fn pathName) filesDo:[:aFile|
@@ -144,6 +146,25 @@
files add:fn.
].
+ fn isDirectory ifFalse:[ |bName|
+ bName := fn baseName.
+ (bName startsWith:'*') ifTrue:[
+ files removeAll.
+ fn := fn directory.
+ attributes at:#requestDirectory put:true.
+ (DirectoryContents directoryNamed:fn pathName) filesDo:[:aFile|
+ files add:aFile
+ ].
+ ].
+ (bName startsWith:'*.') ifTrue:[ |rest|
+ rest := bName restAfter:$*.
+ (rest includesString:'*') ifTrue:[
+ self error:'can''t resolve path:', self printString
+ ].
+ files := files select:[:aFile| aFile pathName endsWith:rest ]
+ ].
+ ].
+
files do:[:aFile| |baseName stream|
[
baseName := aFile baseName.
@@ -235,5 +256,5 @@
!FileURI class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic2/FileURI.st,v 1.3 2003-07-09 12:55:42 tm Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/FileURI.st,v 1.4 2003-07-10 09:42:36 tm Exp $'
! !
--- a/FtpURI.st Wed Jul 09 18:18:48 2003 +0200
+++ b/FtpURI.st Thu Jul 10 11:42:47 2003 +0200
@@ -33,30 +33,6 @@
^ 'anonymous'
! !
-!FtpURI methodsFor:'file operations'!
-
-ftp:aFtpClient copyContentsOfStream:aReadStream toDestFilePath:aDestiantionPath
-
- |writestream buffer n|
-
- writestream := aFtpClient putStreamFor:aDestiantionPath.
-
- (writestream notNil and:[writestream isWritable]) ifTrue:[
- buffer := ByteArray new:(self class transferBufferSize).
- [aReadStream atEnd] whileFalse:[
- n := aReadStream nextBytes:(buffer size) into:buffer.
- writestream isExternalStream ifTrue:[
- writestream writeWait.
- ].
- writestream nextPutBytes:n from:buffer.
- ].
- ] ifFalse:[
- OperatingSystem fileNotFoundErrorSignal
- raiseRequestWith:aDestiantionPath
- errorString:('Write: %1' bindWith:aDestiantionPath asString)
- ].
-! !
-
!FtpURI methodsFor:'ftp requests'!
connectThenDo:aOneArgBlock
@@ -112,24 +88,6 @@
^ self pathExists:self path ftpClient:aFtpClient
! !
-!FtpURI methodsFor:'private'!
-
-ftp:aFtpClient moveStream:anOpenedStream ofPath:aSourcePath baseName:aBasename intoDir:aDirectoryPathName
-
- |path dir|
-
- dir := aDirectoryPathName asFilename.
- path := (dir construct:aBasename) asString.
- (self pathExists:path ftpClient:aFtpClient) ifTrue:[
- path := AbsoluteTime now printString.
- path := (dir construct:(aBasename, '-', path)) asString.
- ].
- anOpenedStream resetPosition.
- self ftp:aFtpClient copyContentsOfStream:anOpenedStream toDestFilePath:path.
- anOpenedStream close.
- aFtpClient delete:aSourcePath.
-! !
-
!FtpURI methodsFor:'stream access'!
readStreamDo:aBlock
@@ -168,10 +126,10 @@
The streams are closed after aBlock has been evaluated.
Attributes may be the mime type (key #MIME)"
- self readStreamsDo:aBlock thenRemove:false
+ self readStreamsDo:aBlock skipFilenamesWithSuffix:nil thenRemove:false
!
-readStreamsDo:aBlock thenRemove:doRemoveSource
+readStreamsDo:aBlock skipFilenamesWithSuffix:aSuffix thenRemove:doRemoveSource
"evaluate the block with a Collection of streams as first argument
and a dictionary containing attributes as second argument,
- a collection with a stream on a single file,
@@ -198,6 +156,28 @@
list addAll:((ftp list) collect:[:aLine| aLine asCollectionOfWords last]).
].
+ requestDirectory ifFalse:[ |bName|
+ bName := self pathSegements last.
+ (bName startsWith:'*') ifTrue:[
+ list removeAll.
+ requestDirectory := true.
+ attributes at:#requestDirectory put:true.
+ ftp cd:(path asFilename directory) pathName.
+ list addAll:((ftp list) collect:[:aLine| aLine asCollectionOfWords last]).
+ ].
+ (bName startsWith:'*.') ifTrue:[ |rest|
+ rest := bName restAfter:$*.
+ (rest includesString:'*') ifTrue:[
+ self error:'can''t resolve path:', self printString
+ ].
+ list := list select:[:str| str endsWith:rest ]
+ ].
+ ].
+
+ aSuffix size ~~ 0 ifTrue:[
+ list := list select:[:str| (str ensWith:aSuffix) not ]
+ ].
+
list do:[:aPathName| |baseName stream|
FTPClient fileErrorSignal handle:[:ex|
"/ skip subdirectories and the summary of the list
@@ -244,6 +224,18 @@
"
!
+readStreamsDo:aBlock thenRemove:doRemoveSource
+ "evaluate the block with a Collection of streams as first argument
+ and a dictionary containing attributes as second argument,
+ - a collection with a stream on a single file,
+ - or a collection with streams on a directorie's files, but not recursive
+
+ The streams are closed after aBlock has been evaluated.
+ Attributes may be the mime type (key #MIME)"
+
+ self readStreamsDo:aBlock skipFilenamesWithSuffix:nil thenRemove:doRemoveSource
+!
+
writeStreamDo:aBlock
"use FTPClient for now"
@@ -272,5 +264,5 @@
!FtpURI class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic2/FtpURI.st,v 1.3 2003-07-09 12:55:24 tm Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/FtpURI.st,v 1.4 2003-07-10 09:42:47 tm Exp $'
! !