diff --git a/atrcopy/__init__.py b/atrcopy/__init__.py index ef96284..e077962 100644 --- a/atrcopy/__init__.py +++ b/atrcopy/__init__.py @@ -129,6 +129,8 @@ def list_files(image, files): for dirent in image.files: if not files or dirent.filename in files: print dirent + if options.metadata: + print dirent.extra_metadata(image) def assemble(image, source_files, data_files): if source_files: @@ -197,6 +199,7 @@ def run(): parser.add_argument("-o", "--output", action="store", default="", help="output file name for those commands that need it") parser.add_argument("--shred", action="store_true", default=False, help="fill empty sectors with 0") parser.add_argument("--vtoc", action="store_true", default=False, help="show the VTOC") + parser.add_argument("-m", "--metadata", action="store_true", default=False, help="show extra metadata for named files") options, extra_args = parser.parse_known_args() print options, extra_args diff --git a/atrcopy/ataridos.py b/atrcopy/ataridos.py index b2b1a7b..07746d2 100644 --- a/atrcopy/ataridos.py +++ b/atrcopy/ataridos.py @@ -124,7 +124,10 @@ class AtariDosDirent(Dirent): if self.deleted: flags.append("DEL") if self.locked: flags.append("LOCK") return "flags=[%s]" % ", ".join(flags) - + + def extra_metadata(self, image): + return self.verbose_info + def parse_raw_dirent(self, image, bytes): if bytes is None: return diff --git a/atrcopy/dos33.py b/atrcopy/dos33.py index 287457a..2248d9e 100644 --- a/atrcopy/dos33.py +++ b/atrcopy/dos33.py @@ -213,6 +213,13 @@ class Dos33Dirent(Dirent): @property def flag(self): return 0xff if self.deleted else self._file_type | (0x80 * int(self.locked)) + + def extra_metadata(self, image): + lines = [] + ts = self.get_track_sector_list(image) + lines.append("track/sector list at: " + str(ts)) + lines.append("sector map: " + str(self.sector_map)) + return "\n".join(lines) def parse_raw_dirent(self, image, bytes): if bytes is None: @@ -289,15 +296,17 @@ class Dos33Dirent(Dirent): log.debug("reading track/sector list at %d for %s" % (sector_num, self)) data, _ = image.get_sectors(sector_num) sector = Dos33TSSector(image.header, data=data) + sector.sector_num = sector_num sector_map.extend(sector.get_tslist()) tslist.append(sector) sector_num = sector.next_sector_num self.sector_map = sector_map[0:self.num_sectors - len(tslist)] self.track_sector_list = tslist + return tslist def get_sectors_in_vtoc(self, image): self.get_track_sector_list(image) - sectors = [] + sectors = BaseSectorList(image.header) sectors.extend(self.track_sector_list) for sector_num in self.sector_map: sector = WriteableSector(image.header.sector_size, None, sector_num) diff --git a/atrcopy/utils.py b/atrcopy/utils.py index 04d1e94..fbf858d 100644 --- a/atrcopy/utils.py +++ b/atrcopy/utils.py @@ -143,6 +143,9 @@ class Dirent(object): def __eq__(self, other): raise NotImplementedError + def extra_metadata(self, image): + raise NotImplementedError + def mark_deleted(self): raise NotImplementedError