Class ArchiveManager


  • public class ArchiveManager
    extends Object
    • Constructor Detail

      • ArchiveManager

        public ArchiveManager()
    • Method Detail

      • isClassInFile

        public boolean isClassInFile​(String clazz,
                                     File c)
                              throws IOException
        Finds out whether desired class is contained in c
        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 directory
        zipEntry - Zip entry
        Returns:
        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 archived
        fName - Name of the file
        zOut - Zip output stream used to output zipped bytes
        Throws:
        IOException
      • delete

        public boolean delete()
        Deletes jrd temporary folder
        Returns:
        whether folder was successfully deleted