Skip to content

Commit

Permalink
Correctie uitleg van .copy() en introductie van .copyFolder()
Browse files Browse the repository at this point in the history
Bugfix en uitbreiding
  • Loading branch information
arjan authored and arjan committed Nov 30, 2024
1 parent c5d981c commit 0d01d49
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/main/java/nl/imvertor/common/file/AnyFolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public AnyFolder(File parent, String filename) {
}

/**
* Create a copy of this folder within the target folder.
* Example /a -> /b creates : /b/a/*
* Create a copy of the files in this folder within the target folder.
* Example /a/m -> /b creates : /b/m/*
*
* @param targetFolder
* @throws Exception
Expand Down Expand Up @@ -109,6 +109,20 @@ public void copy(String targetFolderPath) throws Exception {
copy(new AnyFolder(targetFolderPath),true);
}

/**
* Copy this folder as a new subfolder within target folder, under the source folder name.
* Overwrite any existing files/folders.
*
* Example /a -> /b creates : /b/a
*
* @param targetFolderPath
* @throws Exception
*/
public void copyFolder(AnyFolder targetFolder) throws Exception {
targetFolder = new AnyFolder(targetFolder.getCanonicalPath() + "/" + getName());
FileUtils.copyDirectory(this, targetFolder);
}

public boolean hasFile(String filename) throws IOException {
if (!this.exists() || this.isFile()) return false;
return (new File(this.getCanonicalPath() + File.separator + filename)).isFile();
Expand Down

0 comments on commit 0d01d49

Please sign in to comment.