public static boolean delete(File file) { return delete(file, false); }
/** * Copies a whole directory to a new location. * <p> * This method copies the contents of the specified source directory to within the specified destination directory. * <p> * The destination directory is created if it does not exist. If the destination directory did exist, then this * method merges the source with the destination, with the source taking precedence. * <p> * <strong>Note:</strong> Setting <code>preserveFileDate</code> to {@code true} tries to preserve the files' last * modified date/times using {@link File#setLastModified(long)}, however it is not guaranteed that those operations * will succeed. If the modification operation fails, no indication is provided. * * @param srcDir an existing directory to copy, must not be {@code null} * @param destDir the new directory, must not be {@code null} * * @throws NullPointerException if source or destination is {@code null} * @throws IOException if source or destination is invalid * @throws IOException if an IO error occurs during copying * @since 1.1 */ public static void copyDirectory(File srcDir, File destDir) throws IOException { copyDirectory(srcDir, destDir, null); }
doCopyDirectory(srcFile, dstFile, filter, exclusionList); doCopyFile(srcFile, dstFile);
+ resource.getParentFile().getParentFile().getName(); child = OperatingSystemUtils.getSafeFilename(child); Files.copyDirectory(resource, new File(addonSlotDir, child)); Files.copyFileToDirectory(resource, addonSlotDir);
public static boolean delete(File file, final boolean recursive) { if (recursive) { if (_deleteRecursive(file, true)) { return true; } return false; } if ((file.listFiles() != null) && (file.listFiles().length != 0)) { throw new RuntimeException("directory not empty"); } if (OperatingSystemUtils.isWindows()) { System.gc(); // ensure no lingering handles that would prevent deletion } file.deleteOnExit(); // be paranoid if (file.delete()) { return true; } return false; }
copyFile(srcFile, destFile);
doCopyFile(srcFile, destFile);
doCopyDirectory(srcDir, destDir, filter, exclusionList);
private static boolean _deleteRecursive(final File file, final boolean collect) { if (collect && OperatingSystemUtils.isWindows()) { System.gc(); // ensure no lingering handles that would prevent deletion } if (file == null) { return false; } File[] children = file.listFiles(); if (children != null) { for (File sf : children) { if (sf.isDirectory()) { _deleteRecursive(sf, false); } else { if (!sf.delete()) { throw new RuntimeException("failed to delete: " + sf.getAbsolutePath()); } } } } return file.delete(); }
@Override public void stop() throws LifecycleException { this.runnable.stop(); Files.delete(addonDir, true); }
@Override public Boolean call() throws Exception { File dir = getAddonBaseDir(addon); disable(addon); return Files.delete(dir, true); } });