BrowserView.js
[app.wkmirror] / File.js
diff --git a/File.js b/File.js
index f7ae90c..30d9639 100755 (executable)
--- a/File.js
+++ b/File.js
@@ -2,7 +2,8 @@
 GLib = imports.gi.GLib;
 Gio = imports.gi.Gio;
 
-String  = imports.String.String; 
+String  = imports.String.String;
+
 /**
 * @class File
 * @singleton
@@ -204,6 +205,24 @@ var File = {
         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);
+    },
+        /**
+     * write a string to file
+     * @param {String} pathFile to write to
+     * @param {String} string  Contents of file.
+     * 
+     */
+    writeBinaryArray : function (path, stringAr) {
+        var f = Gio.file_new_for_path(String(path));
+        var data_out = new Gio.DataOutputStream({base_stream:f.replace(null, false, Gio.FileCreateFlags.NONE, null)});
+        for(var i =0; i < stringAr.length; i++) {
+            data_out.put_byte(stringAr[i], null);
+            if (i % 10000 == 0) {
+                print("wrote " + i + "/" + stringAr.length + "\n");
+            }
+            
+        }
+        data_out.close(null);
     },
     /**
      * append a string to a file
@@ -276,6 +295,22 @@ var File = {
         
         return dest.make_directory(null, null);
     },
+    
+    /**
+     * make a directory..
+     * @param {String} dstPath directory to make
+     */
+    mkdirall : function (destPath) {
+        var parent = File.dirname(destPath);
+        if (!File.exists(parent)) {
+            File.mkdirall(parent);
+        }
+        if (!File.exists(destPath)) {
+            return File.mkdir(destPath); 
+        }
+        return true;
+    },
+    
     /**
      * copy a File
      * @param {String} src source path