@@ -30,6 +30,7 @@ import cats.syntax.all._
30
30
31
31
import scala .concurrent .duration ._
32
32
import cats .Traverse
33
+ import fs2 .text
33
34
34
35
/** Provides operations related to working with files in the effect `F`.
35
36
*
@@ -273,6 +274,12 @@ sealed trait Files[F[_]] extends FilesPlatform[F] {
273
274
*/
274
275
def readRange (path : Path , chunkSize : Int , start : Long , end : Long ): Stream [F , Byte ]
275
276
277
+ /** Reads all bytes from the file specified and decodes them as a utf8 string. */
278
+ def readUtf8 (path : Path ): Stream [F , String ]
279
+
280
+ /** Reads all bytes from the file specified and decodes them as utf8 lines. */
281
+ def readUtf8Lines (path : Path ): Stream [F , String ]
282
+
276
283
/** Returns the real path i.e. the actual location of `path`.
277
284
* The precise definition of this method is implementation dependent but in general
278
285
* it derives from this path, an absolute path that locates the same file as this path,
@@ -419,6 +426,12 @@ object Files extends FilesCompanionPlatform {
419
426
cursor.seek(start).readUntil(chunkSize, end).void.stream
420
427
}
421
428
429
+ def readUtf8 (path : Path ): Stream [F , String ] =
430
+ readAll(path).through(text.utf8.decode)
431
+
432
+ def readUtf8Lines (path : Path ): Stream [F , String ] =
433
+ readUtf8(path).through(text.lines)
434
+
422
435
def tail (
423
436
path : Path ,
424
437
chunkSize : Int ,
0 commit comments