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;
}
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);
}
Aggregations