/** * @deprecated since 10.1 - seems unused */ @Deprecated public static void copyTree(File src, File dst, PathFilter filter) throws IOException { copyTree(src, dst, new Path("/"), filter); }
/** * Copies source to destination. If source and destination are the same, does nothing. Both single files and * directories are handled. * * @param src the source file or directory * @param dst the destination file or directory */ public static void copy(File src, File dst) throws IOException { if (src.equals(dst)) { return; } if (src.isFile()) { copyFile(src, dst); } else { copyTree(src, dst); } }
public static void copyTree(File src, File dst, Path prefix, PathFilter filter) throws IOException { if (!prefix.isAbsolute()) { prefix = prefix.makeAbsolute(); } int rootIndex = src.getPath().length() + 1; for (File file : src.listFiles()) { copyTree(rootIndex, file, new File(dst, file.getName()), prefix, filter); } }
/** * Copies recursively source to destination. * <p> * The source file is assumed to be a directory. * * @param src the source directory * @param dst the destination directory * @deprecated since 10.1 - waiting ReloadComponent to be cleaned */ @Deprecated public static void copyTree(File src, File dst) throws IOException { if (src.isFile()) { copyFile(src, dst); } else if (src.isDirectory()) { if (dst.exists()) { dst = new File(dst, src.getName()); dst.mkdir(); } else { // allows renaming dest dir dst.mkdirs(); } File[] files = src.listFiles(); for (File file : files) { copyTree(file, dst); } } }
protected static void copyTree(int rootIndex, File src, File dst, Path prefix, PathFilter filter) throws IOException { if (src.isFile()) { String relPath = src.getPath().substring(rootIndex); if (!filter.accept(new Path(relPath))) { return; } if (!prefix.isRoot()) { // remove prefix from path String path = dst.getPath(); String pff = prefix.toString(); int prefixIndex = path.lastIndexOf(pff); if (prefixIndex > 0) { path = path.substring(0, prefixIndex) + path.substring(prefixIndex + pff.length()); dst = new File(path.toString()); } } dst.getParentFile().mkdirs(); copyFile(src, dst); } else if (src.isDirectory()) { File[] files = src.listFiles(); for (File file : files) { copyTree(rootIndex, file, new File(dst, file.getName()), prefix, filter); } } }
/** * @deprecated since 5.6, use {@link #runDeploymentPreprocessor()} instead. Keep it as compatibility code until * NXP-9642 is done. */ @Override @Deprecated public void installWebResources(File file) throws IOException { log.info("Install web resources"); if (file.isDirectory()) { File war = new File(file, "web"); war = new File(war, "nuxeo.war"); if (war.isDirectory()) { org.nuxeo.common.utils.FileUtils.copyTree(war, getAppDir()); } else { // compatibility mode with studio 1.5 - see NXP-6186 war = new File(file, "nuxeo.war"); if (war.isDirectory()) { org.nuxeo.common.utils.FileUtils.copyTree(war, getAppDir()); } } } else if (file.isFile()) { // a jar File war = getWarDir(); ZipUtils.unzip("web/nuxeo.war", file, war); // compatibility mode with studio 1.5 - see NXP-6186 ZipUtils.unzip("nuxeo.war", file, war); } }