async function readEmbeddedBlockMapData(file: string): Promise<BlockMap> {
  const fd = await open(file, "r")
  try {
    const fileSize = (await fstat(fd)).size
    const sizeBuffer = Buffer.allocUnsafe(4)
    await read(fd, sizeBuffer, 0, sizeBuffer.length, fileSize - sizeBuffer.length)

    const dataBuffer = Buffer.allocUnsafe(sizeBuffer.readUInt32BE(0))
    await read(fd, dataBuffer, 0, dataBuffer.length, fileSize - sizeBuffer.length - dataBuffer.length)
    await close(fd)

    return readBlockMap(dataBuffer)
  }
  catch (e) {
    await close(fd)
    throw e
  }
}
export async function readEmbeddedBlockMapData(file: string) {
  const fd = await open(file, "r")
  try {
    const fileSize = (await fstat(fd)).size
    const sizeBuffer = Buffer.allocUnsafe(4)
    await read(fd, sizeBuffer, 0, sizeBuffer.length, fileSize - sizeBuffer.length)

    const dataBuffer = Buffer.allocUnsafe(sizeBuffer.readUInt32BE(0))
    await read(fd, dataBuffer, 0, dataBuffer.length, fileSize - sizeBuffer.length - dataBuffer.length)
    await close(fd)

    const inflateRaw: any = BluebirdPromise.promisify(require("zlib").inflateRaw)
    return (await inflateRaw(dataBuffer)).toString()
  }
  catch (e) {
    await close(fd)
    throw e
  }
}