[freenet-cvs] r15734 - trunk/freenet/src/freenet/pluginmanager

bombe at freenetproject.org bombe at freenetproject.org
Sat Nov 10 02:34:10 UTC 2007


Author: bombe
Date: 2007-11-10 02:34:10 +0000 (Sat, 10 Nov 2007)
New Revision: 15734

Modified:
   trunk/freenet/src/freenet/pluginmanager/PluginManager.java
Log:
accept local filenames for plugin url

Modified: trunk/freenet/src/freenet/pluginmanager/PluginManager.java
===================================================================
--- trunk/freenet/src/freenet/pluginmanager/PluginManager.java	2007-11-10 02:17:49 UTC (rev 15733)
+++ trunk/freenet/src/freenet/pluginmanager/PluginManager.java	2007-11-10 02:34:10 UTC (rev 15734)
@@ -399,11 +399,21 @@
 	 *             If anything goes wrong.
 	 */
 	private FredPlugin loadPlugin(String name, boolean refresh) throws PluginNotFoundException {
-		/* check if name contains a URL. */
 		URL pluginUrl = null;
-		try {
-			pluginUrl = new URL(name);
-		} catch (MalformedURLException mue1) {
+		/* check if name is a local file. */
+		File pluginFile = new File(name);
+		if (pluginFile.exists() && pluginFile.isFile()) {
+			try {
+				pluginUrl = pluginFile.toURI().toURL();
+			} catch (MalformedURLException e) {
+				throw new PluginNotFoundException("can not convert local path");
+			}
+		} else {
+			/* check if name contains a URL. */
+			try {
+				pluginUrl = new URL(name);
+			} catch (MalformedURLException mue1) {
+			}
 		}
 		if (pluginUrl == null) {
 			try {
@@ -424,7 +434,7 @@
 		/* get plugin filename. */
 		String completeFilename = pluginUrl.getPath();
 		String filename = completeFilename.substring(completeFilename.lastIndexOf('/') + 1);
-		File pluginFile = new File(pluginDirectory, filename);
+		pluginFile = new File(pluginDirectory, filename);
 
 		/* check if file needs to be downloaded. */
 		if (logMINOR) {




More information about the cvs mailing list