[Arakhnę-Dev] [314] * Do not copy hidden files when copying a file tree. |
[ Thread Index |
Date Index
| More arakhne.org/dev Archives
]
Revision: 314
Author: galland
Date: 2011-11-05 14:19:10 +0100 (Sat, 05 Nov 2011)
Log Message:
-----------
* Do not copy hidden files when copying a file tree.
Modified Paths:
--------------
trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java
Modified: trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java
===================================================================
--- trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java 2011-11-05 12:34:12 UTC (rev 313)
+++ trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java 2011-11-05 13:19:10 UTC (rev 314)
@@ -184,33 +184,40 @@
*
* @param in
* @param out
+ * @param skipHiddenFiles indicates if the hidden files should be ignored.
* @throws IOException
* @since 3.3
*/
- public final void dirCopy(File in, File out) throws IOException {
+ public final void dirCopy(File in, File out, boolean skipHiddenFiles) throws IOException {
assert (in != null);
assert (out != null);
- debug("Copying tree "+in.toString()+" into "+out.toString()); //$NON-NLS-1$//$NON-NLS-2$
+ debug(in.toString()+"->"+out.toString()); //$NON-NLS-1$
+ debug("Ignore hidden files: "+skipHiddenFiles); //$NON-NLS-1$
out.mkdirs();
LinkedList<File> candidates = new LinkedList<File>();
candidates.add(in);
- File f;
+ File f, targetFile;
File[] children;
while (!candidates.isEmpty()) {
f = candidates.removeFirst();
+ debug("Scanning: "+f); //$NON-NLS-1$
if (f.isDirectory()) {
- f.mkdirs();
children = f.listFiles();
- if (children!=null && children.length>1) {
+ if (children!=null && children.length>0) {
// Non empty directory
for(File c : children) {
- candidates.add(c);
+ if (!skipHiddenFiles || !c.isHidden()) {
+ debug("Discovering: "+c); //$NON-NLS-1$
+ candidates.add(c);
+ }
}
}
}
else {
// not a directory
- fileCopy(f, toOutput(in, f, out));
+ targetFile = toOutput(in, f, out);
+ targetFile.getParentFile().mkdirs();
+ fileCopy(f, targetFile);
}
}
}