Qt 6.x
The Qt SDK
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
6#include <QtCore/QDebug>
7#include <QNetworkReply>
8#include <QtCore/QDateTime>
9#include <QtCore/QFileInfo>
10#include <QtCore/QMetaObject>
11#include <QtCore/QCoreApplication>
12
14
16 : QFile()
17{
18}
19
21 : QFile(name)
22{
23}
24
26{
27 bool opened = false;
29 if (fi.isDir()) {
30 QString msg = QCoreApplication::translate("QNetworkAccessFileBackend",
31 "Cannot open %1: Path is a directory").arg(fileName());
33 } else {
37 if (!opened) {
38 QString msg = QCoreApplication::translate("QNetworkAccessFileBackend",
39 "Error opening %1: %2").arg(fileName(), errorString());
40 if (exists())
42 else
44 }
45 }
46 emit finished(opened);
47}
48
50{
51 // This override is needed because 'using' keyword cannot be used for slots. And the base
52 // function is not an invokable/slot function.
54}
55
57
58#include "moc_qnetworkfile_p.cpp"
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
void close() override
Calls QFileDevice::flush() and closes the file.
\inmodule QtCore \reentrant
Definition qfileinfo.h:22
QDateTime lastModified() const
Returns the date and time when the file was last modified.
Definition qfileinfo.h:156
bool isDir() const
Returns true if this object points to a directory or to a symbolic link to a directory.
qint64 size() const
Returns the file size in bytes.
\inmodule QtCore
Definition qfile.h:93
bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
Definition qfile.cpp:881
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 error(QNetworkReply::NetworkError error, const QString &message)
void close() override
void headerRead(QNetworkRequest::KnownHeaders header, const QVariant &value)
@ ContentOperationNotPermittedError
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
Definition qstring.cpp:8606
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Definition qvariant.h:531
Combined button and popup list for selecting options.
GLuint name
#define emit
QFileInfo fi("c:/temp/foo")
[newstuff]