base( project, path);
this.xtype = "PlainFile";
+ // 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 = "";
+
// fixme...
- this.language = "vala";
+
- this.contents = "";
+ this.contents = "";
// super?!?!
this.id = "file-plain-%d".printf(plid++);
},
*/
- public override void removeFiles() {
- if (FileUtils.test(this.pat, FileTest.EXISTS)) {
- GLib.FileUtils.remove(this.pat);
- }
-
- }
-
- public override void loadItems() throws GLib.Error // : function(cb, sync) == original was async.
- {
-
- GLib.FileUtils.get_contents(this.path, this.contents);
-
+ public override void removeFiles() {
+ if (FileUtils.test(this.path, FileTest.EXISTS)) {
+ GLib.FileUtils.remove(this.path);
}
-
+
+ }
+
+ public override void loadItems() throws GLib.Error // : function(cb, sync) == original was async.
+ {
+ if (this.loaded) {
+ return;
+ }
+ GLib.FileUtils.get_contents(this.path, out this.contents);
+ this.loaded = true;
+ }
+
public override string toSourcePreview()
{
-
+ return "";
+ }
+ public override void setSource(string str) {
+ this.contents = str;
}
-
public override string toSource()
{
return this.contents;
}
-
+ public override string toSourceCode()
+ {
+ return this.contents;
+
+
+
+ }
public override void save() {
- this.writeFile(this.path, this.contents);
+ if (!this.loaded) {
+ print("Ignoring Save - as file was never loaded?\n");
+ return;
+ }
+ try {
+ this.writeFile(this.path, this.contents);
+ } catch (GLib.Error e) {
+ // error ???
+ }
}
// ignore these calls.