diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/CygPath.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/CygPath.java new file mode 100644 index 00000000000..188e9df76e9 --- /dev/null +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/CygPath.java @@ -0,0 +1,53 @@ +package org.eclipse.cdt.utils; + +/* + * (c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + */ + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; + +import org.eclipse.cdt.utils.spawner.ProcessFactory; + +public class CygPath { + private Process cygpath; + private BufferedReader stdout; + private BufferedWriter stdin; + + public CygPath(String command) throws IOException { + String[] args = {command, "--windows", "--file", "-"}; + cygpath = ProcessFactory.getFactory().exec(args); + //cppfilt = new Spawner(args); + stdin = new BufferedWriter(new OutputStreamWriter(cygpath.getOutputStream())); + stdout = new BufferedReader(new InputStreamReader(cygpath.getInputStream())); + } + + public CygPath() throws IOException { + this("cygpath"); + } + + public String getFileName(String name) throws IOException { + stdin.write(name + "\n"); + stdin.flush(); + String str = stdout.readLine(); + if ( str != null ) { + return str.trim(); + } + throw new IOException(); + } + + public void dispose() { + try { + stdout.close(); + stdin.close(); + cygpath.getErrorStream().close(); + } + catch (IOException e) { + } + cygpath.destroy(); + } +} diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/ICygwinToolsProvider.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/ICygwinToolsProvider.java new file mode 100644 index 00000000000..fcec917bca8 --- /dev/null +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/ICygwinToolsProvider.java @@ -0,0 +1,19 @@ +/********************************************************************** + * Copyright (c) 2002,2003 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation +***********************************************************************/ +package org.eclipse.cdt.utils; + +/** + */ +public interface ICygwinToolsProvider extends IToolsProvider { + + CygPath getCygPath(); + +} diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/IToolsProvider.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/IToolsProvider.java new file mode 100644 index 00000000000..274699c2465 --- /dev/null +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/IToolsProvider.java @@ -0,0 +1,23 @@ +/********************************************************************** + * Copyright (c) 2002,2003 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation +***********************************************************************/ +package org.eclipse.cdt.utils; + +import org.eclipse.core.runtime.IPath; + +/** + */ +public interface IToolsProvider { + + Addr2line getAddr2Line(IPath path); + + CPPFilt getCPPFilt(); + +}