+ /**
+ * needed as Json dumps .xXXX into same directory as it writes...
+ */
+ void writeJson(Json.Generator g, string fname)
+ {
+ var tmp = this.tempdir + GLib.Path.get_basename(fname);
+ g.to_file(tmp);
+
+ if (GLib.FileUtils.test(fname, GLib.FileTest.EXISTS)) {
+ string new_data, old_data;
+ FileUtils.get_contents(tmp, out new_data);
+ FileUtils.get_contents(fname, out old_data);
+ if (old_data == new_data) {
+ GLib.File.new_for_path(tmp).delete();
+ return;
+ }
+ }
+
+ GLib.File.new_for_path(tmp).move( File.new_for_path(fname), GLib.FileCopyFlags.OVERWRITE);
+
+ }
+