* Removed the more leftover #pragma interface/implementation
[ntk/apt.git] / apt-pkg / deb / debindexfile.cc
index 4113137..ed76338 100644 (file)
@@ -9,10 +9,6 @@
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/debindexfile.h"
-#endif
-
 #include <apt-pkg/debindexfile.h>
 #include <apt-pkg/debsrcrecords.h>
 #include <apt-pkg/deblistparser.h>
@@ -24,7 +20,7 @@
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/acquire-item.h>
 #include <apt-pkg/debmetaindex.h>
-    
+
 #include <sys/stat.h>
                                                                        /*}}}*/
 
@@ -290,7 +286,7 @@ bool debPackagesIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
       FileFd Rel(ReleaseFile,FileFd::ReadOnly);
       if (_error->PendingError() == true)
         return false;
-      Parser.LoadReleaseInfo(File,Rel);
+      Parser.LoadReleaseInfo(File,Rel,Section);
    }
    
    return true;
@@ -305,7 +301,7 @@ pkgCache::PkgFileIterator debPackagesIndex::FindInCache(pkgCache &Cache) const
    pkgCache::PkgFileIterator File = Cache.FileBegin();
    for (; File.end() == false; File++)
    {
-      if (FileName != File.FileName())
+       if (File.FileName() == NULL || FileName != File.FileName())
         continue;
       
       struct stat St;
@@ -358,7 +354,7 @@ string debTranslationsIndex::IndexURI(const char *Type) const
 /* */
 bool debTranslationsIndex::GetIndexes(pkgAcquire *Owner) const
 {
-   if (UseTranslation()) {
+   if (TranslationsAvailable()) {
      string TranslationFile = "Translation-" + LanguageCode();
      new pkgAcqIndexTrans(Owner, IndexURI(LanguageCode().c_str()),
                          Info(TranslationFile.c_str()),
@@ -401,12 +397,20 @@ string debTranslationsIndex::Info(const char *Type) const
    return Info;
 }
                                                                        /*}}}*/
+bool debTranslationsIndex::HasPackages() const
+{
+   if(!TranslationsAvailable())
+      return false;
+   
+   return FileExists(IndexFile(LanguageCode().c_str()));
+}
+
 // TranslationsIndex::Exists - Check if the index is available         /*{{{*/
 // ---------------------------------------------------------------------
 /* */
 bool debTranslationsIndex::Exists() const
 {
-   return true;
+   return FileExists(IndexFile(LanguageCode().c_str()));
 }
                                                                        /*}}}*/
 // TranslationsIndex::Size - Return the size of the index              /*{{{*/
@@ -427,7 +431,7 @@ bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
 {
    // Check the translation file, if in use
    string TranslationFile = IndexFile(LanguageCode().c_str());
-   if (UseTranslation() && FileExists(TranslationFile))
+   if (TranslationsAvailable() && FileExists(TranslationFile))
    {
      FileFd Trans(TranslationFile,FileFd::ReadOnly);
      debListParser TransParser(&Trans);
@@ -453,7 +457,29 @@ bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
    return true;
 }
                                                                        /*}}}*/
+// TranslationsIndex::FindInCache - Find this index                            /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+pkgCache::PkgFileIterator debTranslationsIndex::FindInCache(pkgCache &Cache) const
+{
+   string FileName = IndexFile(LanguageCode().c_str());
+   
+   pkgCache::PkgFileIterator File = Cache.FileBegin();
+   for (; File.end() == false; File++)
+   {
+      if (FileName != File.FileName())
+        continue;
 
+      struct stat St;
+      if (stat(File.FileName(),&St) != 0)
+        return pkgCache::PkgFileIterator(Cache);
+      if ((unsigned)St.st_size != File->Size || St.st_mtime != File->mtime)
+        return pkgCache::PkgFileIterator(Cache);
+      return File;
+   }   
+   return File;
+}
+                                                                       /*}}}*/
 // StatusIndex::debStatusIndex - Constructor                           /*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -550,6 +576,11 @@ class debIFTypePkg : public pkgIndexFile::Type
    };
    debIFTypePkg() {Label = "Debian Package Index";};
 };
+class debIFTypeTrans : public debIFTypePkg
+{
+   public:
+   debIFTypeTrans() {Label = "Debian Translation Index";};
+};
 class debIFTypeStatus : public pkgIndexFile::Type
 {
    public:
@@ -562,6 +593,7 @@ class debIFTypeStatus : public pkgIndexFile::Type
 };
 static debIFTypeSrc _apt_Src;
 static debIFTypePkg _apt_Pkg;
+static debIFTypeTrans _apt_Trans;
 static debIFTypeStatus _apt_Status;
 
 const pkgIndexFile::Type *debSourcesIndex::GetType() const
@@ -574,7 +606,7 @@ const pkgIndexFile::Type *debPackagesIndex::GetType() const
 }
 const pkgIndexFile::Type *debTranslationsIndex::GetType() const
 {
-   return &_apt_Pkg;
+   return &_apt_Trans;
 }
 const pkgIndexFile::Type *debStatusIndex::GetType() const
 {