mirror of
https://github.com/robmcmullen/atrcopy.git
synced 2024-11-26 08:49:50 +00:00
Added extra metadata command to print out lots of info about dirent
This commit is contained in:
parent
f00ef7cbea
commit
9a87d10326
@ -129,6 +129,8 @@ def list_files(image, files):
|
|||||||
for dirent in image.files:
|
for dirent in image.files:
|
||||||
if not files or dirent.filename in files:
|
if not files or dirent.filename in files:
|
||||||
print dirent
|
print dirent
|
||||||
|
if options.metadata:
|
||||||
|
print dirent.extra_metadata(image)
|
||||||
|
|
||||||
def assemble(image, source_files, data_files):
|
def assemble(image, source_files, data_files):
|
||||||
if source_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("-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("--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("--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()
|
options, extra_args = parser.parse_known_args()
|
||||||
print options, extra_args
|
print options, extra_args
|
||||||
|
|
||||||
|
@ -125,6 +125,9 @@ class AtariDosDirent(Dirent):
|
|||||||
if self.locked: flags.append("LOCK")
|
if self.locked: flags.append("LOCK")
|
||||||
return "flags=[%s]" % ", ".join(flags)
|
return "flags=[%s]" % ", ".join(flags)
|
||||||
|
|
||||||
|
def extra_metadata(self, image):
|
||||||
|
return self.verbose_info
|
||||||
|
|
||||||
def parse_raw_dirent(self, image, bytes):
|
def parse_raw_dirent(self, image, bytes):
|
||||||
if bytes is None:
|
if bytes is None:
|
||||||
return
|
return
|
||||||
|
@ -214,6 +214,13 @@ class Dos33Dirent(Dirent):
|
|||||||
def flag(self):
|
def flag(self):
|
||||||
return 0xff if self.deleted else self._file_type | (0x80 * int(self.locked))
|
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):
|
def parse_raw_dirent(self, image, bytes):
|
||||||
if bytes is None:
|
if bytes is None:
|
||||||
return
|
return
|
||||||
@ -289,15 +296,17 @@ class Dos33Dirent(Dirent):
|
|||||||
log.debug("reading track/sector list at %d for %s" % (sector_num, self))
|
log.debug("reading track/sector list at %d for %s" % (sector_num, self))
|
||||||
data, _ = image.get_sectors(sector_num)
|
data, _ = image.get_sectors(sector_num)
|
||||||
sector = Dos33TSSector(image.header, data=data)
|
sector = Dos33TSSector(image.header, data=data)
|
||||||
|
sector.sector_num = sector_num
|
||||||
sector_map.extend(sector.get_tslist())
|
sector_map.extend(sector.get_tslist())
|
||||||
tslist.append(sector)
|
tslist.append(sector)
|
||||||
sector_num = sector.next_sector_num
|
sector_num = sector.next_sector_num
|
||||||
self.sector_map = sector_map[0:self.num_sectors - len(tslist)]
|
self.sector_map = sector_map[0:self.num_sectors - len(tslist)]
|
||||||
self.track_sector_list = tslist
|
self.track_sector_list = tslist
|
||||||
|
return tslist
|
||||||
|
|
||||||
def get_sectors_in_vtoc(self, image):
|
def get_sectors_in_vtoc(self, image):
|
||||||
self.get_track_sector_list(image)
|
self.get_track_sector_list(image)
|
||||||
sectors = []
|
sectors = BaseSectorList(image.header)
|
||||||
sectors.extend(self.track_sector_list)
|
sectors.extend(self.track_sector_list)
|
||||||
for sector_num in self.sector_map:
|
for sector_num in self.sector_map:
|
||||||
sector = WriteableSector(image.header.sector_size, None, sector_num)
|
sector = WriteableSector(image.header.sector_size, None, sector_num)
|
||||||
|
@ -143,6 +143,9 @@ class Dirent(object):
|
|||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def extra_metadata(self, image):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def mark_deleted(self):
|
def mark_deleted(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user