1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.codehaus.plexus.archiver.snappy;
18
19 import javax.inject.Named;
20
21 import java.io.IOException;
22
23 import org.codehaus.plexus.archiver.AbstractArchiver;
24 import org.codehaus.plexus.archiver.ArchiveEntry;
25 import org.codehaus.plexus.archiver.ArchiverException;
26 import org.codehaus.plexus.archiver.ResourceIterator;
27 import org.codehaus.plexus.archiver.exceptions.EmptyArchiveException;
28
29
30
31
32 @Named("snappy")
33 public class SnappyArchiver extends AbstractArchiver {
34
35 private final SnappyCompressor compressor = new SnappyCompressor();
36
37 @Override
38 public void execute() throws ArchiverException, IOException {
39 if (!checkForced()) {
40 return;
41 }
42
43 ResourceIterator iter = getResources();
44 if (!iter.hasNext()) {
45 throw new EmptyArchiveException("archive cannot be empty");
46 }
47 ArchiveEntry entry = iter.next();
48 if (iter.hasNext()) {
49 throw new ArchiverException("There is more than one file in input.");
50 }
51 compressor.setSource(entry.getResource());
52 compressor.setDestFile(getDestFile());
53 compressor.compress();
54 }
55
56 @Override
57 public boolean isSupportingForced() {
58 return true;
59 }
60
61 @Override
62 protected void close() {
63 compressor.close();
64 }
65
66 @Override
67 protected String getArchiveType() {
68 return "snappy";
69 }
70 }