python-adfs

changeset 71:6bf4e64c9c17

Added support for reading D format discs with E-format directories.
author David Boddie <david@boddie.org.uk>
date Sat Aug 21 21:35:20 2010 +0200
parents 2595703db85f
children 1699a760928e
files ADFSlib.py
diffstat 1 files changed, 22 insertions(+), 5 deletions(-) [+]
line diff
     1.1 --- a/ADFSlib.py	Sat Aug 21 21:34:28 2010 +0200
     1.2 +++ b/ADFSlib.py	Sat Aug 21 21:35:20 2010 +0200
     1.3 @@ -2,7 +2,7 @@
     1.4  """
     1.5  ADFSlib.py, a library for reading ADFS disc images.
     1.6  
     1.7 -Copyright (c) 2003-2008, David Boddie
     1.8 +Copyright (c) 2003-2010, David Boddie
     1.9  
    1.10  This program is free software: you can redistribute it and/or modify
    1.11  it under the terms of the GNU General Public License as published by
    1.12 @@ -137,6 +137,7 @@
    1.13              self.sector_size = 256
    1.14              interleave = 0
    1.15              self.disc_type = 'adf'
    1.16 +            self.dir_markers = ('Hugo',)
    1.17          
    1.18          #if string.lower(adf_file[-4:])==(suffix+"adf"):
    1.19          elif length == 327680:
    1.20 @@ -145,6 +146,7 @@
    1.21              self.sector_size = 256
    1.22              interleave = 0
    1.23              self.disc_type = 'adf'
    1.24 +            self.dir_markers = ('Hugo',)
    1.25          
    1.26          #elif string.lower(adf_file[-4:])==(suffix+"adl"):
    1.27          elif length == 655360:
    1.28 @@ -155,6 +157,7 @@
    1.29              # ~/Private/ADFS/LFormat.htm).
    1.30              interleave = 1
    1.31              self.disc_type = 'adl'
    1.32 +            self.dir_markers = ('Hugo',)
    1.33          
    1.34          elif length == 819200:
    1.35          
    1.36 @@ -162,6 +165,7 @@
    1.37              self.nsectors = 10
    1.38              self.sector_size = 1024
    1.39              interleave = 0
    1.40 +            self.dir_markers = ('Hugo', 'Nick')
    1.41              
    1.42              format = self._identify_format(adf)
    1.43              
    1.44 @@ -184,6 +188,7 @@
    1.45              self.sector_size = 1024
    1.46              interleave = 0
    1.47              self.disc_type = 'adEbig'
    1.48 +            self.dir_markers = ('Nick',)
    1.49          
    1.50          else:
    1.51              raise ADFS_exception, 'Please supply a .adf, .adl or .adD file.'
    1.52 @@ -403,6 +408,18 @@
    1.53              
    1.54              return 'D'
    1.55          
    1.56 +        elif word1 == 'Nick':
    1.57 +        
    1.58 +            if self.verify:
    1.59 +            
    1.60 +                self.verify_log.append(
    1.61 +                    ( INFORM,
    1.62 +                      "Found E-style directory in typical place for the root " + \
    1.63 +                      "directory of a D format disc." )
    1.64 +                    )
    1.65 +            
    1.66 +            return 'D'
    1.67 +        
    1.68          elif word2 == 'Nick':
    1.69          
    1.70              if self.verify:
    1.71 @@ -943,7 +960,7 @@
    1.72          
    1.73          dir_seq = self.sectors[head + p]
    1.74          dir_start = self.sectors[head+p+1:head+p+5]
    1.75 -        if dir_start != 'Hugo':
    1.76 +        if dir_start not in self.dir_markers:
    1.77          
    1.78              if self.verify:
    1.79              
    1.80 @@ -1043,7 +1060,7 @@
    1.81              tail = head + (self.sector_size*4)    # 1024 bytes
    1.82          
    1.83          dir_end = self.sectors[tail+self.sector_size-5:tail+self.sector_size-1]
    1.84 -        if dir_end != 'Hugo':
    1.85 +        if dir_end not in self.dir_markers:
    1.86          
    1.87              if self.verify:
    1.88              
    1.89 @@ -1158,7 +1175,7 @@
    1.90          
    1.91          dir_seq = self.sectors[head + p]
    1.92          dir_start = self.sectors[head+p+1:head+p+5]
    1.93 -        if dir_start != 'Nick':
    1.94 +        if dir_start not in self.dir_markers:
    1.95          
    1.96              if self.verify:
    1.97              
    1.98 @@ -1307,7 +1324,7 @@
    1.99          
   1.100          dir_end = self.sectors[tail+self.sector_size-5:tail+self.sector_size-1]
   1.101          
   1.102 -        if dir_end != 'Nick':
   1.103 +        if dir_end not in self.dir_markers:
   1.104          
   1.105              if self.verify:
   1.106