Do not use libcurl for reading local files

We originally used libcurl for both downloading images from
Internet and reading local files to have the same code path for both.

It doesn't work that well in practice, as Qt and libcurl are not
on the same page how special characters such as Chinese characters
are represented in a local file URL.

So create a new class to handle local files.

Closes #76
This commit is contained in:
Floris Bos 2020-06-01 19:43:51 +02:00
parent 123542a66b
commit fa7637e7dc
6 changed files with 115 additions and 8 deletions

28
localfileextractthread.h Normal file
View file

@ -0,0 +1,28 @@
#ifndef LOCALFILEEXTRACTTHREAD_H
#define LOCALFILEEXTRACTTHREAD_H
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright (C) 2020 Raspberry Pi (Trading) Limited
*/
#include "downloadextractthread.h"
#include <QFile>
class LocalFileExtractThread : public DownloadExtractThread
{
Q_OBJECT
public:
explicit LocalFileExtractThread(const QByteArray &url, const QByteArray &dst = "", const QByteArray &expectedHash = "", QObject *parent = nullptr);
virtual ~LocalFileExtractThread();
protected:
virtual void _cancelExtract();
virtual void run();
virtual ssize_t _on_read(struct archive *a, const void **buff);
virtual int _on_close(struct archive *a);
QFile _inputfile;
char *_inputBuf;
};
#endif // LOCALFILEEXTRACTTHREAD_H