diff options
Diffstat (limited to 'jsextensions/Gio.js')
-rw-r--r-- | jsextensions/Gio.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/jsextensions/Gio.js b/jsextensions/Gio.js new file mode 100644 index 0000000..cc3db2a --- /dev/null +++ b/jsextensions/Gio.js @@ -0,0 +1,35 @@ +Gio = imports.gi.Gio; + +(function() +{ + var prototype = Gio.FileInputStream.prototype; + + prototype.get_contents = function() + { + var stream = new Gio.DataInputStream.c_new(this); + var line = stream.read_until("", 0); + return line; + } + + Gio.simple_write = function(file, name) + { + var file = Gio.file_new_for_path(file); + var fstream = file.replace(); + var dstream = new Gio.DataOutputStream.c_new(fstream); + + dstream.put_string(name); + fstream.close(); + } + + Gio.simple_read = function(name) + { + var file = Gio.file_new_for_path(name); + + var fstream = file.read(); + var dstream = new Gio.DataInputStream.c_new(fstream); + var line = dstream.read_until("", 0); + + fstream.close(); + return line; + } +}).apply(); |