Skip to content

Commit

Permalink
fix: fix the case when file size is greater than 2G (#323)
Browse files Browse the repository at this point in the history
  • Loading branch information
YuJianrong authored Nov 22, 2023
1 parent eb1ecc8 commit f81cacd
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/cpp/bridge/bridge.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
/* global mergeInto, LibraryManager, Module, UTF32ToString, UTF8ToString */


mergeInto(LibraryManager.library, {
jsOpen: function (filename) {
const handle = Module.extractor.open(UTF32ToString(filename));
Module.setTempRet0(handle / 0x100000000 | 0);
Module.setTempRet0((handle / 0x100000000) | 0);
return handle % 0x100000000;
},
jsCreate: function (filename) {
const handle = Module.extractor.create(UTF32ToString(filename));
Module.setTempRet0(handle / 0x100000000 | 0);
Module.setTempRet0((handle / 0x100000000) | 0);
return handle % 0x100000000;
},
jsClose: function (handleLo, handleHi) {
return Module.extractor.close(handleLo + handleHi * 0x100000000);
return Module.extractor.close((handleLo >>> 0) + handleHi * 0x100000000);
},
jsRead: function (handleLo, handleHi, buf, size) {
return Module.extractor.read(handleLo + handleHi * 0x100000000, buf, size);
return Module.extractor.read((handleLo >>> 0) + handleHi * 0x100000000, buf, size);
},
jsWrite: function (handleLo, handleHi, buf, size) {
return Module.extractor.write(handleLo + handleHi * 0x100000000, buf, size);
return Module.extractor.write((handleLo >>> 0) + handleHi * 0x100000000, buf, size);
},
jsTell: function (handleLo, handleHi) {
const pos = Module.extractor.tell(handleLo + handleHi * 0x100000000);
Module.setTempRet0(pos / 0x100000000 | 0);
const pos = Module.extractor.tell((handleLo >>> 0) + handleHi * 0x100000000);
Module.setTempRet0((pos / 0x100000000) | 0);
return pos % 0x100000000;
},
jsSeek: function (handleLo, handleHi, offsetLo, offsetHi, method) {
return Module.extractor.seek(handleLo + handleHi * 0x100000000, offsetLo + offsetHi * 0x100000000, UTF8ToString(method));
return Module.extractor.seek(
(handleLo >>> 0) + handleHi * 0x100000000,
(offsetLo >>> 0) + offsetHi * 0x100000000,
UTF8ToString(method),
);
},
});

0 comments on commit f81cacd

Please sign in to comment.