1 package org.codehaus.mojo.truezip;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.util.Date;
24 import java.util.Iterator;
25 import java.util.List;
26
27 import org.apache.maven.plugin.MojoExecutionException;
28 import org.apache.maven.plugin.MojoFailureException;
29
30 import de.schlichtherle.truezip.file.TFile;
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 public class CliListMojo
47 extends AbstractArchiveMojo
48 {
49
50
51
52
53
54
55
56 private File from;
57
58
59
60
61
62
63
64
65 private boolean followSubArchive;
66
67 public void execute()
68 throws MojoExecutionException, MojoFailureException
69 {
70
71 if ( skip )
72 {
73 this.getLog().info( "Skip this execution" );
74 return;
75 }
76
77 super.execute();
78
79 intitializeArchiveDectector();
80
81 Fileset fileset = new Fileset();
82 fileset.setDirectory( from.getAbsolutePath() );
83 fileset.setFollowArchive( followSubArchive );
84
85 List<TFile> fileList = truezip.list( fileset );
86
87 Iterator<TFile> iter = fileList.iterator();
88
89 while ( iter.hasNext() )
90 {
91 TFile archiveFile = new TFile( iter.next().toString() );
92
93 String relativePath = archiveFile.getPath();
94 if ( relativePath.startsWith( from.getPath() ) )
95 {
96 relativePath = relativePath.substring( from.getPath().length() + 1 );
97 }
98
99 long fileLen = archiveFile.length();
100
101 System.out.println( fileLen + "\t" + new Date( archiveFile.lastModified() ) + "\t" + relativePath );
102 }
103
104 this.tryImmediateUpdate();
105
106 }
107
108 }