qnetworkreplyfileimpl.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5QNetworkReplyFileImplPrivate::QNetworkReplyFileImplPrivate()-
6 : QNetworkReplyPrivate(), realFileSize(0)-
7{-
8}
executed 30 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_QXmlStream
30
9-
10QNetworkReplyFileImpl::~QNetworkReplyFileImpl()-
11{-
12}-
13-
14QNetworkReplyFileImpl::QNetworkReplyFileImpl(QObject *parent, const QNetworkRequest &req, const QNetworkAccessManager::Operation op)-
15 : QNetworkReply(*new QNetworkReplyFileImplPrivate(), parent)-
16{-
17 setRequest(req);-
18 setUrl(req.url());-
19 setOperation(op);-
20 setFinished(true);-
21 QNetworkReply::open(QIODevice::ReadOnly);-
22-
23 QNetworkReplyFileImplPrivate *d = (QNetworkReplyFileImplPrivate*) d_func();-
24-
25 QUrl url = req.url();-
26 if (url.host() == QLatin1String("localhost")
url.host() == ...g("localhost")Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 29 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlStream
)
1-29
27 url.setHost(QString());
executed 1 time by 1 test: url.setHost(QString());
Executed by:
  • tst_QNetworkReply
1
28-
29-
30-
31 if (!url.host().isEmpty()
!url.host().isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 29 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlStream
) {
1-29
32-
33 QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());-
34 setError(QNetworkReply::ProtocolInvalidOperationError, msg);-
35 QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,-
36 QArgument<QNetworkReply::NetworkError >("QNetworkReply::NetworkError", QNetworkReply::ProtocolInvalidOperationError));-
37 QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);-
38 return;
executed 1 time by 1 test: return;
Executed by:
  • tst_QNetworkReply
1
39 }-
40-
41 if (url.path().isEmpty()
url.path().isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 28 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlStream
)
1-28
42 url.setPath(QLatin1String("/"));
executed 1 time by 1 test: url.setPath(QLatin1String("/"));
Executed by:
  • tst_QNetworkReply
1
43 setUrl(url);-
44-
45-
46 QString fileName = url.toLocalFile();-
47 if (fileName.isEmpty()
fileName.isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 27 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlStream
) {
2-27
48 const QString scheme = url.scheme();-
49 if (scheme == QLatin1String("qrc")
scheme == QLatin1String("qrc")Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
) {
0-2
50 fileName = QLatin1Char(':') + url.path();-
51 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
else {
2
52-
53-
54-
55-
56-
57 fileName = url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery);-
58 }
never executed: end of block
0
59 }-
60-
61 QFileInfo fi(fileName);-
62 if (fi.isDir()
fi.isDir()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 26 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlStream
) {
3-26
63 QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Cannot open %1: Path is a directory").arg(url.toString());-
64 setError(QNetworkReply::ContentOperationNotPermittedError, msg);-
65 QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,-
66 QArgument<QNetworkReply::NetworkError >("QNetworkReply::NetworkError", QNetworkReply::ContentOperationNotPermittedError));-
67 QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);-
68 return;
executed 3 times by 1 test: return;
Executed by:
  • tst_QNetworkReply
3
69 }-
70-
71 d->realFile.setFileName(fileName);-
72 bool opened = d->realFile.open(QIODevice::ReadOnly | QIODevice::Unbuffered);-
73-
74-
75 if (!opened
!openedDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 23 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlStream
) {
3-23
76 QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Error opening %1: %2")-
77 .arg(d->realFile.fileName(), d->realFile.errorString());-
78-
79 if (d->realFile.exists()
d->realFile.exists()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
) {
1-2
80 setError(QNetworkReply::ContentAccessDenied, msg);-
81 QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,-
82 QArgument<QNetworkReply::NetworkError >("QNetworkReply::NetworkError", QNetworkReply::ContentAccessDenied));-
83 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
else {
2
84 setError(QNetworkReply::ContentNotFoundError, msg);-
85 QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,-
86 QArgument<QNetworkReply::NetworkError >("QNetworkReply::NetworkError", QNetworkReply::ContentNotFoundError));-
87 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkReply
1
88 QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);-
89 return;
executed 3 times by 1 test: return;
Executed by:
  • tst_QNetworkReply
3
90 }-
91-
92 setHeader(QNetworkRequest::LastModifiedHeader, fi.lastModified());-
93 d->realFileSize = fi.size();-
94 setHeader(QNetworkRequest::ContentLengthHeader, d->realFileSize);-
95-
96 QMetaObject::invokeMethod(this, "metaDataChanged", Qt::QueuedConnection);-
97 QMetaObject::invokeMethod(this, "downloadProgress", Qt::QueuedConnection,-
98 QArgument<qint64 >("qint64", d->realFileSize), QArgument<qint64 >("qint64", d->realFileSize));-
99 QMetaObject::invokeMethod(this, "readyRead", Qt::QueuedConnection);-
100 QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);-
101}
executed 23 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_QXmlStream
23
102-
103void QNetworkReplyFileImpl::close()-
104{-
105 QNetworkReplyFileImplPrivate * const d = d_func();-
106 QNetworkReply::close();-
107 d->realFile.close();-
108}
never executed: end of block
0
109-
110void QNetworkReplyFileImpl::abort()-
111{-
112 QNetworkReplyFileImplPrivate * const d = d_func();-
113 QNetworkReply::close();-
114 d->realFile.close();-
115}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkReply
1
116-
117qint64 QNetworkReplyFileImpl::bytesAvailable() const-
118{-
119 const QNetworkReplyFileImplPrivate * const d = d_func();-
120 if (!d->realFile.isOpen()
!d->realFile.isOpen()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 184 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlStream
)
2-184
121 return
executed 2 times by 1 test: return QNetworkReply::bytesAvailable();
Executed by:
  • tst_QNetworkReply
QNetworkReply::bytesAvailable();
executed 2 times by 1 test: return QNetworkReply::bytesAvailable();
Executed by:
  • tst_QNetworkReply
2
122 return
executed 184 times by 2 tests: return QNetworkReply::bytesAvailable() + d->realFile.bytesAvailable();
Executed by:
  • tst_QNetworkReply
  • tst_QXmlStream
QNetworkReply::bytesAvailable() + d->realFile.bytesAvailable();
executed 184 times by 2 tests: return QNetworkReply::bytesAvailable() + d->realFile.bytesAvailable();
Executed by:
  • tst_QNetworkReply
  • tst_QXmlStream
184
123}-
124-
125bool QNetworkReplyFileImpl::isSequential () const-
126{-
127 return
executed 183 times by 2 tests: return true;
Executed by:
  • tst_QNetworkReply
  • tst_QXmlStream
true;
executed 183 times by 2 tests: return true;
Executed by:
  • tst_QNetworkReply
  • tst_QXmlStream
183
128}-
129-
130qint64 QNetworkReplyFileImpl::size() const-
131{-
132 const QNetworkReplyFileImplPrivate * const d = d_func();-
133 return
never executed: return d->realFileSize;
d->realFileSize;
never executed: return d->realFileSize;
0
134}-
135-
136-
137-
138-
139qint64 QNetworkReplyFileImpl::readData(char *data, qint64 maxlen)-
140{-
141 QNetworkReplyFileImplPrivate * const d = d_func();-
142 if (!d->realFile.isOpen()
!d->realFile.isOpen()Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 166 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlStream
)
17-166
143 return
executed 17 times by 1 test: return -1;
Executed by:
  • tst_QNetworkReply
-1;
executed 17 times by 1 test: return -1;
Executed by:
  • tst_QNetworkReply
17
144 qint64 ret = d->realFile.read(data, maxlen);-
145 if (bytesAvailable() == 0
bytesAvailable() == 0Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 151 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlStream
&& d->realFile.isOpen()
d->realFile.isOpen()Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
)
0-151
146 d->realFile.close();
executed 15 times by 1 test: d->realFile.close();
Executed by:
  • tst_QNetworkReply
15
147 if (ret == 0
ret == 0Description
TRUEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlStream
FALSEevaluated 163 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlStream
&& bytesAvailable() == 0
bytesAvailable() == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QXmlStream
)
1-163
148 return
executed 2 times by 1 test: return -1;
Executed by:
  • tst_QNetworkReply
-1;
executed 2 times by 1 test: return -1;
Executed by:
  • tst_QNetworkReply
2
149 else {-
150 setAttribute(QNetworkRequest::HttpStatusCodeAttribute, 200);-
151 setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, QLatin1String("OK"));-
152 return
executed 164 times by 2 tests: return ret;
Executed by:
  • tst_QNetworkReply
  • tst_QXmlStream
ret;
executed 164 times by 2 tests: return ret;
Executed by:
  • tst_QNetworkReply
  • tst_QXmlStream
164
153 }-
154}-
155-
156-
157-
158-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9