summaryrefslogtreecommitdiff
path: root/ftparchive/sources.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2014-06-12 08:44:13 +0200
committerMichael Vogt <mvo@debian.org>2014-06-12 08:44:13 +0200
commit826c5fa7b541e93928791470e5df9342cb7db5ed (patch)
tree80dbc4356344653e80beeb03e51a6b5eb6e50e01 /ftparchive/sources.cc
parentb2cde5777fd9ab41d1b9fe5ce91196c0d3e8227d (diff)
parentacea28d0a3a55c4df1390c42288043002610fbc9 (diff)
Merge remote-tracking branch 'mvo/feature/apt-ftparchive-srccache2' into ubuntu/trusty
Diffstat (limited to 'ftparchive/sources.cc')
-rw-r--r--ftparchive/sources.cc47
1 files changed, 47 insertions, 0 deletions
diff --git a/ftparchive/sources.cc b/ftparchive/sources.cc
new file mode 100644
index 000000000..d0878a70a
--- /dev/null
+++ b/ftparchive/sources.cc
@@ -0,0 +1,47 @@
+#include <string>
+#include <iostream>
+
+// for memcpy
+#include <cstring>
+
+#include <apt-pkg/error.h>
+#include <apt-pkg/gpgv.h>
+
+#include "sources.h"
+
+bool DscExtract::TakeDsc(const void *newData, unsigned long newSize)
+{
+ if(newSize > maxSize)
+ return _error->Error("DSC data is too large %lu!", newSize);
+
+ if (newSize == 0)
+ {
+ Length = 0;
+ return true;
+ }
+ memcpy(Data, newData, newSize);
+ Length = newSize;
+
+ return true;
+}
+
+bool DscExtract::Read(std::string FileName)
+{
+ FileFd F;
+ if (OpenMaybeClearSignedFile(FileName, F) == false)
+ return false;
+
+ unsigned long long const FSize = F.FileSize();
+ if(FSize > maxSize)
+ return _error->Error("DSC file '%s' is too large!",FileName.c_str());
+
+ if (F.Read(Data, FSize) == false)
+ return false;
+ Length = FSize;
+
+ IsClearSigned = (FileName != F.Name());
+
+ return true;
+}
+
+