Committing changes needed for the 1.2.0 release build. Removed addition of compat...
[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 public class PHPInterpreter {
7
8         protected File installLocation;
9
10         public PHPInterpreter(File interpreter) {
11                 installLocation = interpreter;
12         }
13
14         public File getInstallLocation() {
15                 return installLocation;
16         }
17
18         public void setInstallLocation(File interpreter) {
19                 installLocation = interpreter;
20         }
21
22         public String getCommand() {
23                 return installLocation.toString();
24         }
25
26         // private boolean executePHPProcess(String arguments, File
27         // workingDirectory, String[] env) {
28         // Process process = null;
29         // try {
30         // StringBuffer buf = new StringBuffer();
31         // buf.append(getCommand() + " " + arguments);
32         // process = Runtime.getRuntime().exec(buf.toString(), env,
33         // workingDirectory);
34         // if (process != null) {
35         // // construct a formatted command line for the process properties
36         //
37         // // for (int i= 0; i < args.length; i++) {
38         // // buf.append(args[i]);
39         // // buf.append(' ');
40         // // }
41         //
42         // ILaunchConfigurationWorkingCopy wc = null;
43         // try {
44         // ILaunchConfigurationType lcType =
45         // DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(
46         // PHPLaunchConfigurationAttribute.PHP_LAUNCH_CONFIGURATION_TYPE);
47         // String name = "PHP Launcher"; //$NON-NLS-1$
48         // wc = lcType.newInstance(null, name);
49         // wc.setAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, true);
50         //
51         // ILaunch newLaunch = new Launch(wc, ILaunchManager.RUN_MODE, null);
52         // IProcess iprocess = DebugPlugin.newProcess(newLaunch, process, "PHP
53         // Process"); //$NON-NLS-1$
54         // iprocess.setAttribute(IProcess.ATTR_CMDLINE, buf.toString());
55         // iprocess.setAttribute(IProcess.ATTR_PROCESS_TYPE,
56         // PHPLaunchConfigurationAttribute.PHP_LAUNCH_PROCESS_TYPE);
57         //
58         // DebugPlugin.getDefault().getLaunchManager().addLaunch(newLaunch);
59         //
60         // } catch (CoreException e) {
61         // }
62         //
63         // return true;
64         //
65         // }
66         // } catch (IOException e) {
67         // return false;
68         // }
69         // return false;
70         //
71         // }
72
73         public Process exec(String arguments, File workingDirectory, String[] env)
74                         throws IOException {
75                 return Runtime.getRuntime().exec(getCommand() + " " + arguments, env,
76                                 workingDirectory);
77                 // executePHPProcess(arguments, workingDirectory, env);
78         }
79
80         public boolean equals(Object other) {
81                 if (other instanceof PHPInterpreter) {
82                         PHPInterpreter otherInterpreter = (PHPInterpreter) other;
83                         return installLocation
84                                         .equals(otherInterpreter.getInstallLocation());
85                 }
86                 return false;
87         }
88 }