public final void dirCopy ( File in , File out , boolean skipHiddenFiles ) throws IOException { assert in != null ; assert out != null ; getLog ( ) . debug ( in . toString ( ) + "->" + out . toString ( ) ) ; //$NON-NLS-1$ getLog ( ) . debug ( "Ignore hidden files: " + skipHiddenFiles ) ; //$NON-NLS-1$ out . mkdirs ( ) ; final LinkedList < File > candidates = new LinkedList <> ( ) ; candidates . add ( in ) ; File [ ] children ; while ( ! candidates . isEmpty ( ) ) { final File f = candidates . removeFirst ( ) ; getLog ( ) . debug ( "Scanning: " + f ) ; //$NON-NLS-1$ if ( f . isDirectory ( ) ) { children = f . listFiles ( ) ; if ( children != null && children . length > 0 ) { // Non empty directory for ( final File c : children ) { if ( ! skipHiddenFiles || ! c . isHidden ( ) ) { getLog ( ) . debug ( "Discovering: " + c ) ; //$NON-NLS-1$ candidates . add ( c ) ; } } } } else { // not a directory final File targetFile = toOutput ( in , f , out ) ; targetFile . getParentFile ( ) . mkdirs ( ) ; fileCopy ( f , targetFile ) ; } } }
Copy a directory .