1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-05 23:35:48 +02:00

Use Eclipse 3.o API to find the fragment location.

This commit is contained in:
Alain Magloire 2004-02-18 03:50:38 +00:00
parent 50f8f8a971
commit 7c2f688b9a
2 changed files with 26 additions and 30 deletions

View file

@ -1,3 +1,10 @@
2004-02-17 Alain Magloire
Remove old Eclipse2.0 interface and
use what 3.0 provides instead.
* src/org/eclipse/cdt/internal/core/win32/ProcessList.java
2004-02-12 Alex Chapiro 2004-02-12 Alex Chapiro
Update starter and spawner to use named pipes. Update starter and spawner to use named pipes.

View file

@ -5,7 +5,6 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
@ -13,10 +12,9 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IProcessInfo; import org.eclipse.cdt.core.IProcessInfo;
import org.eclipse.cdt.core.IProcessList; import org.eclipse.cdt.core.IProcessList;
import org.eclipse.cdt.utils.spawner.ProcessFactory; import org.eclipse.cdt.utils.spawner.ProcessFactory;
import org.eclipse.core.boot.BootLoader;
import org.eclipse.core.runtime.IPluginDescriptor; import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.model.PluginDescriptorModel; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.model.PluginFragmentModel; import org.eclipse.core.runtime.Platform;
/* /*
* Currently this will only work for Windows XP since tasklist * Currently this will only work for Windows XP since tasklist
@ -33,33 +31,23 @@ public class ProcessList implements IProcessList {
Process p = null; Process p = null;
String command = null; String command = null;
InputStream in = null; InputStream in = null;
IPluginDescriptor desc = CCorePlugin.getDefault().getDescriptor(); IPluginDescriptor desc = CCorePlugin.getDefault().getDescriptor();
if (desc instanceof PluginDescriptorModel) { try {
PluginDescriptorModel model = (PluginDescriptorModel) desc; URL url = desc.find(new Path("$os$/listtasks.exe"));
PluginFragmentModel[] fragments = model.getFragments(); url = Platform.resolve(url);
for (int i = 0; i < fragments.length; i++) { String path = url.getFile();
String location = fragments[i].getLocation(); File file = new File(path);
try { if (file.exists()) {
URL url = new URL(location + "/os/" + BootLoader.getOS() + "/" + BootLoader.getOSArch()); command = file.getCanonicalPath();
File path = new File(url.getFile(), "listtasks.exe"); if (command != null) {
if (path.exists()) {
command = path.getCanonicalPath();
break;
}
} catch (MalformedURLException e1) {
} catch (IOException e) {
}
}
}
if (command != null) {
try {
p = ProcessFactory.getFactory().exec(command); p = ProcessFactory.getFactory().exec(command);
in = p.getInputStream(); in = p.getInputStream();
InputStreamReader reader = new InputStreamReader(in); InputStreamReader reader = new InputStreamReader(in);
return parseListTasks(reader); return parseListTasks(reader);
} catch (IOException e) {
} }
} }
} catch (IOException e) {
}
return NOPROCESS; return NOPROCESS;
} }
@ -73,11 +61,12 @@ public class ProcessList implements IProcessList {
if (tab != -1) { if (tab != -1) {
String proc = line.substring(0, tab).trim(); String proc = line.substring(0, tab).trim();
String name = line.substring(tab).trim(); String name = line.substring(tab).trim();
try { if (proc.length() > 0 && name.length() > 0) {
int pid = Integer.parseInt(proc); try {
processList.add(new ProcessInfo(pid, name)); int pid = Integer.parseInt(proc);
} catch (NumberFormatException e) { processList.add(new ProcessInfo(pid, name));
name = null; } catch (NumberFormatException e) {
}
} }
} }
} }