File manager frontend

This commit is contained in:
Guntis Smaukstelis
2023-05-15 16:37:03 +03:00
parent 851229ce9b
commit db900d6a33
11 changed files with 215 additions and 37 deletions
+8
View File
@@ -74,4 +74,12 @@ object DBService {
val dateStr: String = date.format(formatter)
readFileNames(dataPath).map(_.filter(_.startsWith(dateStr)).sorted)
}
def getFileContent(fileName: String): IO[String] = {
val file = new File(dataPath, fileName)
val sourceResource = Resource.fromAutoCloseable(IO(Source.fromFile(file)))
sourceResource.use(source => IO(source.getLines().mkString("<br/>\n"))).handleErrorWith { error =>
IO(println(s"Failed to read file: $error")) *> IO.pure("")
}
}
}