Class VersionedDatabase

java.lang.Object
db.Database
ghidra.framework.store.db.VersionedDatabase

public class VersionedDatabase extends Database
VersionedDatabase corresponds to a versioned database.
  • Field Details

  • Constructor Details

  • Method Details

    • createVersionedDatabase

      public static LocalManagedBufferFile createVersionedDatabase(File dbDir, int bufferSize, VersionedDBListener verDBListener, long checkoutId) throws IOException
      Create a new database and provide the initial buffer file for writing.
      Parameters:
      dbDir -
      bufferSize -
      Returns:
      initial buffer file
      Throws:
      IOException
    • getMinimumVersion

      public int getMinimumVersion()
      Returns the version number associated with the oldest buffer file version.
    • getCurrentVersion

      public int getCurrentVersion()
      Returns the version number associated with the latest buffer file version.
      Overrides:
      getCurrentVersion in class Database
    • deleteMinimumVersion

      public void deleteMinimumVersion() throws IOException
      Delete oldest version.
      Throws:
      IOException - if an error occurs or this is the only version.
    • deleteCurrentVersion

      public void deleteCurrentVersion() throws IOException
      Delete latest version.
      Throws:
      IOException - if an error occurs or this is the only version.
    • openBufferFile

      public LocalManagedBufferFile openBufferFile(int version, int minChangeDataVer) throws IOException
      Open a specific version of this database for non-update use.
      Parameters:
      version - database version or LATEST_VERSION for current version
      minChangeDataVer - the minimum database version whose change data should be associated with the returned buffer file. A value of -1 indicates that change data is not required.
      Returns:
      buffer file for non-update use.
      Throws:
      IOException
    • open

      public DBHandle open(int version, int minChangeDataVer, TaskMonitor monitor) throws IOException
      Open a specific version of the stored database for non-update use. The returned handle does not support the Save operation.
      Parameters:
      version - database version
      monitor - task monitor (may be null)
      Returns:
      database handle
      Throws:
      FileInUseException - thrown if unable to obtain the required database lock(s).
      IOException - thrown if IO error occurs.
    • openForUpdate

      public DBHandle openForUpdate(TaskMonitor monitor) throws IOException
      Description copied from class: Database
      Open the stored database for update use.
      Overrides:
      openForUpdate in class Database
      Parameters:
      monitor - task monitor (may be null)
      Returns:
      buffer file
      Throws:
      IOException - thrown if IO error occurs.
    • openBufferFileForUpdate

      public LocalManagedBufferFile openBufferFileForUpdate(long checkoutId) throws IOException
      Open the current version of this database for update use.
      Parameters:
      checkoutId - checkout ID
      Returns:
      updateable buffer file
      Throws:
      IOException - if update not permitted or other error occurs
    • dbMoved

      public void dbMoved(File dbDir) throws FileNotFoundException
      Following a move of the database directory, this method should be invoked if this instance will continue to be used.
      Parameters:
      dbDir - new database directory
      Throws:
      FileNotFoundException
    • scanFiles

      protected void scanFiles(boolean repair) throws FileNotFoundException
      Scan files and update state.
      Overrides:
      scanFiles in class Database
      Parameters:
      repair - if true files are repaired if needed.
      Throws:
      FileNotFoundException
    • output

      public void output(int version, File outputFile, String name, int filetype, String contentType, TaskMonitor monitor) throws IOException, CancelledException
      Output the current version of this database to a packed storage file.
      Parameters:
      outputFile - packed storage file to be written
      name - database name
      filetype - application file type
      contentType - user content type
      monitor -
      Throws:
      IOException
      CancelledException