2017-04-05 29 views
1

我有这个插件,安装时会在某个临时位置提取一些可执行文件并使用它们。这里是我的代码:Eclipse在某些未知位置提取可执行文件

public class StartCheck implements IStartup { 

private BufferedReader buf=null; 
public static String pathBandwidth; 
public static String pathDeviceQuery; 
public static String pathKernelLaunchOverhead; 
public static String memoryLatency; 

public void earlyStartup() { 
    // This method checks for presence of nvcc when Eclipse starts-up. 
    String command="nvcc --version"; 
    Runtime run = Runtime.getRuntime(); 
    Process pr; 

    try { 
     pr = run.exec(command); 
     pr.waitFor(); 
     buf = new BufferedReader(new InputStreamReader(pr.getInputStream())); 
     //print-out the nvcc version 
     System.out.println(buf.readLine()); 
     Preparation.return_val=true; 

     //extract the executables 
     Bundle bundle = Platform.getBundle("PTXAnalysis"); 
     URL url_bandwidth = FileLocator.find(bundle, new Path("/Executables/bandWidth.out"), null); 
     URL url_deviceQuery = FileLocator.find(bundle, new Path("/Executables/deviceQuery.out"), null); 
     URL url_kernelLaunchOverhead = FileLocator.find(bundle, new Path("/Executables/empty"), null); 
     URL url_memoryLatency = FileLocator.find(bundle, new Path("/Executables/memLatency.out"), null); 
     try { 
      url_bandwidth = FileLocator.toFileURL(url_bandwidth); 
      url_deviceQuery = FileLocator.toFileURL(url_deviceQuery); 
      url_kernelLaunchOverhead = FileLocator.toFileURL(url_kernelLaunchOverhead); 
      url_memoryLatency = FileLocator.toFileURL(url_memoryLatency);    
     } catch (IOException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 
     pathBandwidth=url_bandwidth.toString(); 
     pathDeviceQuery=url_deviceQuery.toString(); 
     pathKernelLaunchOverhead=url_kernelLaunchOverhead.toString(); 
     memoryLatency=url_memoryLatency.toString();   
    }catch (IOException e) { 
     //disable all commands since no further task can be done, prompt user to install nvcc. 
     System.out.println("nvcc was not found on this computer. You won't be able to use the energy estimation plug-in"); 
     EnergyEstimator.return_val=false; 
     Preparation.return_val=false; 

     } catch (InterruptedException e) { 
     e.printStackTrace(); 
     } 


    } 

} 

当我安装插件,它给了我这个位置(许多之一),其中可执行已提取:

/home/limafoxtrottango/.eclipse/org.eclipse.platform_4.4.1_2069420271_linux_gtx_x86_64/configuration/org.eclipse.osgi/460/0/.cp/Executables/bandWidth.out 

现在,问题:我找不到任何这样的目录。我知道这是一个临时目录,但即使Eclipse正在运行,它也不会显示。我正在使用这些路径之一来使用ProcessBuilder运行可执行文件。这里是代码:

public static void runExecutable(){ 
    initializeArray(); 
    path_result="/home/"+System.getProperty("user.name")+"/kernelLaunchOverhead.txt"; 
    String path_executable=StartCheck.pathKernelLaunchOverhead.substring(path_result.indexOf('/'),path_result.lastIndexOf('/')+1); //path to the directory in which the executable is extracted 
    try { 
     fw = new FileWriter(path_result); 
     for(int i=0;i<arr.length;i++){ 

      ProcessBuilder builder=new ProcessBuilder("./empty",Integer.toString(arr[i])); 
      builder.directory(new File(path_executable)); 
      int av=0; 
      float sum=0; 

       while(av<10){ 
        Process pr=builder.start(); 
        stdin = pr.getInputStream(); 
        isr = new InputStreamReader(stdin); 
        br = new BufferedReader(isr); 
        sum=sum+Float.parseFloat(line=br.readLine()); 
        av++; 
       } 
       fw.write(arr[i]+" "+Float.toString(sum/10)); 
       fw.write("\n"); 
      } 
     fw.close(); 

     } catch (IOException e1) { 
     // TODO Auto-generated catch block 
     e1.printStackTrace(); 
    } 
    FillArrays(path_result); 
    BestLineFit(); 
    saveModel("/home/"+System.getProperty("user.name")+"/KernelLaunchOverheadModel.txt"); 
} 

在调用这个函数时,没有任何反应。它甚至不会抛出任何例外的FileNotFound。通常,它应该在目录中找到可执行文件并运行它。但是在安装插件后,没有任何反应。

要重新迭代,类StartCheck已成功向我显示可执行文件已被提取的路径。但是这些路径并不存在于我的系统中的任何地方。

回答

0

.开头的目录(例如您显示的路径中的.eclipse)隐藏在Linux和macOS系统上。

你可以从命令行看到它们使用ls -a

+0

该死的。按下ctrl + H键入文件。在这上面浪费了将近一个小时。 –