Class ArchiveManager
java.lang.Object
org.jrd.backend.data.ArchiveManager
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classprivate static final class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleandelete()Deletes jrd temporary folderprivate booleanDeletes all nested files and directories, so the root can be deletedprivate booleanfindClazz(ZipInputStream zis, String clazz) Recursive search through nested jarsstatic ArchiveManagerbooleanisClassInFile(String clazz, File c) Finds out whether desired class is contained incbooleanReturns whether extraction is necessaryZipSlip guardvoidPacks unpacked filesprivate FilerecursiveUnpack(File toUnpack) Recursively unpacks all required archivesvoidrecursiveZip(File f2zip, String fName, ZipOutputStream zOut) Recursively adds file or files inside folder to archivestatic booleanshouldOpen(String n) Determines whether this file can be opened with ZipInputStreamUnpacks files necessary to access desired class
-
Field Details
-
TMP_DIR
-
FILE_SEPARATOR
-
pathManager
-
jrdFolder
-
currentD
private int currentD
-
-
Constructor Details
-
ArchiveManager
public ArchiveManager()
-
-
Method Details
-
getInstance
-
isClassInFile
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
-
findClazz
Recursive search through nested jars- Parameters:
zis- ZipInputStream of current jarclazz- Class to search- Returns:
- Whether class is in this file
- Throws:
IOException- Error while reading streams
-
shouldOpen
Determines whether this file can be opened with ZipInputStream- Parameters:
n- Name of the file- Returns:
- Whether file can be opened with ZipInputStream
- Throws:
IOException
-
needExtract
public boolean needExtract()Returns whether extraction is necessary- Returns:
- If extraction is necessary
-
unpack
Unpacks files necessary to access desired class- Returns:
- .jar containing desired class
- Throws:
IOException- Error while reading streams
-
recursiveUnpack
Recursively unpacks all required archives- Parameters:
toUnpack- Archive to be unpacked- Returns:
- File pointer to last archive
- Throws:
IOException- if an I/O error occurs during unpacking
-
newFile
ZipSlip guard- Parameters:
destinationDir- Destination directoryzipEntry- Zip entry- Returns:
- File object pointing to "destinationDir/zipEntry"
- Throws:
IOException- cannot happen
-
pack
-
recursiveZip
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- if an I/O error occurs when writing to the output stream
-
delete
public boolean delete()Deletes jrd temporary folder- Returns:
- whether folder was successfully deleted
-
deleteRecursive
Deletes all nested files and directories, so the root can be deleted- Parameters:
f- Directory to be deleted- Returns:
- Whether directory was deleted
-