]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/debindexfile.cc
* merged with debian-sid branch
[apt.git] / apt-pkg / deb / debindexfile.cc
index 4113137eb921c6da4f4d13dcb2bff51df3a184fe..38ecdd16af5249adb44f96d124aa48d792f5b430 100644 (file)
@@ -24,7 +24,7 @@
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/acquire-item.h>
 #include <apt-pkg/debmetaindex.h>
-    
+
 #include <sys/stat.h>
                                                                        /*}}}*/
 
@@ -290,7 +290,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;
@@ -358,7 +358,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 +401,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 +435,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 +461,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 +580,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 +597,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 +610,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
 {