remove redundant QDir methods

only UNIX is supported

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-03-24 02:37:25 +02:00
parent edbeabbf41
commit 07e67b0b52
5 changed files with 6 additions and 64 deletions

View file

@ -90,12 +90,12 @@ bool QDirPrivate::exists() const
inline void QDirPrivate::setPath(const QString &path)
{
QString p = QDir::fromNativeSeparators(path);
QString p = path;
if (p.endsWith(QLatin1Char('/')) && p.length() > 1) {
p.truncate(p.length() - 1);
}
dirEntry = QFileSystemEntry(QDir::fromNativeSeparators(path));
dirEntry = QFileSystemEntry(path);
metaData.clear();
clearFileLists();
absoluteDirEntry = QFileSystemEntry();
@ -384,12 +384,6 @@ inline void QDirPrivate::initFileLists(const QDir &dir) const
Paths can also be simplified by using cleanPath() to remove redundant "/"
and ".." elements.
It is sometimes necessary to be able to show a path in the native
representation for the user's platform. The static toNativeSeparators()
function returns a copy of the specified path in which each directory
separator is replaced by the appropriate separator for the underlying
operating system.
\section1 Examples
Check if a directory exists:
@ -493,7 +487,7 @@ void QDir::setPath(const QString &path)
setPath()).
\sa setPath(), absolutePath(), exists(), cleanPath(), dirName(),
absoluteFilePath(), toNativeSeparators(), makeAbsolute()
absoluteFilePath(), makeAbsolute()
*/
QString QDir::path() const
{
@ -639,34 +633,6 @@ QString QDir::relativeFilePath(const QString &fileName) const
return result;
}
/*!
\fn QDir::toNativeSeparators(const QString &pathName)
\since 4.2
Returns \a pathName with the '/' separators converted to
separators that are appropriate for the underlying operating
system.
The returned string may be the same as the argument on some
operating systems, for example on Unix.
\sa fromNativeSeparators(), separator()
*/
/*!
\fn QString QDir::fromNativeSeparators(const QString &pathName)
\since 4.2
Returns \a pathName using '/' as file separator. On Windows,
for instance, fromNativeSeparators("\c{c:\\winnt\\system32}") returns
"c:/winnt/system32".
The returned string may be the same as the argument on some
operating systems, for example on Unix.
\sa toNativeSeparators(), separator()
*/
/*!
Changes the QDir's directory to \a dirName.
@ -1401,14 +1367,7 @@ bool QDir::exists(const QString &name) const
/*!
\fn QChar QDir::separator()
Returns the native directory separator: "/" under Unix (including
Mac OS X) and "\\" under Windows.
You do not need to use this function to build file paths. If you
always use "/", Qt will translate your paths to conform to the
underlying operating system. If you want to display paths to the
user using their operating system's separator use
toNativeSeparators().
Returns the native directory separator: "/" under Unix.
*/
/*!
@ -1469,9 +1428,6 @@ QString QDir::currentPath()
/*!
Returns the absolute path of the user's home directory.
Use the toNativeSeparators() function to convert the separators to
the ones that are appropriate for the underlying operating system.
For Unix operating systems the \c HOME environment variable is used
if it exists, otherwise the path returned by the rootPath().

View file

@ -101,10 +101,6 @@ public:
static inline QChar separator()
{ return QLatin1Char('/'); }
static QString toNativeSeparators(const QString &pathName)
{ return pathName; }
static QString fromNativeSeparators(const QString &pathName)
{ return pathName; }
bool cd(const QString &dirName);
bool cdUp();

View file

@ -106,7 +106,7 @@ public:
QString basename(const QString &path) const
{
int separator = QDir::toNativeSeparators(path).lastIndexOf(QDir::separator());
int separator = path.lastIndexOf(QDir::separator());
if (separator != -1)
return path.mid(separator + 1);
return path;

View file

@ -123,8 +123,6 @@ private slots:
void tempPath();
void rootPath();
void nativeSeparators();
void longFileName_data();
void longFileName();
@ -1070,14 +1068,6 @@ void tst_QDir::rootPath()
QCOMPARE(path, QString("/"));
}
void tst_QDir::nativeSeparators()
{
QCOMPARE(QDir::toNativeSeparators(QLatin1String("/")), QString("/"));
QCOMPARE(QDir::toNativeSeparators(QLatin1String("\\")), QString("\\"));
QCOMPARE(QDir::fromNativeSeparators(QLatin1String("/")), QString("/"));
QCOMPARE(QDir::fromNativeSeparators(QLatin1String("\\")), QString("\\"));
}
void tst_QDir::longFileName_data()
{
QTest::addColumn<int>("length");

View file

@ -118,7 +118,7 @@ void tst_QLocale::initTestCase()
m_sysLocaleApp = workingDirectory.absoluteFilePath(QLatin1String("qlocale_syslocaleapp"));
QVERIFY2(QFileInfo(m_sysLocaleApp).exists(),
qPrintable(QString::fromLatin1("SysLocalApp executable '%1' does not exist!")
.arg(QDir::toNativeSeparators(m_sysLocaleApp))));
.arg(m_sysLocaleApp)));
}
void tst_QLocale::ctor()