Filename.st
changeset 6383 1197f9507ad2
parent 6382 9e658e5b5734
child 6392 f3c2c3edf2c8
equal deleted inserted replaced
6382:9e658e5b5734 6383:1197f9507ad2
   556     "
   556     "
   557      Filename nullDevice        
   557      Filename nullDevice        
   558     "
   558     "
   559 
   559 
   560     "Created: / 19.5.1999 / 12:24:26 / cg"
   560     "Created: / 19.5.1999 / 12:24:26 / cg"
   561 !
       
   562 
       
   563 readingFile:aPathName do:aBlock
       
   564     "create a read-stream on a file, evaluate aBlock, passing that stream,
       
   565      and return the blocks value.
       
   566      Ensures that the stream is closed."
       
   567 
       
   568     |stream result|
       
   569 
       
   570     stream := aPathName asFilename readStream.
       
   571     [
       
   572         result := aBlock value:stream
       
   573     ] ensure:[
       
   574         stream close
       
   575     ].
       
   576     ^ result
       
   577 
       
   578     "
       
   579      |rslt|
       
   580 
       
   581      rslt := Filename 
       
   582                 readingFile:'/etc/passwd' 
       
   583                 do:[:s |
       
   584                     Transcript showCR:s nextLine
       
   585                 ].
       
   586     "
       
   587 
       
   588     "
       
   589      Filename 
       
   590          readingFile:'/etc/passwd' 
       
   591          do:
       
   592              [:s |
       
   593                  |shells|
       
   594 
       
   595                  shells := Bag new.
       
   596                  s linesDo:
       
   597                      [:line |
       
   598                          |parts|
       
   599 
       
   600                          parts := line asCollectionOfSubstringsSeparatedBy:$:.
       
   601                          shells add:(parts seventh).
       
   602                      ].
       
   603                  shells contents
       
   604              ].           
       
   605     "
       
   606 
       
   607     "Modified: / 31.10.2001 / 09:25:45 / cg"
       
   608 !
   561 !
   609 
   562 
   610 remoteHost:remoteHostString rootComponents:aCollectionOfDirectoryNames
   563 remoteHost:remoteHostString rootComponents:aCollectionOfDirectoryNames
   611     "create & return a new filename from components given in
   564     "create & return a new filename from components given in
   612      aCollectionOfDirectoryNames on a host named remoteHostString. 
   565      aCollectionOfDirectoryNames on a host named remoteHostString. 
  1169 
  1122 
  1170     ^ OperatingSystem getDriveList
  1123     ^ OperatingSystem getDriveList
  1171 
  1124 
  1172     "Modified: 7.9.1995 / 10:45:25 / claus"
  1125     "Modified: 7.9.1995 / 10:45:25 / claus"
  1173     "Modified: 8.9.1997 / 00:35:19 / cg"
  1126     "Modified: 8.9.1997 / 00:35:19 / cg"
       
  1127 ! !
       
  1128 
       
  1129 !Filename class methodsFor:'utilities'!
       
  1130 
       
  1131 readingFile:aPathName do:aBlock
       
  1132     "create a read-stream on a file, evaluate aBlock, passing that stream,
       
  1133      and return the blocks value.
       
  1134      Ensures that the stream is closed."
       
  1135 
       
  1136     |stream result|
       
  1137 
       
  1138     stream := aPathName asFilename readStream.
       
  1139     [
       
  1140         result := aBlock value:stream
       
  1141     ] ensure:[
       
  1142         stream close
       
  1143     ].
       
  1144     ^ result
       
  1145 
       
  1146     "
       
  1147      |rslt|
       
  1148 
       
  1149      rslt := Filename 
       
  1150                 readingFile:'/etc/passwd' 
       
  1151                 do:[:s |
       
  1152                     Transcript showCR:s nextLine
       
  1153                 ].
       
  1154     "
       
  1155 
       
  1156     "
       
  1157      Filename 
       
  1158          readingFile:'/etc/passwd' 
       
  1159          do:
       
  1160              [:s |
       
  1161                  |shells|
       
  1162 
       
  1163                  shells := Bag new.
       
  1164                  s linesDo:
       
  1165                      [:line |
       
  1166                          |parts|
       
  1167 
       
  1168                          parts := line asCollectionOfSubstringsSeparatedBy:$:.
       
  1169                          shells add:(parts seventh).
       
  1170                      ].
       
  1171                  shells contents
       
  1172              ].           
       
  1173     "
       
  1174 
       
  1175     "Modified: / 31.10.2001 / 09:25:45 / cg"
  1174 ! !
  1176 ! !
  1175 
  1177 
  1176 !Filename methodsFor:'Compatibility - VW5.4'!
  1178 !Filename methodsFor:'Compatibility - VW5.4'!
  1177 
  1179 
  1178 asLogicalFileSpecification
  1180 asLogicalFileSpecification
  4216 ! !
  4218 ! !
  4217 
  4219 
  4218 !Filename class methodsFor:'documentation'!
  4220 !Filename class methodsFor:'documentation'!
  4219 
  4221 
  4220 version
  4222 version
  4221     ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.209 2002-02-11 09:19:44 cg Exp $'
  4223     ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.210 2002-02-11 09:20:16 cg Exp $'
  4222 ! !
  4224 ! !
  4223 Filename initialize!
  4225 Filename initialize!