Qt 4.8
Public Functions | List of all members
QNetworkAccessFileBackendFactory Class Reference

#include <qnetworkaccessfilebackend_p.h>

Inheritance diagram for QNetworkAccessFileBackendFactory:
QNetworkAccessBackendFactory

Public Functions

virtual QNetworkAccessBackendcreate (QNetworkAccessManager::Operation op, const QNetworkRequest &request) const
 
- Public Functions inherited from QNetworkAccessBackendFactory
 QNetworkAccessBackendFactory ()
 
virtual ~QNetworkAccessBackendFactory ()
 

Detailed Description

Definition at line 88 of file qnetworkaccessfilebackend_p.h.

Functions

◆ create()

QNetworkAccessBackend * QNetworkAccessFileBackendFactory::create ( QNetworkAccessManager::Operation  op,
const QNetworkRequest request 
) const
virtual

Implements QNetworkAccessBackendFactory.

Definition at line 53 of file qnetworkaccessfilebackend.cpp.

55 {
56  // is it an operation we know of?
57  switch (op) {
60  break;
61 
62  default:
63  // no, we can't handle this operation
64  return 0;
65  }
66 
67  QUrl url = request.url();
68  if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0 || url.isLocalFile()) {
69  return new QNetworkAccessFileBackend;
70  } else if (!url.isEmpty() && url.authority().isEmpty()) {
71  // check if QFile could, in theory, open this URL via the file engines
72  // it has to be in the format:
73  // prefix:path/to/file
74  // or prefix:/path/to/file
75  //
76  // this construct here must match the one below in open()
78  // On Windows and Symbian the drive letter is detected as the scheme.
79  if (fi.exists() && (url.scheme().isEmpty() || (url.scheme().length() == 1)))
80  qWarning("QNetworkAccessFileBackendFactory: URL has no schema set, use file:// for files");
81  if (fi.exists() || (op == QNetworkAccessManager::PutOperation && fi.dir().exists()))
82  return new QNetworkAccessFileBackend;
83  }
84 
85  return 0;
86 }
QString toString(FormattingOptions options=None) const
Returns the human-displayable string representation of the URL.
Definition: qurl.cpp:5896
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
Definition: qurl.cpp:4317
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
QUrl url() const
Returns the URL this network request is referring to.
bool isLocalFile() const
Returns true if this URL is pointing to a local file path.
Definition: qurl.cpp:6453
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QString authority() const
Returns the authority of the URL if it is defined; otherwise an empty string is returned.
Definition: qurl.cpp:4592
Q_CORE_EXPORT void qWarning(const char *,...)
QString scheme() const
Returns the scheme of the URL.
Definition: qurl.cpp:4550
int compare(const QString &s) const
Definition: qstring.cpp:5037
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

The documentation for this class was generated from the following files: