Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
utils.cpp File Reference
#include "utils.h"
#include "elfreader.h"
#include <QtCore/QString>
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QTemporaryFile>
#include <QtCore/QScopedPointer>
#include <QtCore/QScopedArrayPointer>
#include <QtCore/QStandardPaths>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
+ Include dependency graph for utils.cpp:

Go to the source code of this file.

Functions

bool isBuildDirectory (Platform platform, const QString &dirName)
 
bool createSymbolicLink (const QFileInfo &source, const QString &target, QString *errorMessage)
 
bool createDirectory (const QString &directory, QString *errorMessage, bool dryRun)
 
QStringList findSharedLibraries (const QDir &directory, Platform platform, DebugMatchMode debugMatchMode, const QString &prefix)
 
static char * encodeFileName (const QString &f)
 
static char * tempFilePattern ()
 
static QByteArray readOutRedirectFile (int fd)
 
bool runProcess (const QString &binary, const QStringList &args, const QString &workingDirectory, unsigned long *exitCode, QByteArray *stdOut, QByteArray *stdErr, QString *errorMessage)
 
QString findInPath (const QString &file)
 
QMap< QString, QStringqueryQtPaths (const QString &qtpathsBinary, QString *errorMessage)
 
bool updateFile (const QString &sourceFileName, const QStringList &nameFilters, const QString &targetDirectory, unsigned flags, JsonOutput *json, QString *errorMessage)
 
bool readElfExecutable (const QString &elfExecutableFileName, QString *errorMessage, QStringList *dependentLibraries, unsigned *wordSize, bool *isDebug)
 
bool readPeExecutable (const QString &, QString *errorMessage, QStringList *, unsigned *, bool *, bool, unsigned short *)
 
QString findD3dCompiler (Platform, const QString &, unsigned)
 
QStringList findDxc (Platform, const QString &, unsigned)
 
bool patchQtCore (const QString &path, QString *errorMessage)
 

Variables

int optVerboseLevel = 1
 
const char * qmakeInfixKey = "QT_INFIX"
 

Function Documentation

◆ createDirectory()

bool createDirectory ( const QString directory,
QString errorMessage,
bool  dryRun 
)

Definition at line 65 of file utils.cpp.

References QString::arg(), arg, dir, directory, errorMessage(), QFileInfo::exists(), fi, QString::fromLatin1(), QFileInfo::isDir(), optVerboseLevel, and QDir::toNativeSeparators().

Referenced by deploy(), deployWebEngineCore(), and main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createSymbolicLink()

bool createSymbolicLink ( const QFileInfo source,
const QString target,
QString errorMessage 
)

Definition at line 46 of file utils.cpp.

References QString::arg(), QDir::currentPath(), errorMessage(), QIODevice::errorString(), file, QString::fromLatin1(), QFile::link(), QStringLiteral, QDir::setCurrent(), and QDir::toNativeSeparators().

Referenced by updateFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ encodeFileName()

static char * encodeFileName ( const QString f)
inlinestatic

Definition at line 275 of file utils.cpp.

References QByteArray::constData(), encoded, QFile::encodeName(), and QByteArray::size().

Referenced by runProcess(), and tempFilePattern().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findD3dCompiler()

QString findD3dCompiler ( Platform  platform,
const QString qtBinDir,
unsigned  wordSize 
)

Definition at line 955 of file utils.cpp.

Referenced by deploy().

+ Here is the caller graph for this function:

◆ findDxc()

QStringList findDxc ( Platform  platform,
const QString qtBinDir,
unsigned  wordSize 
)

Definition at line 960 of file utils.cpp.

Referenced by deploy().

+ Here is the caller graph for this function:

◆ findInPath()

QString findInPath ( const QString file)

Definition at line 406 of file utils.cpp.

References QDir::cleanPath(), file, QStandardPaths::findExecutable(), QString::fromWCharArray(), MAX_PATH, and QFile::size().

+ Here is the call graph for this function:

◆ findSharedLibraries()

QStringList findSharedLibraries ( const QDir directory,
Platform  platform,
DebugMatchMode  debugMatchMode,
const QString prefix 
)

Definition at line 89 of file utils.cpp.

References directory, errorMessage(), QDir::Files, QString::isEmpty(), MatchDebug, MatchDebugOrRelease, matches(), platform(), platformHasDebugSuffix(), readPeExecutable(), sharedLibrarySuffix(), QDir::toNativeSeparators(), WindowsBased, and WindowsDesktopMinGW.

Referenced by findFileRecursion(), findQtPlugins(), DllDirectoryFileEntryFunction::operator()(), and parseArguments().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isBuildDirectory()

bool isBuildDirectory ( Platform  platform,
const QString dirName 
)

Definition at line 38 of file utils.cpp.

References ClangMsvc, Msvc, and platform().

Referenced by findQmlDirectory(), and qmlDirectoryRecursion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ patchQtCore()

bool patchQtCore ( const QString path,
QString errorMessage 
)

Definition at line 968 of file utils.cpp.

References QString::arg(), QFileDevice::close(), errorMessage(), QIODevice::errorString(), file, QFileInfo::fileName(), QString::fromLatin1(), QByteArray::indexOf(), QByteArray::isEmpty(), QByteArray::length(), QFile::open(), optVerboseLevel, QIODevice::readAll(), QIODeviceBase::ReadOnly, QByteArray::replace(), QByteArray::size(), QDir::toNativeSeparators(), QIODevice::write(), and QIODeviceBase::WriteOnly.

Referenced by deploy().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ queryQtPaths()

QMap< QString, QString > queryQtPaths ( const QString qtpathsBinary,
QString errorMessage 
)

Definition at line 424 of file utils.cpp.

References errorMessage(), QIODevice::errorString(), QFile::fileName(), QString::fromLocal8Bit(), QString::fromUtf8(), QString::indexOf(), QString::isEmpty(), line, QString::number(), QFile::open(), output, pos, qmakeInfixKey, QStringLiteral, QIODevice::readLine(), QIODeviceBase::ReadOnly, QString::remove(), QString::right(), runProcess(), QString::size(), QString::startsWith(), QIODeviceBase::Text, QDir::toNativeSeparators(), and QString::trimmed().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readElfExecutable()

bool readElfExecutable ( const QString elfExecutableFileName,
QString errorMessage,
QStringList dependentLibraries,
unsigned *  wordSize,
bool *  isDebug 
)

Definition at line 556 of file utils.cpp.

References ElfReader::dependencies(), Elf_ELFCLASS64, errorMessage(), ElfReader::errorString(), QString::fromLocal8Bit(), QList< T >::isEmpty(), NoSymbols, QStringLiteral, ElfReader::readHeaders(), QDir::toNativeSeparators(), and UnknownSymbols.

Referenced by readExecutable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readOutRedirectFile()

static QByteArray readOutRedirectFile ( int  fd)
inlinestatic

Definition at line 292 of file utils.cpp.

References read().

Referenced by runProcess().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readPeExecutable()

bool readPeExecutable ( const QString peExecutableFileName,
QString errorMessage,
QStringList dependentLibraries,
unsigned *  wordSize,
bool *  isDebug,
bool  isMinGW,
unsigned short *  machineArch 
)

Definition at line 948 of file utils.cpp.

References errorMessage(), and QStringLiteral.

Referenced by findSharedLibraries(), and readExecutable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ runProcess()

bool runProcess ( const QString binary,
const QStringList args,
const QString workingDirectory,
unsigned long *  exitCode,
QByteArray stdOut,
QByteArray stdErr,
QString errorMessage 
)

Definition at line 312 of file utils.cpp.

References args, QScopedPointer< T, Cleanup >::data(), encodeFileName(), errorMessage(), QString::fromLocal8Bit(), QString::isEmpty(), QStringLiteral, readOutRedirectFile(), QScopedPointer< T, Cleanup >::reset(), QDir::setCurrent(), QList< T >::size(), and tempFilePattern().

Referenced by deployTranslations(), queryQtPaths(), and runQmlImportScanner().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tempFilePattern()

static char * tempFilePattern ( )
inlinestatic

Definition at line 283 of file utils.cpp.

References encodeFileName(), QStringLiteral, and QDir::tempPath().

Referenced by createTemporaryItemCopy(), and runProcess().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateFile()

bool updateFile ( const QString sourceFileName,
const QStringList nameFilters,
const QString targetDirectory,
unsigned  flags,
JsonOutput json,
QString errorMessage 
)

Definition at line 476 of file utils.cpp.

References JsonOutput::addFile(), QString::arg(), QFile::copy(), d, dir, QDir::Dirs, errorMessage(), QIODevice::errorString(), QFileInfo::exists(), file, QFileInfo::fileName(), QDir::Files, ForceUpdateFile, QString::fromLatin1(), QFileInfo::isDir(), QFileInfo::isSymLink(), QFileInfo::lastModified(), QDir::NoDotAndDotDot, optVerboseLevel, QFile::remove(), SkipUpdateFile, QDir::toNativeSeparators(), and updateFile().

Referenced by updateFile(), updateFile(), and updateFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ optVerboseLevel

◆ qmakeInfixKey

const char* qmakeInfixKey = "QT_INFIX"

Definition at line 422 of file utils.cpp.

Referenced by deploy(), and queryQtPaths().