/** {@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$ } }
@Before public void before() throws IOException { removeFiles(); if (!dummyLogFile.exists()) { dummyLogFile.createNewFile(); } }
private void removeFiles() throws IOException { if ((dummyLogFile != null) & dummyLogFile.exists()) { dummyLogFile.rm(); } }