nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
1ff52f8
)
lib/linux: implement `TextAsset`
author
Alexis Laferrière
<alexis.laf@xymus.net>
Tue, 12 Jan 2016 05:05:19 +0000
(
00:05
-0500)
committer
Alexis Laferrière
<alexis.laf@xymus.net>
Tue, 12 Jan 2016 18:13:06 +0000
(13:13 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
lib/linux/linux.nit
patch
|
blob
|
history
diff --git
a/lib/linux/linux.nit
b/lib/linux/linux.nit
index
a861593
..
6b89eb8
100644
(file)
--- a/
lib/linux/linux.nit
+++ b/
lib/linux/linux.nit
@@
-46,3
+46,19
@@
redef class App
on_destroy
end
end
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