| 17 | // |
| 18 | |
| 19 | void 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 |
no test coverage detected