1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 20:22:26 +01:00

Somewhat more resilient File.expandPath and File#init. Fixes Pentadactyl on wine.

This commit is contained in:
Kris Maglione
2010-09-21 09:02:55 -04:00
parent 46673bfc76
commit 21a510588c
2 changed files with 19 additions and 12 deletions

View File

@@ -912,9 +912,9 @@ const Commands = Module("commands", {
} }
// dynamically get completions as specified with the command's completer function // dynamically get completions as specified with the command's completer function
context.highlight();
let command = cmd && commands.get(cmd); let command = cmd && commands.get(cmd);
if (!command) { if (!command) {
context.highlight();
context.highlight(0, cmd && cmd.length, "SPELLCHECK"); context.highlight(0, cmd && cmd.length, "SPELLCHECK");
return; return;
} }

View File

@@ -264,11 +264,12 @@ const Storage = Module("Storage", {
}, { }, {
}, { }, {
init: function (dactyl, modules) { init: function (dactyl, modules) {
let infoPath = services.create("file"); let infoPath = File(modules.IO.runtimePath.replace(/,.*/, ""));
infoPath.initWithPath(File.expandPath(modules.IO.runtimePath.replace(/,.*/, ""))); if (infoPath) {
infoPath.append("info"); infoPath.append("info");
infoPath.append(dactyl.profileName); infoPath.append(dactyl.profileName);
storage.infoPath = infoPath; storage.infoPath = infoPath;
}
} }
}); });
@@ -289,12 +290,18 @@ const File = Class("File", {
else if (/file:\/\//.test(path)) else if (/file:\/\//.test(path))
file = services.create("file:").getFileFromURLSpec(path); file = services.create("file:").getFileFromURLSpec(path);
else { else {
let expandedPath = File.expandPath(path); try {
let expandedPath = File.expandPath(path);
if (!File.isAbsolutePath(expandedPath) && checkPWD) if (!File.isAbsolutePath(expandedPath) && checkPWD)
file = File.joinPaths(checkPWD, expandedPath); file = File.joinPaths(checkPWD, expandedPath);
else else
file.initWithPath(expandedPath); file.initWithPath(expandedPath);
}
catch (e) {
dump("dactyl: " + e + "\n" + String.replace(e.stack, /^/gm, "dactyl: ") + "\n");
return null;
}
} }
let self = XPCSafeJSObjectWrapper(file); let self = XPCSafeJSObjectWrapper(file);
self.__proto__ = File.prototype; self.__proto__ = File.prototype;
@@ -510,7 +517,7 @@ const File = Class("File", {
let home = services.get("environment").get("HOME"); let home = services.get("environment").get("HOME");
// Windows has its own idiosyncratic $HOME variables. // Windows has its own idiosyncratic $HOME variables.
if (!home && win32) if (win32 && (!home || !File(home) || !File(home).exists()))
home = services.get("environment").get("USERPROFILE") || home = services.get("environment").get("USERPROFILE") ||
services.get("environment").get("HOMEDRIVE") + services.get("environment").get("HOMEPATH"); services.get("environment").get("HOMEDRIVE") + services.get("environment").get("HOMEPATH");