From bbb4dedde22d7d73c7b2f474d693f3de00b5013a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Tue, 12 Jan 2016 00:05:19 -0500 Subject: [PATCH] lib/linux: implement `TextAsset` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/linux/linux.nit | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 -- 1.7.9.5