Преглед изворни кода

add a special scenario filename for using stdin

David Kalnischkies пре 15 година
родитељ
комит
41ceaf0248
2 измењених фајлова са 14 додато и 3 уклоњено
  1. 5 1
      apt-pkg/edsp/edspindexfile.cc
  2. 9 2
      apt-pkg/edsp/edspsystem.cc

+ 5 - 1
apt-pkg/edsp/edspindexfile.cc

@@ -28,7 +28,11 @@ edspIndex::edspIndex(string File) : debStatusIndex(File)
 // StatusIndex::Merge - Load the index file into a cache		/*{{{*/
 bool edspIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
 {
-   FileFd Pkg(File,FileFd::ReadOnlyGzip);
+   FileFd Pkg;
+   if (File != "stdin")
+      Pkg.Open(File, FileFd::ReadOnly);
+   else
+      Pkg.OpenDescriptor(STDIN_FILENO, FileFd::ReadOnly);
    if (_error->PendingError() == true)
       return false;
    edspListParser Parser(&Pkg);

+ 9 - 2
apt-pkg/edsp/edspsystem.cc

@@ -86,8 +86,10 @@ bool edspSystem::ArchiveSupported(const char *Type)
 // System::Score - Determine if we should use the edsp system		/*{{{*/
 signed edspSystem::Score(Configuration const &Cnf)
 {
+   if (Cnf.Find("Dir::State::universe", "") == "stdin")
+      return 1000;
    if (FileExists(Cnf.FindFile("Dir::State::universe","")) == true)
-       return 1000;
+      return 1000;
    return -1000;
 }
 									/*}}}*/
@@ -95,7 +97,12 @@ signed edspSystem::Score(Configuration const &Cnf)
 bool edspSystem::AddStatusFiles(vector<pkgIndexFile *> &List)
 {
    if (StatusFile == 0)
-      StatusFile = new edspIndex(_config->FindFile("Dir::State::universe"));
+   {
+      if (_config->Find("Dir::State::universe", "") == "stdin")
+	 StatusFile = new edspIndex("stdin");
+      else
+	 StatusFile = new edspIndex(_config->FindFile("Dir::State::universe"));
+   }
    List.push_back(StatusFile);
    return true;
 }