summaryrefslogtreecommitdiff
path: root/ftparchive/sources.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@ubuntu.com>2014-04-04 14:30:17 +0200
committerMichael Vogt <mvo@ubuntu.com>2014-04-04 14:30:17 +0200
commitce928105d7279c5604f034740b04dc6a745fb859 (patch)
treef31261fdbbae13f1b40f99cf42a1d79d677098a7 /ftparchive/sources.cc
parent62f1ee1cc7a5e16ca0cbfbee3c00cefab1892f87 (diff)
Implement CacheDB for source packages in apt-ftparchive
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;
+}
+
+