Skip to content

Add back fs.findObject and fs.readFile in loadLibData #19513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/library_dylink.js
Original file line number Diff line number Diff line change
Expand Up @@ -993,14 +993,23 @@ var LibraryDylink = {
#endif

// for wasm, we can use fetch for async, but for fs mode we can only imitate it
var libData;
if (handle) {
var data = {{{ makeGetValue('handle', C_STRUCTS.dso.file_data, '*') }}};
var dataSize = {{{ makeGetValue('handle', C_STRUCTS.dso.file_data_size, '*') }}};
if (data && dataSize) {
var libData = HEAP8.slice(data, data + dataSize);
return flags.loadAsync ? Promise.resolve(libData) : libData;
libData = HEAP8.slice(data, data + dataSize);
}
}
if (!libData && flags.fs && flags.fs.findObject(libName)) {
libData = flags.fs.readFile(libName, {encoding: 'binary'});
if (!(libData instanceof Uint8Array)) {
libData = new Uint8Array(libData);
}
}
if (libData) {
return flags.loadAsync ? Promise.resolve(libData) : libData;
}

var libFile = locateFile(libName);
if (flags.loadAsync) {
Expand Down