From 24adb1bb92ec830c51e8b2098be5cf92d3147aac Mon Sep 17 00:00:00 2001 From: Martin Stubenschrott Date: Wed, 12 Dec 2007 17:58:52 +0000 Subject: [PATCH] fixed getCurrentDirectory() to not call an infinite loop, makes :cd etc. work on windows hopefully --- content/io.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/content/io.js b/content/io.js index cefe5d08..3a79876c 100644 --- a/content/io.js +++ b/content/io.js @@ -95,14 +95,27 @@ vimperator.IO = function () //{{{ getCurrentDirectory: function () { + var file = Components.classes["@mozilla.org/file/local;1"]. + createInstance(Components.interfaces.nsILocalFile); + var dirs = [cwd, "$PWD", "~"]; for (var i = 0; i < dirs.length; i++) { if (!dirs[i]) continue; - if (this.getFile(dirs[i]).exists()) - return this.expandPath(dirs[i]); + var fullname = this.expandPath(dirs[i]); + try + { + file.initWithPath(fullname); + } + catch (e) + { + continue; + } + + if (file.exists() && file.isDirectory()) + return fullname; } },