diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 06:14:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 06:14:41 +0000 |
commit | 549a391d6438e828001eeeaf235b080c054a7bf3 (patch) | |
tree | 1bb6b1ea5987fa167a1d13abe82209cc882dd94b /ftparchive/sources.cc | |
parent | Initial commit. (diff) | |
download | apt-549a391d6438e828001eeeaf235b080c054a7bf3.tar.xz apt-549a391d6438e828001eeeaf235b080c054a7bf3.zip |
Adding upstream version 2.2.4.upstream/2.2.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ftparchive/sources.cc')
-rw-r--r-- | ftparchive/sources.cc | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/ftparchive/sources.cc b/ftparchive/sources.cc new file mode 100644 index 0000000..ee6efda --- /dev/null +++ b/ftparchive/sources.cc @@ -0,0 +1,61 @@ +#include <sstream> +#include <string> + +// for memcpy +#include <cstring> + +#include <apt-pkg/error.h> +#include <apt-pkg/fileutl.h> +#include <apt-pkg/gpgv.h> + +#include "sources.h" + +bool DscExtract::TakeDsc(const void *newData, unsigned long long newSize) +{ + if (newSize == 0) + { + // adding two newlines 'off record' for pkgTagSection.Scan() calls + Data = "\n\n"; + Length = 0; + return true; + } + + Data = std::string((const char*)newData, newSize); + // adding two newlines 'off record' for pkgTagSection.Scan() calls + Data.append("\n\n"); + Length = newSize; + + return true; +} + +bool DscExtract::Read(std::string FileName) +{ + Data.clear(); + Length = 0; + + FileFd F; + if (OpenMaybeClearSignedFile(FileName, F) == false) + return false; + + IsClearSigned = (FileName != F.Name()); + + std::ostringstream data; + char buffer[1024]; + do { + unsigned long long actual = 0; + if (F.Read(buffer, sizeof(buffer)-1, &actual) == false) + return _error->Errno("read", "Failed to read dsc file %s", FileName.c_str()); + if (actual == 0) + break; + Length += actual; + buffer[actual] = '\0'; + data << buffer; + } while(true); + + // adding two newlines 'off record' for pkgTagSection.Scan() calls + data << "\n\n"; + Data = data.str(); + return true; +} + + |