Search in sources :

Example 1 with Decompressor

use of com.amaze.filemanager.filesystem.compressed.showcontents.Decompressor in project AmazeFileManager by TeamAmaze.

the class CompressedHelper method getCompressorInstance.

/**
 * To add compatibility with other compressed file types edit this method
 */
public static Decompressor getCompressorInstance(@NonNull Context context, @NonNull File file) {
    Decompressor decompressor;
    String type = getExtension(file.getPath());
    if (isZip(type)) {
        decompressor = new ZipDecompressor(context);
    } else if (isRar(type)) {
        decompressor = new RarDecompressor(context);
    } else if (isTar(type)) {
        decompressor = new TarDecompressor(context);
    } else if (isGzippedTar(type)) {
        decompressor = new GzipDecompressor(context);
    } else if (isBzippedTar(type)) {
        decompressor = new Bzip2Decompressor(context);
    } else if (isXzippedTar(type)) {
        decompressor = new XzDecompressor(context);
    } else if (isLzippedTar(type)) {
        decompressor = new LzmaDecompressor(context);
    } else if (is7zip(type)) {
        decompressor = new SevenZipDecompressor(context);
    } else {
        return null;
    }
    decompressor.setFilePath(file.getPath());
    return decompressor;
}
Also used : LzmaDecompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.LzmaDecompressor) RarDecompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.RarDecompressor) SevenZipDecompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.SevenZipDecompressor) Bzip2Decompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.Bzip2Decompressor) TarDecompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.TarDecompressor) XzDecompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.XzDecompressor) ZipDecompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.ZipDecompressor) GzipDecompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.GzipDecompressor) Decompressor(com.amaze.filemanager.filesystem.compressed.showcontents.Decompressor) SevenZipDecompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.SevenZipDecompressor) ZipDecompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.ZipDecompressor) GzipDecompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.GzipDecompressor) RarDecompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.RarDecompressor) Bzip2Decompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.Bzip2Decompressor) XzDecompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.XzDecompressor) TarDecompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.TarDecompressor) SevenZipDecompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.SevenZipDecompressor) LzmaDecompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.LzmaDecompressor)

Example 2 with Decompressor

use of com.amaze.filemanager.filesystem.compressed.showcontents.Decompressor in project AmazeFileManager by TeamAmaze.

the class CompressedHelperTest method getCompressorInstance.

/**
 * Decompressor check This program use 6 extension and 4 decompressor. Check if each extensions
 * matched correct decompressor
 */
@Test
public void getCompressorInstance() {
    // .zip used by ZipDecompressor
    File file = new File("/test/test.zip");
    Decompressor result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), ZipDecompressor.class);
    // .jar used by ZipDecompressor
    file = new File("/test/test.jar");
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), ZipDecompressor.class);
    // .apk used by ZipDecompressor
    file = new File("/test/test.apk");
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), ZipDecompressor.class);
    // .tar used by TarDecompressor
    file = new File("/test/test.tar");
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), TarDecompressor.class);
    // .tar.gz used by GzipDecompressor
    file = new File("/test/test.tar.gz");
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), GzipDecompressor.class);
    // .tar.gz used by GzipDecompressor
    file = new File("/test/test.tgz");
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), GzipDecompressor.class);
    // .rar used by RarDecompressor
    file = new File("/test/test.rar");
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), RarDecompressor.class);
    // .rar used by RarDecompressor
    file = new File("/test/test.tar.bz2");
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), Bzip2Decompressor.class);
    // .rar used by RarDecompressor
    file = new File("/test/test.tbz");
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), Bzip2Decompressor.class);
    // Can't use 7zip
    file = new File("/test/test.7z");
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), SevenZipDecompressor.class);
    // .rar used by RarDecompressor
    file = new File("/test/test.tar.xz");
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), XzDecompressor.class);
    // .rar used by RarDecompressor
    file = new File("/test/test.tar.lzma");
    result = CompressedHelper.getCompressorInstance(context, file);
    assertEquals(result.getClass(), LzmaDecompressor.class);
}
Also used : LzmaDecompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.LzmaDecompressor) SevenZipDecompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.SevenZipDecompressor) GzipDecompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.GzipDecompressor) RarDecompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.RarDecompressor) Bzip2Decompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.Bzip2Decompressor) TarDecompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.TarDecompressor) XzDecompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.XzDecompressor) ZipDecompressor(com.amaze.filemanager.filesystem.compressed.showcontents.helpers.ZipDecompressor) Decompressor(com.amaze.filemanager.filesystem.compressed.showcontents.Decompressor) File(java.io.File) Test(org.junit.Test)

Aggregations

Decompressor (com.amaze.filemanager.filesystem.compressed.showcontents.Decompressor)2 Bzip2Decompressor (com.amaze.filemanager.filesystem.compressed.showcontents.helpers.Bzip2Decompressor)2 GzipDecompressor (com.amaze.filemanager.filesystem.compressed.showcontents.helpers.GzipDecompressor)2 LzmaDecompressor (com.amaze.filemanager.filesystem.compressed.showcontents.helpers.LzmaDecompressor)2 RarDecompressor (com.amaze.filemanager.filesystem.compressed.showcontents.helpers.RarDecompressor)2 SevenZipDecompressor (com.amaze.filemanager.filesystem.compressed.showcontents.helpers.SevenZipDecompressor)2 TarDecompressor (com.amaze.filemanager.filesystem.compressed.showcontents.helpers.TarDecompressor)2 XzDecompressor (com.amaze.filemanager.filesystem.compressed.showcontents.helpers.XzDecompressor)2 ZipDecompressor (com.amaze.filemanager.filesystem.compressed.showcontents.helpers.ZipDecompressor)2 File (java.io.File)1 Test (org.junit.Test)1