Skip to content

Commit

Permalink
codehaus-plexus#130 DirectoryArchiver: create parent directories for …
Browse files Browse the repository at this point in the history
…symlinks
  • Loading branch information
jameshans committed Dec 14, 2019
1 parent faa4d22 commit f72a9d7
Showing 1 changed file with 16 additions and 10 deletions.
Expand Up @@ -91,7 +91,9 @@ public void execute()
{
String dest = ( (SymlinkDestinationSupplier) resource ).getSymlinkDestination();
File target = new File( dest );
SymlinkUtils.createSymbolicLink( new File( fileName ), target );
File symlink = new File( fileName );
makeParentDirectories( symlink );
SymlinkUtils.createSymbolicLink( symlink, target );
}
else
{
Expand Down Expand Up @@ -142,15 +144,7 @@ protected void copyFile( final ArchiveEntry entry, final String vPath )

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 );
}
}
makeParentDirectories( outFile );
ResourceUtils.copyFile( entry.getInputStream(), outFile );

setFileModes( entry, outFile, inLastModified );
Expand Down Expand Up @@ -187,6 +181,18 @@ public void run()

}

private static void makeParentDirectories( File file ) {
if ( !file.getParentFile().exists() )
{
// create the parent directory...
if ( !file.getParentFile().mkdirs() )
{
// Failure, unable to create specified directory for some unknown reason.
throw new ArchiverException( "Unable to create directory or parent directory of " + file );
}
}
}

private void setFileModes( ArchiveEntry entry, File outFile, long inLastModified )
{
if ( !isIgnorePermissions() )
Expand Down

0 comments on commit f72a9d7

Please sign in to comment.