/** * Convenience method to delete the given file and any content (if the file is a * directory). Equivalent to calling {@link #deleteContent(File, IProgressMonitor)} * with <code>null</code> as the monitor. This operation cannot be undone. * * @param fileToDelete the file to delete */ public static void deleteContent(File fileToDelete) { deleteContent(fileToDelete, null); }
protected IStatus run(IProgressMonitor monitor) { CoreUtility.deleteContent(configDir, monitor); if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } return Status.OK_STATUS; } };
public static void deleteContent(File curr) { if (curr.exists()) { if (curr.isDirectory()) { File[] children = curr.listFiles(); if (children != null) { for (int i = 0; i < children.length; i++) { deleteContent(children[i]); } } } curr.delete(); } }
public static void checkPluginPropertiesConsistency(Map map, File configDir) { File runtimeDir = new File(configDir, "org.eclipse.core.runtime"); //$NON-NLS-1$ if (runtimeDir.exists() && runtimeDir.isDirectory()) { long timestamp = runtimeDir.lastModified(); Iterator iter = map.values().iterator(); while (iter.hasNext()) { if (hasChanged((IPluginModelBase)iter.next(), timestamp)) { CoreUtility.deleteContent(runtimeDir); break; } } } }
public static void checkPluginPropertiesConsistency(Map<?, ?> map, File configDir) { File runtimeDir = new File(configDir, IPDEBuildConstants.BUNDLE_CORE_RUNTIME); if (runtimeDir.exists() && runtimeDir.isDirectory()) { long timestamp = runtimeDir.lastModified(); Iterator<?> iter = map.values().iterator(); while (iter.hasNext()) { if (hasChanged((IPluginModelBase) iter.next(), timestamp)) { CoreUtility.deleteContent(runtimeDir); break; } } } }
/** * In previous releases the state was saved to the PDE .metadata directory. If * any of these states are still around we should delete them. */ private void clearOldCache() { File dir = new File(PDECore.getDefault().getStateLocation().toOSString()); File[] children = dir.listFiles(); if (children != null) { for (int i = 0; i < children.length; i++) { File child = children[i]; if (child.isDirectory()) { String name = child.getName(); if (name.endsWith(".target") && name.length() > ".target".length()) { //$NON-NLS-1$ //$NON-NLS-2$ CoreUtility.deleteContent(child); } else if (name.endsWith(".workspace") && name.length() > ".workspace".length()) { //$NON-NLS-1$ //$NON-NLS-2$ CoreUtility.deleteContent(child); } else if (name.endsWith(".cache") && name.length() > ".cache".length()) { //$NON-NLS-1$ //$NON-NLS-2$ CoreUtility.deleteContent(child); } } } } }
private void clearStaleStates(String extension, long latest) { File dir = new File(PDECore.getDefault().getStateLocation().toOSString()); File[] children = dir.listFiles(); if (children != null) { for (int i = 0; i < children.length; i++) { File child = children[i]; if (child.isDirectory()) { String name = child.getName(); if (name.endsWith(extension) && name.length() > extension.length() && !name.equals(Long.toString(latest) + extension)) { CoreUtility.deleteContent(child); } } } } }
public void targetReloaded() { // stop old registry (which will write contents to FS) and delete the cache it creates // might see if we can dispose of a registry without writing to file system. NOTE: Don't call stop() because we want to still reuse fStrategy if (fRegistry != null) fRegistry.stop(fMasterKey); CoreUtility.deleteContent(new File(PDECore.getDefault().getStateLocation().toFile(), EXTENSION_DIR)); fRegistry = null; }
/** * Clears the configuration area if the area exists and that option is selected. * * @param configuration * the launch configuration * @param monitor * the progress monitor * @throws CoreException * if unable to retrieve launch attribute values * @since 3.3 */ @Override protected void clear(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { // clear config area, if necessary if (configuration.getAttribute(org.eclipse.pde.launching.IPDELauncherConstants.CONFIG_CLEAR_AREA, false)) CoreUtility.deleteContent(getConfigDir(configuration), monitor); if (monitor != null && monitor.isCanceled()) { throw new CoreException(Status.CANCEL_STATUS); } }
/** * Clears the configuration area if the area exists and that option is selected. * * @param configuration * the launch configuration * @param monitor * the progress monitor * @throws CoreException * if unable to retrieve launch attribute values * @since 3.3 */ protected void clear(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { // clear config area, if necessary if (configuration.getAttribute(IPDELauncherConstants.CONFIG_CLEAR_AREA, false)) CoreUtility.deleteContent(getConfigDir(configuration), monitor); }
/** * Deletes all the cached JARs of libraries which are currently not contained * or enabled in the target platform. Will ignore any errors when trying to * delete a directory. * * @param targetModels The current contents of the target platform. */ public void cleanExtractedLibraries(IPluginModelBase[] targetModels) { File fCacheDir = getLibraryCacheDir(); if (!fCacheDir.isDirectory()) return; // build a list with all potential directory names for quick check Set<String> bundleKeys = new HashSet<>(); for (int i = 0; i < targetModels.length; i++) { if (targetModels[i].isEnabled()) { BundleDescription desc = targetModels[i].getBundleDescription(); bundleKeys.add(getBundleLibsCacheDirName(desc)); } } File[] fDirs = fCacheDir.listFiles(); for (int i = 0; i < fDirs.length; i++) { if (fDirs[i].isDirectory() && !bundleKeys.contains(fDirs[i].getName())) CoreUtility.deleteContent(fDirs[i]); } // Delete the cache folder if it is empty fCacheDir.delete(); }
} catch (IOException e) { CoreUtility.deleteContent(new File(location, "Eclipse.app")); //$NON-NLS-1$ if (scriptFile != null && scriptFile.exists()) scriptFile.delete();
/** * Deletes the given file and any content (if the file is a directory). There is * no way to undo this action. Providing a progress monitor allows for cancellation. * * @param fileToDelete the file to delete * @param monitor progress monitor for reporting and cancellation, can be <code>null</code> */ public static void deleteContent(File fileToDelete, IProgressMonitor monitor) { if (fileToDelete.exists()) { SubMonitor subMon = SubMonitor.convert(monitor, 100); if (fileToDelete.isDirectory()) { File[] children = fileToDelete.listFiles(); if (children != null) { subMon.setWorkRemaining(children.length * 10); for (int i = 0; i < children.length; i++) { if (subMon.isCanceled()) { return; } deleteContent(children[i], subMon.split(10)); } } } fileToDelete.delete(); subMon.done(); } if (monitor != null) { monitor.done(); } }
} catch (IOException e) { CoreUtility.deleteContent(new File(location, "Eclipse.app")); //$NON-NLS-1$ if (scriptFile != null && scriptFile.exists()) scriptFile.delete();
CoreUtility.deleteContent(children[i]);
CoreUtility.deleteContent(children[i]);
CoreUtility.deleteContent(children[i]);
/** * Clears the workspace prior to launching if the workspace exists and the option to * clear it is turned on. Also clears the configuration area if that option is chosen. * * @param configuration * the launch configuration * @param monitor * the progress monitor * @throws CoreException * if unable to retrieve launch attribute values * @since 3.3 */ @Override protected void clear(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { if (fWorkspaceLocation == null) { fWorkspaceLocation = LaunchArgumentsHelper.getWorkspaceLocation(configuration); } SubMonitor subMon = SubMonitor.convert(monitor, 50); // Clear workspace and prompt, if necessary if (!LauncherUtils.clearWorkspace(configuration, fWorkspaceLocation, subMon.split(25))) throw new CoreException(Status.CANCEL_STATUS); subMon.setWorkRemaining(25); if (subMon.isCanceled()) { throw new CoreException(Status.CANCEL_STATUS); } // clear config area, if necessary if (configuration.getAttribute(org.eclipse.pde.launching.IPDELauncherConstants.CONFIG_CLEAR_AREA, false)) CoreUtility.deleteContent(getConfigDir(configuration), subMon.split(25)); subMon.done(); }
/** * Clears the workspace prior to launching if the workspace exists and the option to * clear it is turned on. Also clears the configuration area if that option is chosen. * * @param configuration * the launch configuration * @param monitor * the progress monitor * @throws CoreException * if unable to retrieve launch attribute values * @since 3.3 */ protected void clear(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { if (fWorkspaceLocation == null) { fWorkspaceLocation = LaunchArgumentsHelper.getWorkspaceLocation(configuration); } SubMonitor subMon = SubMonitor.convert(monitor, 50); // Clear workspace and prompt, if necessary if (!LauncherUtils.clearWorkspace(configuration, fWorkspaceLocation, subMon.newChild(25))) { throw new CoreException(Status.CANCEL_STATUS); } subMon.setWorkRemaining(25); if (subMon.isCanceled()) { throw new CoreException(Status.CANCEL_STATUS); } // clear config area, if necessary if (configuration.getAttribute(IPDELauncherConstants.CONFIG_CLEAR_AREA, false)) CoreUtility.deleteContent(getConfigurationDirectory(configuration), subMon.newChild(25)); subMon.done(); }
/** * Clears the workspace prior to launching if the workspace exists and the option to * clear it is turned on. Also clears the configuration area if that option is chosen. * * @param configuration * the launch configuration * @param monitor * the progress monitor * @throws CoreException * if unable to retrieve launch attribute values * @since 3.3 */ protected void clear(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { if (fWorkspaceLocation == null) { fWorkspaceLocation = LaunchArgumentsHelper.getWorkspaceLocation(configuration); } SubMonitor subMon = SubMonitor.convert(monitor, 50); // Clear workspace and prompt, if necessary if (!LauncherUtils.clearWorkspace(configuration, fWorkspaceLocation, subMon.newChild(25))) throw new CoreException(Status.CANCEL_STATUS); subMon.setWorkRemaining(25); if (subMon.isCanceled()) { throw new CoreException(Status.CANCEL_STATUS); } // clear config area, if necessary if (configuration.getAttribute(IPDELauncherConstants.CONFIG_CLEAR_AREA, false)) CoreUtility.deleteContent(getConfigDir(configuration), subMon.newChild(25)); subMon.done(); }