-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathutils.js
33 lines (30 loc) · 852 Bytes
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* KeyMan - A gnome shell extension to access the keyring in a convenient way
* (c) 2014 David Poetzsch-Heffter <[email protected]>
* This file is distributed under the same licence as the KeyMan package.
* See file LICENSE for details.
*/
const ByteArray = imports.byteArray;
const GLib = imports.gi.GLib;
function assert(condition) {
if (!condition) {
// remove this in production code
throw "Assertion failed: " + condition;
}
}
function fileExists(path) {
return GLib.file_test(path, GLib.FileTest.EXISTS);
}
function mkdirP(path) {
// 493 == rwxr-xr-x
GLib.mkdir_with_parents(path, 493);
}
function writeToFile(path, content) {
GLib.file_set_contents(path, content);
}
function readFromFile(path) {
return ByteArray.toString(GLib.file_get_contents(path)[1]);
}
function joinPaths(paths) {
return paths.join("/");
}