[libcalamares] Make API more type-explicit with std::chrono

- Having an int timeoutSec is suggestive -- it's probably a number
   of seconds -- but having an explicit type that says it's seconds
   is better.
 - Doesn't compile, because the implementation and consumers have
   not changed.
main
Adriaan de Groot
parent e2aa4e59e2
commit 938b1ac4aa

@ -27,6 +27,8 @@
#include <QPair> #include <QPair>
#include <QString> #include <QString>
#include <chrono>
namespace CalamaresUtils namespace CalamaresUtils
{ {
class ProcessResult : public QPair< int, QString > class ProcessResult : public QPair< int, QString >
@ -138,7 +140,7 @@ public:
const QStringList &args, const QStringList &args,
const QString& workingPath = QString(), const QString& workingPath = QString(),
const QString& stdInput = QString(), const QString& stdInput = QString(),
int timeoutSec = 0 ); std::chrono::seconds timeoutSec = std::chrono::seconds(0) );
/** @brief Convenience wrapper for runCommand(). /** @brief Convenience wrapper for runCommand().
* Runs the command in the location specified through the boolean * Runs the command in the location specified through the boolean
@ -149,7 +151,7 @@ public:
const QStringList &args, const QStringList &args,
const QString& workingPath = QString(), const QString& workingPath = QString(),
const QString& stdInput = QString(), const QString& stdInput = QString(),
int timeoutSec = 0 ) std::chrono::seconds timeoutSec = std::chrono::seconds(0) )
{ {
return runCommand( return runCommand(
m_doChroot ? RunLocation::RunInTarget : RunLocation::RunInHost, m_doChroot ? RunLocation::RunInTarget : RunLocation::RunInHost,
@ -163,7 +165,7 @@ public:
inline int targetEnvCall( const QStringList& args, inline int targetEnvCall( const QStringList& args,
const QString& workingPath = QString(), const QString& workingPath = QString(),
const QString& stdInput = QString(), const QString& stdInput = QString(),
int timeoutSec = 0 ) std::chrono::seconds timeoutSec = std::chrono::seconds(0) )
{ {
return targetEnvCommand( args, workingPath, stdInput, timeoutSec ).first; return targetEnvCommand( args, workingPath, stdInput, timeoutSec ).first;
} }
@ -172,7 +174,7 @@ public:
inline int targetEnvCall( const QString& command, inline int targetEnvCall( const QString& command,
const QString& workingPath = QString(), const QString& workingPath = QString(),
const QString& stdInput = QString(), const QString& stdInput = QString(),
int timeoutSec = 0 ) std::chrono::seconds timeoutSec = std::chrono::seconds(0) )
{ {
return targetEnvCall( QStringList{ command }, workingPath, stdInput, timeoutSec ); return targetEnvCall( QStringList{ command }, workingPath, stdInput, timeoutSec );
} }
@ -185,7 +187,7 @@ public:
QString& output, QString& output,
const QString& workingPath = QString(), const QString& workingPath = QString(),
const QString& stdInput = QString(), const QString& stdInput = QString(),
int timeoutSec = 0 ) std::chrono::seconds timeoutSec = std::chrono::seconds(0) )
{ {
auto r = targetEnvCommand( args, workingPath, stdInput, timeoutSec ); auto r = targetEnvCommand( args, workingPath, stdInput, timeoutSec );
output = r.second; output = r.second;
@ -200,7 +202,7 @@ public:
QString& output, QString& output,
const QString& workingPath = QString(), const QString& workingPath = QString(),
const QString& stdInput = QString(), const QString& stdInput = QString(),
int timeoutSec = 0 ) std::chrono::seconds timeoutSec = std::chrono::seconds(0) )
{ {
return targetEnvOutput( QStringList{ command }, output, workingPath, stdInput, timeoutSec ); return targetEnvOutput( QStringList{ command }, output, workingPath, stdInput, timeoutSec );
} }

Loading…
Cancel
Save