[Pkg-gnupg-commit] [gpgme] 285/412: Cpp: Provide size-hint for seekable and mem data
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Thu Sep 22 21:27:04 UTC 2016
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository gpgme.
commit df7bbf5a66576a5a320b54c8f6ad52bc84f0e833
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Fri Aug 12 16:51:13 2016 +0200
Cpp: Provide size-hint for seekable and mem data
* lang/cpp/src/data.cpp (GpgME::Data::Data): Set size-hint for
mem and DataProvider based Data.
--
This fixes the case that QGpgME did not have a total value for
progress as the size was unknown.
---
lang/cpp/src/data.cpp | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/lang/cpp/src/data.cpp b/lang/cpp/src/data.cpp
index 64acb47..9527b2f 100644
--- a/lang/cpp/src/data.cpp
+++ b/lang/cpp/src/data.cpp
@@ -62,6 +62,9 @@ GpgME::Data::Data(const char *buffer, size_t size, bool copy)
{
gpgme_data_t data;
const gpgme_error_t e = gpgme_data_new_from_mem(&data, buffer, size, int(copy));
+ std::string sizestr = std::to_string(size);
+ // Ignore errors as this is optional
+ gpgme_data_set_flag(data, "size-hint", sizestr.c_str());
d.reset(new Private(e ? 0 : data));
}
@@ -125,6 +128,13 @@ GpgME::Data::Data(DataProvider *dp)
if (e) {
d->data = 0;
}
+ if (dp->isSupported(DataProvider::Seek)) {
+ off_t size = seek(0, SEEK_END);
+ seek(0, SEEK_SET);
+ std::string sizestr = std::to_string(size);
+ // Ignore errors as this is optional
+ gpgme_data_set_flag(d->data, "size-hint", sizestr.c_str());
+ }
#ifndef NDEBUG
//std::cerr << "GpgME::Data(): DataProvider supports: "
// << ( d->cbs.read ? "read" : "no read" ) << ", "
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gpgme.git
More information about the Pkg-gnupg-commit
mailing list