/** * <p>Copies a entire directory structure.</p> * * Note: * <ul> * <li>It will include empty directories. * <li>The <code>sourceDirectory</code> must exists. * </ul> * * @param sourceDirectory the source dir * @param destinationDirectory the target dir * @throws IOException if any */ public static void copyDirectoryStructure( File sourceDirectory, File destinationDirectory ) throws IOException { copyDirectoryStructure( sourceDirectory, destinationDirectory, destinationDirectory, false ); }
/** * <p>Copies an entire directory structure but only source files with timestamp later than the destinations'.</p> * * Note: * <ul> * <li>It will include empty directories. * <li>The <code>sourceDirectory</code> must exists. * </ul> * * @param sourceDirectory the source dir * @param destinationDirectory the target dir * @throws IOException if any */ public static void copyDirectoryStructureIfModified( File sourceDirectory, File destinationDirectory ) throws IOException { copyDirectoryStructure( sourceDirectory, destinationDirectory, destinationDirectory, true ); }
/** * Copies the selected save files to a new recording directory. * * @param oldTitle The name of the original save directory. * @param newTitle The name of the new recording directory. */ private void copySaveDirectoryToRecordingLibrary(String oldTitle, String newTitle) { File saveDirectory = new File(PathManager.getInstance().getSavePath(oldTitle).toString()); Path destinationPath = PathManager.getInstance().getRecordingPath(newTitle); File destDirectory = new File(destinationPath.toString()); try { FileUtils.copyDirectoryStructure(saveDirectory, destDirectory); rewriteManifestTitle(destinationPath, newTitle); } catch (Exception e) { logger.error("Error trying to copy the save directory:", e); } }
copyDirectoryStructure( file, destination, rootDestinationDirectory, onlyModifiedFiles );
/** * Creates new clean copy of test project directory structure. The copy is named after both the test being executed * and test project name, which allows the same test project can be used by multiple tests and by different * instances of the same parametrized tests.<br/> * TODO Provide alternative working directory naming for Windows, which still limits path names to ~250 charecters */ public File getBasedir( String project ) throws IOException { if ( name == null ) { throw new IllegalStateException( getClass().getSimpleName() + " must be a test class field annotated with org.junit.Rule" ); } File src = new File( projectsDir, project ).getCanonicalFile(); Assert.assertTrue( "Test project directory does not exist: " + src.getPath(), src.isDirectory() ); File basedir = new File( workDir, name + "_" + project ).getCanonicalFile(); FileUtils.deleteDirectory( basedir ); Assert.assertTrue( "Test project working directory created", basedir.mkdirs() ); FileUtils.copyDirectoryStructure( src, basedir ); return basedir; }
/** * Copies a entire directory structure. * <p/> * Note: * <ul> * <li>It will include empty directories. * <li>The <code>sourceDirectory</code> must exists. * </ul> * * @param sourceDirectory * @param destinationDirectory * @throws IOException */ public static void copyDirectoryStructure( File sourceDirectory, File destinationDirectory ) throws IOException { copyDirectoryStructure( sourceDirectory, destinationDirectory, destinationDirectory, false ); }
/** * Copies an entire directory structure but only source files with timestamp later than the destinations'. * <p/> * Note: * <ul> * <li>It will include empty directories. * <li>The <code>sourceDirectory</code> must exists. * </ul> * * @param sourceDirectory * @param destinationDirectory * @throws IOException */ public static void copyDirectoryStructureIfModified( File sourceDirectory, File destinationDirectory ) throws IOException { copyDirectoryStructure( sourceDirectory, destinationDirectory, destinationDirectory, true ); }
public void putDirectory(File sourceDirectory, String destinationDirectory) throws IOException { FileUtils.copyDirectoryStructure(sourceDirectory, new File(workDir, destinationDirectory)); } }
protected File backupFile( File file ) throws IOException { File bf = new File( originalFile.getParentFile(), originalFile.getName() + ".buup-bak" ); if ( file.isFile() ) { FileUtils.copyFile( file, bf ); } else if ( file.isDirectory() ) { FileUtils.copyDirectoryStructure( file, bf ); } return bf; }
protected File getBasedir(String test) throws IOException { File src = new File("projects", test).getCanonicalFile(); File dst = new File("target/projects", test).getCanonicalFile(); if (dst.isDirectory()) { FileUtils.deleteDirectory(dst); } else if (dst.isFile()) { if (!dst.delete()) { throw new IOException("Can't delete file " + dst.toString()); } } FileUtils.copyDirectoryStructure(src, dst); return dst; }
private void copyFolderTemplate( String path ) throws MojoExecutionException { File source = new File( path ); if ( !source.isAbsolute() ) { source = new File( project.getBasedir(), path ); } if ( !source.exists() || !source.isDirectory() ) { throw new MojoExecutionException( "Template folder doesn't exists. " + source ); } try { FileUtils.copyDirectoryStructure( source, templateOutputDirectory ); } catch ( IOException e ) { throw new MojoExecutionException( "Unable to copy template to: " + templateOutputDirectory, e ); } }
protected File getBasedir(String test) throws IOException { File src = new File("projects", test).getAbsoluteFile(); File dst = new File("target/projects", getClass().getSimpleName() + "/" + name.getMethodName() + "/" + test) .getAbsoluteFile(); if (dst.isDirectory()) { FileUtils.deleteDirectory(dst); } else if (dst.isFile()) { if (!dst.delete()) { throw new IOException("Can't delete file " + dst.toString()); } } FileUtils.copyDirectoryStructure(src, dst); return dst; }
public static void initRepo( String source, File repository, File workingDirectory ) throws IOException { // Copy the repository to target File src = PlexusTestCase.getTestFile( source ); FileUtils.deleteDirectory( repository ); Assert.assertTrue( repository.mkdirs() ); FileUtils.copyDirectoryStructure( src, repository ); File dotGitDirectory = new File( src, "dotgit" ); if ( dotGitDirectory.exists() ) { FileUtils.copyDirectoryStructure( dotGitDirectory, new File( repository, ".git" ) ); } FileUtils.deleteDirectory( workingDirectory ); Assert.assertTrue( workingDirectory.mkdirs() ); }
public static void initRepo( String source, File repository, File workingDirectory ) throws IOException { // Copy the repository to target File src = PlexusTestCase.getTestFile( source ); FileUtils.deleteDirectory( repository ); Assert.assertTrue( repository.mkdirs() ); FileUtils.copyDirectoryStructure( src, repository ); File dotGitDirectory = new File( src, "dotgit" ); if ( dotGitDirectory.exists() ) { FileUtils.copyDirectoryStructure( dotGitDirectory, new File( repository, ".git" ) ); } FileUtils.deleteDirectory( workingDirectory ); Assert.assertTrue( workingDirectory.mkdirs() ); }
public static File getBasedir(String name) throws IOException { File src = new File(PlexusTestCase.getBasedir(), "src/test/resources/" + name); File dst = new File(PlexusTestCase.getBasedir(), "target/" + name); if (dst.isDirectory()) { FileUtils.deleteDirectory(dst); } else if (dst.isFile()) { if (!dst.delete()) { throw new IOException("Can't delete file " + dst.toString()); } } FileUtils.copyDirectoryStructure(src, dst); return dst; } }
/** * Creates new clean copy of test project directory structure. The copy is named after both the test being executed and test project name, which allows the same test project can be used by multiple * tests and by different instances of the same parametrized tests.<br/> * TODO Provide alternative working directory naming for Windows, which still limits path names to ~250 charecters */ public File getBasedir(String project) throws IOException { if (name == null) { throw new IllegalStateException(getClass().getSimpleName() + " must be a test class field annotated with org.junit.Rule"); } File basedir = new File(workDir, name + "_" + project).getCanonicalFile(); FileUtils.deleteDirectory(basedir); Assert.assertTrue("Test project working directory created", basedir.mkdirs()); File src = new File(projectsDir, project).getCanonicalFile(); Assert.assertTrue("Test project directory does not exist: " + src.getPath(), src.isDirectory()); FileUtils.copyDirectoryStructure(src, basedir); return basedir; }
public static void initRepo( String source, File repository, File workingDirectory ) throws IOException { // Copy the repository to target File src = PlexusTestCase.getTestFile( source ); FileUtils.deleteDirectory( repository ); Assert.assertTrue( repository.mkdirs() ); FileUtils.copyDirectoryStructure( src, repository ); FileUtils.deleteDirectory( workingDirectory ); Assert.assertTrue( workingDirectory.mkdirs() ); } }
public static File getBasedir( String name ) throws IOException { File src = new File( PlexusTestCase.getBasedir(), "src/test/resources/" + name ); File dst = new File( PlexusTestCase.getBasedir(), "target/" + name ); if ( dst.isDirectory() ) { FileUtils.deleteDirectory( dst ); } else if ( dst.isFile() ) { if ( !dst.delete() ) { throw new IOException( "Can't delete file " + dst.toString() ); } } FileUtils.copyDirectoryStructure( src, dst ); return dst; } }
private List<String> unpackFrameworkExtensions(File location, Collection<File> frameworkExtensions) throws IOException { List<String> bundleNames = new ArrayList<>(); for (File bundleFile : frameworkExtensions) { OsgiManifest mf = manifestReader.loadManifest(bundleFile); bundleNames.add(mf.getBundleSymbolicName()); File bundleDir = new File(location, "plugins/" + mf.getBundleSymbolicName() + "_" + mf.getBundleVersion()); if (bundleFile.isFile()) { unpack(bundleFile, bundleDir); } else { FileUtils.copyDirectoryStructure(bundleFile, bundleDir); } } return bundleNames; }
private List<String> unpackFrameworkExtensions(File location, Collection<File> frameworkExtensions) throws IOException { List<String> bundleNames = new ArrayList<String>(); for (File bundleFile : frameworkExtensions) { Manifest mf = manifestReader.loadManifest(bundleFile); ManifestElement[] id = manifestReader.parseHeader(Constants.BUNDLE_SYMBOLICNAME, mf); ManifestElement[] version = manifestReader.parseHeader(Constants.BUNDLE_VERSION, mf); if (id == null || version == null) { throw new IOException("Invalid OSGi manifest in bundle " + bundleFile); } bundleNames.add(id[0].getValue()); File bundleDir = new File(location, "plugins/" + id[0].getValue() + "_" + version[0].getValue()); if (bundleFile.isFile()) { unpack(bundleFile, bundleDir); } else { FileUtils.copyDirectoryStructure(bundleFile, bundleDir); } } return bundleNames; }