Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Inglis2003-04-30 18:18:43 +0000
committerDavid Inglis2003-04-30 18:18:43 +0000
commit040970ff1134043da082f31bff55e3508a32b3bd (patch)
tree3d03beda8d6a7da87ff560339b2316ca6076cd23 /core/org.eclipse.cdt.core.win32/src
parentb9a6688e4aba87beeaff19ff7a1a056450f0e216 (diff)
downloadorg.eclipse.cdt-040970ff1134043da082f31bff55e3508a32b3bd.tar.gz
org.eclipse.cdt-040970ff1134043da082f31bff55e3508a32b3bd.tar.xz
org.eclipse.cdt-040970ff1134043da082f31bff55e3508a32b3bd.zip
task list fix
Diffstat (limited to 'core/org.eclipse.cdt.core.win32/src')
-rw-r--r--core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/ProcessList.java69
1 files changed, 4 insertions, 65 deletions
diff --git a/core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/ProcessList.java b/core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/ProcessList.java
index 4dff5ec3c9e..6ffe99c723e 100644
--- a/core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/ProcessList.java
+++ b/core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/ProcessList.java
@@ -5,7 +5,6 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.io.StreamTokenizer;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
@@ -14,6 +13,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IProcessInfo;
import org.eclipse.cdt.core.IProcessList;
import org.eclipse.cdt.utils.spawner.ProcessFactory;
+import org.eclipse.core.boot.BootLoader;
import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.model.PluginDescriptorModel;
import org.eclipse.core.runtime.model.PluginFragmentModel;
@@ -28,25 +28,11 @@ import org.eclipse.core.runtime.model.PluginFragmentModel;
public class ProcessList implements IProcessList {
private IProcessInfo[] NOPROCESS = new IProcessInfo[0];
- private final int NAME = 1;
- private final int PID = 2;
- private final int OTHER = 3;
public IProcessInfo[] getProcessList() {
- String OS = System.getProperty("os.name").toLowerCase();
Process p = null;
String command = null;
InputStream in = null;
- if ((OS.indexOf("windows xp") > -1)) {
- command = "tasklist /fo csv /nh /svc";
- try {
- p = ProcessFactory.getFactory().exec(command);
- in = p.getInputStream();
- InputStreamReader reader = new InputStreamReader(in);
- return parseTaskList(reader);
- } catch (IOException e) {
- }
- } else {
IPluginDescriptor desc = CCorePlugin.getDefault().getDescriptor();
if (desc instanceof PluginDescriptorModel) {
PluginDescriptorModel model = (PluginDescriptorModel) desc;
@@ -54,8 +40,8 @@ public class ProcessList implements IProcessList {
for (int i = 0; i < fragments.length; i++) {
String location = fragments[i].getLocation();
try {
- URL url = new URL(location);
- File path = new File(url.getFile(), "listtasks");
+ URL url = new URL(location + "/os/" + BootLoader.getOS() + "/" + BootLoader.getOSArch());
+ File path = new File(url.getFile(), "listtasks.exe");
if (path.exists()) {
command = path.getCanonicalPath();
break;
@@ -74,56 +60,9 @@ public class ProcessList implements IProcessList {
} catch (IOException e) {
}
}
- }
return NOPROCESS;
}
-
- public IProcessInfo[] parseTaskList(InputStreamReader reader) {
- StreamTokenizer tokenizer = new StreamTokenizer(reader);
- tokenizer.eolIsSignificant(true);
- tokenizer.parseNumbers();
- boolean done = false;
- ArrayList processList = new ArrayList();
- String name = null;
- int pid = 0, token_state = NAME;
- while (!done) {
- try {
- switch (tokenizer.nextToken()) {
- case StreamTokenizer.TT_EOL :
- if (name != null) {
- processList.add(new ProcessInfo(pid, name));
- name = null;
- }
- break;
- case StreamTokenizer.TT_EOF :
- done = true;
- break;
- case '"' :
- switch (token_state) {
- case NAME :
- name = tokenizer.sval;
- token_state = PID;
- break;
- case PID :
- try {
- pid = Integer.parseInt(tokenizer.sval);
- } catch (NumberFormatException e) {
- name = null;
- }
- token_state = OTHER;
- break;
- case OTHER :
- token_state = NAME;
- break;
- }
- break;
- }
- } catch (IOException e) {
- }
- }
- return (IProcessInfo[]) processList.toArray(new IProcessInfo[processList.size()]);
- }
-
+
public IProcessInfo[] parseListTasks(InputStreamReader reader) {
BufferedReader br = new BufferedReader(reader);
ArrayList processList = new ArrayList();

Back to the top