+ else
+ {
+ if (Debug == true)
+ std::clog << "Patching " << Path << " with all " << Path << ".ed.*.gz files and "
+ << "putting result into " << Itm->DestFile << std::endl;
+
+ int From = open(Path.c_str(), O_RDONLY);
+ unlink(Itm->DestFile.c_str());
+ int To = open(Itm->DestFile.c_str(), O_WRONLY | O_CREAT | O_EXCL, 0644);
+ SetCloseExec(From, false);
+ SetCloseExec(To, false);
+
+ _error->PushToStack();
+ std::vector<std::string> patches = GetListOfFilesInDir(flNotFile(Path), "gz", true, false);
+ _error->RevertToStack();
+
+ std::string externalrred = _config->Find("Dir::Bin::rred", "/usr/bin/diffindex-rred");
+ std::vector<const char *> Args;
+ Args.reserve(22);
+ Args.push_back(externalrred.c_str());
+
+ std::string const baseName = Path + ".ed.";
+ for (std::vector<std::string>::const_iterator p = patches.begin();
+ p != patches.end(); ++p)
+ if (p->compare(0, baseName.length(), baseName) == 0)
+ Args.push_back(p->c_str());
+
+ Args.push_back(NULL);
+
+ pid_t Patcher = ExecFork();
+ if (Patcher == 0) {
+ dup2(From, STDIN_FILENO);
+ dup2(To, STDOUT_FILENO);
+
+ execvp(Args[0], (char **) &Args[0]);
+ std::cerr << "Failed to execute patcher " << Args[0] << "!" << std::endl;
+ _exit(100);
+ }
+ // last is NULL, so the one before is the last patch
+ lastPatchName = Args[Args.size() - 2];
+
+ if (ExecWait(Patcher, "rred") == false)
+ return _error->Errno("rred", "Patching via external rred failed");