summaryrefslogtreecommitdiff
path: root/overrides
diff options
context:
space:
mode:
authorMatt Watson <mattdangerw@gmail.com>2014-04-04 17:53:22 -0700
committerMatt Watson <mattdangerw@gmail.com>2014-04-04 18:27:07 -0700
commit69865546166527075c1daab32737e3288e403bff (patch)
treedc2943eccb3484d200d4e0931a3744386aef2c72 /overrides
parent4120612ce88aa09de995e3acb584ddbf59a7ae7e (diff)
Handle relative symlinks properly in getCurrentFileDir
g_file_read_link can return a relative path, we were evaluating that from the current working directory while can lead to getCurrentFileDir returning non existent paths [endlessm/eos-sdk#885]
Diffstat (limited to 'overrides')
-rw-r--r--overrides/Endless.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/overrides/Endless.js b/overrides/Endless.js
index 60a42e7..02eed50 100644
--- a/overrides/Endless.js
+++ b/overrides/Endless.js
@@ -10,12 +10,15 @@ function getCurrentFileDir() {
let caller = e.stack.split('\n')[1];
let pathAndLine = caller.split('@')[1];
let path = pathAndLine.split(':')[0];
- while (GLib.file_test(path, GLib.FileTest.IS_SYMLINK)) {
- path = GLib.file_read_link(path);
+ let file = Gio.File.new_for_path(path);
+ while (GLib.file_test(file.get_path(), GLib.FileTest.IS_SYMLINK)) {
+ let link_path = GLib.file_read_link(file.get_path());
+ // link_path may be relative, we need to resolve it from current dir
+ file = file.get_parent().resolve_relative_path(link_path);
}
// Get full path from GIO
- return Gio.File.new_for_path(path).get_parent().get_path();
+ return file.get_parent().get_path();
}
imports.searchPath.unshift(getCurrentFileDir());