if ( vPath.length() <= 0 )
{
return;
}
PlexusIoResource in = entry.getResource();
File outFile = new File( vPath );
final long inLastModified = in.getLastModified();
long outLastModified = outFile.lastModified();
if ( ResourceUtils.isUptodate( inLastModified, outLastModified ) )
{
return;
}
outFile.setLastModified( inLastModified == PlexusIoResource.UNKNOWN_MODIFICATION_DATE
? System.currentTimeMillis() : inLastModified );
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( in, outFile );
ArchiveEntryUtils.chmod( outFile, entry.getMode(), getLogger() );
}
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.