Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1e72f9da authored by Adrian Velicu's avatar Adrian Velicu
Browse files

Dicttool to handle unpackaging non-latest version dicts

Change-Id: I738735186213b3a40eff997ae2fd83069c6445f1
parent da99cfc2
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.inputmethod.latin.dicttool;

import com.android.inputmethod.latin.makedict.DictionaryHeader;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
@@ -77,16 +79,16 @@ public class Package {
            if (mArgs.length != 2) {
                throw new RuntimeException("Too many/too few arguments for command " + COMMAND);
            }
            final BinaryDictOffdeviceUtils.DecoderChainSpec<File> decodedSpec =
                    BinaryDictOffdeviceUtils.getRawDictionaryOrNull(new File(mArgs[0]));
            final BinaryDictOffdeviceUtils.DecoderChainSpec<DictionaryHeader> decodedSpec =
                    BinaryDictOffdeviceUtils.decodeDictionaryForProcess(new File(mArgs[0]),
                            new BinaryDictOffdeviceUtils.HeaderReaderProcessor());
            if (null == decodedSpec) {
                System.out.println(mArgs[0] + " does not seem to be a dictionary");
                return;
            }
            System.out.println("Packaging : " + decodedSpec.describeChain());
            System.out.println("Uncompressed size : " + decodedSpec.mResult.length());
            try (
                final InputStream input = getFileInputStream(decodedSpec.mResult);
                final InputStream input = decodedSpec.getStream(new File(mArgs[0]));
                final OutputStream output = new BufferedOutputStream(
                        getFileOutputStreamOrStdOut(mArgs[1]))
            ) {