46 #include "private/qnoncontiguousbytedevice_p.h" 48 #include <QtCore/QCoreApplication> 80 qWarning(
"QNetworkAccessFileBackendFactory: URL has no schema set, use file:// for files");
89 : uploadByteDevice(0), totalBytes(0), hasUploadFinished(false)
103 #if !defined(Q_OS_WIN) 112 #endif // !defined(Q_OS_WIN) 131 QIODevice::OpenMode mode;
143 Q_ASSERT_X(
false,
"QNetworkAccessFileBackend::open",
144 "Got a request operation I cannot handle!!");
175 if (haveRead == -1) {
182 }
else if (haveRead == 0 || readPointer == 0) {
187 haveWritten =
file.
write(readPointer, haveRead);
189 if (haveWritten < 0) {
217 "We're being told to download data but operation isn't GET!");
251 if (actuallyRead <= 0) {
266 data.
resize(actuallyRead);
#define QT_END_NAMESPACE
This macro expands to.
char * data()
Returns a pointer to the data stored in the byte array.
QString toString(FormattingOptions options=None) const
Returns the human-displayable string representation of the URL.
bool open(OpenMode flags)
Opens the file using OpenMode mode, returning true if successful; otherwise false.
The QByteArray class provides an array of bytes.
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
int length() const
Returns the number of characters in this string.
QString errorString() const
Returns a human-readable description of the last device error that occurred.
virtual void closeDownstreamChannel()
Operation
Indicates the operation this reply is processing.
void setPath(const QString &path)
Sets the path of the URL to path.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void append(QByteDataBuffer &other)
The QUrl class provides a convenient interface for working with URLs.
The QString class provides a Unicode character string.
QString host() const
Returns the host of the URL if it is defined; otherwise an empty string is returned.
void setHost(const QString &host)
Sets the host of the URL to host.
qint64 nextDownstreamBlockSize() const
QString path() const
Returns the path of the URL.
QUrl url() const
Returns the URL this network request is referring to.
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
virtual const char * readPointer(qint64 maximumLength, qint64 &len)=0
Return a byte pointer for at most maximumLength bytes of that device.
bool isLocalFile() const
Returns true if this URL is pointing to a local file path.
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read...
bool exists() const
Returns true if the file specified by fileName() exists; otherwise returns false. ...
static QString toString(Register *reg, int type, bool *ok=0)
QNonContiguousByteDevice * createUploadByteDevice()
#define QT_BEGIN_NAMESPACE
This macro expands to.
bool isDir() const
Returns true if this object points to a directory or to a symbolic link to a directory; otherwise ret...
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
virtual ~QNetworkAccessFileBackend()
QString authority() const
Returns the authority of the URL if it is defined; otherwise an empty string is returned.
void uploadReadyReadSlot()
bool flush()
Flushes any buffered data to the file.
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
QNetworkAccessFileBackend()
void setHeader(QNetworkRequest::KnownHeaders header, const QVariant &value)
QNetworkAccessManager::Operation operation() const
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
QString scheme() const
Returns the scheme of the URL.
#define Q_ASSERT_X(cond, where, what)
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
void error(QNetworkReply::NetworkError code, const QString &errorString)
int compare(const QString &s) const
qint64 size() const
Returns the file size in bytes.
virtual bool advanceReadPointer(qint64 amount)=0
The old readPointer is invalid after this call.
void setUrl(const QUrl &url)
virtual QNetworkAccessBackend * create(QNetworkAccessManager::Operation op, const QNetworkRequest &request) const
virtual void downstreamReadyWrite()
void resize(int size)
Sets the size of the byte array to size bytes.
void writeDownstreamData(QByteDataBuffer &list)
QNonContiguousByteDevice * uploadByteDevice
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
FileError error() const
Returns the file error status.
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
The QFileInfo class provides system-independent file information.
void reserve(int size)
Attempts to allocate memory for at least size bytes.
virtual void close()
Calls QFile::flush() and closes the file.
static QString fileName(const QString &fileUrl)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
void clear()
Clears the contents of the byte array and makes it empty.
void setFileName(const QString &name)
Sets the name of the file.
QDateTime lastModified() const
Returns the date and time when the file was last modified.
#define forever
This macro is provided for convenience for writing infinite loops.