]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/debindexfile.cc
German translation proof read by Helge Kreutzmann
[apt.git] / apt-pkg / deb / debindexfile.cc
index c11efd0aefe690fbf5bfd056e30d3f89fd670291..c55847305ff96c4038c64eae425a6b173f0d28e2 100644 (file)
@@ -30,6 +30,7 @@
 #include <sstream>
 
 #include <sys/stat.h>
+#include <unistd.h>
                                                                        /*}}}*/
 
 // Sources Index                                                       /*{{{*/
@@ -80,7 +81,11 @@ debPackagesIndex::debPackagesIndex(IndexTarget const &Target, bool const Trusted
 std::string debPackagesIndex::ArchiveInfo(pkgCache::VerIterator const &Ver) const
 {
    std::string Res = Target.Description;
-   Res.erase(Target.Description.rfind(' '));
+   {
+      auto const space = Target.Description.rfind(' ');
+      if (space != std::string::npos)
+        Res.erase(space);
+   }
 
    Res += " ";
    Res += Ver.ParentPkg().Name();
@@ -121,12 +126,18 @@ std::string debTranslationsIndex::GetArchitecture() const
 pkgCacheListParser * debTranslationsIndex::CreateListParser(FileFd &Pkg)
 {
    if (Pkg.IsOpen() == false)
-      return NULL;
+      return nullptr;
    _error->PushToStack();
    pkgCacheListParser * const Parser = new debTranslationsParser(&Pkg);
    bool const newError = _error->PendingError();
    _error->MergeWithStack();
-   return newError ? NULL : Parser;
+   if (newError)
+   {
+      delete Parser;
+      return nullptr;
+   }
+   else
+      return Parser;
 }
                                                                        /*}}}*/
 // dpkg/status Index                                                   /*{{{*/
@@ -149,12 +160,18 @@ uint8_t debStatusIndex::GetIndexFlags() const
 pkgCacheListParser * debStatusIndex::CreateListParser(FileFd &Pkg)
 {
    if (Pkg.IsOpen() == false)
-      return NULL;
+      return nullptr;
    _error->PushToStack();
    pkgCacheListParser * const Parser = new debStatusListParser(&Pkg);
    bool const newError = _error->PendingError();
    _error->MergeWithStack();
-   return newError ? NULL : Parser;
+   if (newError)
+   {
+      delete Parser;
+      return nullptr;
+   }
+   else
+      return Parser;
 }
                                                                        /*}}}*/
 // DebPkgFile Index - a single .deb file as an index                   /*{{{*/
@@ -182,7 +199,7 @@ bool debDebPkgFileIndex::GetContent(std::ostream &content, std::string const &de
       return _error->Error("Popen failed");
 
    content << "Filename: " << debfile << "\n";
-   content << "Size: " << Buf.st_size << "\n";
+   content << "Size: " << std::to_string(Buf.st_size) << "\n";
    bool first_line_seen = false;
    char buffer[1024];
    do {
@@ -225,12 +242,18 @@ bool debDebPkgFileIndex::OpenListFile(FileFd &Pkg, std::string const &FileName)
 pkgCacheListParser * debDebPkgFileIndex::CreateListParser(FileFd &Pkg)
 {
    if (Pkg.IsOpen() == false)
-      return NULL;
+      return nullptr;
    _error->PushToStack();
    pkgCacheListParser * const Parser = new debDebFileParser(&Pkg, DebFile);
    bool const newError = _error->PendingError();
    _error->MergeWithStack();
-   return newError ? NULL : Parser;
+   if (newError)
+   {
+      delete Parser;
+      return nullptr;
+   }
+   else
+      return Parser;
 }
 uint8_t debDebPkgFileIndex::GetIndexFlags() const
 {
@@ -297,6 +320,39 @@ std::string debDebianSourceDirIndex::GetComponent() const
    return "local-control";
 }
                                                                        /*}}}*/
+// String Package Index - a string of Packages file content            /*{{{*/
+std::string debStringPackageIndex::GetArchitecture() const
+{
+   return std::string();
+}
+std::string debStringPackageIndex::GetComponent() const
+{
+   return "apt-tmp-index";
+}
+uint8_t debStringPackageIndex::GetIndexFlags() const
+{
+   return pkgCache::Flag::NotSource;
+}
+const pkgIndexFile::Type *debStringPackageIndex::GetType() const
+{
+   return pkgIndexFile::Type::GetType("Debian Package Index");
+}
+debStringPackageIndex::debStringPackageIndex(std::string const &content) :
+   pkgDebianIndexRealFile("", false), d(NULL)
+{
+   char fn[1024];
+   std::string const tempdir = GetTempDir();
+   snprintf(fn, sizeof(fn), "%s/%s.XXXXXX", tempdir.c_str(), "apt-tmp-index");
+   int const fd = mkstemp(fn);
+   File = fn;
+   FileFd::Write(fd, content.data(), content.length());
+   close(fd);
+}
+debStringPackageIndex::~debStringPackageIndex()
+{
+   RemoveFile("~debStringPackageIndex", File);
+}
+                                                                       /*}}}*/
 
 // Index File types for Debian                                         /*{{{*/
 class APT_HIDDEN debIFTypeSrc : public pkgIndexFile::Type