mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-14 03:33:52 +01:00
8553bcb8fc
* Use Compression Streams API instead of jszip or other libraries. * Remove usage of base64 in the new binary format. * Do not convert binary data to string and back. The type of save data is SaveData, it's either string (old base64 format) or Uint8Array (new binary format). * Proper support for interacting with electron-related code. Electron-related code assumes that save data is in the base64 format. * Proper support for other tools (DevMenu, pretty-save.js). Full support for DevMenu will be added in a follow-up PR. Check the comments in src\DevMenu\ui\SaveFileDev.tsx for details.
14 lines
335 B
JavaScript
14 lines
335 B
JavaScript
// The 2 magic bytes of the gzip header plus the mandatory compression type of DEFLATE
|
|
const magicBytes = [0x1f, 0x8b, 0x08];
|
|
|
|
function isBinaryFormat(rawData) {
|
|
for (let i = 0; i < magicBytes.length; ++i) {
|
|
if (magicBytes[i] !== rawData[i]) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
module.exports = { isBinaryFormat };
|