lib/DOSDisk.rb in dsktool-0.1.6 vs lib/DOSDisk.rb in dsktool-0.2.1
- old
+ new
@@ -97,14 +97,14 @@
end
#reads the VTOC, and populate the "files" array with files
def read_vtoc
vtoc_sector=get_sector(17,0)
-
catalog_sector=get_sector(vtoc_sector[01],vtoc_sector[02])
done=false
- while !done
+ while !done
+ break if catalog_sector.nil?
(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=""
@@ -131,22 +131,22 @@
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))
+ if contents.length>0 then
+ @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
-
end
}
next_track=catalog_sector[1]
next_sector=catalog_sector[2]
if (next_track==0) &&( next_sector==0) then