X-Git-Url: http://nitlanguage.org diff --git a/lib/linux/linux.nit b/lib/linux/linux.nit index b106d62..3f08b98 100644 --- a/lib/linux/linux.nit +++ b/lib/linux/linux.nit @@ -18,4 +18,50 @@ module linux import app -private import linux_data_store +intrude import app::app_base # For test_bound_platform + +redef class App + # Path to the expected location of the asset folder of this program + # + # The asset folder should be located relative to the executable at `../assets/`. + # This value can be redefined to change the expected location. + var assets_dir: String = sys.program_name.dirname / "../assets/" is lazy + + redef fun setup + do + super + + on_create + on_restore_state + on_resume + end + + redef fun run + do + super + + on_pause + on_save_state + on_stop + 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 + +redef fun bound_platform do return "GNU/Linux" + +redef fun test_bound_platform do end