Class: AtariDos

Inherits:
FileSystem show all
Defined in:
lib/file_systems/AtariDos.rb

Overview

Constant Summary collapse

ATARI_DOS_FILE_RECORD_LENGTH =
16
ATARI_DOS_CATALOG_START_SECTOR =
361
ATARI_DOS_CATALOG_END_SECTOR =
368

Class Method Summary collapse

Methods inherited from FileSystem

all_file_systems, code_for_tests, compatability_score, is_valid_file_system_if, matching_score, non_matching_score

Methods included from SubclassTracking

extended

Class Method Details

.files(file_system_image) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/file_systems/AtariDos.rb', line 27

def self.files(file_system_image)
  return [] unless file_system_image.image_format.sector_count>=ATARI_DOS_CATALOG_END_SECTOR
  files=FileContainer.new
#  @file_start_sectors={}
	ATARI_DOS_CATALOG_START_SECTOR.upto(ATARI_DOS_CATALOG_END_SECTOR) do |sector_no|
		catalog_sector_data=file_system_image.get_sector(0,sector_no)
		raise "invalid sector no #{sector_no} (max sector number is #{file_system_image.image_format.sector_count})" if catalog_sector_data.nil?
		0.upto(7) do |record_no|
			catalog_record_data=catalog_sector_data[record_no*ATARI_DOS_FILE_RECORD_LENGTH,ATARI_DOS_FILE_RECORD_LENGTH]
			directory_flag,file_length,start_sector,filename_prefix,filename_ext=catalog_record_data.unpack("CvvA8A3")
			file_name="#{filename_prefix}.#{filename_ext}"
#			puts "%08b %02x %02x %s" % [directory_flag,file_length,start_sector,file_name]
			if (start_sector>0 && start_sector<file_system_image.image_format.sector_count&& (directory_flag & 0x80 !=0x80)) then
        current_sector=start_sector
        file_contents=""
        while current_sector!=0 && current_sector<=file_system_image.image_format.sector_count
          file_sector_data=file_system_image.get_sector(0,current_sector)
          #raise "invalid sector #{current_sector} in #{file_name}" if file_sector_data.nil?
          bytes_used=(file_sector_data[127] & 0x7F)
          file_contents+=file_sector_data[0,bytes_used]
          next_sector_hi=(file_sector_data[125] & 0b00000011)
          next_sector_lo=file_sector_data[126]
          current_sector=next_sector_hi*0x100+next_sector_lo
        end
      files<<NativeFileType.best_fit(file_system_image,file_name,file_contents,filename_ext)
      end      
    end
	end  
  files
end

.host_systemObject



15
16
17
# File 'lib/file_systems/AtariDos.rb', line 15

def self.host_system
  Atari800
end