All Downloads are FREE. Search and download functionalities are using the official Maven repository.

alluxio.shaded.client.org.reflections.vfs.ZipDir Maven / Gradle / Ivy

package alluxio.shaded.client.org.reflections.vfs;

import alluxio.shaded.client.org.reflections.Reflections;

import java.alluxio.shaded.client.io.IOException;
import java.util.jar.JarFile;

/** an implementation of {@link alluxio.shaded.client.org.reflections.vfs.Vfs.Dir} for {@link java.util.zip.ZipFile} */
public class ZipDir implements Vfs.Dir {
    final java.util.zip.ZipFile jarFile;

    public ZipDir(JarFile jarFile) {
        this.jarFile = jarFile;
    }

    public String getPath() {
        return jarFile.getName();
    }

    public Iterable getFiles() {
        return () -> jarFile.stream()
                .filter(entry -> !entry.isDirectory())
                .map(entry -> (Vfs.File) new ZipFile(ZipDir.this, entry))
                .iterator();
    }

    public void close() {
        try { jarFile.close(); } catch (IOException e) {
            if (Reflections.log != null) {
                Reflections.log.warn("Could not close JarFile", e);
            }
        }
    }

    @Override
    public String toString() {
        return jarFile.getName();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy