Package net.lahwran.bukkit.jython

Source Code of net.lahwran.bukkit.jython.PluginPythonZip

/**
*
*/
package net.lahwran.bukkit.jython;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

import org.bukkit.plugin.InvalidPluginException;

/**
* @author lahwran
*
*/
public class PluginPythonZip extends PluginDataFile {

    /**
     * Zipfile we belong to
     */
    public final ZipFile zip;

    /**
     * @param file Zipfile we belong to
     * @throws InvalidPluginException thrown if there is an error opening zip
     */
    public PluginPythonZip(File file) throws InvalidPluginException {
        try {
            zip = new ZipFile(file);
        } catch (IOException e) {
            throw new InvalidPluginException(e);
        }
    }

    public void close() throws IOException {
        zip.close();
    }

    @Override
    public InputStream getStream(String filename) throws IOException {
        ZipEntry entry = zip.getEntry(filename);
        if (entry == null)
            return null;
        return zip.getInputStream(entry);
    }

    @Override
    public boolean shouldAddPathEntry() {
        return true;
    }

    @Override
    public boolean getNeedsSolidMeta() {
        return true;
    }
}
TOP

Related Classes of net.lahwran.bukkit.jython.PluginPythonZip

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.