JSDOC/TokenReader.js
[gnome.introspection-doc-generator] / File.js
diff --git a/File.js b/File.js
index e38e4ec..29e0c05 100755 (executable)
--- a/File.js
+++ b/File.js
@@ -1,8 +1,8 @@
 // <script type ="text/Javascript">
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
+const Gio = imports.gi.Gio;
 
-String  = imports.String.String; 
+var String  = imports.String.String; 
 /**
 * @namespace File
 * 
@@ -17,7 +17,7 @@ String  = imports.String.String;
 * 
 * 
 */
-var File = {
+const  File = {
 
     SEPARATOR : '/',
 
@@ -32,8 +32,8 @@ var File = {
         return s;
     },
     trim : function (s,toTrim) {
-        var out = s.ltrim(toTrim);
-        out = out.rtrim(toTrim);
+        var out = this.ltrim(s,toTrim);
+        out = this.rtrim(out,toTrim);
         return out;
     },
     
@@ -62,8 +62,11 @@ var File = {
     }, 
     read : function (path) {
         var out = {};
-        GLib.file_get_contents(path, out, null, null);
-        return out['value'];
+        print(path);
+        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 @@ var 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 @@ var 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 @@ var 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 @@ var 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 @@ var 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 @@ var 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 @@ var 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 @@ var 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 @@ var 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