MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / preloadFromJS

Method preloadFromJS

system/lib/wasmfs/file.cpp:19–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17//
18
19void DataFile::Handle::preloadFromJS(int index) {
20 // TODO: Each Datafile type could have its own impl of file preloading.
21 // Create a buffer with the required file size.
22 std::vector<uint8_t> buffer(_wasmfs_get_preloaded_file_size(index));
23
24 // Ensure that files are preloaded from the main thread.
25 assert(emscripten_is_main_runtime_thread());
26
27 // Load data into the in-memory buffer.
28 _wasmfs_copy_preloaded_file_data(index, buffer.data());
29
30 write((const uint8_t*)buffer.data(), buffer.size(), 0);
31}
32
33//
34// Directory

Callers 1

preloadFilesMethod · 0.80

Calls 7

sizeMethod · 0.65
assertFunction · 0.50
writeFunction · 0.50
dataMethod · 0.45

Tested by

no test coverage detected