summaryrefslogtreecommitdiff
path: root/wikipedia/utils.js
diff options
context:
space:
mode:
authorP. F. Chimento <philip.chimento@gmail.com>2013-08-06 11:37:05 -0700
committerP. F. Chimento <philip.chimento@gmail.com>2013-08-06 11:37:05 -0700
commitda44c7be3a095c917876d04e3ddfd6d61e2e3097 (patch)
treede159dc174bb0b37aa75501574825c65e4a68059 /wikipedia/utils.js
parent199105c35da09282f1377c8ea4a553799e36f9c7 (diff)
parente7fb92889791785ad3c663808d4e40cb481d1503 (diff)
Merge pull request #221 from endlessm/issues/220
#220 Dealt with relative paths in wikipedia view
Diffstat (limited to 'wikipedia/utils.js')
-rw-r--r--wikipedia/utils.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/wikipedia/utils.js b/wikipedia/utils.js
index 0edb6d4..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,9 +48,25 @@ function load_file_from_resource(filename) {
return data[0];
}
+function get_path_for_relative_path(relative_path){
+ let file = Gio.file_new_for_path(relative_path);
+ 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");
}
/*