def self.files(file_system_image)
sector_0=file_system_image.get_sector(0,0)
file_system_image.volume_name=sector_0[0,10].unpack("A*")[0]
files=FileContainer.new
file_descriptor_index_sector=file_system_image.get_sector(0,1)
127.times do |file_descriptor_index|
dir_sector_no=(file_descriptor_index_sector[file_descriptor_index*2]<<8)+(file_descriptor_index_sector[(file_descriptor_index*2)+1])
break if dir_sector_no==0
dir_sector=file_system_image.get_sector(0,dir_sector_no)
filename=dir_sector[0,10].unpack("A*")[0]
if dir_sector[0]>=0x20 && dir_sector[0x0a]==0 && dir_sector[0x0b]==0 then
file_status_flag=dir_sector[0x0c]
record_length=dir_sector[0x11]
records_per_sector=dir_sector[0x0d]
valid_bytes_in_sector=records_per_sector*record_length
valid_bytes_in_sector=0x100 if valid_bytes_in_sector==0
data_chain_pointer=0x1c
last_sector_offset=-1
file_contents=""
while data_chain_pointer<0xFD do
byte_1=dir_sector[data_chain_pointer]
byte_2=dir_sector[data_chain_pointer+1]
byte_3=dir_sector[data_chain_pointer+2]
n3=byte_2%0x10
m1=byte_2>>4
first_sector=(n3<<8)+byte_1
highest_sector_offset=(byte_3<<4)+m1
sectors_in_this_block=highest_sector_offset-last_sector_offset
last_sector_offset=highest_sector_offset
break if first_sector==0 || first_sector>file_system_image.image_format.sectors_per_track*file_system_image.track_count
sectors_in_this_block.times {|i| file_contents<<file_system_image.get_sector(0,i+first_sector)}
data_chain_pointer+=3
end
file_type=file_status_flag
files<<NativeFileType.best_fit(file_system_image,filename,file_contents,file_type)
end
end
files
end