Class ItemSerializer

java.lang.Object
ghidra.framework.store.local.ItemSerializer

public class ItemSerializer extends Object
ItemSerializer facilitates the compressing and writing of a data stream to a "packed" file. The resulting "packed" file will contain the following meta-data which is available after construction:
  • Item name
  • Content type (int)
  • File type (int)
  • Data length
  • Method Details

    • outputItem

      public static void outputItem(String itemName, String contentType, int fileType, long length, InputStream content, File packedFile, TaskMonitor monitor) throws CancelledException, IOException
      Read and compress data from the specified content stream and write to a packed file along with additional meta-data.
      Parameters:
      itemName - item name
      contentType - content type
      fileType - file type
      length - content length to be read
      content - content input stream
      packedFile - output packed file to be created
      monitor - task monitor
      Throws:
      CancelledException - if output is cancelled
      IOException - if IO error occurs
    • isPackedFile

      public static boolean isPackedFile(File file) throws IOException
      A simple utility method to determine if the given file is a packed file as created by this class.
      Parameters:
      file - The file to check
      Returns:
      True if it is a packed file
      Throws:
      IOException - If there is a problem reading the given file
    • isPackedFile

      public static boolean isPackedFile(InputStream inputStream) throws IOException
      A convenience method for checking if the file denoted by the given inputStream is a packed file.

      Note: This method will NOT close the given inputStream.

      Parameters:
      inputStream - a stream for accessing bytes of what may be a packed file
      Returns:
      true if the bytes from the inputStream represent the bytes of a packed file
      Throws:
      IOException - If there is a problem accessing the inputStream
      See Also: