Package ghidra.framework.store.db
Class PrivateDatabase
java.lang.Object
db.Database
ghidra.framework.store.db.PrivateDatabase
PrivateDatabase
corresponds to a non-versioned database.-
Nested Class Summary
Nested classes/interfaces inherited from class db.Database
Database.DBBufferFileManager
-
Field Summary
Fields 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
ConstructorDescriptionPrivateDatabase
(File dbDir) Constructor for an existing "Non-Versioned" Database.PrivateDatabase
(File dbDir, BufferFile srcFile, boolean resetDatabaseId, TaskMonitor monitor) Construct a new Database from an existing srcFile.PrivateDatabase
(File dbDir, File packedFile, TaskMonitor monitor) Constructs a new Database from an existing packed database file. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns true if recovery data exists which may enable recovery of unsaved changes resulting from a previous crash.static LocalManagedBufferFile
createDatabase
(File dbDir, DBFileListener dbFileListener, int bufferSize) 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.Open the current version of this database for non-update use.Open the current version of this database for update use.void
output
(File outputFile, String name, int filetype, String contentType, TaskMonitor monitor) Output the current version of this database to a packed storage file.void
setIsCheckoutCopy
(boolean state) If this is a checked-out copy and a cumulative change file should be maintained, this method must be invoked following construction.void
If a cumulative change files exists, it will be deleted.void
updateCheckoutCopy
(ManagedBufferFile srcFile, int oldVersion, TaskMonitor monitor) If this is a checked-out copy, replace the buffer file content with that provided by the specified srcFile.void
updateCheckoutFrom
(PrivateDatabase otherDb) Move the content of the otherDb into this database.Methods inherited from class db.Database
deleteDir, getCurrentVersion, lastModified, length, open, openForUpdate, refresh, scanFiles, setSynchronizationObject
-
Constructor Details
-
PrivateDatabase
Constructor for an existing "Non-Versioned" Database.- Parameters:
dbDir
- database directory- Throws:
IOException
-
PrivateDatabase
public PrivateDatabase(File dbDir, BufferFile srcFile, boolean resetDatabaseId, TaskMonitor monitor) throws IOException, CancelledException Construct a new Database from an existing srcFile.- Parameters:
dbDir
-srcFile
-resetDatabaseId
- if true database ID will be reset for new Databasemonitor
-- Throws:
IOException
CancelledException
-
PrivateDatabase
public PrivateDatabase(File dbDir, File packedFile, TaskMonitor monitor) throws IOException, CancelledException Constructs a new Database from an existing packed database file.- Parameters:
dbDir
- private database directorypackedFile
- packed database storage filemonitor
-- Throws:
IOException
CancelledException
-
-
Method Details
-
createDatabase
public static LocalManagedBufferFile createDatabase(File dbDir, DBFileListener dbFileListener, int bufferSize) throws IOException Create a new database and provide the initial buffer file for writing.- Parameters:
dbDir
-bufferSize
-- Returns:
- initial buffer file
- Throws:
IOException
-
setIsCheckoutCopy
public void setIsCheckoutCopy(boolean state) If this is a checked-out copy and a cumulative change file should be maintained, this method must be invoked following construction. -
openBufferFile
Open the current version of this database for non-update use.- Returns:
- buffer file for non-update use
- Throws:
IOException
-
openBufferFileForUpdate
Open the current version of this database for update use.- Returns:
- updateable buffer file
- Throws:
IOException
- if updating this database file is not allowed
-
canRecover
public boolean canRecover()Returns true if recovery data exists which may enable recovery of unsaved changes resulting from a previous crash. -
dbMoved
Following a move of the database directory, this method should be invoked if this instance will continue to be used.- Parameters:
dir
- new database directory- Throws:
FileNotFoundException
- if the database directory cannot be found
-
updateCheckoutCopy
public void updateCheckoutCopy(ManagedBufferFile srcFile, int oldVersion, TaskMonitor monitor) throws CancelledException, IOException If this is a checked-out copy, replace the buffer file content with that provided by the specified srcFile. This Database must be a checkout copy. If a cumulative change files exists, it will be deleted following the update.- Parameters:
srcFile
- open source data buffer file or null if current version is already up-to-date.oldVersion
- older version of srcFile from which this database originated.- Throws:
IOException
CancelledException
-
updateCheckoutCopy
If a cumulative change files exists, it will be deleted.- Throws:
IOException
-
updateCheckoutFrom
Move the content of the otherDb into this database. The otherDb will no longer exist if this method is successful. If already open for update, a save should not be done or the database may become corrupted. All existing handles should be closed and reopened when this method is complete.- Parameters:
otherDb
- the other database.- Throws:
IOException
- if an IO error occurs. An attempt will be made to restore this database to its original state, however the otherDb will not be repaired and may become unusable.
-
output
public void output(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
-