net.sf.sevenzipjbinding.impl.RandomAccessFileInStream Java Examples

The following examples show how to use net.sf.sevenzipjbinding.impl.RandomAccessFileInStream. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SevenZipFileSystem.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Opens the specified sevenzip container file and initializes this file system with the
 * contents.
 *  
 * @param containerFile file to open
 * @param monitor {@link TaskMonitor} to allow the user to monitor and cancel
 * @throws CancelledException if user cancels
 * @throws IOException if error when reading data
 */
public void mount(File containerFile, TaskMonitor monitor)
		throws CancelledException, IOException {
	randomAccessFile = new RandomAccessFile(containerFile, "r");
	try {
		archive = SevenZip.openInArchive(null, new RandomAccessFileInStream(randomAccessFile));
		archiveInterface = archive.getSimpleInterface();

		ISimpleInArchiveItem[] items = archiveInterface.getArchiveItems();
		for (ISimpleInArchiveItem item : items) {
			if (monitor.isCancelled()) {
				throw new CancelledException();
			}

			fsIndexHelper.storeFile(item.getPath(), item.getItemIndex(), item.isFolder(),
				getSize(item), item);
		}
		preCacheAll(monitor);
	}
	catch (SevenZipException e) {
		throw new IOException("Failed to open archive: " + fsrl, e);
	}
}
 
Example #2
Source File: SevenZipUtils.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
public static void extractFile(@NonNull File compressFile, @NonNull File destDir, ExtractCallback callback) throws IOException {
    if (!compressFile.exists() || !compressFile.isFile())
        throw new IOException("compress file not found");
    if (!destDir.exists() || !destDir.isDirectory())
        throw new IOException("Dest directory not found");


    RandomAccessFile randomAccessFile = new RandomAccessFile(compressFile, "r");
    RandomAccessFileInStream accessFileInStream = new RandomAccessFileInStream(randomAccessFile);

    IInArchive inArchive = SevenZip.openInArchive(null, accessFileInStream);
    inArchive.extract(null, false, new ArchiveExtractCallback(inArchive, destDir, callback));
}