X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPInterpreter.java b/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPInterpreter.java new file mode 100644 index 0000000..2e342b9 --- /dev/null +++ b/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPInterpreter.java @@ -0,0 +1,60 @@ +package net.sourceforge.phpdt.internal.launching; + +import java.io.File; +import java.io.IOException; + +import org.eclipse.core.internal.resources.OS; +import org.eclipse.core.runtime.IPath; + +public class PHPInterpreter { + //public final String endOfOptionsDelimeter = " -- "; + + protected IPath installLocation; + protected String name; + + public PHPInterpreter(String aName, IPath validInstallLocation) { + name = aName; + installLocation = validInstallLocation; + } + + public IPath getInstallLocation() { + return installLocation; + } + + public void setInstallLocation(IPath validInstallLocation) { + installLocation = validInstallLocation; + } + + public String getName() { + return name; + } + + public void setName(String newName) { + name = newName; + } + + public String getCommand() { + String directory = installLocation.toOSString() + File.separator; + if (new File(directory + "php.exe").isFile()) + return directory + "php.exe"; + + if (new File(directory, "php").isFile()) + return directory + "php"; + + return null; + } + + public Process exec(String arguments, File workingDirectory) throws IOException { + return Runtime.getRuntime().exec(this.getCommand() + " " + arguments, null, workingDirectory); + } + + public boolean equals(Object other) { + if (other instanceof PHPInterpreter) { + PHPInterpreter otherInterpreter = (PHPInterpreter) other; + if (name.equals(otherInterpreter.getName())) + return installLocation.equals(otherInterpreter.getInstallLocation()); + } + + return false; + } +}