示例#1
0
    def __encodeCatRecord(self, buff, recname, ftype, sectors, recordLength):
        logger.debug("cat record: %s, %d, %d, %d", recname, ftype, sectors,
                     recordLength)

        buff[0] = len(recname)
        i = 1
        for c in recname:
            buff[i] = c
            i += 1
        ft = tifloat.asFloat(ftype)
        for b in ft:
            buff[i] = b
            i += 1
        sc = tifloat.asFloat(sectors)
        for b in sc:
            buff[i] = b
            i += 1
        rl = tifloat.asFloat(recordLength)
        for b in rl:
            buff[i] = b
            i += 1
        if not self.longnames:
            # pad the rest of the fixed record length
            for i in range(i, 38):
                buff[i] = 0

        return buff
示例#2
0
    def __encodeDirRecord(self, name, ftype, sectors, recordLength):
        bytes = bytearray(38)

        shortname = tinames.asTiShortName(name)
        logger.debug("cat record: %s, %d, %d, %d", shortname, ftype, sectors, recordLength)

        bytes[0] = len(shortname)
        i = 1
        for c in shortname:
            bytes[i] = c
            i += 1
        ft = tifloat.asFloat(ftype)
        for b in ft:
            bytes[i] = b
            i += 1
        sc = tifloat.asFloat(sectors)
        for b in sc:
            bytes[i] = b
            i += 1
        rl = tifloat.asFloat(recordLength)
        for b in rl:
            bytes[i] = b
            i += 1
        for i in range(i, 38):
            bytes[i] = 0

        return bytes
示例#3
0
    def encodeTimestampedRecord(self, buff, recname, ftype, sectors, recordLength, timestamp):
        logger.debug(
            "catalog with timestamp record: %s, %d, %d, %d", recname, ftype, sectors, recordLength
        )

        buff[0] = len(recname)
        i = 1
        for c in recname:
            buff[i] = c
            i += 1
        ft = tifloat.asFloat(ftype)
        for b in ft:
            buff[i] = b
            i += 1
        sc = tifloat.asFloat(sectors)
        for b in sc:
            buff[i] = b
            i += 1
        rl = tifloat.asFloat(recordLength)
        for b in rl:
            buff[i] = b
            i += 1

        # add a zero timestamp for creation time, cause we don't support it
        i = self.encodeTimestamp(buff, i, 0, 0, 0, 0, 0, 0)

        if timestamp:
            i = self.encodeTimestamp(
                buff, 
                i, 
                timestamp.day, 
                timestamp.month, 
                timestamp.year, 
                timestamp.hour, 
                timestamp.minute, 
                timestamp.second, 
            )
        else:
            # directory and volume entry don't get a modified time
            i = self.encodeTimestamp(buff, i, 0, 0, 0, 0, 0, 0)

        # pad the rest of the fixed record length
        for i in range(i, 146):
            buff[i] = 0

        return buff
示例#4
0
 def encodeTimestamp(self, buff, i, day, month, year, hour, minute, seconds):
     ft = tifloat.asFloat(seconds)
     for b in ft:
         buff[i] = b
         i += 1
     ft = tifloat.asFloat(minute)
     for b in ft:
         buff[i] = b
         i += 1
     ft = tifloat.asFloat(hour)
     for b in ft:
         buff[i] = b
         i += 1
     ft = tifloat.asFloat(day)
     for b in ft:
         buff[i] = b
         i += 1
     ft = tifloat.asFloat(month)
     for b in ft:
         buff[i] = b
         i += 1
     ft = tifloat.asFloat(year)
     for b in ft:
         buff[i] = b
         i += 1
     return i