mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 18:32:55 +00:00
remove redundant QDir methods
only UNIX is supported Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
edbeabbf41
commit
07e67b0b52
5 changed files with 6 additions and 64 deletions
|
@ -90,12 +90,12 @@ bool QDirPrivate::exists() const
|
||||||
|
|
||||||
inline void QDirPrivate::setPath(const QString &path)
|
inline void QDirPrivate::setPath(const QString &path)
|
||||||
{
|
{
|
||||||
QString p = QDir::fromNativeSeparators(path);
|
QString p = path;
|
||||||
if (p.endsWith(QLatin1Char('/')) && p.length() > 1) {
|
if (p.endsWith(QLatin1Char('/')) && p.length() > 1) {
|
||||||
p.truncate(p.length() - 1);
|
p.truncate(p.length() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
dirEntry = QFileSystemEntry(QDir::fromNativeSeparators(path));
|
dirEntry = QFileSystemEntry(path);
|
||||||
metaData.clear();
|
metaData.clear();
|
||||||
clearFileLists();
|
clearFileLists();
|
||||||
absoluteDirEntry = QFileSystemEntry();
|
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 "/"
|
Paths can also be simplified by using cleanPath() to remove redundant "/"
|
||||||
and ".." elements.
|
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
|
\section1 Examples
|
||||||
|
|
||||||
Check if a directory exists:
|
Check if a directory exists:
|
||||||
|
@ -493,7 +487,7 @@ void QDir::setPath(const QString &path)
|
||||||
setPath()).
|
setPath()).
|
||||||
|
|
||||||
\sa setPath(), absolutePath(), exists(), cleanPath(), dirName(),
|
\sa setPath(), absolutePath(), exists(), cleanPath(), dirName(),
|
||||||
absoluteFilePath(), toNativeSeparators(), makeAbsolute()
|
absoluteFilePath(), makeAbsolute()
|
||||||
*/
|
*/
|
||||||
QString QDir::path() const
|
QString QDir::path() const
|
||||||
{
|
{
|
||||||
|
@ -639,34 +633,6 @@ QString QDir::relativeFilePath(const QString &fileName) const
|
||||||
return result;
|
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.
|
Changes the QDir's directory to \a dirName.
|
||||||
|
|
||||||
|
@ -1401,14 +1367,7 @@ bool QDir::exists(const QString &name) const
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn QChar QDir::separator()
|
\fn QChar QDir::separator()
|
||||||
Returns the native directory separator: "/" under Unix (including
|
Returns the native directory separator: "/" under Unix.
|
||||||
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().
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -1469,9 +1428,6 @@ QString QDir::currentPath()
|
||||||
/*!
|
/*!
|
||||||
Returns the absolute path of the user's home directory.
|
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
|
For Unix operating systems the \c HOME environment variable is used
|
||||||
if it exists, otherwise the path returned by the rootPath().
|
if it exists, otherwise the path returned by the rootPath().
|
||||||
|
|
||||||
|
|
|
@ -101,10 +101,6 @@ public:
|
||||||
|
|
||||||
static inline QChar separator()
|
static inline QChar separator()
|
||||||
{ return QLatin1Char('/'); }
|
{ return QLatin1Char('/'); }
|
||||||
static QString toNativeSeparators(const QString &pathName)
|
|
||||||
{ return pathName; }
|
|
||||||
static QString fromNativeSeparators(const QString &pathName)
|
|
||||||
{ return pathName; }
|
|
||||||
|
|
||||||
bool cd(const QString &dirName);
|
bool cd(const QString &dirName);
|
||||||
bool cdUp();
|
bool cdUp();
|
||||||
|
|
|
@ -106,7 +106,7 @@ public:
|
||||||
|
|
||||||
QString basename(const QString &path) const
|
QString basename(const QString &path) const
|
||||||
{
|
{
|
||||||
int separator = QDir::toNativeSeparators(path).lastIndexOf(QDir::separator());
|
int separator = path.lastIndexOf(QDir::separator());
|
||||||
if (separator != -1)
|
if (separator != -1)
|
||||||
return path.mid(separator + 1);
|
return path.mid(separator + 1);
|
||||||
return path;
|
return path;
|
||||||
|
|
|
@ -123,8 +123,6 @@ private slots:
|
||||||
void tempPath();
|
void tempPath();
|
||||||
void rootPath();
|
void rootPath();
|
||||||
|
|
||||||
void nativeSeparators();
|
|
||||||
|
|
||||||
void longFileName_data();
|
void longFileName_data();
|
||||||
void longFileName();
|
void longFileName();
|
||||||
|
|
||||||
|
@ -1070,14 +1068,6 @@ void tst_QDir::rootPath()
|
||||||
QCOMPARE(path, QString("/"));
|
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()
|
void tst_QDir::longFileName_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<int>("length");
|
QTest::addColumn<int>("length");
|
||||||
|
|
|
@ -118,7 +118,7 @@ void tst_QLocale::initTestCase()
|
||||||
m_sysLocaleApp = workingDirectory.absoluteFilePath(QLatin1String("qlocale_syslocaleapp"));
|
m_sysLocaleApp = workingDirectory.absoluteFilePath(QLatin1String("qlocale_syslocaleapp"));
|
||||||
QVERIFY2(QFileInfo(m_sysLocaleApp).exists(),
|
QVERIFY2(QFileInfo(m_sysLocaleApp).exists(),
|
||||||
qPrintable(QString::fromLatin1("SysLocalApp executable '%1' does not exist!")
|
qPrintable(QString::fromLatin1("SysLocalApp executable '%1' does not exist!")
|
||||||
.arg(QDir::toNativeSeparators(m_sysLocaleApp))));
|
.arg(m_sysLocaleApp)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QLocale::ctor()
|
void tst_QLocale::ctor()
|
||||||
|
|
Loading…
Add table
Reference in a new issue