Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qnetworkfile.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
include
"qnetworkfile_p.h"
6
#
include
"qnetworkrequest_p.h"
7
8
#
include
<
QtCore
/
QDebug
>
9
#
include
<
QNetworkReply
>
10
#
include
<
QtCore
/
QDateTime
>
11
#
include
<
QtCore
/
QFileInfo
>
12
#
include
<
QtCore
/
QMetaObject
>
13
#
include
<
QtCore
/
QCoreApplication
>
14
15
QT_BEGIN_NAMESPACE
16
17
QNetworkFile::QNetworkFile()
18
: QFile()
19
{
20
}
21
22
QNetworkFile::QNetworkFile(
const
QString &name)
23
: QFile(name)
24
{
25
}
26
27
void
QNetworkFile::open()
28
{
29
bool
opened =
false
;
30
QFileInfo fi(fileName());
31
if
(fi.isDir()) {
32
QString msg = QCoreApplication::translate(
"QNetworkAccessFileBackend"
,
33
"Cannot open %1: Path is a directory"
).arg(fileName());
34
emit networkError(QNetworkReply::ContentOperationNotPermittedError, msg);
35
}
else
{
36
emit headerRead(QHttpHeaders::WellKnownHeader::LastModified,
37
QNetworkHeadersPrivate::toHttpDate(fi.lastModified()));
38
emit headerRead(QHttpHeaders::WellKnownHeader::ContentLength,
39
QByteArray::number(fi.size()));
40
opened = QFile::open(QIODevice::ReadOnly | QIODevice::Unbuffered);
41
if
(!opened) {
42
QString msg = QCoreApplication::translate(
"QNetworkAccessFileBackend"
,
43
"Error opening %1: %2"
).arg(fileName(), errorString());
44
if
(exists())
45
emit networkError(QNetworkReply::ContentAccessDenied, msg);
46
else
47
emit networkError(QNetworkReply::ContentNotFoundError, msg);
48
}
49
}
50
emit finished(opened);
51
}
52
53
void
QNetworkFile::close()
54
{
55
// This override is needed because 'using' keyword cannot be used for slots. And the base
56
// function is not an invokable/slot function.
57
QFile::close();
58
}
59
60
QT_END_NAMESPACE
61
62
#
include
"moc_qnetworkfile_p.cpp"
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtbase
src
network
access
qnetworkfile.cpp
Generated on
for Qt by
1.18.0