Move CommandLine out of fileutils.h

to ProcessArgs and rename the files to commandline.*.
fileutils was a strange place for CommandLine, and this
reduces the dependencies needed for sdktool.

Change-Id: I9d7e8ffe8a3560f5d12934457b086f9446976883
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Eike Ziller
2021-05-11 14:34:56 +02:00
parent 0c8d8c6b2a
commit f18ac508e8
28 changed files with 139 additions and 124 deletions

View File

@@ -27,7 +27,7 @@
#include "savefile.h"
#include "algorithm.h"
#include "processargs.h"
#include "commandline.h"
#include "qtcassert.h"
#include <QDataStream>
@@ -65,76 +65,6 @@ namespace Utils {
static DeviceFileHooks s_deviceHooks;
/*! \class Utils::CommandLine
\brief The CommandLine class represents a command line of a QProcess
or similar utility.
*/
CommandLine::CommandLine() = default;
CommandLine::CommandLine(const QString &executable)
: m_executable(FilePath::fromString(executable))
{}
CommandLine::CommandLine(const FilePath &executable)
: m_executable(executable)
{}
CommandLine::CommandLine(const QString &exe, const QStringList &args)
: CommandLine(FilePath::fromString(exe), args)
{}
CommandLine::CommandLine(const FilePath &exe, const QStringList &args)
: m_executable(exe)
{
addArgs(args);
}
CommandLine::CommandLine(const FilePath &exe, const QString &args, RawType)
: m_executable(exe)
{
addArgs(args, Raw);
}
void CommandLine::addArg(const QString &arg, OsType osType)
{
ProcessArgs::addArg(&m_arguments, arg, osType);
}
void CommandLine::addArgs(const QStringList &inArgs, OsType osType)
{
for (const QString &arg : inArgs)
addArg(arg, osType);
}
// Adds cmd's executable and arguments one by one to this commandline.
// Useful for 'sudo', 'nice', etc
void CommandLine::addArgs(const CommandLine &cmd, OsType osType)
{
addArg(cmd.executable().toString());
addArgs(cmd.splitArguments(osType));
}
void CommandLine::addArgs(const QString &inArgs, RawType)
{
ProcessArgs::addArgs(&m_arguments, inArgs);
}
QString CommandLine::toUserOutput() const
{
QString res = m_executable.toUserOutput();
if (!m_arguments.isEmpty())
res += ' ' + m_arguments;
return res;
}
QStringList CommandLine::splitArguments(OsType osType) const
{
return ProcessArgs::splitArgs(m_arguments, osType);
}
/*! \class Utils::FileUtils
\brief The FileUtils class contains file and directory related convenience