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 "algorithm.h"
|
||||||
#include "qtcassert.h"
|
#include "qtcassert.h"
|
||||||
|
#include "qtcprocess.h"
|
||||||
|
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@@ -66,6 +67,33 @@ QT_END_NAMESPACE
|
|||||||
|
|
||||||
namespace Utils {
|
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
|
/*! \class Utils::FileUtils
|
||||||
|
|
||||||
\brief The FileUtils class contains file and directory related convenience
|
\brief The FileUtils class contains file and directory related convenience
|
||||||
|
@@ -128,6 +128,29 @@ using FilePathList = QList<FilePath>;
|
|||||||
using FileName = FilePath;
|
using FileName = FilePath;
|
||||||
using FileNameList = FilePathList;
|
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 {
|
class QTCREATOR_UTILS_EXPORT FileUtils {
|
||||||
public:
|
public:
|
||||||
static bool removeRecursively(const FilePath &filePath, QString *error = nullptr);
|
static bool removeRecursively(const FilePath &filePath, QString *error = nullptr);
|
||||||
|
@@ -1521,24 +1521,4 @@ QString QtcProcess::Arguments::toString() const
|
|||||||
return QtcProcess::joinArgs(m_unixArgs, OsTypeLinux);
|
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
|
} // namespace Utils
|
||||||
|
@@ -32,29 +32,6 @@
|
|||||||
namespace Utils {
|
namespace Utils {
|
||||||
class AbstractMacroExpander;
|
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
|
class QTCREATOR_UTILS_EXPORT QtcProcess : public QProcess
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@@ -30,10 +30,12 @@ SOURCES += \
|
|||||||
rmqtoperation.cpp \
|
rmqtoperation.cpp \
|
||||||
rmtoolchainoperation.cpp \
|
rmtoolchainoperation.cpp \
|
||||||
settings.cpp \
|
settings.cpp \
|
||||||
|
$$UTILS/environment.cpp \
|
||||||
$$UTILS/fileutils.cpp \
|
$$UTILS/fileutils.cpp \
|
||||||
$$UTILS/hostosinfo.cpp \
|
$$UTILS/hostosinfo.cpp \
|
||||||
$$UTILS/persistentsettings.cpp \
|
$$UTILS/persistentsettings.cpp \
|
||||||
$$UTILS/qtcassert.cpp \
|
$$UTILS/qtcassert.cpp \
|
||||||
|
$$UTILS/qtcprocess.cpp \
|
||||||
$$UTILS/savefile.cpp \
|
$$UTILS/savefile.cpp \
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
@@ -57,10 +59,12 @@ HEADERS += \
|
|||||||
rmqtoperation.h \
|
rmqtoperation.h \
|
||||||
rmtoolchainoperation.h \
|
rmtoolchainoperation.h \
|
||||||
settings.h \
|
settings.h \
|
||||||
|
$$UTILS/environment.h \
|
||||||
$$UTILS/fileutils.h \
|
$$UTILS/fileutils.h \
|
||||||
$$UTILS/hostosinfo.h \
|
$$UTILS/hostosinfo.h \
|
||||||
$$UTILS/persistentsettings.h \
|
$$UTILS/persistentsettings.h \
|
||||||
$$UTILS/qtcassert.h \
|
$$UTILS/qtcassert.h \
|
||||||
|
$$UTILS/qtcprocess.h \
|
||||||
$$UTILS/savefile.h \
|
$$UTILS/savefile.h \
|
||||||
|
|
||||||
macos {
|
macos {
|
||||||
|
@@ -66,10 +66,12 @@ QtcTool {
|
|||||||
name: "Utils"
|
name: "Utils"
|
||||||
prefix: libsDir + "/utils/"
|
prefix: libsDir + "/utils/"
|
||||||
files: [
|
files: [
|
||||||
|
"environment.cpp", "environment.h",
|
||||||
"fileutils.cpp", "fileutils.h",
|
"fileutils.cpp", "fileutils.h",
|
||||||
"hostosinfo.cpp", "hostosinfo.h",
|
"hostosinfo.cpp", "hostosinfo.h",
|
||||||
"persistentsettings.cpp", "persistentsettings.h",
|
"persistentsettings.cpp", "persistentsettings.h",
|
||||||
"qtcassert.cpp", "qtcassert.h",
|
"qtcassert.cpp", "qtcassert.h",
|
||||||
|
"qtcprocess.cpp", "qtcprocess.h",
|
||||||
"savefile.cpp", "savefile.h"
|
"savefile.cpp", "savefile.h"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user