summaryrefslogtreecommitdiff
path: root/extensions/Gio.js
blob: cc3db2a69923acd0a892bcf7af208b8ea73b2af4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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();