protected void copyFile ( final ArchiveEntry entry , final String vPath ) throws ArchiverException , IOException { // don't add "" to the archive if ( vPath . length ( ) <= 0 ) { return ; } final PlexusIoResource in = entry . getResource ( ) ; final File outFile = new File ( vPath ) ; final long inLastModified = in . getLastModified ( ) ; final long outLastModified = outFile . lastModified ( ) ; if ( ResourceUtils . isUptodate ( inLastModified , outLastModified ) ) { return ; } if ( ! in . isDirectory ( ) ) { if ( ! outFile . getParentFile ( ) . exists ( ) ) { // create the parent directory... if ( ! outFile . getParentFile ( ) . mkdirs ( ) ) { // Failure, unable to create specified directory for some unknown reason. throw new ArchiverException ( "Unable to create directory or parent directory of " + outFile ) ; } } ResourceUtils . copyFile ( entry . getInputStream ( ) , outFile ) ; if ( ! isIgnorePermissions ( ) ) { ArchiveEntryUtils . chmod ( outFile , entry . getMode ( ) , getLogger ( ) , isUseJvmChmod ( ) ) ; } } else { // file is a directory if ( outFile . exists ( ) ) { if ( ! outFile . isDirectory ( ) ) { // should we just delete the file and replace it with a directory? // throw an exception, let the user delete the file manually. throw new ArchiverException ( "Expected directory and found file at copy destination of " + in . getName ( ) + " to " + outFile ) ; } } else if ( ! outFile . mkdirs ( ) ) { // Failure, unable to create specified directory for some unknown reason. throw new ArchiverException ( "Unable to create directory or parent directory of " + outFile ) ; } } outFile . setLastModified ( inLastModified == PlexusIoResource . UNKNOWN_MODIFICATION_DATE ? System . currentTimeMillis ( ) : inLastModified ) ; }
Copies the specified file to the specified path creating any ancestor directory structure as necessary .