From dc2a99e1159c3951b91935490ec8d2da5fc8e1e7 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Mon, 27 Dec 2021 15:18:11 -0500 Subject: Make various database progress functions cancellable --- filemetadata.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'filemetadata.cpp') diff --git a/filemetadata.cpp b/filemetadata.cpp index a7e2b78f..540151c7 100644 --- a/filemetadata.cpp +++ b/filemetadata.cpp @@ -27,14 +27,14 @@ using namespace std; struct DatabaseProgressCallbackContext { - std::function func; + std::function func; }; -static void DatabaseProgressCallback(void* ctxt, size_t progress, size_t total) +static bool DatabaseProgressCallback(void* ctxt, size_t progress, size_t total) { DatabaseProgressCallbackContext* cb = (DatabaseProgressCallbackContext*)ctxt; - cb->func(progress, total); + return cb->func(progress, total); } @@ -170,7 +170,7 @@ bool FileMetadata::CreateDatabase(const string& name, BinaryView* data, Ref& progressCallback, Ref settings) + const function& progressCallback, Ref settings) { DatabaseProgressCallbackContext cb; cb.func = progressCallback; @@ -188,7 +188,7 @@ Ref FileMetadata::OpenExistingDatabase(const string& path) Ref FileMetadata::OpenExistingDatabase(const string& path, - const function& progressCallback) + const function& progressCallback) { DatabaseProgressCallbackContext cb; cb.func = progressCallback; @@ -215,7 +215,7 @@ bool FileMetadata::SaveAutoSnapshot(BinaryView* data, Ref settings bool FileMetadata::SaveAutoSnapshot(BinaryView* data, - const function& progressCallback, Ref settings) + const function& progressCallback, Ref settings) { DatabaseProgressCallbackContext cb; cb.func = progressCallback; @@ -224,7 +224,7 @@ bool FileMetadata::SaveAutoSnapshot(BinaryView* data, void FileMetadata::GetSnapshotData(Ref data, Ref cache, - const std::function& progress) + const std::function& progress) { DatabaseProgressCallbackContext cb; cb.func = progress; @@ -233,7 +233,7 @@ void FileMetadata::GetSnapshotData(Ref data, Ref c void FileMetadata::ApplySnapshotData(BinaryView* file, Ref data, Ref cache, - const std::function& progress, bool openForConfiguration, bool restoreRawView) + const std::function& progress, bool openForConfiguration, bool restoreRawView) { DatabaseProgressCallbackContext cb; cb.func = progress; @@ -256,7 +256,7 @@ bool FileMetadata::Rebase(BinaryView* data, uint64_t address) } -bool FileMetadata::Rebase(BinaryView* data, uint64_t address, const function& progressCallback) +bool FileMetadata::Rebase(BinaryView* data, uint64_t address, const function& progressCallback) { DatabaseProgressCallbackContext cb; cb.func = progressCallback; @@ -264,7 +264,7 @@ bool FileMetadata::Rebase(BinaryView* data, uint64_t address, const function& progress, std::vector excludedHashes) +MergeResult FileMetadata::MergeUserAnalysis(const std::string& name, const std::function& progress, std::vector excludedHashes) { size_t numHashes = excludedHashes.size(); char** tempList = new char*[numHashes]; -- cgit v1.3.1