From 556bdbf05dcdef3928a906d552a9ce767fdd5d2c Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Wed, 8 Aug 2007 10:19:41 +0000 Subject: [PATCH] move global isDirectory() to Commands() --- chrome/content/vimperator/commands.js | 24 ------------------------ chrome/content/vimperator/mappings.js | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/chrome/content/vimperator/commands.js b/chrome/content/vimperator/commands.js index 674328c5..db25bd7d 100644 --- a/chrome/content/vimperator/commands.js +++ b/chrome/content/vimperator/commands.js @@ -1258,30 +1258,6 @@ String.prototype.toURLArray = function() return urls; } -/* returns true if the currently loaded URI is - * a directory or false if it is a file - */ -function isDirectory(url) -{ - if (url.match(/^file:\/\//) || url.match(/^\//)) - { - var stripedFilename = url.replace(/^(file:\/\/)?(.*)/, "$2"); - var file = vimperator.fopen(stripedFilename, '<'); - if (!file) - return false; - - if (file.localFile.isDirectory()) - return true; - else - return false; - } - // for all other locations just check if the URL ends with / - if (url.match(/\/$/)) - return true; - else - return false; -} - /////////////////////////////////////////////////////////////////////}}} // misc helper functions /////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////{{{ diff --git a/chrome/content/vimperator/mappings.js b/chrome/content/vimperator/mappings.js index 069cfdcd..fcf8d287 100644 --- a/chrome/content/vimperator/mappings.js +++ b/chrome/content/vimperator/mappings.js @@ -759,6 +759,26 @@ function Mappings() //{{{ flags: Mappings.flags.COUNT } )); + function isDirectory(url) + { + if (url.match(/^file:\/\//) || url.match(/^\//)) + { + var stripedFilename = url.replace(/^(file:\/\/)?(.*)/, "$2"); + var file = vimperator.fopen(stripedFilename, '<'); + if (!file) + return false; + + if (file.localFile.isDirectory()) + return true; + else + return false; + } + // for all other locations just check if the URL ends with / + if (url.match(/\/$/)) + return true; + else + return false; + } addDefaultMap(new Map(vimperator.modes.NORMAL, ["gu", ""], function(count) {