Package ghidra.framework.store.db
Class PackedDatabase
- java.lang.Object
-
- db.Database
-
- ghidra.framework.store.db.PackedDatabase
-
public class PackedDatabase extends Database
PackedDatabaseprovides a packed form of Database which compresses a single version into a file.
When opening a packed database, a PackedDBHandle is returned after first expanding the file into a temporary Database.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class db.Database
Database.DBBufferFileManager
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringREAD_ONLY_DIRECTORY_LOCK_FILEPresence of the directory lock file will prevent the creation or modification of any packed database files contained within that directory or any sub-directory.-
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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidcleanupOldTempDatabases()Attempt to remove all old temporary databases.voiddelete()Deletes the storage file associated with this packed database.static voiddelete(java.io.File packedDbFile)Deletes the storage file associated with this packed database.voiddispose()Free resources consumed by this object.protected voidfinalize()java.lang.StringgetContentType()Returns the user defined content type associated with this database.static PackedDatabasegetPackedDatabase(ResourceFile packedDbFile, boolean neverCache, TaskMonitor monitor)Get a packed database whose unpacking may be cached if possible provided doNotCache is false.static PackedDatabasegetPackedDatabase(java.io.File packedDbFile, boolean neverCache, TaskMonitor monitor)Get a packed database whose unpacking may be cached if possible provided doNotCache is false.static PackedDatabasegetPackedDatabase(java.io.File packedDbFile, TaskMonitor monitor)Get a packed database which whose unpacking will be cached if possibleResourceFilegetPackedFile()Returns the storage file associated with this packed database.booleanisReadOnly()static booleanisReadOnlyPDBDirectory(ResourceFile directory)Check for the presence of directory read-only lockDBHandleopen(TaskMonitor monitor)Open the stored database for non-update use.DBHandleopenForUpdate(TaskMonitor monitor)Open the stored database for update use.static voidpackDatabase(DBHandle dbh, java.lang.String itemName, java.lang.String contentType, java.io.File outputFile, TaskMonitor monitor)Serialize (i.e., pack) an open database into the specified outputFile.static voidunpackDatabase(BufferFileManager bfMgr, long checkinId, java.io.File packedFile, TaskMonitor monitor)Create a new Database with data provided by an ItemDeserializer.-
Methods inherited from class db.Database
deleteDir, getCurrentVersion, lastModified, length, refresh, scanFiles, setSynchronizationObject
-
-
-
-
Field Detail
-
READ_ONLY_DIRECTORY_LOCK_FILE
public static final java.lang.String READ_ONLY_DIRECTORY_LOCK_FILE
Presence of the directory lock file will prevent the creation or modification of any packed database files contained within that directory or any sub-directory.- See Also:
- Constant Field Values
-
-
Method Detail
-
isReadOnly
public boolean isReadOnly()
-
getPackedDatabase
public static PackedDatabase getPackedDatabase(java.io.File packedDbFile, TaskMonitor monitor) throws java.io.IOException, CancelledException
Get a packed database which whose unpacking will be cached if possible- Parameters:
packedDbFile-monitor-- Returns:
- packed database which corresponds to the specified packedDbFile
- Throws:
java.io.IOExceptionCancelledException
-
getPackedDatabase
public static PackedDatabase getPackedDatabase(java.io.File packedDbFile, boolean neverCache, TaskMonitor monitor) throws java.io.IOException, CancelledException
Get a packed database whose unpacking may be cached if possible provided doNotCache is false.- Parameters:
packedDbFile-neverCache- if true unpacking will never be cache.monitor-- Returns:
- packed database which corresponds to the specified packedDbFile
- Throws:
java.io.IOExceptionCancelledException
-
getPackedDatabase
public static PackedDatabase getPackedDatabase(ResourceFile packedDbFile, boolean neverCache, TaskMonitor monitor) throws java.io.IOException, CancelledException
Get a packed database whose unpacking may be cached if possible provided doNotCache is false.- Parameters:
packedDbFile-neverCache- if true unpacking will never be cache.monitor-- Returns:
- packed database which corresponds to the specified packedDbFile
- Throws:
java.io.IOExceptionCancelledException
-
isReadOnlyPDBDirectory
public static boolean isReadOnlyPDBDirectory(ResourceFile directory)
Check for the presence of directory read-only lock- Parameters:
directory-- Returns:
- true if read-only lock exists+
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
dispose
public void dispose()
Free resources consumed by this object. If there is an associated database handle it will be closed.
-
getContentType
public java.lang.String getContentType()
Returns the user defined content type associated with this database.
-
getPackedFile
public ResourceFile getPackedFile()
Returns the storage file associated with this packed database.
-
delete
public void delete() throws java.io.IOExceptionDeletes the storage file associated with this packed database. This method should not be called while the database is open, if it is an attempt will be made to close the handle.- Throws:
java.io.IOException
-
delete
public static void delete(java.io.File packedDbFile) throws java.io.IOExceptionDeletes the storage file associated with this packed database.- Throws:
java.io.IOException
-
unpackDatabase
public static void unpackDatabase(BufferFileManager bfMgr, long checkinId, java.io.File packedFile, TaskMonitor monitor) throws java.io.IOException, CancelledException
Create a new Database with data provided by an ItemDeserializer.- Parameters:
dir- the parent directory which contains the "Hidden" database directory.dbName- the unmangled database namecheckinId-packedFile-monitor-- Throws:
CancelledExceptionjava.io.IOException
-
packDatabase
public static void packDatabase(DBHandle dbh, java.lang.String itemName, java.lang.String contentType, java.io.File outputFile, TaskMonitor monitor) throws CancelledException, java.io.IOException
Serialize (i.e., pack) an open database into the specified outputFile.- Parameters:
dbh- open database handleitemName- item name to associate with packed contentcontentType- supported content typeoutputFile- packed output file to be createdmonitor- progress monitor- Throws:
java.io.IOExceptionCancelledException- if monitor cancels operation
-
open
public DBHandle open(TaskMonitor monitor) throws CancelledException, java.io.IOException
Description copied from class:DatabaseOpen the stored database for non-update use. The returned handle does not support the Save operation.- Overrides:
openin classDatabase- Parameters:
monitor- task monitor (may be null)- Returns:
- database handle
- Throws:
CancelledException- if cancelled by monitorFileInUseException- thrown if unable to obtain the required database lock(s).java.io.IOException- thrown if IO error occurs.
-
openForUpdate
public DBHandle openForUpdate(TaskMonitor monitor) throws CancelledException, java.io.IOException
Description copied from class:DatabaseOpen the stored database for update use.- Overrides:
openForUpdatein classDatabase- Parameters:
monitor- task monitor (may be null)- Returns:
- buffer file
- Throws:
CancelledException- if cancelled by monitorFileInUseException- thrown if unable to obtain the required database lock(s).java.io.IOException- thrown if IO error occurs.
-
cleanupOldTempDatabases
public static void cleanupOldTempDatabases()
Attempt to remove all old temporary databases. Those still open by an existing process should not be removed by the operating system.
-
-