Added DESC_INC and IMG_INC for the image of include/require in outline (maybe we...
[phpeclipse.git] / net.sourceforge.phpeclipse.launching / src / net / sourceforge / phpdt / internal / launching / PHPInterpreter.java
1 package net.sourceforge.phpdt.internal.launching;
2
3 import java.io.File;
4 import java.io.IOException;
5
6 import org.eclipse.core.internal.resources.OS;
7 import org.eclipse.core.runtime.IPath;
8
9 public class PHPInterpreter {
10         //public final String endOfOptionsDelimeter = " -- ";
11
12         protected IPath installLocation;
13         protected String name;
14
15         public PHPInterpreter(String aName, IPath validInstallLocation) {
16                 name = aName;
17                 installLocation = validInstallLocation;
18         }
19
20         public IPath getInstallLocation() {
21                 return installLocation;
22         }
23
24         public void setInstallLocation(IPath validInstallLocation) {
25                 installLocation = validInstallLocation;
26         }
27         
28         public String getName() {
29                 return name;
30         }
31         
32         public void setName(String newName) {
33                 name = newName;
34         }
35         
36         public String getCommand() {
37                 String directory = installLocation.toOSString() + File.separator;
38                 if (new File(directory + "php.exe").isFile())
39                         return directory + "php.exe";
40
41                 if (new File(directory, "php").isFile())
42                         return directory + "php";
43                         
44                 return null;
45         }
46         
47         public Process exec(String arguments, File workingDirectory) throws IOException {
48                 return Runtime.getRuntime().exec(this.getCommand() + " " +  arguments, null, workingDirectory);
49         }
50         
51         public boolean equals(Object other) {
52                 if (other instanceof PHPInterpreter) {
53                         PHPInterpreter otherInterpreter = (PHPInterpreter) other;
54                         if (name.equals(otherInterpreter.getName()))
55                                 return installLocation.equals(otherInterpreter.getInstallLocation());
56                 }
57                 
58                 return false;
59         }
60 }