X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/a7a5b0d941a8e56a1be2822226a5a81cd94d6ea6..131a2dc0cb36c29d002c2a61f96411e5d84f4adf:/apt-pkg/deb/debindexfile.cc diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc index 4113137eb..38ecdd16a 100644 --- a/apt-pkg/deb/debindexfile.cc +++ b/apt-pkg/deb/debindexfile.cc @@ -24,7 +24,7 @@ #include #include #include - + #include /*}}}*/ @@ -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 {