Esempio n. 1
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
Esempio n. 2
0
def _getFileInfo(name):
    dv80suffixes = (".txt", ".a99", ".b99", ".bas", ".xb", ".tb")
    basicSuffixes = (".b99", ".bas", ".xb", ".tb")
        
    header = None
    
    with open(name,"rb") as fdata:
        header = bytearray(fdata.read())[:128]

    valid = ti_files.isValid(header)

    isprotected = 0
    icon = "native"
    type = "DIS/FIX 128"
    tiname = tinames.asTiShortName(name)
    size = os.stat(name).st_size

    if valid:
        type = ti_files.flagsToString(header) 
        if type != 'PROGRAM':
            type = type + " " + str(ti_files.recordLength(header))
        isprotected = ti_files.isProtected(header)
        icon = 'tifile'
    elif name.lower().endswith(dv80suffixes):
        type = "DIS/VAR 80"
        if name.lower().endswith(basicSuffixes):
            icon = 'basic'

    if type == 'PROGRAM' and ti_files.isTiBasicPrg(name):
        icon = 'basic'
    if type == 'INT/VAR 254' and ti_files.isTiBasicPrg(name):
        icon = 'basic'

    return (name, icon, type, tiname, size, isprotected)
Esempio n. 3
0
    def __encodeDirRecord(self, name, ftype, sectors, recordLength):
        if self.longnames:
            recname = bytearray(name, 'utf-8')
            buff = bytearray(28 + len(recname))
        else:
            recname = bytearray(tinames.asTiShortName(name), 'utf-8')
            buff = bytearray(38)

        return self.__encodeCatRecord(buff, recname, ftype, sectors, recordLength)
Esempio n. 4
0
    def encodeDirRecord(self, name, ftype, sectors, recordLength):
        recname = bytearray(tinames.asTiShortName(name), 'utf-8')
        buff = bytearray(146)

        if ftype != 6:
            fp = os.path.join(self.localpath, name)
            modTimesinceEpoc = os.path.getmtime(fp)
            dt_timestamp = datetime.fromtimestamp(modTimesinceEpoc)
        else:
            dt_timestamp = None

        return self.encodeTimestampedRecord(buff, recname, ftype, sectors, recordLength, dt_timestamp)