# File lib/DOSDisk.rb, line 100
        def read_vtoc
                vtoc_sector=get_sector(17,0)

                catalog_sector=get_sector(vtoc_sector[01],vtoc_sector[02])
                done=false
                while !done 
                        (0..6).each {|file_number|
                                file_descriptive_entry_start=11+file_number*35
                                file_descriptive_entry=catalog_sector[file_descriptive_entry_start..file_descriptive_entry_start+35]                                        
                                break if (file_descriptive_entry[0]==0xFF) # skip deleted files
                                filename=""
                                file_descriptive_entry[3..32].to_s.each_byte{|b| filename+=(b.%128).chr}
                                filename.sub!(/ *$/,"") #strip off trailing spaces
                                locked=(file_descriptive_entry[2]>=0x80)
                                sector_count=file_descriptive_entry[0x21]+file_descriptive_entry[0x22]*256
                
                                file_type_code=file_descriptive_entry[2]%0x80
                                
                                
                                if (sector_count>0) then
                                        contents=""
                                        ts_list_track_no=file_descriptive_entry[0]
                                        ts_list_sector_no=file_descriptive_entry[1]
                                        while (ts_list_track_no>0) && (ts_list_track_no<=0X22) && (ts_list_sector_no<=0x0f)
                                                ts_list_sector=get_sector(ts_list_track_no,ts_list_sector_no)
                                                ts_list_track_no=ts_list_sector[1]
                                                ts_list_sector_no=ts_list_sector[2]

                                                0x0C.step(0xff,2) {|i|                                            
                                                        data_track_no=ts_list_sector[i]
                                                        data_sector_no=ts_list_sector[i+1]
                                                        if (data_track_no>0) && (data_track_no<=0X22) && (data_sector_no<=0x0f) then
                                                                contents+=get_sector(data_track_no,data_sector_no)
                                                        end
                                                }
                                        end

                                        @files[filename]= case file_type_code
                                                when 0x00 then TextFile.new(filename,locked,sector_count,contents)
                                                when 0x01 then SCAsmFile.can_be_scasm_file(contents)? SCAsmFile.new(filename,locked,sector_count,contents): IntegerBasicFile.new(filename,locked,sector_count,contents)
                                                when 0x02 then AppleSoftFile.new(filename,locked,sector_count,contents)
                                                when 0x04 then BinaryFile.new(filename,locked,sector_count,contents)
#                                               when 0x08 then "S"       #S type file
#                                               when 0x10 then "R"       #RELOCATABLE object module file
#                                               when 0x20 then "a"       #??
#                                               when 0x40 then "b"       #??
                                                else DOSFile.new(filename,locked,sector_count,contents,sprintf("$%02X",file_type_code))
                                        end
        
                                end
                        }
                        next_track=catalog_sector[1]         
                        next_sector=catalog_sector[2]
                        if (next_track==0) &&( next_sector==0) then
                                done=true
                        else 
                                catalog_sector=get_sector(next_track,next_sector)
                        end
                end

        end