1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 04:07:58 +01:00

fixed getCurrentDirectory() to not call an infinite loop, makes :cd etc. work on windows hopefully

This commit is contained in:
Martin Stubenschrott
2007-12-12 17:58:52 +00:00
parent c86e4297f5
commit 24adb1bb92

View File

@@ -95,14 +95,27 @@ vimperator.IO = function () //{{{
getCurrentDirectory: function () getCurrentDirectory: function ()
{ {
var file = Components.classes["@mozilla.org/file/local;1"].
createInstance(Components.interfaces.nsILocalFile);
var dirs = [cwd, "$PWD", "~"]; var dirs = [cwd, "$PWD", "~"];
for (var i = 0; i < dirs.length; i++) for (var i = 0; i < dirs.length; i++)
{ {
if (!dirs[i]) if (!dirs[i])
continue; continue;
if (this.getFile(dirs[i]).exists()) var fullname = this.expandPath(dirs[i]);
return this.expandPath(dirs[i]); try
{
file.initWithPath(fullname);
}
catch (e)
{
continue;
}
if (file.exists() && file.isDirectory())
return fullname;
} }
}, },