- /*}}}*/
-// PackagesIndex::Merge - Load the index file into a cache /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool debPackagesIndex::Merge(pkgCacheGenerator &Gen,OpProgress &Prog) const
-{
- string PackageFile = IndexFile("Packages");
- FileFd Pkg(PackageFile,FileFd::ReadOnly);
- debListParser Parser(&Pkg);
- if (_error->PendingError() == true)
- return _error->Error("Problem opening %s",PackageFile.c_str());
-
- Prog.SubProgress(0,Info("Packages"));
- ::URI Tmp(URI);
- if (Gen.SelectFile(PackageFile,Tmp.Host,*this) == false)
- return _error->Error("Problem with SelectFile %s",PackageFile.c_str());
-
- // Store the IMS information
- pkgCache::PkgFileIterator File = Gen.GetCurFile();
- struct stat St;
- if (fstat(Pkg.Fd(),&St) != 0)
- return _error->Errno("fstat","Failed to stat");
- File->Size = St.st_size;
- File->mtime = St.st_mtime;
-
- if (Gen.MergeList(Parser) == false)
- return _error->Error("Problem with MergeList %s",PackageFile.c_str());
-
- // Check the release file
- string ReleaseFile = debReleaseIndex(URI,Dist).MetaIndexFile("Release");
- if (FileExists(ReleaseFile) == true)
- {
- FileFd Rel(ReleaseFile,FileFd::ReadOnly);
- if (_error->PendingError() == true)
- return false;
- Parser.LoadReleaseInfo(File,Rel,Section);
- }
-
- return true;
+pkgCacheListParser * debTranslationsIndex::CreateListParser(FileFd &Pkg)
+{
+ if (Pkg.IsOpen() == false)
+ return NULL;
+ _error->PushToStack();
+ pkgCacheListParser * const Parser = new debTranslationsParser(&Pkg);
+ bool const newError = _error->PendingError();
+ _error->MergeWithStack();
+ return newError ? NULL : Parser;