Class: Ti99Fms
Overview
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
extended
Class Method Details
.files(file_system_image) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/file_systems/Ti99Fms.rb', line 34
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
|
.host_system ⇒ Object
15
16
17
|
# File 'lib/file_systems/Ti99Fms.rb', line 15
def self.host_system
Ti99
end
|