40 volatile bool doIt =
false;
42 emscripten_set_wheel_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, 0, 0, NULL);
45Q_CONSTRUCTOR_FUNCTION(usePotentialyUnusedSymbols)
49struct ChunkedFileReader
52 static void read(File file,
char *buffer, uint32_t offset, uint32_t end,
53 std::function<
void()> onCompleted)
55 (
new ChunkedFileReader(end,
std::move(onCompleted),
std::move(file)))
56 ->readNextChunk(offset, buffer);
60 ChunkedFileReader(uint32_t end,
std::function<
void()> onCompleted, File file)
61 : end(end), onCompleted(std::move(onCompleted)), file(std::move(file))
65 void readNextChunk(uint32_t chunkBegin,
char *chunkBuffer)
68 qstdweb::ArrayBuffer result = fileReader.result();
69 qstdweb::Uint8Array(result).copyTo(chunkBuffer);
72 const uint32_t nextChunkBegin =
std::min(chunkBegin + result.byteLength(), end);
73 if (nextChunkBegin == end) {
78 char *nextChunkBuffer = chunkBuffer + result.byteLength();
79 fileReader.onLoad([
this, nextChunkBegin, nextChunkBuffer](emscripten::val) {
80 readNextChunk(nextChunkBegin, nextChunkBuffer);
82 const uint32_t nextChunkEnd =
std::min(nextChunkBegin + chunkSize, end);
83 qstdweb::Blob blob = file.slice(nextChunkBegin, nextChunkEnd);
84 fileReader.readAsArrayBuffer(blob);
87 static constexpr uint32_t chunkSize = 256 * 1024;
91 std::function<
void()> onCompleted;
97EM_JS(
bool, jsHaveAsyncify, (), {
return typeof Asyncify !==
"undefined"; });
98EM_JS(
bool, jsHaveJspi, (),
99 {
return typeof Asyncify !==
"undefined" && !!Asyncify.makeAsyncFunction && (!!WebAssembly.Function || !!WebAssembly.Suspending); });
103bool jsHaveAsyncify() {
return false; }
104bool jsHaveJspi() {
return false; }
565 "Promise::adoptPromise",
"must provide at least one callback function");
656 static bool HaveJspi = jsHaveJspi();
662 static bool HaveAsyncify = jsHaveAsyncify() ||
haveJspi();
726 return QIODevice::open(mode);
736 return m_array.length();
743 return QIODevice::seek(pos);
748 uint64_t begin = QIODevice::pos();
749 uint64_t end =
std::min<uint64_t>(begin + maxSize, size());
750 uint64_t size = end - begin;
752 m_array.subarray(begin, end).copyTo(data);
758 uint64_t begin = QIODevice::pos();
759 uint64_t end =
std::min<uint64_t>(begin + maxSize, size());
760 uint64_t size = end - begin;
762 m_array.subarray(begin, end).set(Uint8Array(data, size));
bool seek(qint64 pos) override
For random-access devices, this function sets the current position to pos, returning true on success,...