mirror of
https://github.com/robmcmullen/atrcopy.git
synced 2025-01-23 16:31:44 +00:00
Added verbose info for segments using dirents
This commit is contained in:
parent
d6fec961b8
commit
06aa3bfa9b
@ -50,6 +50,17 @@ class AtariDosDirent(object):
|
||||
flags = "%s%s%s%s%s%s" % (output, dos2, mydos, in_use, deleted, locked)
|
||||
return flags
|
||||
|
||||
@property
|
||||
def verbose_info(self):
|
||||
flags = []
|
||||
if self.opened_output: flags.append("OUT")
|
||||
if self.dos_2: flags.append("DOS2")
|
||||
if self.mydos: flags.append("MYDOS")
|
||||
if self.in_use: flags.append("IN_USE")
|
||||
if self.deleted: flags.append("DEL")
|
||||
if self.locked: flags.append("LOCK")
|
||||
return "flags=[%s]" % ", ".join(flags)
|
||||
|
||||
def parse_raw_dirent(self, image, bytes):
|
||||
if bytes is None:
|
||||
return
|
||||
@ -295,8 +306,10 @@ class AtariDosDiskImage(DiskImageBase):
|
||||
if last:
|
||||
break
|
||||
if len(byte_order) > 0:
|
||||
name = "%s (%s) %ds@%d" % (dirent.get_filename(), dirent.summary(), dirent.num_sectors, dirent.starting_sector)
|
||||
segment = IndexedByteSegment(self.bytes, self.style, byte_order, name=name)
|
||||
name = "%s %ds@%d" % (dirent.get_filename(), dirent.num_sectors, dirent.starting_sector)
|
||||
verbose_name = "%s (%d sectors, first@%d) %s" % (dirent.get_filename(), dirent.num_sectors, dirent.starting_sector, dirent.verbose_info)
|
||||
print verbose_name
|
||||
segment = IndexedByteSegment(self.bytes, self.style, byte_order, name=name, verbose_name=verbose_name)
|
||||
else:
|
||||
segment = EmptySegment(self.bytes, self.style, name=dirent.get_filename())
|
||||
return segment
|
||||
|
@ -25,12 +25,13 @@ class SegmentSaver(object):
|
||||
class DefaultSegment(object):
|
||||
savers = [SegmentSaver]
|
||||
|
||||
def __init__(self, data, style, start_addr=0, name="All", error=None):
|
||||
def __init__(self, data, style, start_addr=0, name="All", error=None, verbose_name=None):
|
||||
self.start_addr = int(start_addr) # force python int to decouple from possibly being a numpy datatype
|
||||
self.data = data
|
||||
self.style = style
|
||||
self.error = error
|
||||
self.name = name
|
||||
self.verbose_name = verbose_name
|
||||
self.page_size = -1
|
||||
self.map_width = 40
|
||||
self._search_copy = None
|
||||
@ -43,7 +44,8 @@ class DefaultSegment(object):
|
||||
|
||||
@property
|
||||
def verbose_info(self):
|
||||
s = "%s ($%x bytes)" % (self.name, len(self))
|
||||
name = self.verbose_name or self.name
|
||||
s = "%s ($%x bytes)" % (name, len(self))
|
||||
if self.error:
|
||||
s += " error='%s'" % self.error
|
||||
return s
|
||||
@ -209,8 +211,8 @@ class EmptySegment(DefaultSegment):
|
||||
|
||||
|
||||
class ObjSegment(DefaultSegment):
|
||||
def __init__(self, data, style, metadata_start, data_start, start_addr, end_addr, name="", error=None):
|
||||
DefaultSegment.__init__(self, data, style, start_addr, name, error)
|
||||
def __init__(self, data, style, metadata_start, data_start, start_addr, end_addr, name="", **kwargs):
|
||||
DefaultSegment.__init__(self, data, style, start_addr, name, **kwargs)
|
||||
self.metadata_start = metadata_start
|
||||
self.data_start = data_start
|
||||
|
||||
@ -224,7 +226,8 @@ class ObjSegment(DefaultSegment):
|
||||
@property
|
||||
def verbose_info(self):
|
||||
count = len(self)
|
||||
s = "%s address range: $%04x-$%04x ($%04x bytes), file index of first byte: $%04x" % (self.name, self.start_addr, self.start_addr + count, count, self.data_start)
|
||||
name = self.verbose_name or self.name
|
||||
s = "%s address range: $%04x-$%04x ($%04x bytes), file index of first byte: $%04x" % (name, self.start_addr, self.start_addr + count, count, self.data_start)
|
||||
if self.error:
|
||||
s += " error='%s'" % self.error
|
||||
return s
|
||||
@ -250,10 +253,11 @@ class RawSectorsSegment(DefaultSegment):
|
||||
|
||||
@property
|
||||
def verbose_info(self):
|
||||
name = self.verbose_name or self.name
|
||||
if self.num_sectors > 1:
|
||||
s = "%s (sectors %d-%d)" % (self.name, self.first_sector, self.first_sector + self.num_sectors - 1)
|
||||
s = "%s (sectors %d-%d)" % (name, self.first_sector, self.first_sector + self.num_sectors - 1)
|
||||
else:
|
||||
s = "%s (sector %d)" % (self.name, self.first_sector)
|
||||
s = "%s (sector %d)" % (name, self.first_sector)
|
||||
s += " $%x bytes" % (len(self), )
|
||||
if self.error:
|
||||
s += " error='%s'" % self.error
|
||||
@ -310,7 +314,8 @@ class IndexedByteSegment(DefaultSegment):
|
||||
|
||||
@property
|
||||
def verbose_info(self):
|
||||
s = "%s ($%04x bytes) non-contiguous file; file index of first byte: $%04x" % (self.name, len(self), self.order[0])
|
||||
name = self.verbose_name or self.name
|
||||
s = "%s ($%04x bytes) non-contiguous file; file index of first byte: $%04x" % (name, len(self), self.order[0])
|
||||
if self.error:
|
||||
s += " error='%s'" % self.error
|
||||
return s
|
||||
|
@ -38,6 +38,16 @@ class SpartaDosDirent(AtariDosDirent):
|
||||
flags = "%s%s%s%s%s %03d" % (output, subdir, in_use, deleted, locked, self.starting_sector)
|
||||
return "File #%-2d (%s) %-8s%-3s %8d %s" % (self.file_num, flags, self.filename, self.ext, self.length, self.str_timestamp)
|
||||
|
||||
@property
|
||||
def verbose_info(self):
|
||||
flags = []
|
||||
if self.opened_output: flags.append("OUT")
|
||||
if self.is_dir: flags.append("DIR")
|
||||
if self.in_use: flags.append("IN_USE")
|
||||
if self.deleted: flags.append("DEL")
|
||||
if self.locked: flags.append("LOCK")
|
||||
return "flags=[%s]" % ", ".join(flags)
|
||||
|
||||
def parse_raw_dirent(self, image, bytes):
|
||||
if bytes is None:
|
||||
return
|
||||
@ -53,7 +63,10 @@ class SpartaDosDirent(AtariDosDirent):
|
||||
self.opened_output = (flag&0b10000000) > 0
|
||||
self.starting_sector = int(values['sector'])
|
||||
self.filename = str(values['filename']).rstrip()
|
||||
self.ext = str(values['ext']).rstrip()
|
||||
if self.is_dir:
|
||||
self.ext = ""
|
||||
else:
|
||||
self.ext = str(values['ext']).rstrip()
|
||||
self.length = 256*256*values['len_h'] + values['len_l']
|
||||
self.date_array = tuple(bytes[17:20])
|
||||
self.time_array = tuple(bytes[20:23])
|
||||
@ -221,7 +234,9 @@ class SpartaDosDiskImage(DiskImageBase):
|
||||
else:
|
||||
break
|
||||
if len(byte_order) > 0:
|
||||
segment = IndexedByteSegment(self.bytes, self.style, byte_order, name=dirent.get_filename(), error=dirent.str_timestamp)
|
||||
name = "%s %d@%d %s" % (dirent.get_filename(), dirent.length, dirent.starting_sector, dirent.str_timestamp)
|
||||
verbose_name = "%s (%d bytes, sector map@%d) %s %s" % (dirent.get_filename(), dirent.length, dirent.starting_sector, dirent.verbose_info, dirent.str_timestamp)
|
||||
segment = IndexedByteSegment(self.bytes, self.style, byte_order, name=name, verbose_name=verbose_name)
|
||||
else:
|
||||
segment = EmptySegment(self.bytes, self.style, name=dirent.get_filename(), error=dirent.str_timestamp)
|
||||
return segment
|
||||
|
Loading…
x
Reference in New Issue
Block a user