public static void copy(File[] src, File dst) throws IOException { for (File file : src) { copy(file, dst); } }
public void run(Installer installer, File bundleDir, File installDir) throws IOException { File dest = new File(installDir, target); if (path.endsWith("/*")) { dest.mkdirs(); File file = new File(bundleDir, path.substring(0, path.length() - 1)); FileUtils.copy(file.listFiles(), dest); } else { File file = new File(bundleDir, path); FileUtils.copy(file, dest); } }
protected void copy(File src, File dst) throws PackageException { try { dst.getParentFile().mkdirs(); File tmp = new File(dst.getPath() + ".tmp"); // File tmp = new File(dst.getParentFile(), dst.getName() + // ".tmp"); FileUtils.copy(src, tmp); if (!tmp.renameTo(dst)) { tmp.delete(); FileUtils.copy(src, dst); } } catch (IOException e) { throw new PackageException("Failed to copy file: " + src + " to " + dst, e); } }
public static void copyResources(Bundle bundle, String path, File root) throws IOException { File file = Framework.getRuntime().getBundleFile(bundle); if (file == null) { throw new UnsupportedOperationException("Couldn't transform the bundle location into a file"); } root.mkdirs(); if (file.isDirectory()) { file = new File(file, path); FileUtils.copy(file.listFiles(), root); } else { ZipUtils.unzip(path, file, root); } }
/** * Backup the given file to the package backup directory. The backup file will be returned. The backup file will be * named: MD5ofFilepath_filename. * * @return the name of the backup file. */ public static File backup(LocalPackage pkg, File file) throws IOException { file = file.getCanonicalFile(); String md5 = createMd5(file.getAbsolutePath()); File bak = pkg.getData().getEntry(LocalPackage.BACKUP_DIR); bak.mkdirs(); String name = file.getName(); File bakFile = new File(bak, md5 + "_" + name); FileUtils.copy(file, bakFile); return bakFile; }