Added count of free sectors based on VTOC allocation table

This commit is contained in:
Rob McMullen 2017-02-24 10:14:38 -08:00
parent 68469e8e92
commit efb0d6ef28
2 changed files with 7 additions and 2 deletions

View File

@ -92,10 +92,10 @@ class Dos33VTOC(VTOC):
# so we need to reorder them using numpy's indexing before stuffing
# them into the sector map
self.sector_map[0:self.max_sectors] = bits[self.vtoc_bit_reorder_index]
log.debug("vtoc before: %s" % self.sector_map[0:35*16])
log.debug("vtoc before: %s (%d free)" % (self.sector_map[0:35*16], self.num_free_sectors))
def calc_bitmap(self):
log.debug("vtoc after: %s" % self.sector_map[0:35*16])
log.debug("vtoc after: %s (%d free)" % (self.sector_map[0:35*16], self.num_free_sectors))
# reverse the process from above, so swap the order of every 16 bits,
# turn them into bytes, then stuff them back into the vtoc. The bit

View File

@ -224,6 +224,11 @@ class VTOC(BaseSectorList):
if segments is not None:
self.parse_segments(segments)
@property
def num_free_sectors(self):
free = np.where(self.sector_map == 1)[0]
return len(free)
def parse_segments(self, segments):
raise NotImplementedError