diff options
| -rw-r--r-- | binaryninjaapi.h | 1 | ||||
| -rw-r--r-- | binaryninjacore.h | 1 | ||||
| -rw-r--r-- | database.cpp | 9 | ||||
| -rw-r--r-- | python/database.py | 4 |
4 files changed, 15 insertions, 0 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 04cdfd12..95a3a677 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -962,6 +962,7 @@ namespace BinaryNinja { Ref<Snapshot> GetCurrentSnapshot(); int64_t WriteSnapshotData(std::vector<int64_t> parents, Ref<BinaryView> file, const std::string& name, const Ref<KeyValueStore>& data, bool autoSave, const std::function<bool(size_t, size_t)>& progress); + void TrimSnapshot(int64_t id); void RemoveSnapshot(int64_t id); std::vector<std::string> GetGlobalKeys() const; diff --git a/binaryninjacore.h b/binaryninjacore.h index 05eb44fa..32c88fd2 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -2978,6 +2978,7 @@ extern "C" BINARYNINJACOREAPI int64_t BNWriteDatabaseSnapshotData(BNDatabase* database, int64_t* parents, size_t parentCount, BNBinaryView* file, const char* name, BNKeyValueStore* data, bool autoSave, void* ctxt, bool (*progress)(void*, size_t, size_t)); + BINARYNINJACOREAPI bool BNTrimDatabaseSnapshot(BNDatabase* database, int64_t id); BINARYNINJACOREAPI bool BNRemoveDatabaseSnapshot(BNDatabase* database, int64_t id); BINARYNINJACOREAPI char** BNGetDatabaseGlobalKeys(BNDatabase* database, size_t* count); BINARYNINJACOREAPI int BNDatabaseHasGlobal(BNDatabase* database, const char* key); diff --git a/database.cpp b/database.cpp index 0a846f09..326b57f2 100644 --- a/database.cpp +++ b/database.cpp @@ -403,6 +403,15 @@ int64_t Database::WriteSnapshotData(std::vector<int64_t> parents, Ref<BinaryView } +void Database::TrimSnapshot(int64_t id) +{ + if (!BNTrimDatabaseSnapshot(m_object, id)) + { + throw DatabaseException("BNTrimDatabaseSnapshot"); + } +} + + void Database::RemoveSnapshot(int64_t id) { if (!BNRemoveDatabaseSnapshot(m_object, id)) diff --git a/python/database.py b/python/database.py index 84d5979b..f1aefb6a 100644 --- a/python/database.py +++ b/python/database.py @@ -279,6 +279,10 @@ class Database: def current_snapshot(self, value: Snapshot): core.BNSetDatabaseCurrentSnapshot(self.handle, value.id) + def trim_snapshot(self, id: int): + """Trim a snapshot's contents in the database by id, but leave the """ + core.BNRemoveDatabaseSnapshot(self.handle, id) + def remove_snapshot(self, id: int): """Remove a snapshot in the database by id""" core.BNRemoveDatabaseSnapshot(self.handle, id) |
