From: Alexis Laferrière Date: Tue, 12 Jan 2016 05:05:19 +0000 (-0500) Subject: lib/linux: implement `TextAsset` X-Git-Tag: v0.8~15^2~6 X-Git-Url: http://nitlanguage.org lib/linux: implement `TextAsset` Signed-off-by: Alexis Laferrière --- diff --git a/lib/linux/linux.nit b/lib/linux/linux.nit index a861593..6b89eb8 100644 --- a/lib/linux/linux.nit +++ b/lib/linux/linux.nit @@ -46,3 +46,19 @@ redef class App on_destroy end end + +redef class TextAsset + redef fun load + do + var path = app.assets_dir / path + var reader = path.to_path.open_ro + var content = reader.read_all + reader.close + + var error = reader.last_error + if error != null then self.error = error + + self.to_s = content + return content + end +end