diff options
| author | Glenn Smith <glenn@vector35.com> | 2022-04-13 22:40:28 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2022-04-13 22:40:28 -0400 |
| commit | 43730ec61dc280d0915a9db0fdbd38bb1cdc8f9a (patch) | |
| tree | 0a7f4cf3296407743949f18b6a6491403de38280 | |
| parent | 91eb7be1f537b15795559ffc62c1ee6ecdcdf412 (diff) | |
Add Database::TrimSnapshot api
| -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) |
