Skip to content

Package io.github.qishr.cascara.common.util

Class ArchiveFile

java.lang.Object
        io.github.qishr.cascara.common.util.ArchiveFile

All Implemented Interfaces:
    AutoCloseable

Direct Known Subtypes:
    JarFile


public class ArchiveFile

Nested Class Summary

Modifier and Type Class Description
public static io.github.qishr.cascara.common.util.ArchiveFile.EntryInfo

Field Summary

Modifier and Type Field Description
protected Path archivePath

Constructor Summary

Constructor Description
ArchiveFile(Path archivePath, boolean create)

Method Summary

Modifier and Type Method Description
public static ArchiveFile open(Path archivePath)
public static ArchiveFile create(Path archivePath)
public void close()
public InputStream getInputStream(String filePath)
public byte[] extractFile(String filePath)
protected static byte[] extractFile(Path archivePath, String filePath)
public List<EntryInfo> listFiles()
public List<EntryInfo> listFiles(String dirPath)
public void addDirectory(Path dirPath)
public void addDirectory(Path sourcePath, String entryName)
protected void walk(Path sourcePath, String entryName, List<LocalizableIOException> exceptions, BiConsumer<Path, Path> run)
public void addFile(Path sourcePath, String entryName)
public void addFile(String content, String entryName)
protected static List<EntryInfo> listFiles(Path archivePath, String dirPath)

Field Details

archivePath

protected Path archivePath


Method Details

open

public static ArchiveFile open(Path archivePath)

Throws:

LocalizableIOException


create

public static ArchiveFile create(Path archivePath)

Throws:

LocalizableIOException


close

public void close()

Throws:

Exception

Specified By:

AutoCloseable


getInputStream

public InputStream getInputStream(String filePath)

Throws:

LocalizableIOException


extractFile

public byte[] extractFile(String filePath)

Throws:

LocalizableIOException


extractFile

protected static byte[] extractFile(Path archivePath, String filePath)

Throws:

LocalizableIOException


listFiles

public List<EntryInfo> listFiles()

Throws:

LocalizableIOException


listFiles

public List<EntryInfo> listFiles(String dirPath)

Throws:

LocalizableIOException


addDirectory

public void addDirectory(Path dirPath)

Throws:

LocalizableIOException


addDirectory

public void addDirectory(Path sourcePath, String entryName)

Throws:

LocalizableIOException


walk

protected void walk(Path sourcePath, String entryName, List<LocalizableIOException> exceptions, BiConsumer<Path, Path> run)

Throws:

LocalizableIOException


addFile

public void addFile(Path sourcePath, String entryName)

Throws:

LocalizableIOException


addFile

public void addFile(String content, String entryName)

Throws:

LocalizableIOException


listFiles

protected static List<EntryInfo> listFiles(Path archivePath, String dirPath)

Throws:

LocalizableIOException