Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#include "qnetworkfile_p.h"
5#include "qnetworkrequest_p.h"
6
7#include <QtCore/QDebug>
8#include <QNetworkReply>
9#include <QtCore/QDateTime>
10#include <QtCore/QFileInfo>
11#include <QtCore/QMetaObject>
12#include <QtCore/QCoreApplication>
13
15
20
25
27{
28 bool opened = false;
29 QFileInfo fi(fileName());
30 if (fi.isDir()) {
31 QString msg = QCoreApplication::translate("QNetworkAccessFileBackend",
32 "Cannot open %1: Path is a directory").arg(fileName());
34 } else {
36 QNetworkHeadersPrivate::toHttpDate(fi.lastModified()));
38 QByteArray::number(fi.size()));
40 if (!opened) {
41 QString msg = QCoreApplication::translate("QNetworkAccessFileBackend",
42 "Error opening %1: %2").arg(fileName(), errorString());
43 if (exists())
45 else
47 }
48 }
49 emit finished(opened);
50}
51
53{
54 // This override is needed because 'using' keyword cannot be used for slots. And the base
55 // function is not an invokable/slot function.
57}
58
60
61#include "moc_qnetworkfile_p.cpp"
static QByteArray number(int, int base=10)
Returns a byte-array representing the whole number n as text.
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
FileError error() const
Returns the file error status.
void close() override
Calls QFileDevice::flush() and closes the file.
\inmodule QtCore
Definition qfile.h:93
QFILE_MAYBE_NODISCARD bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
Definition qfile.cpp:904
QString fileName() const override
Returns the name set by setFileName() or to the QFile constructors.
Definition qfile.cpp:277
bool exists() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qfile.cpp:351
QString errorString() const
Returns a human-readable description of the last device error that occurred.
void finished(bool ok)
void close() override
void headerRead(QHttpHeaders::WellKnownHeader, const QByteArray &value)
static QByteArray toHttpDate(const QDateTime &dt)
@ ContentOperationNotPermittedError
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
GLuint name
#define emit