1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
3 | |
4 | #ifndef IOUTILS_H |
5 | #define IOUTILS_H |
6 | |
7 | #include "qmake_global.h" |
8 | |
9 | #include <qstring.h> |
10 | |
11 | QT_BEGIN_NAMESPACE |
12 | |
13 | namespace QMakeInternal { |
14 | |
15 | /*! |
16 | This class provides replacement functionality for QFileInfo, QFile & QDir, |
17 | as these are abysmally slow. |
18 | */ |
19 | class QMAKE_EXPORT IoUtils { |
20 | public: |
21 | enum FileType { |
22 | FileNotFound = 0, |
23 | FileIsRegular = 1, |
24 | FileIsDir = 2 |
25 | }; |
26 | |
27 | static QString binaryAbsLocation(const QString &argv0); |
28 | static FileType fileType(const QString &fileName); |
29 | static bool exists(const QString &fileName) { return fileType(fileName) != FileNotFound; } |
30 | static bool isRelativePath(const QString &fileName); |
31 | static bool isAbsolutePath(const QString &fileName) { return !isRelativePath(fileName); } |
32 | static QStringView pathName(const QString &fileName); // Requires normalized path |
33 | static QStringView fileName(const QString &fileName); // Requires normalized path |
34 | static QString resolvePath(const QString &baseDir, const QString &fileName); |
35 | static QString shellQuoteUnix(const QString &arg); |
36 | static QString shellQuoteWin(const QString &arg); |
37 | static QString shellQuote(const QString &arg) |
38 | #ifdef Q_OS_UNIX |
39 | { return shellQuoteUnix(arg); } |
40 | #else |
41 | { return shellQuoteWin(arg); } |
42 | #endif |
43 | #if defined(PROEVALUATOR_FULL) |
44 | static bool touchFile(const QString &targetFileName, const QString &referenceFileName, QString *errorString); |
45 | # if defined(QT_BUILD_QMAKE) && defined(Q_OS_UNIX) |
46 | static bool readLinkTarget(const QString &symlinkPath, QString *target); |
47 | # endif |
48 | #endif |
49 | }; |
50 | |
51 | } // namespace ProFileEvaluatorInternal |
52 | |
53 | QT_END_NAMESPACE |
54 | |
55 | #endif // IOUTILS_H |
56 | |