X-Git-Url: http://git.roojs.org/?p=gnome.introspection-doc-generator;a=blobdiff_plain;f=File.js;fp=File.js;h=b34a8df3d03ded9886a0032848149fbd89b2a41a;hp=ebb74cfa726d4aa29f6114efb0ebe6c4611ec764;hb=6ee0a01d3485b87e0514c6da4665a12aa00562b0;hpb=1c112ad8d5cecd0351642c79419edab08e1a9074 diff --git a/File.js b/File.js index ebb74cf..b34a8df 100755 --- a/File.js +++ b/File.js @@ -2,7 +2,7 @@ const GLib = imports.gi.GLib; const Gio = imports.gi.Gio; -const String = imports.String.String; +var String = imports.String.String; /** * @namespace File * @@ -62,8 +62,11 @@ const File = { }, read : function (path) { var out = {}; - GLib.file_get_contents(path, out, null, null); - return out['value']; + + var ret = GLib.file_get_contents(path, out, null, null); + //print(ret[1]); + //throw "oops"; + return '' + ((typeof(ret) == 'object') ? ret[1] : out['value']); }, isFile : function (path) { @@ -79,7 +82,7 @@ const File = { list : function (path) { var listing = []; - var f = Gio.file_new_for_path(String(path)); + var f = Gio.file_new_for_path('' +(path)); var file_enum = f.enumerate_children(Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, Gio.FileQueryInfoFlags.NONE, null); var next_file = null; @@ -96,7 +99,7 @@ const File = { }, mtime : function (path) { - var f = Gio.file_new_for_path(String(path)); + var f = Gio.file_new_for_path('' +(path)); var mtime = new GLib.TimeVal(); var info = f.query_info(Gio.FILE_ATTRIBUTE_TIME_MODIFIED, Gio.FileQueryInfoFlags.NONE, null); @@ -106,7 +109,7 @@ const File = { }, canonical : function (path) { - var f = Gio.file_new_for_path(String(path)); + var f = Gio.file_new_for_path('' +(path)); var can = f.resolve_relative_path(''); return can.get_path(); }, @@ -118,7 +121,7 @@ const File = { * */ write : function (path, string) { - var f = Gio.file_new_for_path(String(path)); + var f = Gio.file_new_for_path('' +(path)); var data_out = new Gio.DataOutputStream({base_stream:f.replace(null, false, Gio.FileCreateFlags.NONE, null)}); data_out.put_string(string, null); data_out.close(null); @@ -130,7 +133,7 @@ const File = { * */ append : function (path, string) { - var f = Gio.file_new_for_path(String(path)); + var f = Gio.file_new_for_path('' +(path)); var data_out = new Gio.DataOutputStream({ base_stream:f.append_to(Gio.FileCreateFlags.NONE, null) }); @@ -146,8 +149,9 @@ const File = { */ remove : function (path) { - var f = Gio.file_new_for_path(String(path)); - return f['delete'](); + var f = Gio.file_new_for_path('' +(path)); + var c = new Gio.Cancellable(); + return f['delete'](c); }, /** * silentRecursiveCopy @@ -168,8 +172,8 @@ const File = { } for (var index in filesToCopy) { - srcPath = File.join(String(fromDir), filesToCopy[index]); - destPath = File.join(String(toDir), filesToCopy[index]); + srcPath = File.join('' +(fromDir), filesToCopy[index]); + destPath = File.join('' +(toDir), filesToCopy[index]); if (File.isDirectory(srcPath) && !File.isDirectory(destPath)) { File.mkdir(destPath); @@ -195,7 +199,7 @@ const File = { * @arg {String} dstPath directory to make */ mkdir : function (destPath) { - var dest = Gio.file_new_for_path(String(destPath)); + var dest = Gio.file_new_for_path('' +(destPath)); return dest.make_directory(null, null); }, @@ -210,8 +214,8 @@ const File = { if (typeof(opts) =='undefined') { opts = Gio.FileCopyFlags.NONE; } - var dest = Gio.file_new_for_path(String(destPath)); - var src = Gio.file_new_for_path(String(srcPath)); + var dest = Gio.file_new_for_path('' +(destPath)); + var src = Gio.file_new_for_path('' +(srcPath)); // a bit of a hack for the fact that Gio.File.copy arguments // can be nulled, but not according to the GIR file