Uploaded image for project: 'Qbs ("Cubes")'
  1. Qbs ("Cubes")
  2. QBS-421

Add support for reading/writing binary data using the JS File class

    XMLWordPrintable

Details

    • Task
    • Resolution: Done
    • P3: Somewhat important
    • 1.11.0
    • None
    • General
    • None
    • 66aa42314346a49b1219df125b730349e8051f05

    Description

      The following methods on the File class would be welcome:

      The terms 'short', 'int', and 'long' should be documented to mean 16, 32, and 64 bit integers, respectively. The S and U infixes are signed and unsigned. The BE and LE suffixes are of course, endianness.

      If the argument to any of the following functions is out of range, it should wrap. If the argument to any of the following functions is of the incorrect data type or in an invalid format, an exception should be thrown.

      • writeSByte
      • writeByte
      • writeShortBE
      • writeShortLE
      • writeUShortBE
      • writeUShortLE
      • writeIntBE
      • writeIntLE
      • writeUIntBE
      • writeUIntLE
      • writeLongBE
      • writeLongLE
      • writeULongBE
      • writeULongLE
      • writeFloat - write a 32-bit floating point number in IEEE 754 format
      • writeDouble - write a 64-bit floating point number in IEEE 754 format
      • writeBool - equivalent to writeByte(x ? 1 : 0)
      • writeBytes - write an array of unsigned bytes; the argument is a hex string such as "ff34f207"

      While we're at it, might as well add read support?

      Corresponding read functions which take no arguments are needed for all the numeric/bool write functions. Lastly, readBytes takes a number argument specifying the number of bytes to read, or can be left unspecified to read until EOF is reached. It returns a hex string.

      All functions should throw an exception on I/O error, additionally read functions should throw an exception when attempting to read past EOF.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              jbornema Joerg Bornemann
              jakepetroules Jake Petroules (DO NOT ASSIGN ISSUES)
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes