Package org.jrd.backend.data
Class ArchiveManager
- java.lang.Object
-
- org.jrd.backend.data.ArchiveManager
-
public class ArchiveManager extends Object
-
-
Constructor Summary
Constructors Constructor Description ArchiveManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
delete()
Deletes jrd temporary folderstatic ArchiveManager
getInstance()
boolean
isClassInFile(String clazz, File c)
Finds out whether desired class is contained inc
boolean
needExtract()
Returns whether extraction is necessaryFile
newFile(File destinationDir, ZipEntry zipEntry)
ZipSlip guardvoid
pack(File c)
Packs unpacked filesvoid
recursiveZip(File f2zip, String fName, ZipOutputStream zOut)
Recursively adds file or files inside folder to archivestatic boolean
shouldOpen(String n)
Determines whether this file can be opened with ZipInputStreamFile
unpack(File c)
Unpacks files necessary to access desired class
-
-
-
Method Detail
-
getInstance
public static ArchiveManager getInstance()
-
isClassInFile
public boolean isClassInFile(String clazz, File c) throws IOException
Finds out whether desired class is contained inc
- Parameters:
clazz
- Class to search- Returns:
- Whether class is in this file
- Throws:
IOException
- Error while reading streams
-
shouldOpen
public static boolean shouldOpen(String n) throws IOException
Determines whether this file can be opened with ZipInputStream- Parameters:
n
- Name of the file- Returns:
- Whether file can opened with ZipInputStream
- Throws:
IOException
-
needExtract
public boolean needExtract()
Returns whether extraction is necessary- Returns:
- If extraction is necessary
-
unpack
public File unpack(File c) throws IOException
Unpacks files necessary to access desired class- Returns:
- .jar containing desired class
- Throws:
IOException
- Error while reading streams
-
newFile
public File newFile(File destinationDir, ZipEntry zipEntry) throws IOException
ZipSlip guard- Parameters:
destinationDir
- Destination directoryzipEntry
- Zip entry- Returns:
- Throws:
IOException
-
pack
public void pack(File c) throws IOException
Packs unpacked files- Throws:
IOException
-
recursiveZip
public void recursiveZip(File f2zip, String fName, ZipOutputStream zOut) throws IOException
Recursively adds file or files inside folder to archive- Parameters:
f2zip
- File/Folder to be archivedfName
- Name of the filezOut
- Zip output stream used to output zipped bytes- Throws:
IOException
-
delete
public boolean delete()
Deletes jrd temporary folder- Returns:
- whether folder was successfully deleted
-
-