Class: PascalDos
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
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
96
97
98
99
100
101
102
103
|
# File 'lib/file_systems/PascalDos.rb', line 57
def self.files(file_system_image)
files=FileContainer.new
catalog=get_block(file_system_image,2)
catalog_size=catalog[2]
3.upto(catalog_size-1) do |i|
catalog<<get_block(file_system_image,i)
end
volume_name_length=catalog[6]
file_system_image.volume_name=catalog[7..6+volume_name_length]
files_in_volume=catalog[0x10]
1.upto(files_in_volume) do |file_no|
file_record=catalog[file_no*0x1a..(file_no*0x1a+0x19)]
first_block=file_record[0]+file_record[1]*0x100
first_block_in_next_file=file_record[2]+file_record[3]*0x100
last_block=first_block_in_next_file-1
file_type=file_record[4]
file_name_length=file_record[6]
file_name=file_record[7..6+file_name_length]
bytes_in_last_block=file_record[0x16]+file_record[0x17]*0x100
file_contents=""
first_block.upto(last_block) do |block_no|
this_block=get_block(file_system_image,block_no)
if block_no==last_block then
file_contents<<this_block[0..bytes_in_last_block-1]
else
file_contents<<this_block
end
end
files<<NativeFileType.best_fit(file_system_image,file_name,file_contents,file_type)
end
files
end
|
.get_block(file_system_image, block_no) ⇒ Object
39
40
41
42
43
44
|
# File 'lib/file_systems/PascalDos.rb', line 39
def self.get_block(file_system_image,block_no)
track=(block_no / 8).to_i
first_sector=2*(block_no % 8)
raise "illegal block no #{block_no}" if track>=file_system_image.track_count
return file_system_image.get_sector(track,first_sector)+file_system_image.get_sector(track,first_sector+1)
end
|
.host_system ⇒ Object
34
35
36
|
# File 'lib/file_systems/PascalDos.rb', line 34
def self.host_system
Apple2
end
|