Package ghidra.framework.store.db
Class PrivateDatabase
- java.lang.Object
-
- db.Database
-
- ghidra.framework.store.db.PrivateDatabase
-
public class PrivateDatabase extends Database
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
Constructors Constructor Description PrivateDatabase(java.io.File dbDir)
Constructor for an existing "Non-Versioned" Database.PrivateDatabase(java.io.File dbDir, BufferFile srcFile, boolean resetDatabaseId, TaskMonitor monitor)
Construct a new Database from an existing srcFile.PrivateDatabase(java.io.File dbDir, java.io.File packedFile, TaskMonitor monitor)
Constructs a new Database from an existing packed database file.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canRecover()
Returns true if recovery data exists which may enable recovery of unsaved changes resulting from a previous crash.static LocalManagedBufferFile
createDatabase(java.io.File dbDir, DBFileListener dbFileListener, int bufferSize)
Create a new database and provide the initial buffer file for writing.void
dbMoved(java.io.File dir)
Following a move of the database directory, this method should be invoked if this instance will continue to be used.LocalManagedBufferFile
openBufferFile()
Open the current version of this database for non-update use.LocalManagedBufferFile
openBufferFileForUpdate()
Open the current version of this database for update use.void
output(java.io.File outputFile, java.lang.String name, int filetype, java.lang.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
updateCheckoutCopy()
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 Detail
-
PrivateDatabase
public PrivateDatabase(java.io.File dbDir) throws java.io.IOException
Constructor for an existing "Non-Versioned" Database.- Parameters:
dbDir
- database directory- Throws:
java.io.IOException
-
PrivateDatabase
public PrivateDatabase(java.io.File dbDir, BufferFile srcFile, boolean resetDatabaseId, TaskMonitor monitor) throws java.io.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:
java.io.IOException
CancelledException
-
PrivateDatabase
public PrivateDatabase(java.io.File dbDir, java.io.File packedFile, TaskMonitor monitor) throws java.io.IOException, CancelledException
Constructs a new Database from an existing packed database file.- Parameters:
dbDir
- private database directorypackedFile
- packed database storage filemonitor
-- Throws:
java.io.IOException
CancelledException
-
-
Method Detail
-
createDatabase
public static LocalManagedBufferFile createDatabase(java.io.File dbDir, DBFileListener dbFileListener, int bufferSize) throws java.io.IOException
Create a new database and provide the initial buffer file for writing.- Parameters:
dbDir
-bufferSize
-- Returns:
- initial buffer file
- Throws:
java.io.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
public LocalManagedBufferFile openBufferFile() throws java.io.IOException
Open the current version of this database for non-update use.- Returns:
- buffer file for non-update use
- Throws:
java.io.IOException
-
openBufferFileForUpdate
public LocalManagedBufferFile openBufferFileForUpdate() throws java.io.IOException
Open the current version of this database for update use.- Returns:
- updateable buffer file
- Throws:
java.io.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
public void dbMoved(java.io.File dir) throws java.io.FileNotFoundException
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:
java.io.FileNotFoundException
- if the database directory cannot be found
-
updateCheckoutCopy
public void updateCheckoutCopy(ManagedBufferFile srcFile, int oldVersion, TaskMonitor monitor) throws CancelledException, java.io.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:
java.io.IOException
CancelledException
-
updateCheckoutCopy
public void updateCheckoutCopy() throws java.io.IOException
If a cumulative change files exists, it will be deleted.- Throws:
java.io.IOException
-
updateCheckoutFrom
public void updateCheckoutFrom(PrivateDatabase otherDb) throws java.io.IOException
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:
java.io.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(java.io.File outputFile, java.lang.String name, int filetype, java.lang.String contentType, TaskMonitor monitor) throws java.io.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:
java.io.IOException
CancelledException
-
-