QFile/QFileInfo: mark readLink() as deprecated
QFile/QFileInfo::readLink() functions are obsolete but were not marked as deprecated. Explicit mark them as deprecated so they can be removed with Qt6. Change-Id: I52424dc5441e1f5b01015713df990bbec5186caa Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
This commit is contained in:
parent
5eab68bbee
commit
7c69f6171d
@ -1190,7 +1190,7 @@ bool QMakeEvaluator::loadSpecInternal()
|
|||||||
# ifdef Q_OS_UNIX
|
# ifdef Q_OS_UNIX
|
||||||
if (m_qmakespec.endsWith(QLatin1String("/default-host"))
|
if (m_qmakespec.endsWith(QLatin1String("/default-host"))
|
||||||
|| m_qmakespec.endsWith(QLatin1String("/default"))) {
|
|| m_qmakespec.endsWith(QLatin1String("/default"))) {
|
||||||
QString rspec = QFileInfo(m_qmakespec).readLink();
|
QString rspec = QFileInfo(m_qmakespec).symLinkTarget();
|
||||||
if (!rspec.isEmpty())
|
if (!rspec.isEmpty())
|
||||||
m_qmakespec = QDir::cleanPath(QDir(m_qmakespec).absoluteFilePath(rspec));
|
m_qmakespec = QDir::cleanPath(QDir(m_qmakespec).absoluteFilePath(rspec));
|
||||||
}
|
}
|
||||||
|
@ -454,7 +454,13 @@ QFile::exists(const QString &fileName)
|
|||||||
|
|
||||||
\sa fileName(), setFileName()
|
\sa fileName(), setFileName()
|
||||||
*/
|
*/
|
||||||
|
QString QFile::symLinkTarget() const
|
||||||
|
{
|
||||||
|
Q_D(const QFile);
|
||||||
|
return d->engine()->fileName(QAbstractFileEngine::LinkName);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(5, 13)
|
||||||
/*!
|
/*!
|
||||||
\obsolete
|
\obsolete
|
||||||
|
|
||||||
@ -463,9 +469,9 @@ QFile::exists(const QString &fileName)
|
|||||||
QString
|
QString
|
||||||
QFile::readLink() const
|
QFile::readLink() const
|
||||||
{
|
{
|
||||||
Q_D(const QFile);
|
return symLinkTarget();
|
||||||
return d->engine()->fileName(QAbstractFileEngine::LinkName);
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn static QString QFile::symLinkTarget(const QString &fileName)
|
\fn static QString QFile::symLinkTarget(const QString &fileName)
|
||||||
@ -478,7 +484,12 @@ QFile::readLink() const
|
|||||||
This name may not represent an existing file; it is only a string.
|
This name may not represent an existing file; it is only a string.
|
||||||
QFile::exists() returns \c true if the symlink points to an existing file.
|
QFile::exists() returns \c true if the symlink points to an existing file.
|
||||||
*/
|
*/
|
||||||
|
QString QFile::symLinkTarget(const QString &fileName)
|
||||||
|
{
|
||||||
|
return QFileInfo(fileName).symLinkTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(5, 13)
|
||||||
/*!
|
/*!
|
||||||
\obsolete
|
\obsolete
|
||||||
|
|
||||||
@ -487,8 +498,9 @@ QFile::readLink() const
|
|||||||
QString
|
QString
|
||||||
QFile::readLink(const QString &fileName)
|
QFile::readLink(const QString &fileName)
|
||||||
{
|
{
|
||||||
return QFileInfo(fileName).readLink();
|
return symLinkTarget(fileName);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Removes the file specified by fileName(). Returns \c true if successful;
|
Removes the file specified by fileName(). Returns \c true if successful;
|
||||||
|
@ -107,10 +107,14 @@ public:
|
|||||||
bool exists() const;
|
bool exists() const;
|
||||||
static bool exists(const QString &fileName);
|
static bool exists(const QString &fileName);
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(5, 13)
|
||||||
|
QT_DEPRECATED_X("Use QFile::symLinkTarget() instead")
|
||||||
QString readLink() const;
|
QString readLink() const;
|
||||||
|
QT_DEPRECATED_X("Use QFile::symLinkTarget(QString) instead")
|
||||||
static QString readLink(const QString &fileName);
|
static QString readLink(const QString &fileName);
|
||||||
inline QString symLinkTarget() const { return readLink(); }
|
#endif
|
||||||
inline static QString symLinkTarget(const QString &fileName) { return readLink(fileName); }
|
QString symLinkTarget() const;
|
||||||
|
static QString symLinkTarget(const QString &fileName);
|
||||||
|
|
||||||
bool remove();
|
bool remove();
|
||||||
static bool remove(const QString &fileName);
|
static bool remove(const QString &fileName);
|
||||||
|
@ -1107,12 +1107,19 @@ bool QFileInfo::isRoot() const
|
|||||||
\sa exists(), isSymLink(), isDir(), isFile()
|
\sa exists(), isSymLink(), isDir(), isFile()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(5, 13)
|
||||||
/*!
|
/*!
|
||||||
\obsolete
|
\obsolete
|
||||||
|
|
||||||
Use symLinkTarget() instead.
|
Use symLinkTarget() instead.
|
||||||
*/
|
*/
|
||||||
QString QFileInfo::readLink() const
|
QString QFileInfo::readLink() const
|
||||||
|
{
|
||||||
|
return symLinkTarget();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QString QFileInfo::symLinkTarget() const
|
||||||
{
|
{
|
||||||
Q_D(const QFileInfo);
|
Q_D(const QFileInfo);
|
||||||
if (d->isDefaultConstructed)
|
if (d->isDefaultConstructed)
|
||||||
|
@ -116,8 +116,11 @@ public:
|
|||||||
bool isRoot() const;
|
bool isRoot() const;
|
||||||
bool isBundle() const;
|
bool isBundle() const;
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(5, 13)
|
||||||
|
QT_DEPRECATED_X("Use QFileInfo::symLinkTarget() instead")
|
||||||
QString readLink() const;
|
QString readLink() const;
|
||||||
inline QString symLinkTarget() const { return readLink(); }
|
#endif
|
||||||
|
QString symLinkTarget() const;
|
||||||
|
|
||||||
QString owner() const;
|
QString owner() const;
|
||||||
uint ownerId() const;
|
uint ownerId() const;
|
||||||
|
@ -2022,7 +2022,7 @@ static void stateCheck(const QFileInfo &info, const QString &dirname, const QStr
|
|||||||
QVERIFY(!info.isRoot());
|
QVERIFY(!info.isRoot());
|
||||||
QCOMPARE(info.isNativePath(), !filename.isEmpty());
|
QCOMPARE(info.isNativePath(), !filename.isEmpty());
|
||||||
|
|
||||||
QCOMPARE(info.readLink(), QString());
|
QCOMPARE(info.symLinkTarget(), QString());
|
||||||
QCOMPARE(info.ownerId(), uint(-2));
|
QCOMPARE(info.ownerId(), uint(-2));
|
||||||
QCOMPARE(info.groupId(), uint(-2));
|
QCOMPARE(info.groupId(), uint(-2));
|
||||||
QCOMPARE(info.owner(), QString());
|
QCOMPARE(info.owner(), QString());
|
||||||
|
@ -376,7 +376,7 @@ void tst_QTemporaryFile::io()
|
|||||||
before.setSecsSinceEpoch(before.toSecsSinceEpoch());
|
before.setSecsSinceEpoch(before.toSecsSinceEpoch());
|
||||||
|
|
||||||
QVERIFY(file.open());
|
QVERIFY(file.open());
|
||||||
QVERIFY(file.readLink().isEmpty()); // it's not a link!
|
QVERIFY(file.symLinkTarget().isEmpty()); // it's not a link!
|
||||||
QFile::Permissions perm = file.permissions();
|
QFile::Permissions perm = file.permissions();
|
||||||
QVERIFY(perm & QFile::ReadOwner);
|
QVERIFY(perm & QFile::ReadOwner);
|
||||||
QVERIFY(file.setPermissions(perm));
|
QVERIFY(file.setPermissions(perm));
|
||||||
|
@ -81,7 +81,7 @@ void qfileinfo::symLinkTargetPerformanceLNK()
|
|||||||
QString linkTarget;
|
QString linkTarget;
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
for(int i=0; i<100; i++)
|
for(int i=0; i<100; i++)
|
||||||
linkTarget = info.readLink();
|
linkTarget = info.symLinkTarget();
|
||||||
}
|
}
|
||||||
QVERIFY(QFile::remove("link.lnk"));
|
QVERIFY(QFile::remove("link.lnk"));
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ void qfileinfo::symLinkTargetPerformanceMounpoint()
|
|||||||
QString linkTarget;
|
QString linkTarget;
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
for(int i=0; i<100; i++)
|
for(int i=0; i<100; i++)
|
||||||
linkTarget = info.readLink();
|
linkTarget = info.symLinkTarget();
|
||||||
}
|
}
|
||||||
QVERIFY(QDir().rmdir(mountpoint));
|
QVERIFY(QDir().rmdir(mountpoint));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user