python-adfs
changeset 83:7ae071979b73
Started to generalise use of sector information.
Added a diagnostic tool.
| author | David Boddie <david@boddie.org.uk> |
|---|---|
| date | Thu Oct 13 23:03:21 2011 +0200 |
| parents | fe806064ace5 |
| children | 9f1ea30aa03c |
| files | ADFSlib.py tests/show_formats.py |
| diffstat | 2 files changed, 34 insertions(+), 9 deletions(-) [+] |
line diff
1.1 --- a/ADFSlib.py Tue Oct 11 23:17:26 2011 +0200 1.2 +++ b/ADFSlib.py Thu Oct 13 23:03:21 2011 +0200 1.3 @@ -1,4 +1,4 @@ 1.4 -#! /usr/bin/env python 1.5 +#!/usr/bin/env python 1.6 1.7 """ 1.8 ADFSlib.py, a library for reading ADFS disc images. 1.9 @@ -180,8 +180,8 @@ 1.10 self.ntracks = 160 1.11 self.nsectors = 16 # per track 1.12 self.sector_size = 256 # in bytes 1.13 - # Interleave was originally 1 then 0 (from 1.14 - # ~/Private/ADFS/LFormat.htm). 1.15 + # Most L format discs are interleaved, but at least one is 1.16 + # sequenced. 1.17 interleave = 1 1.18 self.disc_type = 'adl' 1.19 self.dir_markers = ('Hugo',) 1.20 @@ -234,7 +234,7 @@ 1.21 if self.disc_type == 'adD': 1.22 1.23 # Find the root directory name and all the files and directories 1.24 - # contained within it 1.25 + # contained within it. 1.26 self.root_name, self.files = self._read_old_catalogue(0x400) 1.27 1.28 elif self.disc_type == 'adE': 1.29 @@ -243,8 +243,8 @@ 1.30 self.disc_name = self._safe(self._read_disc_info(), with_space = 1) 1.31 1.32 # Find the root directory name and all the files and directories 1.33 - # contained within it 1.34 - self.root_name, self.files = self._read_new_catalogue(0x800) 1.35 + # contained within it. 1.36 + self.root_name, self.files = self._read_new_catalogue(2*self.sector_size) 1.37 1.38 elif self.disc_type == 'adEbig': 1.39 1.40 @@ -252,13 +252,13 @@ 1.41 self.disc_name = self._safe(self._read_disc_info(), with_space = 1) 1.42 1.43 # Find the root directory name and all the files and directories 1.44 - # contained within it 1.45 - self.root_name, self.files = self._read_new_catalogue(0xc8800) 1.46 + # contained within it. The 1.47 + self.root_name, self.files = self._read_new_catalogue((self.ntracks * self.nsectors/2 + 2) * self.sector_size) 1.48 1.49 else: 1.50 1.51 # Find the root directory name and all the files and directories 1.52 - # contained within it 1.53 + # contained within it. 1.54 self.root_name, self.files = self._read_old_catalogue(2*self.sector_size) 1.55 1.56
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/tests/show_formats.py Thu Oct 13 23:03:21 2011 +0200 2.3 @@ -0,0 +1,25 @@ 2.4 +#!/usr/bin/env python 2.5 + 2.6 +import ADFSlib 2.7 +import glob, os, sys 2.8 + 2.9 +if __name__ == "__main__": 2.10 + 2.11 + if len(sys.argv) < 2: 2.12 + 2.13 + sys.stderr.write("Usage: %s <ADFS disc image> ...\n" % sys.argv[0]) 2.14 + sys.exit(1) 2.15 + 2.16 + paths = sys.argv[1:] 2.17 + 2.18 + for path in paths: 2.19 + 2.20 + if os.path.isfile(path): 2.21 + 2.22 + try: 2.23 + d = ADFSlib.ADFSdisc(open(path)) 2.24 + print path, d.disc_format() 2.25 + except ADFSlib.ADFS_exception: 2.26 + sys.stderr.write("Unrecognised file: %s\n" % path) 2.27 + 2.28 + sys.exit()
