How to use the chromium-pickle-js.createFromBuffer function in chromium-pickle-js

To help you get started, we’ve selected a few chromium-pickle-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github onmyway133 / PushNotifications / node_modules / asar / lib / disk.js View on Github external
const sizeBuf = new Buffer(8)
    if (fs.readSync(fd, sizeBuf, 0, 8, null) !== 8) {
      throw new Error('Unable to read header size')
    }

    const sizePickle = pickle.createFromBuffer(sizeBuf)
    size = sizePickle.createIterator().readUInt32()
    headerBuf = new Buffer(size)
    if (fs.readSync(fd, headerBuf, 0, size, null) !== size) {
      throw new Error('Unable to read header')
    }
  } finally {
    fs.closeSync(fd)
  }

  const headerPickle = pickle.createFromBuffer(headerBuf)
  const header = headerPickle.createIterator().readString()
  return {header: JSON.parse(header), headerSize: size}
}
github Tustin / PlayStationDiscord / src / Asar / Asar.ts View on Github external
fs.read(fd, headerBuffer, 0, size, null, (pickleReadErr, pickleReadBytes) => {
					if (pickleReadErr)
					{
						return reject(pickleReadErr);
					}

					const header = pickle.createFromBuffer(headerBuffer).createIterator().readString();

					return resolve({
						header: JSON.parse(header),
						size
					});
				});
			});
github Tustin / PlayStationDiscord / src / Asar / Asar.ts View on Github external
fs.read(fd, headerSizeBuffer, 0, 8, null, (headerReadErr, headerBytesRead) => {
				if (headerReadErr)
				{
					return reject(headerReadErr);
				}
				const size = pickle.createFromBuffer(headerSizeBuffer).createIterator().readUInt32();

				const headerBuffer = Buffer.alloc(size);

				fs.read(fd, headerBuffer, 0, size, null, (pickleReadErr, pickleReadBytes) => {
					if (pickleReadErr)
					{
						return reject(pickleReadErr);
					}

					const header = pickle.createFromBuffer(headerBuffer).createIterator().readString();

					return resolve({
						header: JSON.parse(header),
						size
					});
				});
github electron-userland / electron-builder / packages / app-builder-lib / src / asar / asar.ts View on Github external
export async function readAsar(archive: string): Promise {
  const fd = await open(archive, "r")
  let size: number
  let headerBuf
  try {
    const sizeBuf = Buffer.allocUnsafe(8)
    if ((await read(fd, sizeBuf, 0, 8, null as any)).bytesRead !== 8) {
      throw new Error("Unable to read header size")
    }

    const sizePickle = createFromBuffer(sizeBuf)
    size = sizePickle.createIterator().readUInt32()
    headerBuf = Buffer.allocUnsafe(size)
    if ((await read(fd, headerBuf, 0, size, null as any)).bytesRead !== size) {
      throw new Error("Unable to read header")
    }
  }
  finally {
    await close(fd)
  }

  const headerPickle = createFromBuffer(headerBuf!)
  const header = headerPickle.createIterator().readString()
  return new AsarFilesystem(archive, JSON.parse(header), size)
}
github electron / asar / lib / disk.js View on Github external
const sizeBuf = Buffer.alloc(8)
    if (fs.readSync(fd, sizeBuf, 0, 8, null) !== 8) {
      throw new Error('Unable to read header size')
    }

    const sizePickle = pickle.createFromBuffer(sizeBuf)
    size = sizePickle.createIterator().readUInt32()
    headerBuf = Buffer.alloc(size)
    if (fs.readSync(fd, headerBuf, 0, size, null) !== size) {
      throw new Error('Unable to read header')
    }
  } finally {
    fs.closeSync(fd)
  }

  const headerPickle = pickle.createFromBuffer(headerBuf)
  const header = headerPickle.createIterator().readString()
  return { header: JSON.parse(header), headerSize: size }
}
github cellardoor42 / whatever / node_modules / electron-packager / node_modules / asar / lib / disk.js View on Github external
const sizeBuf = new Buffer(8)
    if (fs.readSync(fd, sizeBuf, 0, 8, null) !== 8) {
      throw new Error('Unable to read header size')
    }

    const sizePickle = pickle.createFromBuffer(sizeBuf)
    size = sizePickle.createIterator().readUInt32()
    headerBuf = new Buffer(size)
    if (fs.readSync(fd, headerBuf, 0, size, null) !== size) {
      throw new Error('Unable to read header')
    }
  } finally {
    fs.closeSync(fd)
  }

  const headerPickle = pickle.createFromBuffer(headerBuf)
  const header = headerPickle.createIterator().readString()
  return {header: JSON.parse(header), headerSize: size}
}
github onmyway133 / PushNotifications / node_modules / asar / lib / disk.js View on Github external
module.exports.readArchiveHeaderSync = function (archive) {
  const fd = fs.openSync(archive, 'r')
  let size
  let headerBuf
  try {
    const sizeBuf = new Buffer(8)
    if (fs.readSync(fd, sizeBuf, 0, 8, null) !== 8) {
      throw new Error('Unable to read header size')
    }

    const sizePickle = pickle.createFromBuffer(sizeBuf)
    size = sizePickle.createIterator().readUInt32()
    headerBuf = new Buffer(size)
    if (fs.readSync(fd, headerBuf, 0, size, null) !== size) {
      throw new Error('Unable to read header')
    }
  } finally {
    fs.closeSync(fd)
  }

  const headerPickle = pickle.createFromBuffer(headerBuf)
  const header = headerPickle.createIterator().readString()
  return {header: JSON.parse(header), headerSize: size}
}
github electron / asar / lib / disk.js View on Github external
module.exports.readArchiveHeader = function(archive) {
  var fd = fs.openSync(archive, 'r');
  var sizeBuf = new Buffer(8);
  if (fs.readSync(fd, sizeBuf, 0, 8, null) != 8)
    throw new Error('Unable to read header size');

  var sizePickle = pickle.createFromBuffer(sizeBuf);
  var size = sizePickle.createIterator().readUInt32();
  var headerBuf = new Buffer(size);
  if (fs.readSync(fd, headerBuf, 0, size, null) != size)
    throw new Error('Unable to read header');
  fs.closeSync(fd);

  var headerPickle = pickle.createFromBuffer(headerBuf);
  var header = headerPickle.createIterator().readString();
  return { header: JSON.parse(header), headerSize: size };
};
github electron-userland / electron-builder / packages / app-builder-lib / src / asar / asar.ts View on Github external
if ((await read(fd, sizeBuf, 0, 8, null as any)).bytesRead !== 8) {
      throw new Error("Unable to read header size")
    }

    const sizePickle = createFromBuffer(sizeBuf)
    size = sizePickle.createIterator().readUInt32()
    headerBuf = Buffer.allocUnsafe(size)
    if ((await read(fd, headerBuf, 0, size, null as any)).bytesRead !== size) {
      throw new Error("Unable to read header")
    }
  }
  finally {
    await close(fd)
  }

  const headerPickle = createFromBuffer(headerBuf!)
  const header = headerPickle.createIterator().readString()
  return new AsarFilesystem(archive, JSON.parse(header), size)
}

chromium-pickle-js

Binary value packing and unpacking

MIT
Latest version published 8 years ago

Package Health Score

53 / 100
Full package analysis