$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) $:.unshift(File.dirname(__FILE__+"\\..")) unless $:.include?(File.dirname(__FILE__+"\\..")) || $:.include?(File.expand_path(File.dirname(__FILE__+"\\.."))) require 'FileSystem' #Disk image in ProDOS format class ProDos=0xF0) && (first_sector_in_block_2[0x29]+first_sector_in_block_2[0x2a]*0x100==file_system_image.track_count*8) ) } #returns a FileContainer of of the native files contained in file system image def self.files(file_system_image) files=FileContainer.new ProDos.read_catalog(file_system_image,2,"").flatten.each do |file| files<=file_system_image.track_count return file_system_image.get_sector(track,first_sector)+file_system_image.get_sector(track,first_sector+1) end def self.read_catalog(file_system_image,starting_block,dir_path) files=FileContainer.new next_block_no=starting_block while (next_block_no!=0) block=ProDos.get_block(file_system_image,next_block_no) offset=4 while (offset<(0x200-0x27)) directory_entry=block[offset..offset+0x27] storage_type=directory_entry[0]>>4 name_length=directory_entry[0]%0x10 name=directory_entry[1..name_length] file_type=directory_entry[0x10] key_pointer=directory_entry[0x11]+directory_entry[0x12]*0x100 blocks_used=directory_entry[0x13]+directory_entry[0x14]*0x100 file_length=directory_entry[0x15]+directory_entry[0x16]*0x100+directory_entry[0x17]*0x10000 aux_code=directory_entry[0x1f]+directory_entry[0x20]*0x100 full_filename="#{dir_path}#{name}" case storage_type when 0x00 then #nop when 0x01 then #it's a seedling file_contents=ProDos.get_block(file_system_image,key_pointer) files<