OutStatusFd = progress_fd;
}
+void PackageManagerProgressFd::WriteToStatusFd(std::string s)
+{
+ if(OutStatusFd <= 0)
+ return;
+ FileFd::Write(OutStatusFd, s.c_str(), s.size());
+}
+
void PackageManagerProgressFd::Started()
{
_config->Set("APT::Keep-Fds::", OutStatusFd);
// send status information that we are about to fork dpkg
- if(OutStatusFd > 0) {
- std::ostringstream status;
- status << "pmstatus:dpkg-exec:"
- << (StepsDone/float(StepsTotal)*100.0)
- << ":" << _("Running dpkg")
- << std::endl;
- FileFd::Write(OutStatusFd, status.str().c_str(), status.str().size());
- }
+ std::ostringstream status;
+ status << "pmstatus:dpkg-exec:"
+ << (StepsDone/float(StepsTotal)*100.0)
+ << ":" << _("Running dpkg")
+ << std::endl;
+ WriteToStatusFd(status.str());
}
void PackageManagerProgressFd::Finished()
<< ":" << (StepsDone/float(TotalSteps)*100.0)
<< ":" << ErrorMessage
<< std::endl;
- if(OutStatusFd > 0)
- FileFd::Write(OutStatusFd, status.str().c_str(), status.str().size());
+ WriteToStatusFd(status.str());
}
void PackageManagerProgressFd::ConffilePrompt(std::string PackageName,
<< ":" << (StepsDone/float(TotalSteps)*100.0)
<< ":" << ConfMessage
<< std::endl;
- if(OutStatusFd > 0)
- FileFd::Write(OutStatusFd, status.str().c_str(), status.str().size());
+ WriteToStatusFd(status.str());
}
<< ":" << (StepsDone/float(StepsTotal)*100.0)
<< ":" << pkg_action
<< std::endl;
- if(OutStatusFd > 0)
- FileFd::Write(OutStatusFd, status.str().c_str(), status.str().size());
+ WriteToStatusFd(status.str());
return true;
}