summaryrefslogtreecommitdiff
path: root/wikipedia
diff options
context:
space:
mode:
authorRory MacQueen <rorymacqueen@gmail.com>2013-08-06 00:12:19 -0700
committerRory MacQueen <rorymacqueen@gmail.com>2013-08-06 00:12:19 -0700
commitc80c9e765f7ba6c3ba5d5e78f90fe37f58b1e818 (patch)
tree1c5526a4548df233fc8cc11d309ce91117d6bc60 /wikipedia
parentd9fe26c2141a191d4acc530be0da2310f890c425 (diff)
Added utility functions for reading and writing to temporary files
[endlessm/eos-sdk#220]
Diffstat (limited to 'wikipedia')
-rw-r--r--wikipedia/utils.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/wikipedia/utils.js b/wikipedia/utils.js
index 662b2b4..234efcd 100644
--- a/wikipedia/utils.js
+++ b/wikipedia/utils.js
@@ -1,5 +1,6 @@
const Gio = imports.gi.Gio;
const GdkPixbuf = imports.gi.GdkPixbuf;
+const GLib = imports.gi.GLib;
const set_default = function(obj, key, val) {
// Similar to python's dict.setdefault(key, val)
@@ -47,14 +48,25 @@ function load_file_from_resource(filename) {
return data[0];
}
-function get_uri_for_relative_path(relative_path){
+function get_path_for_relative_path(relative_path){
let file = Gio.file_new_for_path(relative_path);
- return file.get_uri();
+ return file.get_path();
}
function write_contents_to_file(filename, content){
let file = Gio.file_new_for_path(filename);
file.replace_contents(content, null, false, 0, null);
+ return file.get_uri();
+}
+
+function write_contents_to_temp_file(name, content){
+ let file = Gio.file_new_tmp(name + "XXXXXX")[0];
+ file.replace_contents(content, null, false, 0, null);
+ return file.get_uri();
+}
+
+function make_temp_dir(name){
+ return GLib.dir_make_tmp(name + "XXXXXX");
}
/*