]> git.saurik.com Git - apt.git/blob - ftparchive/sources.cc
fix typo in SrvRecords documentation
[apt.git] / ftparchive / sources.cc
1 #include <string>
2 #include <sstream>
3
4 // for memcpy
5 #include <cstring>
6
7 #include <apt-pkg/error.h>
8 #include <apt-pkg/gpgv.h>
9
10 #include "sources.h"
11
12 bool DscExtract::TakeDsc(const void *newData, unsigned long long newSize)
13 {
14 if (newSize == 0)
15 {
16 // adding two newlines 'off record' for pkgTagSection.Scan() calls
17 Data = "\n\n";
18 Length = 0;
19 return true;
20 }
21
22 Data = std::string((const char*)newData, newSize);
23 // adding two newlines 'off record' for pkgTagSection.Scan() calls
24 Data.append("\n\n");
25 Length = newSize;
26
27 return true;
28 }
29
30 bool DscExtract::Read(std::string FileName)
31 {
32 Data.clear();
33 Length = 0;
34
35 FileFd F;
36 if (OpenMaybeClearSignedFile(FileName, F) == false)
37 return false;
38
39 IsClearSigned = (FileName != F.Name());
40
41 std::ostringstream data;
42 char buffer[1024];
43 do {
44 unsigned long long actual = 0;
45 if (F.Read(buffer, sizeof(buffer)-1, &actual) == false)
46 return _error->Errno("read", "Failed to read dsc file %s", FileName.c_str());
47 if (actual == 0)
48 break;
49 Length += actual;
50 buffer[actual] = '\0';
51 data << buffer;
52 } while(true);
53
54 // adding two newlines 'off record' for pkgTagSection.Scan() calls
55 data << "\n\n";
56 Data = data.str();
57 return true;
58 }
59
60