Skip to content

Commit

Permalink
Support following symbolic links to files
Browse files Browse the repository at this point in the history
This implements the necessary support to allow plexus-archiver to
archive the contents of symlinks (instead of the symbolic links
themselves), depending on the (already-extant) follow-symlinks flag.

Closes: codehaus-plexus#37

Signed-off-by: mirabilos <[email protected]>
  • Loading branch information
mirabilos committed Jan 8, 2021
1 parent 3759018 commit a17f4f0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,13 @@ public FileAttributes( @Nonnull File file, @Nonnull Map<Integer, String> userCac
@Nonnull Map<Integer, String> groupCache )
throws IOException
{
this( file.toPath(), userCache, groupCache );
}

Path path = file.toPath();
public FileAttributes( @Nonnull Path path, @Nonnull Map<Integer, String> userCache,
@Nonnull Map<Integer, String> groupCache )
throws IOException
{
Set<String> views = path.getFileSystem().supportedFileAttributeViews();
String names;
if ( views.contains( "unix" ) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
Expand Down Expand Up @@ -158,8 +159,13 @@ private void addResources( List<PlexusIoResource> result, String[] resources )
{
String sourceDir = name.replace( '\\', '/' );
File f = new File( dir, sourceDir );
Path p = f.toPath();
if ( isFollowingSymLinks() )
{
p = p.toRealPath();
}

FileAttributes fattrs = new FileAttributes( f, cache1, cache2 );
FileAttributes fattrs = new FileAttributes( p, cache1, cache2 );
PlexusIoResourceAttributes attrs = mergeAttributes( fattrs, fattrs.isDirectory() );

String remappedName = getName( name );
Expand Down

0 comments on commit a17f4f0

Please sign in to comment.