# HG changeset patch # User Claus Gittinger # Date 1013419216 -3600 # Node ID 1197f9507ad2607a5a20d5599d9af232f86b6384 # Parent 9e658e5b57343db16f0d1c0f2b37e495e6b868b3 *** empty log message *** diff -r 9e658e5b5734 -r 1197f9507ad2 Filename.st --- a/Filename.st Mon Feb 11 10:19:44 2002 +0100 +++ b/Filename.st Mon Feb 11 10:20:16 2002 +0100 @@ -560,53 +560,6 @@ "Created: / 19.5.1999 / 12:24:26 / cg" ! -readingFile:aPathName do:aBlock - "create a read-stream on a file, evaluate aBlock, passing that stream, - and return the blocks value. - Ensures that the stream is closed." - - |stream result| - - stream := aPathName asFilename readStream. - [ - result := aBlock value:stream - ] ensure:[ - stream close - ]. - ^ result - - " - |rslt| - - rslt := Filename - readingFile:'/etc/passwd' - do:[:s | - Transcript showCR:s nextLine - ]. - " - - " - Filename - readingFile:'/etc/passwd' - do: - [:s | - |shells| - - shells := Bag new. - s linesDo: - [:line | - |parts| - - parts := line asCollectionOfSubstringsSeparatedBy:$:. - shells add:(parts seventh). - ]. - shells contents - ]. - " - - "Modified: / 31.10.2001 / 09:25:45 / cg" -! - remoteHost:remoteHostString rootComponents:aCollectionOfDirectoryNames "create & return a new filename from components given in aCollectionOfDirectoryNames on a host named remoteHostString. @@ -1173,6 +1126,55 @@ "Modified: 8.9.1997 / 00:35:19 / cg" ! ! +!Filename class methodsFor:'utilities'! + +readingFile:aPathName do:aBlock + "create a read-stream on a file, evaluate aBlock, passing that stream, + and return the blocks value. + Ensures that the stream is closed." + + |stream result| + + stream := aPathName asFilename readStream. + [ + result := aBlock value:stream + ] ensure:[ + stream close + ]. + ^ result + + " + |rslt| + + rslt := Filename + readingFile:'/etc/passwd' + do:[:s | + Transcript showCR:s nextLine + ]. + " + + " + Filename + readingFile:'/etc/passwd' + do: + [:s | + |shells| + + shells := Bag new. + s linesDo: + [:line | + |parts| + + parts := line asCollectionOfSubstringsSeparatedBy:$:. + shells add:(parts seventh). + ]. + shells contents + ]. + " + + "Modified: / 31.10.2001 / 09:25:45 / cg" +! ! + !Filename methodsFor:'Compatibility - VW5.4'! asLogicalFileSpecification @@ -4218,6 +4220,6 @@ !Filename class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.209 2002-02-11 09:19:44 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.210 2002-02-11 09:20:16 cg Exp $' ! ! Filename initialize!