--- a/Filename.st Mon Jul 22 15:04:10 2019 +0200
+++ b/Filename.st Mon Jul 22 17:35:23 2019 +0200
@@ -6748,6 +6748,30 @@
"Modified: / 12-01-2018 / 18:21:32 / stefan"
!
+readingFileWithEncoding:encodingNameSymbol do:aBlock
+ "Create a read stream on the receiver file, evaluate aBlock, passing that stream as arg,
+ and return the block's value.
+ If the file cannot be opened, an exception is raised or
+ (old behavior, will vanish:)the block is evaluated with a nil argument.
+ Ensures that the stream is closed.
+ The file is decoded on the fly."
+
+ ^ self readingFileDo:[:s |
+ aBlock value:(EncodedStream stream:s encoder:(CharacterEncoder encoderFor:encodingNameSymbol))
+ ].
+
+ "
+ 'Make.proto' asFilename
+ readingFileWithEncoding:#utf8
+ do:[:stream |
+ stream upToEnd
+ ]
+ "
+
+
+ "Modified: / 12-01-2018 / 18:21:32 / stefan"
+!
+
readingLinesDo:aBlock
"Create a read stream on the receiver file and
evaluate aBlock for each line read from the stream.