Package ghidra.framework.store.db
Class VersionedDatabase
java.lang.Object
db.Database
ghidra.framework.store.db.VersionedDatabase
VersionedDatabase
corresponds to a versioned database.-
Nested Class Summary
Nested classes/interfaces inherited from class db.Database
Database.DBBufferFileManager
-
Field Summary
Modifier and TypeFieldDescriptionstatic final long
final int
protected VersionedDBListener
Change listenerFields inherited from class db.Database
bfMgr, CHANGE_FILE_PREFIX, CUMULATIVE_CHANGE_FILENAME, CUMULATIVE_MODMAP_FILENAME, currentVersion, DATABASE_FILE_PREFIX, dbDir, dbDirCreated, dbFileListener, isCheckOutCopy, isVersioned, lastModified, minVersion, syncObject, updateAllowed, VERSION_FILE_PREFIX
-
Constructor Summary
ConstructorDescriptionVersionedDatabase
(File dbDir, BufferFile srcFile, VersionedDBListener verDBListener, long checkoutId, String comment, TaskMonitor monitor) Construct a new "Versioned" Database from an existing srcFile.VersionedDatabase
(File dbDir, VersionedDBListener verDBListener) Constructor for an existing "Versioned" Database.VersionedDatabase
(File dbDir, File packedFile, VersionedDBListener verDBListener, long checkoutId, String comment, TaskMonitor monitor) Construct a new "Versioned" Database from a packed database file -
Method Summary
Modifier and TypeMethodDescriptionstatic LocalManagedBufferFile
createVersionedDatabase
(File dbDir, int bufferSize, VersionedDBListener verDBListener, long checkoutId) Create a new database and provide the initial buffer file for writing.void
Following a move of the database directory, this method should be invoked if this instance will continue to be used.void
Delete latest version.void
Delete oldest version.int
Returns the version number associated with the latest buffer file version.int
Returns the version number associated with the oldest buffer file version.open
(int version, int minChangeDataVer, TaskMonitor monitor) Open a specific version of the stored database for non-update use.openBufferFile
(int version, int minChangeDataVer) Open a specific version of this database for non-update use.openBufferFileForUpdate
(long checkoutId) Open the current version of this database for update use.openForUpdate
(TaskMonitor monitor) Open the stored database for update use.void
output
(int version, File outputFile, String name, int filetype, String contentType, TaskMonitor monitor) Output the current version of this database to a packed storage file.protected void
scanFiles
(boolean repair) Scan files and update state.Methods inherited from class db.Database
deleteDir, lastModified, length, open, refresh, setSynchronizationObject
-
Field Details
-
LATEST_VERSION
public final int LATEST_VERSION- See Also:
-
DEFAULT_CHECKOUT_ID
public static final long DEFAULT_CHECKOUT_ID- See Also:
-
verDBListener
Change listener
-
-
Constructor Details
-
VersionedDatabase
Constructor for an existing "Versioned" Database.- Parameters:
dbDir
- database directoryverDBListener
-- Throws:
IOException
-
VersionedDatabase
public VersionedDatabase(File dbDir, BufferFile srcFile, VersionedDBListener verDBListener, long checkoutId, String comment, TaskMonitor monitor) throws IOException, CancelledException Construct a new "Versioned" Database from an existing srcFile.- Parameters:
dbDir
-srcFile
-monitor
-- Throws:
IOException
CancelledException
-
VersionedDatabase
public VersionedDatabase(File dbDir, File packedFile, VersionedDBListener verDBListener, long checkoutId, String comment, TaskMonitor monitor) throws IOException, CancelledException Construct a new "Versioned" Database from a packed database file- Parameters:
dbDir
-packedFile
-verDBListener
-checkoutId
-comment
-monitor
-- Throws:
IOException
CancelledException
-
-
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 classDatabase
-
deleteMinimumVersion
Delete oldest version.- Throws:
IOException
- if an error occurs or this is the only version.
-
deleteCurrentVersion
Delete latest version.- Throws:
IOException
- if an error occurs or this is the only version.
-
openBufferFile
Open a specific version of this database for non-update use.- Parameters:
version
- database version or LATEST_VERSION for current versionminChangeDataVer
- 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
Open a specific version of the stored database for non-update use. The returned handle does not support the Save operation.- Parameters:
version
- database versionmonitor
- 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
Description copied from class:Database
Open the stored database for update use.- Overrides:
openForUpdate
in classDatabase
- Parameters:
monitor
- task monitor (may be null)- Returns:
- buffer file
- Throws:
IOException
- thrown if IO error occurs.
-
openBufferFileForUpdate
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
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
Scan files and update state.- Overrides:
scanFiles
in classDatabase
- 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 writtenname
- database namefiletype
- application file typecontentType
- user content typemonitor
-- Throws:
IOException
CancelledException
-