/**
  * Iterates over the contents of the pluginJarFile to find the sauce-connect-3.0.jar file.
  *
  * @param jarFileEntry
  * @param updatedSauceConnectJarFile
  * @throws java.io.IOException
  */
 private void search(TFile jarFileEntry, TFile updatedSauceConnectJarFile) throws IOException {
   if (jarFileEntry.getName().endsWith("sauce-connect-3.0.jar")) {
     update(jarFileEntry, updatedSauceConnectJarFile);
   } else if (jarFileEntry.isDirectory()) {
     for (TFile member : jarFileEntry.listFiles()) search(member, updatedSauceConnectJarFile);
   }
 }
  /**
   * Adds the updatedSauceConnectJarFile to the pluginJarFile.
   *
   * @param pluginJarFile
   * @param updatedSauceConnectJarFile
   * @throws java.io.IOException
   */
  public void addFileToJar(File pluginJarFile, TFile updatedSauceConnectJarFile)
      throws IOException {

    TFile.setDefaultArchiveDetector(new TArchiveDetector("jar"));
    search(new TFile(pluginJarFile), updatedSauceConnectJarFile);
    TFile.umount();
  }
 @Before
 public void before() throws IOException {
   removeFiles();
   if (!dummyLogFile.exists()) {
     dummyLogFile.createNewFile();
   }
 }
  /** {@inheritDoc} */
  @Override
  public void execute() throws NoSuchFileOrDirectory, ExecutionException {
    if (isTrace()) {
      Log.v(TAG, String.format("Deleting directory: %s", this.mPath)); // $NON-NLS-1$
    }

    TFile f = getConsole().buildRealFile(this.mPath);
    if (!f.exists()) {
      if (isTrace()) {
        Log.v(TAG, "Result: FAIL. NoSuchFileOrDirectory"); // $NON-NLS-1$
      }
      throw new NoSuchFileOrDirectory(this.mPath);
    }

    // Check that if the path exist, it need to be a folder. Otherwise something is
    // wrong
    if (f.exists() && !f.isDirectory()) {
      if (isTrace()) {
        Log.v(TAG, "Result: FAIL. ExecutionException"); // $NON-NLS-1$
      }
      throw new ExecutionException("the path exists but is not a folder"); // $NON-NLS-1$
    }

    // Delete the file
    if (!FileHelper.deleteFolder(f)) {
      if (isTrace()) {
        Log.v(TAG, "Result: FAIL. ExecutionException"); // $NON-NLS-1$
      }
      throw new ExecutionException("Failed to delete directory");
    }

    if (isTrace()) {
      Log.v(TAG, "Result: OK"); // $NON-NLS-1$
    }
  }
 /**
  * Updates the plugin jar file to include the updatedSauceConnectJarFile.
  *
  * @param pluginJarFile
  * @param updatedSauceConnectJarFile
  * @throws java.io.IOException
  */
 private void update(TFile pluginJarFile, TFile updatedSauceConnectJarFile) throws IOException {
   logger.info("Modifying plugin jar file");
   updatedSauceConnectJarFile.cp_rp(pluginJarFile);
 }
 private void removeFiles() throws IOException {
   if ((dummyLogFile != null) & dummyLogFile.exists()) {
     dummyLogFile.rm();
   }
 }