public File[] listFiles(File file) { //TODO: till API review if (executionEnvironment.isLocal()) { return file.listFiles(); } else { final ExitStatus res = ProcessUtils.execute(executionEnvironment, "ls", "-A1"); //NOI18N if (res.isOK()) { String files = res.output; if (files != null) { BufferedReader bufferedReader = new BufferedReader(new StringReader(files)); String line; ArrayList<File> lines = new ArrayList<File>(); try { while ((line = bufferedReader.readLine()) != null) { lines.add(new File(line)); } bufferedReader.close(); } catch (IOException ex) { //hardly can happen during reading string Exceptions.printStackTrace(ex); return null; } return lines.toArray(new File[lines.size()]); } } } return null; }
if (uname_exe.exists()) { ProcessUtils.ExitStatus exitStatus = ProcessUtils.execute(ExecutionEnvironmentFactory.getLocal(), uname_exe.getPath(), "-m"); // NOI18N if (exitStatus.isOK()) { cygwinBitness = exitStatus.getOutputString().trim();
if (uname_exe.exists()) { ProcessUtils.ExitStatus exitStatus = ProcessUtils.execute(ExecutionEnvironmentFactory.getLocal(), uname_exe.getPath(), "-m"); // NOI18N if (exitStatus.isOK()) { cygwinBitness = exitStatus.output.trim();
if (testUtility != null) { //otherwise will try to run/debug ExitStatus res = ProcessUtils.execute(execEnv, testUtility, "-x", executable, "-a", "-f", executable); // NOI18N ok = res.isOK();
logger.log(Level.INFO, execute.output); if (!execute.isOK()) {
private static String preprocessValueField(String value, MakeConfiguration conf) { value = value.trim(); if (value.startsWith("`") && value.endsWith("`")) { //NOI18N final String command = value.substring(1, value.length() - 1); final String[] execAndArgs = command.split(" "); //NOI18N final String exec = execAndArgs[0]; final String[] args = Arrays.copyOfRange(execAndArgs, 1, execAndArgs.length); final NativeProcessBuilder builder = NativeProcessBuilder.newProcessBuilder( conf.getFileSystemHost()).setExecutable(exec).setArguments(args); final ProcessUtils.ExitStatus status = ProcessUtils.execute(builder); if (status.isOK()) { value = status.output; } else { LOG.info(status.error); } } else { String out = value; do { value = out; out = conf.expandMacros(value); } while (!out.equals(value)); value = CndPathUtilities.expandAllMacroses(out, "${PROJECT_DIR}", conf.getProfile().getBaseDir()); //NOI18N } return value; }
private void getCompilerOutput(String arguments, List<String> options, List<String> undefinedAlternatives, boolean isGcc) { String compilerPath = getPath(); if (compilerPath == null || compilerPath.length() == 0) { return; } ExecutionEnvironment execEnv = getExecutionEnvironment(); if (execEnv.isLocal() && Utilities.isWindows()) { compilerPath = LinkSupport.resolveWindowsLink(compilerPath); } try { if (!HostInfoUtils.fileExists(execEnv, compilerPath)) { compilerPath = getDefaultPath(); if (!HostInfoUtils.fileExists(execEnv, compilerPath)) { return; } } } catch (Throwable ex) { return; } List<String> argsList = new ArrayList<String>(); argsList.addAll(Arrays.asList(arguments.trim().split(" +"))); // NOI18N ProcessUtils.ExitStatus execute = ProcessUtils.execute(execEnv, compilerPath, argsList.toArray(new String[argsList.size()])); if (execute.isOK()) { discoverFlags(execute.output, options, undefinedAlternatives, isGcc); } }
@Override public String call() throws Exception { String tmpDir; try { tmpDir = HostInfoUtils.getHostInfo(execEnv).getTempDir(); } catch (Exception iOException) { tmpDir = "/tmp"; // NOI18N } String name = tmpDir + '/' + FILENAME_PREFIX + "$$" + FILENAME_EXTENSION; // NOI18N ExitStatus status = ProcessUtils.execute(execEnv, "sh", "-c", "mkfifo " + name + ";echo " + name); //NOI18N if (status.isOK()) { return status.output; } return null; } });
public boolean fileCanRead(File file) { //TODO: till API review if (executionEnvironment.isLocal()) { return file.canRead(); } else { return ProcessUtils.execute(executionEnvironment, "test", "-r" ,"\"" + file.getPath() + "\"").isOK(); //NOI18N } }
public boolean fileIsFile(File file) { //TODO: till API review if (executionEnvironment.isLocal()) { return file.isFile(); } else { return ProcessUtils.execute(executionEnvironment, "test", "-f", "\"" + file.getPath() + "\"").isOK(); //NOI18N } }
public boolean fileIsDirectory(File file) { //TODO: till API review if (executionEnvironment.isLocal()) { return file.isDirectory(); } else { return ProcessUtils.execute(executionEnvironment, "test", "-d", "\"" + file.getPath() + "\"").isOK(); //NOI18N } }