1 package org.codehaus.plexus.archiver.snappy;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import java.io.File;
22 import java.io.IOException;
23 import java.io.InputStream;
24 import java.io.FileInputStream;
25
26 import java.util.List;
27 import java.util.ArrayList;
28 import java.net.URL;
29
30
31
32
33
34
35
36
37 import org.codehaus.plexus.archiver.AbstractArchiveContentLister;
38 import org.codehaus.plexus.archiver.ArchiveContentEntry;
39 import org.codehaus.plexus.archiver.ArchiverException;
40
41 import org.codehaus.plexus.components.io.resources.AbstractPlexusIoResource;
42 import org.codehaus.plexus.components.io.resources.PlexusIoResource;
43
44 import org.apache.commons.io.FilenameUtils;
45
46
47
48
49
50 public class SnappyArchiveContentLister
51 extends AbstractArchiveContentLister
52 {
53 private static final String OPERATION_SNAPPY = "snappy";
54
55 public SnappyArchiveContentLister()
56 {
57 }
58
59 public SnappyArchiveContentLister( File sourceFile )
60 {
61 super( sourceFile );
62 }
63
64
65
66
67 protected class SnappyFileInfo
68 extends AbstractPlexusIoResource
69 {
70 private final File sourceFile;
71
72 public SnappyFileInfo( File sourceFile )
73 {
74 super( sourceFile.getName(), sourceFile.lastModified(),
75 PlexusIoResource.UNKNOWN_RESOURCE_SIZE, true, false, true );
76 this.sourceFile = sourceFile;
77 }
78
79 public URL getURL()
80 throws IOException
81 {
82 return null;
83 }
84
85 public InputStream getContents()
86 throws IOException
87 {
88
89 return ( new FileInputStream( sourceFile ) );
90 }
91 }
92
93 protected List<ArchiveContentEntry> execute()
94 throws ArchiverException
95 {
96 ArrayList<ArchiveContentEntry> archiveContentList = new ArrayList<ArchiveContentEntry>();
97 getLogger().debug( "listing: " + getSourceFile() );
98
99 ArchiveContentEntry ae = ArchiveContentEntry.createFileEntry(
100 FilenameUtils.removeExtension( getSourceFile().getName() ), new SnappyFileInfo( getSourceFile() ), -1 );
101 archiveContentList.add( ae );
102
103 getLogger().debug( "listing complete" );
104
105 return archiveContentList;
106 }
107 }