$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) # Disk image with Pascal File System #catalog will be at block 2. #each entry consists of $1A bytes, which are: #VOLUME HEADER # 00..01 FIRST BLOCK (word) # 02..03 LAST BLOCK+1 (word) # 04 FILE TYPE (byte) = untypedfile,xdskfile,codefile,textfile,infofile,datafile,graffile,fotofile,securdir # 05 FILLER # 06 VOLUME NAME LENGTH (1 byte) # 07..0D VOLUME NAME (17 bytes) # 0E..0F VOLUME SIZE (WORD) # 10 NUMBER OF FILES (BYTE) # 11..1A FILLER # #FILES # 00..01 FIRST BLOCK (word) # 02..03 LAST BLOCK+1 (word) # 04 FILE TYPE (byte) = untypedfile,xdskfile,codefile,textfile,infofile,datafile,graffile,fotofile,securdir # 05 STATUS (byte) # 06 FILENAME LENGTH (1 byte) # 07..16 FILENAME (15 bytes) # 17..18 BYTES IN LAST BLOCK (word) # 19..1A FILE ACCESS DATE require 'PascalFile' class PascalDisk < DSK attr_accessor :volume_name def dump_catalog s="" files.keys.sort.each { |file_name| file=files[file_name] s<< "#{sprintf('% 6d',file.contents.length)}\t #{file.file_type}\t#{file.filename}\n" } s end def initialize(file_bytes,sector_order) super(file_bytes,sector_order) self.read_catalog end def file_system :pascal end #reads the catalog, and populate the "files" array with files def read_catalog catalog=get_block(2) #we've read the first block in the catalog, now read the rest catalog_size=catalog[2] 3.upto(catalog_size-1) do |i| catalog<