mirror of
https://github.com/robmcmullen/atrcopy.git
synced 2024-11-26 08:49:50 +00:00
Fixed deleted flag and track/sector list length. Most delete tests pass
This commit is contained in:
parent
fe5fc502ca
commit
4485cd7e63
@ -330,7 +330,6 @@ class DiskImageBase(object):
|
|||||||
self.write_sector_list(sector_list)
|
self.write_sector_list(sector_list)
|
||||||
self.write_sector_list(vtoc)
|
self.write_sector_list(vtoc)
|
||||||
self.write_sector_list(directory)
|
self.write_sector_list(directory)
|
||||||
self.get_metadata()
|
|
||||||
except AtrError:
|
except AtrError:
|
||||||
self.rollback_transaction(state)
|
self.rollback_transaction(state)
|
||||||
raise
|
raise
|
||||||
@ -366,7 +365,6 @@ class DiskImageBase(object):
|
|||||||
directory.remove_dirent(self, dirent, vtoc, sector_list)
|
directory.remove_dirent(self, dirent, vtoc, sector_list)
|
||||||
self.write_sector_list(vtoc)
|
self.write_sector_list(vtoc)
|
||||||
self.write_sector_list(directory)
|
self.write_sector_list(directory)
|
||||||
self.get_metadata()
|
|
||||||
except AtrError:
|
except AtrError:
|
||||||
self.rollback_transaction(state)
|
self.rollback_transaction(state)
|
||||||
raise
|
raise
|
||||||
|
@ -102,12 +102,9 @@ class Dos33VTOC(VTOC):
|
|||||||
# reorder list is commutative, so we don't need another order here.
|
# reorder list is commutative, so we don't need another order here.
|
||||||
packed = np.packbits(self.sector_map[self.vtoc_bit_reorder_index])
|
packed = np.packbits(self.sector_map[self.vtoc_bit_reorder_index])
|
||||||
vtoc = self.vtoc[0x38:].reshape((-1, 4))
|
vtoc = self.vtoc[0x38:].reshape((-1, 4))
|
||||||
print vtoc
|
|
||||||
packed = packed.reshape((-1, 2))
|
packed = packed.reshape((-1, 2))
|
||||||
vtoc[:,:2] = packed[:,:]
|
vtoc[:,:2] = packed[:,:]
|
||||||
|
|
||||||
print vtoc
|
|
||||||
|
|
||||||
# FIXME
|
# FIXME
|
||||||
self.vtoc[0x38:] = vtoc.flatten()
|
self.vtoc[0x38:] = vtoc.flatten()
|
||||||
s = WriteableSector(self.sector_size, self.vtoc)
|
s = WriteableSector(self.sector_size, self.vtoc)
|
||||||
@ -187,11 +184,15 @@ class Dos33Dirent(object):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def summary(self):
|
def summary(self):
|
||||||
locked = "*" if self.locked else " "
|
if self.deleted:
|
||||||
try:
|
locked = "D"
|
||||||
file_type = self.type_map[self.file_type]
|
file_type = " "
|
||||||
except KeyError:
|
else:
|
||||||
file_type = "?"
|
locked = "*" if self.locked else " "
|
||||||
|
try:
|
||||||
|
file_type = self.type_map[self.file_type]
|
||||||
|
except KeyError:
|
||||||
|
file_type = "?"
|
||||||
flag = "%s%s" % (locked, file_type)
|
flag = "%s%s" % (locked, file_type)
|
||||||
return flag
|
return flag
|
||||||
|
|
||||||
@ -227,12 +228,14 @@ class Dos33Dirent(object):
|
|||||||
def encode_dirent(self):
|
def encode_dirent(self):
|
||||||
data = np.zeros([self.format.itemsize], dtype=np.uint8)
|
data = np.zeros([self.format.itemsize], dtype=np.uint8)
|
||||||
values = data.view(dtype=self.format)[0]
|
values = data.view(dtype=self.format)[0]
|
||||||
values[0] = self.track
|
values[0] = 0xff if self.deleted else self.track
|
||||||
values[1] = self.sector
|
values[1] = self.sector
|
||||||
values[2] = self.flag
|
values[2] = self.flag
|
||||||
n = min(len(self.filename), 30)
|
n = min(len(self.filename), 30)
|
||||||
data[3:3+n] = np.fromstring(self.filename, dtype=np.uint8) | 0x80
|
data[3:3+n] = np.fromstring(self.filename, dtype=np.uint8) | 0x80
|
||||||
data[3+n:] = ord(' ') | 0x80
|
data[3+n:] = ord(' ') | 0x80
|
||||||
|
if self.deleted:
|
||||||
|
data[0x20] = self.track
|
||||||
values[4] = self.num_sectors
|
values[4] = self.num_sectors
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@ -283,7 +286,7 @@ class Dos33Dirent(object):
|
|||||||
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
|
self.sector_map = sector_map[0:self.num_sectors - len(tslist)]
|
||||||
self.track_sector_list = tslist
|
self.track_sector_list = tslist
|
||||||
|
|
||||||
def get_sectors_in_vtoc(self, image):
|
def get_sectors_in_vtoc(self, image):
|
||||||
@ -304,11 +307,11 @@ class Dos33Dirent(object):
|
|||||||
self.current_read = self.num_sectors
|
self.current_read = self.num_sectors
|
||||||
|
|
||||||
def read_sector(self, image):
|
def read_sector(self, image):
|
||||||
log.debug("read_sector: index=%d in %s" % (self.current_sector_index, str(self)))
|
|
||||||
try:
|
try:
|
||||||
sector = self.sector_map[self.current_sector_index]
|
sector = self.sector_map[self.current_sector_index]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
sector = -1
|
sector = -1 # force ByteNotInFile166 error at next read
|
||||||
|
log.debug("read_sector: index %d=%d in %s" % (self.current_sector_index,sector, str(self)))
|
||||||
last = (self.current_sector_index == len(self.sector_map) - 1)
|
last = (self.current_sector_index == len(self.sector_map) - 1)
|
||||||
raw, pos, size = image.get_raw_bytes(sector)
|
raw, pos, size = image.get_raw_bytes(sector)
|
||||||
bytes, num_data_bytes = self.process_raw_sector(image, raw)
|
bytes, num_data_bytes = self.process_raw_sector(image, raw)
|
||||||
@ -438,7 +441,7 @@ class Dos33DiskImage(DiskImageBase):
|
|||||||
if not dirent.is_sane:
|
if not dirent.is_sane:
|
||||||
print "not sane: %s" % dirent
|
print "not sane: %s" % dirent
|
||||||
self.all_sane = False
|
self.all_sane = False
|
||||||
else:
|
elif not dirent.deleted:
|
||||||
files.append(dirent)
|
files.append(dirent)
|
||||||
if directory is not None:
|
if directory is not None:
|
||||||
directory.set(num, dirent)
|
directory.set(num, dirent)
|
||||||
|
Loading…
Reference in New Issue
Block a user