X-Git-Url: http://secure.phpeclipse.com

diff --git a/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPRuntime.java b/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPRuntime.java
index 03447e1..0b392a6 100644
--- a/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPRuntime.java
+++ b/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPRuntime.java
@@ -16,8 +16,8 @@ import java.util.Iterator;
 import java.util.List;
 
 import javax.xml.parsers.SAXParserFactory;
+
 import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.InputSource;
@@ -27,7 +27,7 @@ import org.xml.sax.XMLReader;
 
 public class PHPRuntime {
 	protected static PHPRuntime runtime;
-	
+
 	protected List installedInterpreters;
 	protected PHPInterpreter selectedInterpreter;
 	protected PHPRuntime() {
@@ -40,7 +40,7 @@ public class PHPRuntime {
 		}
 		return runtime;
 	}
-	
+
 	public PHPInterpreter getSelectedInterpreter() {
 		if (selectedInterpreter == null) {
 			loadRuntimeConfiguration();
@@ -48,14 +48,14 @@ public class PHPRuntime {
 		return selectedInterpreter;
 	}
 
-	public PHPInterpreter getInterpreter(String name) {
+	public PHPInterpreter getInterpreter(String installLocation) {
 		Iterator interpreters = getInstalledInterpreters().iterator();
 		while(interpreters.hasNext()) {
 			PHPInterpreter each = (PHPInterpreter) interpreters.next();
-			if (each.getName().equals(name))
+			if (each.getInstallLocation().toString().equals(installLocation))
 				return each;
 		}
-		
+
 		return getSelectedInterpreter();
 	}
 
@@ -77,7 +77,7 @@ public class PHPRuntime {
 			loadRuntimeConfiguration();
 		return installedInterpreters;
 	}
-	
+
 	public void setInstalledInterpreters(List newInstalledInterpreters) {
 		installedInterpreters = newInstalledInterpreters;
 		if (installedInterpreters.size() > 0)
@@ -85,7 +85,7 @@ public class PHPRuntime {
 		else
 			setSelectedInterpreter(null);
 	}
-	
+
 	protected void saveRuntimeConfiguration() {
 		writeXML(getRuntimeConfigurationWriter());
 	}
@@ -98,40 +98,43 @@ public class PHPRuntime {
 
 		return null;
 	}
-	
+
 	protected void loadRuntimeConfiguration() {
 		installedInterpreters = new ArrayList();
 		try {
-			XMLReader reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
-			reader.setContentHandler(getRuntimeConfigurationContentHandler());
-			reader.parse(new InputSource(getRuntimeConfigurationReader()));
+			File file = getRuntimeConfigurationFile();
+			if (file.exists()) {
+		  	    XMLReader reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
+			    reader.setContentHandler(getRuntimeConfigurationContentHandler());
+			    reader.parse(new InputSource(getRuntimeConfigurationReader(file)));
+			}
 		} catch(Exception e) {
-			PHPLaunchingPlugin.getDefault().log(e);
+			PHPLaunchingPlugin.log(e);
 		}
 	}
 
-	protected Reader getRuntimeConfigurationReader() {
+	protected Reader getRuntimeConfigurationReader(File file) {
 		try {
-			return new FileReader(getRuntimeConfigurationFile());
+			return new FileReader(file);
 		} catch(FileNotFoundException e) {}
 		return new StringReader("");
 	}
-	
+
 	protected void writeXML(Writer writer) {
 		try {
 			writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?><runtimeconfig>");
 			Iterator interpretersIterator = installedInterpreters.iterator();
 			while (interpretersIterator.hasNext()) {
 				writer.write("<interpreter name=\"");
-				
+
 				PHPInterpreter entry = (PHPInterpreter) interpretersIterator.next();
-				writer.write(entry.getName());
+//				writer.write(entry.getName());
 				writer.write("\" path=\"");
 				writer.write(entry.getInstallLocation().toString());
 				writer.write("\"");
 				if (entry.equals(selectedInterpreter))
 					writer.write(" selected=\"true\"");
-					
+
 				writer.write("/>");
 			}
 			writer.write("</runtimeconfig>");
@@ -150,9 +153,14 @@ public class PHPRuntime {
 			public void endPrefixMapping(String prefix) throws SAXException {}
 			public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
 				if ("interpreter".equals(qName)) {
-					String interpreterName = atts.getValue("name");
-					IPath installLocation = new Path(atts.getValue("path"));
-					PHPInterpreter interpreter = new PHPInterpreter(interpreterName, installLocation);
+ 					String interpreterName = atts.getValue("name");
+ 					java.io.File installLocation;
+ 					if (interpreterName!=null) {
+ 				 	  installLocation = new File(atts.getValue("path")+File.separatorChar+interpreterName);
+ 					} else {
+					  installLocation = new File(atts.getValue("path"));
+ 					}
+					PHPInterpreter interpreter = new PHPInterpreter(installLocation);
 					installedInterpreters.add(interpreter);
 					if (atts.getValue("selected") != null)
 						selectedInterpreter = interpreter;
@@ -165,7 +173,7 @@ public class PHPRuntime {
 			public void skippedEntity(String name) throws SAXException {}
 		};
 	}
-	
+
 	protected File getRuntimeConfigurationFile() {
 		IPath stateLocation = PHPLaunchingPlugin.getDefault().getStateLocation();
 		IPath fileLocation = stateLocation.append("runtimeConfiguration.xml");