Implement the package command

Bug: 7388852
Change-Id: Ib6a50e02894961b4c7d3f57bc0fc70c3b3bfe4e9
main
Jean Chalard 2012-10-30 18:36:00 +09:00
parent ba98b63983
commit ee0b5488b5
1 changed files with 17 additions and 3 deletions

View File

@ -33,6 +33,8 @@ public class Package {
static public class Packager extends Dicttool.Command { static public class Packager extends Dicttool.Command {
public static final String COMMAND = "package"; public static final String COMMAND = "package";
private final static String PREFIX = "dicttool";
private final static String SUFFIX = ".tmp";
public Packager() { public Packager() {
} }
@ -41,9 +43,21 @@ public class Package {
return COMMAND + " <src_filename> <dst_filename>: Package a file for distribution"; return COMMAND + " <src_filename> <dst_filename>: Package a file for distribution";
} }
public void run() { public void run() throws IOException {
// Not implemented yet if (mArgs.length != 2) {
throw new UnsupportedOperationException(); throw new RuntimeException("Too many/too few arguments for command " + COMMAND);
}
final File intermediateFile = File.createTempFile(PREFIX, SUFFIX);
try {
final Compress.Compressor compressCommand = new Compress.Compressor();
compressCommand.setArgs(new String[] { mArgs[0], intermediateFile.getPath() });
compressCommand.run();
final Crypt.Encrypter cryptCommand = new Crypt.Encrypter();
cryptCommand.setArgs(new String[] { intermediateFile.getPath(), mArgs[1] });
cryptCommand.run();
} finally {
intermediateFile.delete();
}
} }
} }