forked from qt-creator/qt-creator
Utils: Move CommandLine to fileutils.{cpp,h}
Causes less #include hassle when using downstream instead of command/argument pairs. Change-Id: I0fa0d016374df0b8e0a22f3786623652af684d36 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
|
||||
#include "algorithm.h"
|
||||
#include "qtcassert.h"
|
||||
#include "qtcprocess.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDir>
|
||||
@@ -66,6 +67,33 @@ QT_END_NAMESPACE
|
||||
|
||||
namespace Utils {
|
||||
|
||||
/*! \class Utils::CommandLine
|
||||
|
||||
\brief The CommandLine class represents a command line of a QProcess
|
||||
or similar utility.
|
||||
|
||||
*/
|
||||
|
||||
void CommandLine::addArg(const QString &arg)
|
||||
{
|
||||
QtcProcess::addArg(&m_arguments, arg);
|
||||
}
|
||||
|
||||
void CommandLine::addArgs(const QStringList &inArgs)
|
||||
{
|
||||
QtcProcess::addArgs(&m_arguments, inArgs);
|
||||
}
|
||||
|
||||
void CommandLine::addArgs(const QString &inArgs)
|
||||
{
|
||||
QtcProcess::addArgs(&m_arguments, inArgs);
|
||||
}
|
||||
|
||||
QString CommandLine::toUserOutput() const
|
||||
{
|
||||
return m_executable.toUserOutput() + ' ' + m_arguments;
|
||||
}
|
||||
|
||||
/*! \class Utils::FileUtils
|
||||
|
||||
\brief The FileUtils class contains file and directory related convenience
|
||||
|
@@ -128,6 +128,29 @@ using FilePathList = QList<FilePath>;
|
||||
using FileName = FilePath;
|
||||
using FileNameList = FilePathList;
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT CommandLine
|
||||
{
|
||||
public:
|
||||
CommandLine() {}
|
||||
|
||||
CommandLine(const FilePath &executable, const QString &arguments)
|
||||
: m_executable(executable), m_arguments(arguments)
|
||||
{}
|
||||
|
||||
void addArg(const QString &arg);
|
||||
void addArgs(const QStringList &inArgs);
|
||||
void addArgs(const QString &inArgs);
|
||||
|
||||
QString toUserOutput() const;
|
||||
|
||||
FilePath executable() const { return m_executable; }
|
||||
QString arguments() const { return m_arguments; }
|
||||
|
||||
private:
|
||||
FilePath m_executable;
|
||||
QString m_arguments;
|
||||
};
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT FileUtils {
|
||||
public:
|
||||
static bool removeRecursively(const FilePath &filePath, QString *error = nullptr);
|
||||
|
@@ -1521,24 +1521,4 @@ QString QtcProcess::Arguments::toString() const
|
||||
return QtcProcess::joinArgs(m_unixArgs, OsTypeLinux);
|
||||
}
|
||||
|
||||
void CommandLine::addArg(const QString &arg)
|
||||
{
|
||||
QtcProcess::addArg(&m_arguments, arg);
|
||||
}
|
||||
|
||||
void CommandLine::addArgs(const QStringList &inArgs)
|
||||
{
|
||||
QtcProcess::addArgs(&m_arguments, inArgs);
|
||||
}
|
||||
|
||||
void CommandLine::addArgs(const QString &inArgs)
|
||||
{
|
||||
QtcProcess::addArgs(&m_arguments, inArgs);
|
||||
}
|
||||
|
||||
QString CommandLine::toUserOutput() const
|
||||
{
|
||||
return m_executable.toUserOutput() + ' ' + m_arguments;
|
||||
}
|
||||
|
||||
} // namespace Utils
|
||||
|
@@ -32,29 +32,6 @@
|
||||
namespace Utils {
|
||||
class AbstractMacroExpander;
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT CommandLine
|
||||
{
|
||||
public:
|
||||
CommandLine() {}
|
||||
|
||||
CommandLine(const FilePath &executable, const QString &arguments)
|
||||
: m_executable(executable), m_arguments(arguments)
|
||||
{}
|
||||
|
||||
void addArg(const QString &arg);
|
||||
void addArgs(const QStringList &inArgs);
|
||||
void addArgs(const QString &inArgs);
|
||||
|
||||
QString toUserOutput() const;
|
||||
|
||||
FilePath executable() const { return m_executable; }
|
||||
QString arguments() const { return m_arguments; }
|
||||
|
||||
private:
|
||||
FilePath m_executable;
|
||||
QString m_arguments;
|
||||
};
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT QtcProcess : public QProcess
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@@ -30,10 +30,12 @@ SOURCES += \
|
||||
rmqtoperation.cpp \
|
||||
rmtoolchainoperation.cpp \
|
||||
settings.cpp \
|
||||
$$UTILS/environment.cpp \
|
||||
$$UTILS/fileutils.cpp \
|
||||
$$UTILS/hostosinfo.cpp \
|
||||
$$UTILS/persistentsettings.cpp \
|
||||
$$UTILS/qtcassert.cpp \
|
||||
$$UTILS/qtcprocess.cpp \
|
||||
$$UTILS/savefile.cpp \
|
||||
|
||||
HEADERS += \
|
||||
@@ -57,10 +59,12 @@ HEADERS += \
|
||||
rmqtoperation.h \
|
||||
rmtoolchainoperation.h \
|
||||
settings.h \
|
||||
$$UTILS/environment.h \
|
||||
$$UTILS/fileutils.h \
|
||||
$$UTILS/hostosinfo.h \
|
||||
$$UTILS/persistentsettings.h \
|
||||
$$UTILS/qtcassert.h \
|
||||
$$UTILS/qtcprocess.h \
|
||||
$$UTILS/savefile.h \
|
||||
|
||||
macos {
|
||||
|
@@ -66,10 +66,12 @@ QtcTool {
|
||||
name: "Utils"
|
||||
prefix: libsDir + "/utils/"
|
||||
files: [
|
||||
"environment.cpp", "environment.h",
|
||||
"fileutils.cpp", "fileutils.h",
|
||||
"hostosinfo.cpp", "hostosinfo.h",
|
||||
"persistentsettings.cpp", "persistentsettings.h",
|
||||
"qtcassert.cpp", "qtcassert.h",
|
||||
"qtcprocess.cpp", "qtcprocess.h",
|
||||
"savefile.cpp", "savefile.h"
|
||||
]
|
||||
}
|
||||
|
Reference in New Issue
Block a user