+ content << "Filename: " << debfile << "\n";
+ content << "Size: " << std::to_string(Buf.st_size) << "\n";
+ bool first_line_seen = false;
+ char buffer[1024];
+ do {
+ unsigned long long actual = 0;
+ if (PipeFd.Read(buffer, sizeof(buffer)-1, &actual) == false)
+ return _error->Errno("read", "Failed to read dpkg pipe");
+ if (actual == 0)
+ break;
+ buffer[actual] = '\0';
+ char const * b = buffer;
+ if (first_line_seen == false)
+ {
+ for (; *b != '\0' && (*b == '\n' || *b == '\r'); ++b)
+ /* skip over leading newlines */;
+ if (*b == '\0')
+ continue;
+ first_line_seen = true;
+ }
+ content << b;
+ } while(true);
+ ExecWait(Child, "Popen");
+
+ return true;
+}
+bool debDebPkgFileIndex::OpenListFile(FileFd &Pkg, std::string const &FileName)
+{
+ // write the control data to a tempfile
+ if (GetTempFile("deb-file-" + flNotDir(FileName), true, &Pkg) == NULL)
+ return false;
+ std::ostringstream content;
+ if (GetContent(content, FileName) == false)
+ return false;
+ std::string const contentstr = content.str();
+ if (contentstr.empty())
+ return true;
+ if (Pkg.Write(contentstr.c_str(), contentstr.length()) == false || Pkg.Seek(0) == false)
+ return false;
+ return true;
+}
+pkgCacheListParser * debDebPkgFileIndex::CreateListParser(FileFd &Pkg)
+{
+ if (Pkg.IsOpen() == false)
+ return nullptr;
+ _error->PushToStack();
+ pkgCacheListParser * const Parser = new debDebFileParser(&Pkg, DebFile);
+ bool const newError = _error->PendingError();
+ _error->MergeWithStack();
+ if (newError)