Qt 4.8
Functions
qfilesystementry.cpp File Reference
#include "qfilesystementry_p.h"
#include <QtCore/qdir.h>
#include <QtCore/qfile.h>
#include <QtCore/private/qfsfileengine_p.h>
#include <QtCore/qstringbuilder.h>

Go to the source code of this file.

Functions

static QString fixIfRelativeUncPath (const QString &path)
 
static bool isUncRoot (const QString &server)
 

Function Documentation

◆ fixIfRelativeUncPath()

static QString fixIfRelativeUncPath ( const QString path)
inlinestatic

Definition at line 68 of file qfilesystementry.cpp.

Referenced by QFileSystemEntry::resolveNativeFilePath().

69 {
70  QString currentPath = QDir::currentPath();
71  if (currentPath.startsWith(QLatin1String("//")))
72  return currentPath % QChar(QLatin1Char('/')) % path;
73  return path;
74 }
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString currentPath()
Returns the absolute path of the application&#39;s current directory.
Definition: qdir.cpp:1875
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ isUncRoot()

static bool isUncRoot ( const QString server)
static

Definition at line 54 of file qfilesystementry.cpp.

Referenced by QFileSystemEntry::isRoot().

55 {
56  QString localPath = QDir::toNativeSeparators(server);
57  if (!localPath.startsWith(QLatin1String("\\\\")))
58  return false;
59 
60  int idx = localPath.indexOf(QLatin1Char('\\'), 2);
61  if (idx == -1 || idx + 1 == localPath.length())
62  return true;
63 
64  localPath = localPath.right(localPath.length() - idx - 1).trimmed();
65  return localPath.isEmpty();
66 }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
QString right(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n rightmost characters of the string.
Definition: qstring.cpp:3682
QString trimmed(QString source)
Definition: generator.cpp:233
static QString toNativeSeparators(const QString &pathName)
Returns pathName with the &#39;/&#39; separators converted to separators that are appropriate for the underly...
Definition: qdir.cpp:812
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55