python-adfs
changeset 51:a8eead849e21
Fixed problems with recording the extent of map entries for fragments
which terminate immediately, taking up the minimum amount of space in the
map.
The test_files.py script now runs without reporting any problems, but this
does not mean that no problems still remain.
| author | David Boddie <david@boddie.org.uk> |
|---|---|
| date | Sat Jul 19 21:42:57 2003 +0200 |
| parents | 86844fe8700b |
| children | a9449aa046e1 |
| files | ADFSlib.py |
| diffstat | 1 files changed, 54 insertions(+), 22 deletions(-) [+] |
line diff
1.1 --- a/ADFSlib.py Sat Jul 19 18:30:56 2003 +0200 1.2 +++ b/ADFSlib.py Sat Jul 19 21:42:57 2003 +0200 1.3 @@ -309,6 +309,10 @@ 1.4 1.5 # Set the next zone offset. 1.6 next_zone = next_zone + self.sector_size 1.7 + 1.8 + # Reset the current piece and starting offset. 1.9 + current_piece = None 1.10 + current_start = 0 1.11 1.12 elif free_space != [] and a >= free_space[0][0]: 1.13 1.14 @@ -317,6 +321,10 @@ 1.15 next = free_space[0][1] 1.16 1.17 free_space.pop(0) 1.18 + 1.19 + # Reset the current piece and starting offset. 1.20 + current_piece = None 1.21 + current_start = 0 1.22 1.23 elif current_piece is None and (next_zone - a) >= 2: 1.24 1.25 @@ -328,9 +336,14 @@ 1.26 # the disc address and hence the file number. 1.27 # i.e.the top bit of the file number cannot be set. 1.28 1.29 - # Entry must be above 1 (defect) 1.30 - if entry > 1: 1.31 + if entry == 1: 1.32 1.33 + # File number 1 (defect) 1.34 + next = a + 2 1.35 + 1.36 + elif entry > 1: 1.37 + 1.38 + # Files or directories (greater than 1) 1.39 next = a + 2 1.40 1.41 # Define a new entry. 1.42 @@ -340,27 +353,36 @@ 1.43 1.44 disc_map[entry] = [] 1.45 1.46 - # For the relevant entry, add the block to the list 1.47 - # of pieces found and implicitly finish reading this 1.48 - # fragment. 1.49 - 1.50 - disc_map[entry].append( 1.51 - [ self.find_address_from_map(a, begin, entry), 1.52 - self.find_address_from_map(next, begin, entry) 1.53 - ] ) 1.54 - 1.55 if (value & 0x8000) == 0: 1.56 1.57 # Record the file number and start of this fragment. 1.58 current_piece = entry 1.59 current_start = a 1.60 + 1.61 + else: 1.62 + 1.63 + # For an immediately terminated fragment, add the 1.64 + # extents of the block to the list of pieces found 1.65 + # and implicitly finish reading this fragment. 1.66 + 1.67 + start_addr = self.find_address_from_map( 1.68 + a, begin, entry 1.69 + ) 1.70 + end_addr = self.find_address_from_map( 1.71 + next, begin, entry 1.72 + ) 1.73 + 1.74 + if [start_addr, end_addr] not in disc_map[entry]: 1.75 + 1.76 + disc_map[entry].append( [start_addr, end_addr] ) 1.77 1.78 else: 1.79 1.80 # Search for a valid file number. 1.81 + # Should probably stop looking in this zone. 1.82 next = a + 1 1.83 1.84 - else: 1.85 + elif current_piece is not None: 1.86 1.87 # In a piece being read. 1.88 1.89 @@ -378,14 +400,18 @@ 1.90 1.91 # For relevant entries add the block to the list of 1.92 # pieces found. 1.93 - disc_map[current_piece].append( 1.94 - [ self.find_address_from_map( 1.95 - current_start, begin, current_piece 1.96 - ), 1.97 - self.find_address_from_map( 1.98 - next, begin, current_piece 1.99 - ) 1.100 - ] ) 1.101 + start_addr = self.find_address_from_map( 1.102 + current_start, begin, current_piece 1.103 + ) 1.104 + end_addr = self.find_address_from_map( 1.105 + next, begin, current_piece 1.106 + ) 1.107 + 1.108 + if [start_addr, end_addr] not in disc_map[current_piece]: 1.109 + 1.110 + disc_map[current_piece].append( 1.111 + [ start_addr, end_addr] 1.112 + ) 1.113 1.114 current_piece = None 1.115 1.116 @@ -861,7 +887,8 @@ 1.117 1.118 if self.verify: 1.119 1.120 - self.verify_log.append('Not a directory: %x' % head) 1.121 + self.verify_log.append('Not a directory: %s' % hex(head)) 1.122 + print 'Not a directory: %s' % hex(head) 1.123 1.124 return '', [] 1.125 1.126 @@ -941,13 +968,18 @@ 1.127 else: 1.128 1.129 if (newdiratts & 0x8) != 0: 1.130 + 1.131 #print '%s -> %s' % (name, hex(inddiscadd)) 1.132 1.133 # Remember that inddiscadd will be a sequence of 1.134 # pairs of addresses. 1.135 1.136 - #print inddiscadd 1.137 + #print 1.138 #print hex(head+p+22), 1.139 + #print name, hex(load), hex(exe), hex(length) 1.140 + #print hex(ord(self.sectors[head+p+22])), \ 1.141 + # hex(ord(self.sectors[head+p+23])), \ 1.142 + # hex(ord(self.sectors[head+p+24])) 1.143 #print "addrs:", map(lambda x: map(hex, x), inddiscadd), 1.144 #print "atts:", hex(newdiratts) 1.145
