Filename.st
changeset 24454 9b9e7d371d89
parent 24403 2381ea8610f7
child 24473 699cce1b1667
equal deleted inserted replaced
24453:042e5f43fdc5 24454:9b9e7d371d89
  6746     "
  6746     "
  6747 
  6747 
  6748     "Modified: / 12-01-2018 / 18:21:32 / stefan"
  6748     "Modified: / 12-01-2018 / 18:21:32 / stefan"
  6749 !
  6749 !
  6750 
  6750 
       
  6751 readingFileWithEncoding:encodingNameSymbol do:aBlock
       
  6752     "Create a read stream on the receiver file, evaluate aBlock, passing that stream as arg,
       
  6753      and return the block's value.
       
  6754      If the file cannot be opened, an exception is raised or
       
  6755      (old behavior, will vanish:)the block is evaluated with a nil argument.
       
  6756      Ensures that the stream is closed.
       
  6757      The file is decoded on the fly."
       
  6758 
       
  6759     ^ self readingFileDo:[:s |
       
  6760         aBlock value:(EncodedStream stream:s encoder:(CharacterEncoder encoderFor:encodingNameSymbol))
       
  6761     ].
       
  6762 
       
  6763     "
       
  6764      'Make.proto' asFilename 
       
  6765         readingFileWithEncoding:#utf8 
       
  6766         do:[:stream |
       
  6767             stream upToEnd
       
  6768         ]
       
  6769     "
       
  6770 
       
  6771 
       
  6772     "Modified: / 12-01-2018 / 18:21:32 / stefan"
       
  6773 !
       
  6774 
  6751 readingLinesDo:aBlock
  6775 readingLinesDo:aBlock
  6752     "Create a read stream on the receiver file and
  6776     "Create a read stream on the receiver file and
  6753      evaluate aBlock for each line read from the stream.
  6777      evaluate aBlock for each line read from the stream.
  6754      If the file cannot be opened, an error is raised.
  6778      If the file cannot be opened, an error is raised.
  6755      Ensures that the stream is closed."
  6779      Ensures that the stream is closed."