Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorDavid Inglis2002-09-18 13:49:43 +0000
committerDavid Inglis2002-09-18 13:49:43 +0000
commitf45c2224185cc9cf83e8e2f47cb1607f98918fb4 (patch)
tree966bba485f9208a44c5cce6da1c1b58444337cb7 /core
parent4f7803089b34208738f6684deab3f2738a18b554 (diff)
downloadorg.eclipse.cdt-f45c2224185cc9cf83e8e2f47cb1607f98918fb4.tar.gz
org.eclipse.cdt-f45c2224185cc9cf83e8e2f47cb1607f98918fb4.tar.xz
org.eclipse.cdt-f45c2224185cc9cf83e8e2f47cb1607f98918fb4.zip
cleanup fragment supported IProcessList extension
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.win32/.classpath7
-rw-r--r--core/org.eclipse.cdt.core.win32/.cvsignore1
-rw-r--r--core/org.eclipse.cdt.core.win32/.project2
-rw-r--r--core/org.eclipse.cdt.core.win32/build.properties4
-rw-r--r--core/org.eclipse.cdt.core.win32/fragment.xml14
-rw-r--r--core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/ProcessInfo.java45
-rw-r--r--core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/ProcessList.java92
7 files changed, 152 insertions, 13 deletions
diff --git a/core/org.eclipse.cdt.core.win32/.classpath b/core/org.eclipse.cdt.core.win32/.classpath
index 782d615590a..d2b793e8a1f 100644
--- a/core/org.eclipse.cdt.core.win32/.classpath
+++ b/core/org.eclipse.cdt.core.win32/.classpath
@@ -1,15 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="/org.eclipse.core.resources"/>
- <classpathentry kind="src" path="/org.eclipse.ui"/>
<classpathentry kind="src" path="/org.eclipse.cdt.core"/>
+ <classpathentry kind="src" path="/org.eclipse.core.resources"/>
<classpathentry kind="src" path="/org.eclipse.core.runtime"/>
<classpathentry kind="src" path="/org.apache.xerces"/>
<classpathentry kind="src" path="/org.eclipse.search"/>
<classpathentry kind="src" path="/org.eclipse.compare"/>
- <classpathentry kind="src" path="/org.eclipse.debug.ui"/>
<classpathentry kind="src" path="/org.eclipse.debug.core"/>
<classpathentry kind="src" path="/org.eclipse.core.boot"/>
<classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
- <classpathentry kind="output" path=""/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/core/org.eclipse.cdt.core.win32/.cvsignore b/core/org.eclipse.cdt.core.win32/.cvsignore
new file mode 100644
index 00000000000..ba077a4031a
--- /dev/null
+++ b/core/org.eclipse.cdt.core.win32/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/core/org.eclipse.cdt.core.win32/.project b/core/org.eclipse.cdt.core.win32/.project
index 2b0ee24a60c..c0dc3c4eb89 100644
--- a/core/org.eclipse.cdt.core.win32/.project
+++ b/core/org.eclipse.cdt.core.win32/.project
@@ -10,9 +10,7 @@
<project>org.eclipse.core.resources</project>
<project>org.eclipse.core.runtime</project>
<project>org.eclipse.debug.core</project>
- <project>org.eclipse.debug.ui</project>
<project>org.eclipse.search</project>
- <project>org.eclipse.ui</project>
</projects>
<buildSpec>
<buildCommand>
diff --git a/core/org.eclipse.cdt.core.win32/build.properties b/core/org.eclipse.cdt.core.win32/build.properties
index 99f473dc81f..8292292ad0e 100644
--- a/core/org.eclipse.cdt.core.win32/build.properties
+++ b/core/org.eclipse.cdt.core.win32/build.properties
@@ -1,2 +1,4 @@
bin.includes = fragment.xml,\
- os/
+ os/,\
+ *.jar
+source.cdt_win32.jar = src/
diff --git a/core/org.eclipse.cdt.core.win32/fragment.xml b/core/org.eclipse.cdt.core.win32/fragment.xml
index 325be653302..b60650512eb 100644
--- a/core/org.eclipse.cdt.core.win32/fragment.xml
+++ b/core/org.eclipse.cdt.core.win32/fragment.xml
@@ -1,19 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<fragment
id="org.eclipse.cdt.core.win32"
- name="Win32 Fragment"
+ name="CDT Core Win32 Fragment"
version="1.0.0"
provider-name="Eclipse.org"
plugin-id="org.eclipse.cdt.core"
plugin-version="1.0.0">
<runtime>
+ <library name="cdt_win32.jar"/>
</runtime>
- <requires>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.ui"/>
- </requires>
-
+ <extension
+ point="org.eclipse.cdt.core.ProcessList">
+ <processList
+ class="org.eclipse.cdt.internal.core.win32.ProcessList">
+ </processList>
+ </extension>
</fragment>
diff --git a/core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/ProcessInfo.java b/core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/ProcessInfo.java
new file mode 100644
index 00000000000..13c88e07aaf
--- /dev/null
+++ b/core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/ProcessInfo.java
@@ -0,0 +1,45 @@
+package org.eclipse.cdt.internal.core.win32;
+
+import org.eclipse.cdt.core.IProcessInfo;
+
+/**
+ * @author alain
+ *
+ * To change this generated comment edit the template variable "typecomment":
+ * Window>Preferences>Java>Templates.
+ * To enable and disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
+ */
+public class ProcessInfo implements IProcessInfo {
+
+ int pid;
+ String name;
+
+ public ProcessInfo(String pidString, String name) {
+ try {
+ pid = Integer.parseInt(pidString);
+ } catch (NumberFormatException e) {
+ }
+ this.name = name;
+ }
+
+ public ProcessInfo(int pid, String name) {
+ this.pid = pid;
+ this.name = name;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.IProcessInfo#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.IProcessInfo#getPid()
+ */
+ public int getPid() {
+ return pid;
+ }
+
+}
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
new file mode 100644
index 00000000000..eadeddc03e4
--- /dev/null
+++ b/core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/ProcessList.java
@@ -0,0 +1,92 @@
+package org.eclipse.cdt.internal.core.win32;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StreamTokenizer;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
+import org.eclipse.cdt.core.IProcessInfo;
+import org.eclipse.cdt.core.IProcessList;
+import org.eclipse.cdt.utils.spawner.ProcessFactory;
+
+/*
+ * Currently this will only work for Windows XP since tasklist
+ * is only shipped on XP. This could change to some JNI
+ * call out to get the list since the source to 'tlist' is
+ * on the msdn web site but that can be done later.
+ */
+
+public class ProcessList implements IProcessList {
+
+ 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";
+ } else {
+ return new IProcessInfo[0];
+ }
+ try {
+ p = ProcessFactory.getFactory().exec(command);
+ }
+ catch (IOException e) {
+ return null;
+ }
+ in = p .getInputStream();
+ InputStreamReader reader = new InputStreamReader(in);
+ String line;
+ 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()]);
+ }
+}

Back to the top