*** empty log message ***
authortm
Fri, 25 Jul 2003 11:02:20 +0200
changeset 1286 cbf02dc8ddef
parent 1285 0b70d88e4a74
child 1287 a49df91aeb78
*** empty log message ***
FtpURI.st
--- a/FtpURI.st	Thu Jul 24 13:09:34 2003 +0200
+++ b/FtpURI.st	Fri Jul 25 11:02:20 2003 +0200
@@ -80,12 +80,12 @@
     |stream ok|
 
     FTPClient fileNotFoundErrorSignal handle:[:ex|] do:[
-        stream := aFtpClient getStreamFor:aPathname.
+	stream := aFtpClient getStreamFor:aPathname.
     ].
 
     ok := stream notNil.
     stream notNil ifTrue:[
-        stream close
+	stream close
     ].
 
     ^ ok
@@ -164,107 +164,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.
-            list addAll:
-                (ftp nlist select:[:filenameString| filenameString matches:baseName]).
-        ] ifFalse:[
-            [
-                dirUri := self.
-                dirPath := path.
-                ftp cd:dirPath.
-                requestDirectory := true.
-                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').
 "/                        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).
+	    ].
     "
 !
 
@@ -299,62 +307,62 @@
 
      If doCreate is true, a nonExistent directory will be created.
      If doAtomic is true, files will appear atomically, by using
-        an intermediate file theat will be renamed"
+	an intermediate file theat will be renamed"
 
     |path toPath directory|
 
     path := self path.
     "kludge"
     (path startsWith:'/~') ifTrue:[
-        path := path copyFrom:2.
+	path := path copyFrom:2.
     ].
 
     doAtomic ifTrue:[
-        toPath := self directoryPath, '/.transferFile'.
-        "kludge"
-        (toPath startsWith:'/~') ifTrue:[
-            toPath := toPath copyFrom:2.
-        ].
+	toPath := self directoryPath, '/.transferFile'.
+	"kludge"
+	(toPath startsWith:'/~') ifTrue:[
+	    toPath := toPath copyFrom:2.
+	].
     ] ifFalse:[
-        toPath := path.
+	toPath := path.
     ].
         
     self connectThenDo:[:ftp| |stream|
-        [
-            [
-                (self pathExists:path ftpClient:ftp) ifTrue:[ |infoStream|
-                    infoStream := '' writeStream.
-                    self publicPrintOn:infoStream.
-                    self error:('FTP write: Datei %1 already exists!!' bindWith:infoStream contents).
-                ].
-                stream := ftp putStreamFor:toPath.
-            ] on:FTPClient filePutErrorSignal do:[:ex|
-                doCreate ifFalse:[
-                    ex reject
-                ].
-                "create the missing directory on the fly"
-                directory := self directoryPath.
-                FTPClient fileNotFoundErrorSignal handle:[:ex| ] do:[
-                    ftp mkdir:directory.
-                ].
-                ftp cd:directory.
-                (self pathExists:path ftpClient:ftp) ifTrue:[ |infoStream|
-                    infoStream := '' writeStream.
-                    self publicPrintOn:infoStream.
-                    self error:('FTP write: Datei %1 already exists!!' bindWith:infoStream contents).
-                ].
-                stream := ftp putStreamFor:toPath.
-            ].
-            aBlock value:stream value:self class attributes.
-            stream close.
-            doAtomic ifTrue:[
-                ftp rename:toPath to:path
-            ].
-        ] ifCurtailed:[
-            stream notNil ifTrue:[
-                stream close.
-            ].
-        ].
+	[
+	    [
+		(self pathExists:path ftpClient:ftp) ifTrue:[ |infoStream|
+		    infoStream := '' writeStream.
+		    self publicPrintOn:infoStream.
+		    self error:('FTP write: Datei %1 already exists!!' bindWith:infoStream contents).
+		].
+		stream := ftp putStreamFor:toPath.
+	    ] on:FTPClient filePutErrorSignal do:[:ex|
+		doCreate ifFalse:[
+		    ex reject
+		].
+		"create the missing directory on the fly"
+		directory := self directoryPath.
+		FTPClient fileNotFoundErrorSignal handle:[:ex| ] do:[
+		    ftp mkdir:directory.
+		].
+		ftp cd:directory.
+		(self pathExists:path ftpClient:ftp) ifTrue:[ |infoStream|
+		    infoStream := '' writeStream.
+		    self publicPrintOn:infoStream.
+		    self error:('FTP write: Datei %1 already exists!!' bindWith:infoStream contents).
+		].
+		stream := ftp putStreamFor:toPath.
+	    ].
+	    aBlock value:stream value:self class attributes.
+	    stream close.
+	    doAtomic ifTrue:[
+		ftp rename:toPath to:path
+	    ].
+	] ifCurtailed:[
+	    stream notNil ifTrue:[
+		stream close.
+	    ].
+	].
     ]
 ! !
 
@@ -375,5 +383,5 @@
 !FtpURI class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/FtpURI.st,v 1.12 2003-07-24 09:29:33 tm Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/FtpURI.st,v 1.13 2003-07-25 09:02:20 tm Exp $'
 ! !