DigestRootConfiguration rootConfiguration = processConfiguration(cfgbuf, args, l10n);
DigestConfiguration configuration = rootConfiguration.getDigestConfiguration();
// load SWC
SwcCache cache = null;
File libraryFile = null;
BufferedInputStream libraryInput = null;
try
{
cache = new SwcCache();
libraryFile = configuration.getRslFile();
libraryInput = new BufferedInputStream(new FileInputStream(libraryFile));
String[] paths = {configuration.getSwcPath()};
SwcGroup group = cache.getSwcGroup(paths);
// calculate hash of file and update the catalog.
long fileLength = libraryFile.length();
if (fileLength > Integer.MAX_VALUE)
{
throw new ConfigurationException.FileTooBig(libraryFile.getAbsolutePath(),
"rsl-file", null, 0);
}
byte[] fileBytes = new byte[(int)fileLength];
libraryInput.read(fileBytes);
Digest digest = new Digest();
digest.computeDigest(fileBytes);
digest.setSigned(configuration.getSigned());
Swc[] swcs = group.getSwcs().values().toArray(new Swc[1]);
if (swcs.length != 1)
{
throw new IllegalStateException("expecting one swc file, found " + swcs.length); //$NON-NLS-1$
}
Swc swc = swcs[0];
swc.setDigest(Swc.LIBRARY_SWF, digest);
// export SWC
cache.export(swc);
//confirmation message
if (ThreadLocalToolkit.errorCount() == 0)
{
ThreadLocalToolkit.log(new OutputMessage(swc.getLocation()));