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
|
||||
if (m_qmakespec.endsWith(QLatin1String("/default-host"))
|
||||
|| m_qmakespec.endsWith(QLatin1String("/default"))) {
|
||||
QString rspec = QFileInfo(m_qmakespec).readLink();
|
||||
QString rspec = QFileInfo(m_qmakespec).symLinkTarget();
|
||||
if (!rspec.isEmpty())
|
||||
m_qmakespec = QDir::cleanPath(QDir(m_qmakespec).absoluteFilePath(rspec));
|
||||
}
|
||||
|
@ -454,7 +454,13 @@ QFile::exists(const QString &fileName)
|
||||
|
||||
\sa fileName(), setFileName()
|
||||
*/
|
||||
QString QFile::symLinkTarget() const
|
||||
{
|
||||
Q_D(const QFile);
|
||||
return d->engine()->fileName(QAbstractFileEngine::LinkName);
|
||||
}
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5, 13)
|
||||
/*!
|
||||
\obsolete
|
||||
|
||||
@ -463,9 +469,9 @@ QFile::exists(const QString &fileName)
|
||||
QString
|
||||
QFile::readLink() const
|
||||
{
|
||||
Q_D(const QFile);
|
||||
return d->engine()->fileName(QAbstractFileEngine::LinkName);
|
||||
return symLinkTarget();
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\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.
|
||||
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
|
||||
|
||||
@ -487,8 +498,9 @@ QFile::readLink() const
|
||||
QString
|
||||
QFile::readLink(const QString &fileName)
|
||||
{
|
||||
return QFileInfo(fileName).readLink();
|
||||
return symLinkTarget(fileName);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
Removes the file specified by fileName(). Returns \c true if successful;
|
||||
|
@ -107,10 +107,14 @@ public:
|
||||
bool exists() const;
|
||||
static bool exists(const QString &fileName);
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5, 13)
|
||||
QT_DEPRECATED_X("Use QFile::symLinkTarget() instead")
|
||||
QString readLink() const;
|
||||
QT_DEPRECATED_X("Use QFile::symLinkTarget(QString) instead")
|
||||
static QString readLink(const QString &fileName);
|
||||
inline QString symLinkTarget() const { return readLink(); }
|
||||
inline static QString symLinkTarget(const QString &fileName) { return readLink(fileName); }
|
||||
#endif
|
||||
QString symLinkTarget() const;
|
||||
static QString symLinkTarget(const QString &fileName);
|
||||
|
||||
bool remove();
|
||||
static bool remove(const QString &fileName);
|
||||
|
@ -1107,12 +1107,19 @@ bool QFileInfo::isRoot() const
|
||||
\sa exists(), isSymLink(), isDir(), isFile()
|
||||
*/
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5, 13)
|
||||
/*!
|
||||
\obsolete
|
||||
|
||||
Use symLinkTarget() instead.
|
||||
*/
|
||||
QString QFileInfo::readLink() const
|
||||
{
|
||||
return symLinkTarget();
|
||||
}
|
||||
#endif
|
||||
|
||||
QString QFileInfo::symLinkTarget() const
|
||||
{
|
||||
Q_D(const QFileInfo);
|
||||
if (d->isDefaultConstructed)
|
||||
|
@ -116,8 +116,11 @@ public:
|
||||
bool isRoot() const;
|
||||
bool isBundle() const;
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5, 13)
|
||||
QT_DEPRECATED_X("Use QFileInfo::symLinkTarget() instead")
|
||||
QString readLink() const;
|
||||
inline QString symLinkTarget() const { return readLink(); }
|
||||
#endif
|
||||
QString symLinkTarget() const;
|
||||
|
||||
QString owner() const;
|
||||
uint ownerId() const;
|
||||
|
@ -2022,7 +2022,7 @@ static void stateCheck(const QFileInfo &info, const QString &dirname, const QStr
|
||||
QVERIFY(!info.isRoot());
|
||||
QCOMPARE(info.isNativePath(), !filename.isEmpty());
|
||||
|
||||
QCOMPARE(info.readLink(), QString());
|
||||
QCOMPARE(info.symLinkTarget(), QString());
|
||||
QCOMPARE(info.ownerId(), uint(-2));
|
||||
QCOMPARE(info.groupId(), uint(-2));
|
||||
QCOMPARE(info.owner(), QString());
|
||||
|
@ -376,7 +376,7 @@ void tst_QTemporaryFile::io()
|
||||
before.setSecsSinceEpoch(before.toSecsSinceEpoch());
|
||||
|
||||
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();
|
||||
QVERIFY(perm & QFile::ReadOwner);
|
||||
QVERIFY(file.setPermissions(perm));
|
||||
|
@ -81,7 +81,7 @@ void qfileinfo::symLinkTargetPerformanceLNK()
|
||||
QString linkTarget;
|
||||
QBENCHMARK {
|
||||
for(int i=0; i<100; i++)
|
||||
linkTarget = info.readLink();
|
||||
linkTarget = info.symLinkTarget();
|
||||
}
|
||||
QVERIFY(QFile::remove("link.lnk"));
|
||||
}
|
||||
@ -104,7 +104,7 @@ void qfileinfo::symLinkTargetPerformanceMounpoint()
|
||||
QString linkTarget;
|
||||
QBENCHMARK {
|
||||
for(int i=0; i<100; i++)
|
||||
linkTarget = info.readLink();
|
||||
linkTarget = info.symLinkTarget();
|
||||
}
|
||||
QVERIFY(QDir().rmdir(mountpoint));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user