X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=src%2FJsRender%2FPlainFile.vala;h=69872879e17045d7ebda6b9aedebf6db5d9aed7b;hb=HEAD;hp=ee5bab0697387345bf9159cab0b3eabd5f4aef8a;hpb=55a0fae12591e1471183489e1d7bfc189837b472;p=app.Builder.js diff --git a/src/JsRender/PlainFile.vala b/src/JsRender/PlainFile.vala index ee5bab069..69872879e 100644 --- a/src/JsRender/PlainFile.vala +++ b/src/JsRender/PlainFile.vala @@ -24,10 +24,23 @@ namespace JsRender { base( project, path); this.xtype = "PlainFile"; - var f = File.new_for_path (path) ; - var info = f.query_info ("standard::*", 0); - var ct = info.get_content_type(); - this.content_type = ct; + // if the file does not exist... + if (GLib.FileUtils.test(path, GLib.FileTest.EXISTS)) { + var f = File.new_for_path (path) ; + var info = f.query_info ("standard::*", 0); + var ct = info.get_content_type(); + this.content_type = ct; + } else { + this.content_type = "text/plain"; // hopefully.. +// var ar = path.split("."); + // var ext = ar[ar.length -1]; // hopefully not fail... + + // switch(ext) { + // case "vala"; + this.loaded = true; + + + } this.language = ""; @@ -71,9 +84,11 @@ namespace JsRender { public override void loadItems() throws GLib.Error // : function(cb, sync) == original was async. { - - GLib.FileUtils.get_contents(this.path, out this.contents); - this.loaded = true; + if (this.loaded) { + return; + } + GLib.FileUtils.get_contents(this.path, out this.contents); + this.loaded = true; } @@ -92,7 +107,13 @@ namespace JsRender { } - + public override string toSourceCode() + { + return this.contents; + + + + } public override void save() { if (!this.loaded) { print("Ignoring Save - as file was never loaded?\n");